-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues modelling tides with JSON definition files #318
Comments
I guess on a similar/related note - does this look correct for loading JSON format definitions directly from a dictionary, e.g. passing the
|
Got it. Having the |
feat: add attribute for minor constituents to model object feat: allow inferring only specific minor constituents feat: allow searching over iterable glob strings in definition files for #318
Ah, makes sense - thanks! One other slight usability improvement could also be auto-guessing the definition file format from the extension/datatype... e.g. if it's a JSON file or |
That's a great idea! Implemented in #319 |
…els (#319) * feat: add attribute for minor constituents to model object * feat: allow inferring only specific minor constituents * feat: allow searching over iterable glob strings in definition files for #318 * feat: add option to auto-detect definition file format for #318 * feat: add back nodal arguments from PERTH3 for backwards compatibility * chore: trim trim trailing whitespace
…els (#319) * feat: add attribute for minor constituents to model object * feat: allow inferring only specific minor constituents * feat: allow searching over iterable glob strings in definition files for #318 * feat: add option to auto-detect definition file format for #318 * feat: add back nodal arguments from PERTH3 for backwards compatibility * chore: trim trim trailing whitespace * docs: add GOT5.5 to getting started
* feat: add attribute for minor constituents to model object * feat: allow inferring only specific minor constituents * feat: allow searching over iterable glob strings in definition files for #318 * feat: add option to auto-detect definition file format for #318 * feat: add back nodal arguments from PERTH3 for backwards compatibility * chore: trim trim trailing whitespace * docs: add GOT5.5 to getting started
Awesome, can confirm that both of these fixes/features work for me! Will do a small validatation of the new GOT models and see how they perform at our tide gauges. 🙂 |
Hey @tsutterley, I've been trying to test out the new GOT5.5/5.6 using the JSON definition files included in
tests
. My directory looks like this:I can run tide modelling for other models (e.g. FES2012) from a
.def
format definition file pretty easily, e.g.:However, if I try to do something similar with a JSON fromat definition, I get an
TypeError: intern() argument must be str, not list
error:Is there anything I'm doing obviously wrong here? I wasn't exactly sure what additional params need to be provided when specifying JSON definition files, beyond
DEFINITION_FORMAT="json"
...Full error
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[23], line 40 18 import numpy as np 20 # out = tide_elevations( 21 # x=[122.14], 22 # y=[-17.9], (...) 36 37 # out ---> 40 out = tide_elevations( 41 x=[122.14], 42 y=[-17.9], 43 delta_time=pd.date_range("2020", "2021", periods=2), 44 DIRECTORY="/gdata1/data/tide_models/", 45 MODEL="GOT5.6", 46 DEFINITION_FILE="/gdata1/data/tide_models/model_GOT5.6.json", 47 DEFINITION_FORMAT="json", 48 EPSG=4326, 49 TIME="datetime", 50 EXTRAPOLATE=True, 51 CUTOFF=np.inf, 52 ) 54 out 56 # # from pyTMD.compute_tide_corrections import compute_tide_corrections 57 58 # # out = compute_tide_corrections( (...) 68 69 # # outFile /env/lib/python3.10/site-packages/pyTMD/compute.py:299, in tide_elevations(x, y, delta_time, DIRECTORY, MODEL, ATLAS_FORMAT, GZIP, DEFINITION_FILE, DEFINITION_FORMAT, CROP, BOUNDS, EPSG, EPOCH, TYPE, TIME, METHOD, EXTRAPOLATE, CUTOFF, INFER_MINOR, APPLY_FLEXURE, FILL_VALUE, **kwargs)
297 # get parameters for tide model
298 if DEFINITION_FILE is not None:
--> 299 model = pyTMD.io.model(DIRECTORY).from_file(DEFINITION_FILE,
300 format=DEFINITION_FORMAT)
301 else:
302 model = pyTMD.io.model(DIRECTORY, format=ATLAS_FORMAT,
303 compressed=GZIP).elevation(MODEL)
File /env/lib/python3.10/site-packages/pyTMD/io/model.py:1408, in model.from_file(self, definition_file, format)
1406 self.from_ascii(fid)
1407 elif (format.lower() == 'json'):
-> 1408 self.from_json(fid)
1409 # close the definition file
1410 fid.close()
File /env/lib/python3.10/site-packages/pyTMD/io/model.py:1734, in model.from_json(self, fid)
1730 elif (temp.type == 'z') and (temp.directory is not None):
1731 # use glob strings to find files in directory
1732 glob_string = copy.copy(temp.model_file)
-> 1734 temp.model_file = list(temp.directory.glob(glob_string))
1735 # attempt to extract model directory
1736 try:
File /env/lib/python3.10/pathlib.py:1030, in Path.glob(self, pattern)
1028 if not pattern:
1029 raise ValueError("Unacceptable pattern: {!r}".format(pattern))
-> 1030 drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
1031 if drv or root:
1032 raise NotImplementedError("Non-relative patterns are unsupported")
File /env/lib/python3.10/pathlib.py:74, in _Flavour.parse_parts(self, parts)
72 else:
73 if rel and rel != '.':
---> 74 parsed.append(sys.intern(rel))
75 if drv or root:
76 if not drv:
77 # If no drive is present, try to find one in the previous
78 # parts. This makes the result of parsing e.g.
79 # ("C:", "/", "a") reasonably intuitive.
TypeError: intern() argument must be str, not list
The text was updated successfully, but these errors were encountered: