oceanmodeling / adcircpy Goto Github PK
View Code? Open in Web Editor NEWPython library for managing input and output files for the ADCIRC model
Home Page: https://adcircpy.readthedocs.io/en/latest/
License: GNU General Public License v3.0
Python library for managing input and output files for the ADCIRC model
Home Page: https://adcircpy.readthedocs.io/en/latest/
License: GNU General Public License v3.0
Hi all,
I just want to learn more about the format of the fort22 file to drive the adcirc simulation. When I use the simplest code to download Sandy's best track, it failed. I don't know how to solve this problem. Could you please give some advice to help me fix this error? Many thanks to you.
some screenshot is shown blow:
fort_22
file, the RUNDAY ends up being too long in comparison to the time extent in the fort.22; this results in a SEGFAULT when attempting to run ADCIRC. NWS = 8 # wind forcing option
SPIN_UP_TIME = 0.5 # how long to coldstart for in days
MESH = "/work/meshes/SIRA25m.14" # mesh name
FORT13 = "/work/meshes/SIRA25m_P_TIDES_001.13" # nodal attribute file
OUTPUT_DIRECTORY = Path("/work/forced/ncep/running_simulations/")
if not OUTPUT_DIRECTORY.exists():
OUTPUT_DIRECTORY.mkdir(parents=True, exist_ok=True)
##########################################
print(f"Writing input files for: {track_file} using NWS={NWS} wind forcing option")
# open mesh file
mesh = AdcircMesh.open(MESH, crs=4326)
# add the nodal attributes file
mesh.import_nodal_attributes(FORT13)
for attr in mesh.get_nodal_attribute_names():
mesh.set_nodal_attribute_coldstart_state(attr, True)
mesh.set_nodal_attribute_hotstart_state(attr, True)
# for each best track file, write out some model forcing files
wind_forcing = BestTrackForcing.from_fort22(track_file, nws=NWS)
print(wind_forcing.summary())
mesh.add_forcing(wind_forcing)
# instantiate driver object
driver = AdcircRun(
mesh,
)
# request global outputs every 30 minutes
driver.set_elevation_surface_output(sampling_rate=timedelta(minutes=30))
# request station output every 6 minutes
if station_file is not None:
driver.set_elevation_stations_output(sampling_rate=timedelta(minutes=6))
stations = np.loadtxt(station_file,dtype=float,delimiter=',')
for idx,sta in enumerate(stations):
driver.add_elevation_output_station(f"Station_{idx}",sta)
# set numerical parameters
driver.timestep = 2.0
#driver.NFOVER = [1 ,6, 0, 50, 8]
driver.RUNID = track_file[-11:]
driver.NSCREEN = 1800
driver.NOLIBF = 1
driver.DRAMP = SPIN_UP_TIME
driver.smagorinsky = True
driver.smagorinsky_coefficient=0.05
driver.TAU0 = -3
driver.gwce_solution_scheme ='explicit'
driver.H0 = 0.10
# write driver to disk
driver.write(OUTPUT_DIRECTORY, overwrite=True)
Hi @jreniel ,
I wonder if the adcircpy package is installed by using "pip install adcircpy" on the Linux OS? Because I tried to install it with pip on the Windows OS, some errors appeared like below. If the Linux OS is the right choice I will have a new try. Many thanks to you!
Regards,
Jiangchao
BestTrackForcing
file you're working with as a sanity check.For example
best_track = BestTrackForcing(best_track_file, nws=8)
best_track.summary()
giving you things like
and anything else that could be useful to ensure the tracks are not bogus automatically.
when running ADCIRC inside NEMS, the following error occurs:
** ERROR: Elevation.gt.ErrorElev, ADCIRC stopping. **
this error occurs when using a fort.15
generated with adcircpy
with the following code:
# open mesh file
mesh = AdcircMesh.open(fort14_filename, crs=4326)
# init tidal forcing and setup requests
tidal_forcing = Tides()
tidal_forcing.use_all()
wind_forcing = WindForcing(17, 3600)
wave_forcing = WaveForcing(5, 3600)
mesh.add_forcing(tidal_forcing)
mesh.add_forcing(wind_forcing)
mesh.add_forcing(wave_forcing)
slurm = SlurmConfig(
account=None,
ntasks=nems.processors,
run_name=run_name,
partition=partition,
walltime=wall_clock_time,
nodes=int(numpy.ceil(nems.processors / 68)) if tacc else None,
mail_type='all' if email_address is not None else None,
mail_user=email_address,
log_filename=f'{name}.log',
modules=[],
path_prefix='$HOME/adcirc/build',
launcher=launcher,
extra_commands=[f'source {module_file}'],
)
# instantiate AdcircRun object.
driver = AdcircRun(
mesh=mesh,
start_date=nems.start_time,
end_date=nems.start_time + nems.duration,
spinup_time=timedelta(days=5),
server_config=slurm,
)
driver.import_stations(Path(repository_root()) / 'examples/data/stations.txt')
driver.set_elevation_stations_output(timedelta(minutes=6), spinup=timedelta(minutes=6))
driver.set_elevation_surface_output(timedelta(minutes=6), spinup=timedelta(minutes=6))
driver.set_velocity_stations_output(timedelta(minutes=6), spinup=timedelta(minutes=6))
driver.set_velocity_surface_output(timedelta(minutes=6), spinup=timedelta(minutes=6))
plot_mesh myfort.14 --crs=EPSG:4326
Does not appear to produce a plot nor show anything to the screen. I guess this functionality isn't yet implemented?
When calling one of the AdcircRun
output setting functions, if passing spinup_end
or end
to the function, the following error occurs:
NotImplementedError: specific spinup end time is not implemented
This comes from this function:
https://github.com/JaimeCalzadaNOAA/adcircpy/blob/ceee09407b6099d715e4f2374c1b04676169cd57/adcircpy/fort15.py#L2286-L2327
We need to do some app_data_dir sorcery here as well (for when len()>0)
@jreniel in #53 (comment)
class WindForcing(Forcing, ABC):
def __init__(self, nws: int, interval_seconds: int):
self.NWS = nws
self.WTIMINC = interval_seconds
self.WTIMINC = interval_seconds
AttributeError: can't set attribute
The current output of best_track_file entrypoint needs to be piped to a file best_track_file storm_id > fort.22
but we can reinstate basic functionality that was commented out on a debug cycle, particularly a --save argument. Some thought can be given to improve the argument parser behavior.
Remove conda method of intsllation and replace with python virtualenv installation method.
setting outputs on an AdcircRun
object, if passing start and end times for spinup:
nems = ModelingSystem(
start_time=datetime(2008, 8, 23),
end_time=datetime(2008, 8, 23) + timedelta(days=14.5),
interval=timedelta(hours=1),
atm=AtmosphericMeshEntry(forcings_directory / 'wind_atm_fin_ch_time_vec.nc'),
wav=WaveMeshEntry(forcings_directory / 'ww3.Constant.20151214_sxy_ike_date.nc'),
ocn=ADCIRCEntry(382)
)
spinup = ModelingSystem(
start_time=nems.start_time - spinup_time,
end_time=nems.start_time,
interval=nems.interval,
ocn=copy.deepcopy(nems['OCN']),
**nems.attributes
)
slurm_config = ...
driver = AdcircRun(
mesh=mesh,
start_date=nems.start_time,
end_date=nems.end_time,
spinup_time=timedelta(days=5),
server_config=slurm_config
)
driver.set_elevation_surface_output(
nems.interval,
spinup=spinup.interval,
spinup_start=spinup.start_time,
spinup_end=spinup.end_time
)
they are treated as timedelta
objects,
https://github.com/JaimeCalzadaNOAA/adcircpy/blob/3cc26e9a9b9ec5a6456db265c591095f29ca59e3/adcircpy/driver.py#L761-L762
https://github.com/JaimeCalzadaNOAA/adcircpy/blob/3cc26e9a9b9ec5a6456db265c591095f29ca59e3/adcircpy/driver.py#L786-L791
raising an AssertionError
:
name = 'spinup_start', var = datetime.datetime(2008, 8, 10, 12, 0)
@staticmethod
def _certify__OUT__(name, var):
# certifies TOUTS* and TOUTF*
msg = f'Error: {name} argument must be either {None}, '
msg += f'{int} or an instance of type {timedelta}.'
> assert isinstance(var, (type(None), timedelta, int)), msg
E AssertionError: Error: spinup_start argument must be either None, <class 'int'> or an instance of type <class 'datetime.timedelta'>.
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\driver.py:791: AssertionError
Fort63
produce an animation automatically finding the appropriate bbox.Fort63.animation
but additionally reads the log file, finds the node which first exhibited the instability then draws a small region around this area.best_track_run ../sira25m_tides.14 external --external_track=1R1.trk --fort13 ../sira25m_tides.13 --constituents=major --spinup-days=15.0 --elev=30. --mete=30. --velo=30. --skip-run --crs='epsg:4326' --output-directory=testing/ --overwrite --timestep=1.0
This produces a run 16.625 days long. However the wind forcing duration lasts 2008101617 to 2008102020 nearly four simulation days.
The track file is attached (just remove suffix)
The following error happens only in the Github Action (I can't reproduce it on my local Windows)
https://github.com/noaa-ocs-modeling/CoupledModelDriver/runs/2272056215?check_suite_focus=true
________________ ERROR collecting tests/test_configurations.py _________________
ImportError while importing test module '/home/runner/work/CoupledModelDriver/CoupledModelDriver/tests/test_configurations.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_configurations.py:7: in <module>
from coupledmodeldriver.configuration import (
coupledmodeldriver/configuration.py:9: in <module>
from adcircpy.driver.driver import AdcircRun
/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/adcircpy/__init__.py:6: in <module>
from adcircpy.driver.driver import AdcircRun
E ModuleNotFoundError: No module named 'adcircpy.driver'
best_track_run
factory to accept externally defined best track files.plot_track
functionality does not appear to work for example when called with best_track_file
. The function plot_trajectory
doesn't exist anymore; perhaps this should be plot_track
?when inputting a HSOFS fort.14
from
/scratch2/COASTAL/coastal/save/shared/models/meshes/hsofs/grid_v1/fort.14
the weir boundaries (24:.+
) are only IDs and are not written with data in the output fort.14
:
/scratch2/COASTAL/coastal/save/shared/working/zach/hera_hsofs_sandy_rewritten_mesh_20210325/coldstart/fort.14
This issue blocks noaa-ocs-modeling/CoupledModelDriver#44
- The resource is always a path to the hard disk, never a URL.
Ok, that makes sense. I wasn't sure if we wanted to support another source for HAMTIDE to be served online though, perhaps via FTP. I will revert this change for now
- start_date should always be a datetime object. If it´s not,
it should be cast into onethrow a TypeError.
Yes, however the function was acting upon it as if it was a timedelta by calling .total_seconds()
, so this provides a fix for that that hopefully doesn't break anything existing
Originally posted by @zacharyburnettNOAA in #70 (comment)
It seem that codecov might need a token refresh. I'm not fully familiar with this but it seems to be the reason why the tests are failing.
BestTrack
objects in a loop leads to a jam up. storms = [f"{track}R1.trk" for track in track_numbers]]
files = [pathlib.Path(f"{pold}/{storm}") for storm in storms]
mesh = AdcircMesh.open(mesh_path, crs=4326)
bbox = mesh.get_bbox(output_type="bbox")
for k, (storm_name, storm) in enumerate(zip( files, storms)):
t1 = time.time()
print("about to read it in...")
bt = BestTrackForcing(storm_name, nws=8)
try:
print("about to clip...")
bt.clip_to_bbox(bbox, mesh.crs)
except:
print(f"failure on storm {storm}")
pass
filenew = pathlib.Path(f"{pnew}/{storm}")
print("about to write")
bt.write(filenew, overwrite=True)
print(f"Processed storm {storm}")
print(f"Elapsed time is: {time.time()-t1}")
On https://github.com/jreniel/AdcircPy/blob/master/AdcircPy/Validation/COOPS/TidalStations.py, if the date range is larger than 31 days, the data fetching will fail.
running from CoupledModelDriver
with ADCIRCpy v1.0.24
:
(coupledmodeldriver) Zachary.Burnett@hfe08 /scratch2/COASTAL/coastal/save/shared/working/zach
➜ python scripts/hera_hsofs_sandy_rewritten_mesh.py
[2021-03-25 12:34:17,149] cplmdldrv INFO : generating 1 "hera" configuration(s) in "/scratch2/COASTAL/coastal/save/shared/working/zach/hera_hsofs_sandy_rewritten_mesh_20210325T123417"
[2021-03-25 12:34:17,150] cplmdldrv INFO : opening mesh "/scratch2/COASTAL/coastal/save/shared/models/meshes/hsofs/grid_v1/fort.14"
[2021-03-25 12:36:26,595] cplmdldrv INFO : wrote NEMS coldstart configuration: nems.configure, config.rc, model_configure
[2021-03-25 12:36:27,141] cplmdldrv INFO : writing NEMS hotstart configuration: nems.configure, config.rc, model_configure
[2021-03-25 12:36:27,172] cplmdldrv INFO : rewriting original mesh "/scratch2/COASTAL/coastal/save/shared/models/meshes/hsofs/grid_v1/fort.14"
Traceback (most recent call last):
File "/scratch2/COASTAL/coastal/save/shared/working/zach/scripts/hera_hsofs_sandy_rewritten_mesh.py", line 76, in <module>
write_adcirc_configurations(
File "/scratch2/COASTAL/coastal/save/shared/repositories/CoupledModelDriver/coupledmodeldriver/adcirc.py", line 392, in write_adcirc_configurations
driver.write(
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/driver.py", line 408, in write
super().write('coldstart', output_directory / coldstart,
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/fort15.py", line 311, in write
f.write(self.fort15(runtype))
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/fort15.py", line 90, in fort15
f.append(self.get_tidal_forcing())
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/fort15.py", line 344, in get_tidal_forcing
amp, phase = self.tidal_forcing.tidal_dataset(
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/forcing/tides/dataset.py", line 29, in __call__
return self.get_amplitude(constituent, vertices), \
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/forcing/tides/hamtide.py", line 49, in get_amplitude
return self._get_interpolation('elevation', 'AMPL', constituent,
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/forcing/tides/hamtide.py", line 125, in _get_interpolation
dataset = self._get_dataset(variable, constituent)
File "/scratch2/COASTAL/coastal/save/shared/repositories/adcircpy/adcircpy/forcing/tides/hamtide.py", line 101, in _get_dataset
self.datasets[variable][constituent]['path'] = path
KeyError: 'Q1'
Originally posted by @zacharyburnettNOAA in noaa-ocs-modeling/CoupledModelDriver#44 (comment)
Development of class to manage GFS wind forcing files.
in the techreport
branch on 420d3f4, related to #57
https://github.com/JaimeCalzadaNOAA/adcircpy/runs/2115671220?check_suite_focus=true
======================================================================
ERROR: test_make_plot_flat_domain (tests.mesh.test_adcirc_mesh.AdcircMeshTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/unittest/mock.py", line 1325, in patched
return func(*newargs, **newkeywargs)
File "/home/runner/work/adcircpy/adcircpy/tests/mesh/test_adcirc_mesh.py", line 224, in test_make_plot_flat_domain
h.make_plot()
File "/home/runner/work/adcircpy/adcircpy/adcircpy/mesh/figures.py", line 87, in decorator
axes = f(*argv, **kwargs)
File "/home/runner/work/adcircpy/adcircpy/adcircpy/mesh/mesh.py", line 425, in make_plot
self.tricontourf(
File "/home/runner/work/adcircpy/adcircpy/adcircpy/mesh/figures.py", line 87, in decorator
axes = f(*argv, **kwargs)
File "/home/runner/work/adcircpy/adcircpy/adcircpy/mesh/base.py", line 192, in tricontourf
axes.tricontourf(self.triangulation, self.values, **kwargs)
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/matplotlib/tri/tricontour.py", line 321, in tricontourf
return TriContourSet(ax, *args, **kwargs)
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/matplotlib/tri/tricontour.py", line 40, in __init__
ContourSet.__init__(self, ax, *args, **kwargs)
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/matplotlib/contour.py", line 816, in __init__
kwargs = self._process_args(*args, **kwargs)
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/matplotlib/tri/tricontour.py", line 52, in _process_args
tri, z = self._contour_args(args, kwargs)
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/matplotlib/tri/tricontour.py", line 107, in _contour_args
self._process_contour_level_args(args[1:])
File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/site-packages/matplotlib/contour.py", line 1172, in _process_contour_level_args
raise ValueError("Contour levels must be increasing")
ValueError: Contour levels must be increasing
----------------------------------------------------------------------
Ran 63 tests in 4.008s
FAILED (errors=1)
There's a previous commit
I did some quick searches with the keyword "shoreline" and "shapefile" but no commits turned up. Do you have a recollection when this commit was made to narrow it down?
def __fetch_coastline(self):
cache = _get_cache_directory()
file_path = str(Path(
cache + '/ne_110m_coastline/ne_110m_coastline.shp'))
if not os.path.isfile(file_path):
zip_file_path = str(Path(cache + '/ne_110m_coastline.zip'))
url = 'http://naciscdn.org/naturalearth/'
url += '110m/physical/ne_110m_coastline.zip'
urllib.request.urlretrieve(url, zip_file_path)
_zip = zipfile.ZipFile(zip_file_path)
outdir = str(Path(cache + '/ne_110m_coastline'))
os.makedirs(outdir, exist_ok=True)
for name in _zip.namelist():
data = _zip.read(name)
outfile = os.path.join(outdir, name)
f = open(outfile, 'wb')
f.write(data)
f.close()
os.remove(zip_file_path)
DataSource = ogr.Open(file_path)
Layer = DataSource.GetLayer()
vertices_collection = list()
for feature in Layer:
Geometry = feature.GetGeometryRef()
points = Geometry.GetPoints()
vertices_collection.append(np.asarray(points))
return vertices_collection
This is a very old protoype which uses GDAL bindings directly. We need to check if the URL is still alive, and replace the _get_cache_directory()
with appdirs
module. Then just plot the geometry as background. It's not very high res but is a small file and it gives you a good idea of how far the storm is from the land.
Originally posted by @JaimeCalzadaNOAA in #81 (comment)
when running from besttrack
on nws=8
, ADCIRC gives the following error:
ERROR: getHollandStormData: The fort.22 file ends before RNDAY.
ERROR: windTerminate: ADCIRC terminating.
I've checked that the modeled forcing start time (at the bottom of fort.15
) is consistent with the beginning of the fort.22
, but @WPringle tells me that it should actually be consistent with the beginning of spinup time, and that is why it is breaking (it's starting late and ending past the end of the fort.22
)
related issue:
noaa-ocs-modeling/EnsemblePerturbation#40 (comment)
I'm working on a fix that uses the spinup start time instead of the run start.
I can guarantee you that a convex hull is not what represents the mesh's outer boundary. This breaks a lot of things.
https://github.com/jreniel/adcircpy/blob/5618de27360bced8d796168b6e70c1c0c0959b7c/adcircpy/mesh/base.py#L310
There's no reason for the "hull" of a mesh to be convex. In fact in most cases it is concave! Making a convex assumption is simply mathematically incorrect.
This is similar to the conversation we were having a few year ago about not using alpha shapes. Alpha shapes and the convex hull are not appropriate to compute the mesh's outer shell.
@zacharyburnettNOAA I've updated pip to v1.0.13 but dunamai doesn't seem to be pip friendly. Can you test and suggest a fix? Thanks!
Originally posted by @JaimeCalzadaNOAA in #37 (comment)
======================================================================
ERROR: test_best_track_run (tests.test_best_track_run.BestTrackRunCliTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/adcircpy/adcircpy/tests/test_best_track_run.py", line 51, in test_best_track_run
best_track_run.main()
File "/home/runner/work/adcircpy/adcircpy/adcircpy/cmd/best_track_run.py", line 57, in main
BestTrackRunCommand(args).run()
File "/home/runner/work/adcircpy/adcircpy/adcircpy/cmd/best_track_run.py", line 25, in __init__
bt.clip_to_bbox(self.mesh.get_bbox(output_type='bbox'), self.mesh.crs)
File "/home/runner/work/adcircpy/adcircpy/adcircpy/forcing/winds/best_track.py", line 524, in clip_to_bbox
utm_crs = CRS(
File "/opt/hostedtoolcache/Python/3.8.10/x64/lib/python3.8/site-packages/pyproj/crs/crs.py", line 313, in __init__
self._local.crs = _CRS(self.srs)
File "pyproj/_crs.pyx", line 2326, in pyproj._crs._CRS.__init__
pyproj.exceptions.CRSError: Invalid projection: +proj=utm +zone=18P +ellps=WGS84 +type=crs: (Internal Proj Error: proj_create: Error 1027 (Invalid value for an argument): utm: Invalid value for zone)
When installing with the constraint adcircpy>=1.0.20
, for instance, the matched version becomes 1.10b0
:
2021-03-02T17:29:36.2375381Z Searching for adcircpy>=1.0.20
2021-03-02T17:29:36.2377907Z Reading https://pypi.org/simple/adcircpy/
2021-03-02T17:29:36.3776097Z Downloading https://files.pythonhosted.org/packages/cb/2d/58dde0d59777923eb41bd5fad8ee5c151cdd0285e1e40685e916e95d569e/adcircpy-1.10b0.tar.gz#sha256=90c3d18b80fc243ca265b27e29e527e9b7ed93c387152cc4fce3761623d707c8
2021-03-02T17:29:36.4839137Z Best match: adcircpy 1.10b0
2021-03-02T17:29:36.4841675Z Processing adcircpy-1.10b0.tar.gz
@JaimeCalzadaNOAA would you mind yanking the 1.10b0 release from pypi? This would solve this problem
See results of action on last 2 releases.
I just installed adcircpy (I use Anaconda on Windows 10) and am now trying to look at my fort.14 grid. When trying to import
from AdcircPy.Model import AdcircMesh
or
from AdcircPy import read_mesh
I get the following error
URLError: <urlopen error ftp error: URLError("ftp error: error_perm('550 tpxo9_netcdf.tar.gz: No such file or directory')")>
Note, I have not installed Adcirc (or the TPXO database) as I'm just using the grid in SWAN at the moment. I haven't properly dug into the code yet but from the description of adcircpy I should be able to simply read the mesh. Any idea why I need TPXO for that? Thanks for your help.
when running tests in CoupledModelDriver
on my local (Windows) machine, the following error is raised:
OSError: [Errno -37] NetCDF: Write to read only: b'https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/m2.hamtide11a.nc'
here is the full pytest output:
FAILED [ 33%][2021-03-02 10:20:50,534] adcirc INFO : writing config to "output\local_shinnecock_ike\runs\test_case_1"
[2021-03-02 10:19:49,922] adcirc WARNING : mesh values (nodal attributes) not found at "input\shinnecock_ike\mesh\fort.13"
[2021-03-02 10:19:53,153] configuration WARNING : could not create symbolic link: [WinError 1314] A required privilege is not held by the client: 'output\\local_shinnecock_ike\\model_configure' -> 'output\\local_shinnecock_ike\\atm_namelist.rc'
[2021-03-02 10:19:56,326] configuration WARNING : could not create symbolic link: [WinError 1314] A required privilege is not held by the client: 'output\\local_shinnecock_ike\\model_configure' -> 'output\\local_shinnecock_ike\\atm_namelist.rc'
Cookie file cannot be read and written: (null)
tests\test_configurations.py:30 (test_local_shinnecock_ike)
def test_local_shinnecock_ike():
platform = 'local'
mesh = 'shinnecock'
storm = 'ike'
input_directory = Path('.') / 'input' / f'{mesh}_{storm}'
mesh_directory = download_mesh(mesh, storm, input_directory)
forcings_directory = input_directory / 'forcings'
output_directory = Path('.') / 'output' / f'{platform}_{mesh}_{storm}'
reference_directory = Path('.') / 'reference' / f'{platform}_{mesh}_{storm}'
runs = {f'test_case_1': (None, None)}
nems = ModelingSystem(
start_time=datetime(2008, 8, 23),
end_time=datetime(2008, 8, 23) + timedelta(days=14.5),
interval=timedelta(hours=1),
atm=AtmosphericMeshEntry(forcings_directory / 'wind_atm_fin_ch_time_vec.nc'),
wav=WaveMeshEntry(forcings_directory / 'ww3.Constant.20151214_sxy_ike_date.nc'),
ocn=ADCIRCEntry(11),
)
nems.connect('ATM', 'OCN')
nems.connect('WAV', 'OCN')
nems.sequence = [
'ATM -> OCN',
'WAV -> OCN',
'ATM',
'WAV',
'OCN',
]
tidal_forcing = Tides()
tidal_forcing.use_all()
wind_forcing = AtmosphericMeshForcing(nws=17, interval_seconds=3600)
wave_forcing = WaveWatch3DataForcing(nrs=5, interval_seconds=3600)
> write_adcirc_configurations(
nems,
runs,
mesh_directory,
output_directory,
email_address='[email protected]',
platform=Platform.LOCAL,
spinup=timedelta(days=12.5),
forcings=[tidal_forcing, wind_forcing, wave_forcing],
overwrite=True,
)
C:\Repositories\CoupledModelDriver\tests\test_configurations.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Repositories\CoupledModelDriver\coupledmodeldriver\adcirc.py:298: in write_adcirc_configurations
driver.write(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\driver.py:411: in write
super().write('hotstart', output_directory / hotstart,
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\fort15.py:312: in write
f.write(self.fort15(runtype))
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\fort15.py:91: in fort15
f.append(self.get_tidal_forcing())
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\fort15.py:345: in get_tidal_forcing
amp, phase = self.tidal_forcing.tidal_database(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:44: in __call__
amp = self.get_amplitude(constituent, vertices)
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:51: in get_amplitude
return self._get_interpolation(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:97: in _get_interpolation
zi = self._get_resource(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:84: in _get_resource
return Dataset(base_url + fname)
src\netCDF4\_netCDF4.pyx:2330: in netCDF4._netCDF4.Dataset.__init__
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E OSError: [Errno -37] NetCDF: Write to read only: b'https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/m2.hamtide11a.nc'
src\netCDF4\_netCDF4.pyx:1948: OSError
# open mesh file
mesh = AdcircMesh.open(MESH, crs=4326)
# add the nodal attributes file
mesh.import_nodal_attributes(FORT13)
for attr in mesh.get_nodal_attribute_names():
mesh.set_nodal_attribute_coldstart_state(attr, True)
mesh.set_nodal_attribute_hotstart_state(attr, True)
which is fairly non-intuitive if you ask me. I guess you have a reason for that.
driver = AdcircRun(mesh)
driver.write(OUTPUT_DIRECTORY, overwrite=True)
BestTrack
file) the start date and end date do not appear to be automatically specified and this leads to an error when figuring out the tidal potentials. from datetime import timedelta
from pathlib import Path
from adcircpy import AdcircMesh, AdcircRun, Tides
from adcircpy.forcing.winds import BestTrackForcing
from adcircpy.server import SlurmConfig
from tests import download_mesh
MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_3'
download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
)
# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
# initialize tidal forcing and constituents
tidal_forcing = Tides()
tidal_forcing.use_all()
mesh.add_forcing(tidal_forcing)
# initialize wind forcing
wind_forcing = BestTrackForcing('Sandy2012')
mesh.add_forcing(wind_forcing)
# initialize Slurm configuration
slurm = SlurmConfig(
account='account',
ntasks=1000,
run_name='adcircpy/examples/example_3.py',
partition='partition',
walltime=timedelta(hours=8),
mail_type='all',
mail_user='[email protected]',
log_filename='example_3.log',
modules=['intel/2020', 'impi/2020', 'netcdf/4.7.2-parallel'],
path_prefix='$HOME/adcirc/build',
)
# instantiate driver object
driver = AdcircRun(mesh, spinup_time=timedelta(days=15), server_config=slurm)
# write driver state to disk
driver.write(OUTPUT_DIRECTORY, overwrite=True)
results in
(firedrake) (base) keiths-MacBook-Pro:prep Keith$ python debug.py
100% [..........................................................................] 4260693 / 4260693Traceback (most recent call last):
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 459, in start_date
return self.__start_date
AttributeError: 'Tides' object has no attribute '_Tides__start_date'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "debug.py", line 49, in <module>
driver.write(OUTPUT_DIRECTORY, overwrite=True)
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/driver.py", line 404, in write
super().write('coldstart', output_directory / coldstart, overwrite)
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/fort15.py", line 431, in write
f.write(self.fort15(runtype))
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/fort15.py", line 161, in fort15
f.append(self.get_tidal_forcing())
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/fort15.py", line 445, in get_tidal_forcing
forcing = self.mesh.forcings.tides(constituent)
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 39, in __call__
return self.get_tidal_constituent(constituent)
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 112, in get_tidal_constituent
self.get_nodal_factor(constituent),
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 174, in get_nodal_factor
return self.EQ75
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 394, in EQ75
return np.sin(self.I) * np.cos(self.I / 2.0) ** 2 / 0.37988
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 578, in I
return np.arccos(0.9136949 - 0.0356926 * np.cos(self.N))
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 582, in N
return np.deg2rad(self.DN)
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 586, in DN
return self.get_lunar_node()
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 346, in get_lunar_node
- 0.0022064139 * self.hour_middle
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 590, in DYR
return self.forcing_start_date.year - 1900.0
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 474, in forcing_start_date
return self.start_date - self.spinup_time
File "/Users/Keith/Desktop/PostDoctoralWork/codes/firedrake/lib/python3.7/site-packages/adcircpy/forcing/tides/tides.py", line 462, in start_date
raise AttributeError(msg)
driver.NFOVER = [1 ,6, 0, 50, 8]
adcircpy
via pip install adcircpy
I wanted to use the best_track_file functionality to produce a fort.20 from a best track (Hurricane Sandy).(base) keiths-MacBook-Pro:KeithJaredR Keith$ best_track_file -h
Traceback (most recent call last):
File "/Applications/miniconda3/bin/best_track_file", line 5, in <module>
from adcircpy.cmd.best_track_file import main
File "/Applications/miniconda3/lib/python3.7/site-packages/adcircpy/cmd/best_track_file.py", line 4, in <module>
from adcircpy.forcing.winds.best_track import BestTrackForcing
File "/Applications/miniconda3/lib/python3.7/site-packages/adcircpy/forcing/winds/best_track.py", line 10, in <module>
from adcircpy.forcing.winds.base import _WindForcing
ModuleNotFoundError: No module named 'adcircpy.forcing.winds.base'
GHW tests returns
=========================== short test summary info ============================
FAILED tests/test_besttrack.py::test_from_atcf - requests.exceptions.Connecti...
============= 1 failed, 19 passed, 1 warning in 152.74s (0:02:32) ==============
This is because best_track.plot_track(show=True)
tries to download data and the server may block.
Some potential fixes:
Development of OwiForcing class to manage OWI wind forcing files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.