-
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
Issue with Iterating Over Model Files in pyTMD.io.ATLAS.extract_constants() #258
Comments
Hi @mirkorupani, for t in model.type:
amplitude, phase, D, constituents = pyTMD.io.ATLAS.extract_constants(
ilon, ilat, model.grid_file, model.model_file[t], type=t,
scale=model.scale) Let me know if this fixes the issue. |
test: fix u and v for TPXO9-atlas netCDF fix: escape sequences in docstrings to raw
Changes are now merged into main. Feel free to reopen this issue if need be :) |
Description:
I have encountered an issue in the extract_constants function in pyTMD.io.ATLAS, specifically when using the 'TPXO9-atlas-v2' model for currents. In previous versions, the function iterated over a list of model files directly, while in the latest version, it iterates over the keys ("u" and "v") of a dictionary containing the model files. This change causes the function to incorrectly loop over the dictionary keys instead of the actual files.
Affected Code:
The relevant code snippets in the latest version looks like this:
# number of constituents nc = len(model_files)
for i, model_file in enumerate(model_files):
Proposed Fix:
I have found that these corrections fix this issue, at least in my specific case.
The loop should iterate over the list of model files corresponding to the specified type. The modified snippets should be:
# number of constituents nc = len(model_files[kwargs['type']])
for i, model_file in enumerate(model_files[kwargs['type']]):
These changes ensure that the function correctly calculates the number of constituents and iterates over the actual files associated with the specified type.
Steps to Reproduce:
model = pyTMD.io.model(tpxodirectory).current('TPXO9-atlas-v2')
(amplitude, phase, D, constituents) = extract_constants(ilon, ilat, model.grid_file, model.model_file, type="u")
Expected Result:
The function should iterate over the list of model files for the specified type.
Actual Result:
The function currently iterates over the dictionary keys, causing a FileNotFoundError.
Additional Information:
Thank you for your attention to this matter.
Best regards,
Mirko.
The text was updated successfully, but these errors were encountered: