-
Notifications
You must be signed in to change notification settings - Fork 168
Fixes error raised when using multiple files for fields with no time dimension #1886
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
Fixes error raised when using multiple files for fields with no time dimension #1886
Conversation
VeckoTheGecko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pr! Just a small edit - I think due to the nature of this issue it would be good to also link to it in the error message
parcels/field.py
Outdated
|
|
||
| if len(data_filenames) > 1 and "time" not in dimensions and timestamps is None: | ||
| raise RuntimeError("Multiple files given but no time dimension specified") | ||
| warnings.warn("Multiple files given but no time dimension specified", FieldSetWarning, stacklevel=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| warnings.warn("Multiple files given but no time dimension specified", FieldSetWarning, stacklevel=2) | |
| warnings.warn("Multiple files given but no time dimension specified. See https://github.com/OceanParcels/Parcels/issues/1831 for more info.", FieldSetWarning, stacklevel=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, on second thought, perhaps linkint to the issue would be confusing - I'm not sure in which scenarios people would be expected to see the error message ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm not sure linking to the issue is necessary here. Prior to the implementation of the CROCO model support, which relies on parameters like Cs_w and H that don't change in time and was the original source of issues, the error would have caught someone using multiple velocity files (perhaps each intended to each be a different time), but without a time dimension in the files themselves, which does seems like it would be a rare edge case.
A potential alternative that would leave that error in place would be to add on to the if statement a condition that excludes only the fields names (self.name?) used by the CROCO advection (H, Cs_w, and zeta). But I thought just keeping it simple and swapping to a warning is also fine, since this is all an admittedly niche use case.
for more information, see https://pre-commit.ci
mainfor v3 changes,v4-devfor v4 changes)This is a small change that changes a
ValueError(raised when initializing a field which does not have a time dimension from multiple files, e.g.,Cs_wused inFieldSet.from_croco()) into aFieldSetWarning. This enables the support for such fields implemented in #1835.