You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: parcels/field.py
+27-1Lines changed: 27 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -165,7 +165,13 @@ def __init__(
165
165
self.name=name
166
166
self.data=data
167
167
self.grid=grid
168
-
self.time_interval=get_time_interval(data)
168
+
try:
169
+
self.time_interval=get_time_interval(data)
170
+
exceptValueErrorase:
171
+
e.add_note(
172
+
f"Error getting time interval for field {name!r}. Are you sure that the time dimension on the xarray dataset is stored as datetime or cftime datetime objects?"
173
+
)
174
+
raisee
169
175
170
176
# For compatibility with parts of the codebase that rely on v3 definition of Grid.
classCalendarError(Exception): # TODO: Move to a parcels errors module
252
+
"""Exception raised when the calendar of a field is not compatible with the rest of the Fields. The user should ensure that they only add fields to a FieldSet that have compatible CFtime calendars."""
returnf"Expected field {field.name!r} to have calendar compatible with datetime object {datetime_to_msg(reference_datetime)}. Got field with calendar {datetime_to_msg(field.time_interval.left)}. Have you considered using xarray to update the time dimension of the dataset to have a compatible calendar?"
0 commit comments