Filtering out time object in netcdf data #8650
-
What happened?I work with netcdf data and need to convert time variable to datetimeindex before using it with another package. However, function What did you expect to happen?I expected this command to work: however, I get the following error: Snapshot of the data
Peek into the variable
Ideal scenarioI would like either to automatically get rid of all dates that don't exist, or at least be able to filter them manually with the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for the very clear question! I recommend taking a look at the data.convert_calendar("standard", dim="time", align_on="date") Regarding data.drop_sel(time=cftime.Datetime360Day(2091, 2, 29, 12)) |
Beta Was this translation helpful? Give feedback.
Thanks for the very clear question! I recommend taking a look at the
convert_calendar
method—I think the following should do what you are looking for:Regarding
drop_sel
, for data indexed by aCFTimeIndex
, xarray currently only accepts explicit cftime objects. Right now it will not automatically convert strings to dates, but we could consider changing that: