Stream: python-questions
Topic: trouble with time axis using open_mfdataset
Isla Simpson (Oct 14 2020 at 14:14):
Hello, I'm having some trouble reading in the files here on the CGD machines... /project/cmip6/ssp585/Amon/ua/IPSL-CM6A-LR/r1i1p1f1/gr/. I am doing the following...
dat.xr_open_mfdataset(filepath+"*.nc", coords="minimal", join="override", decode_times = False)
where filepath is the above path. I am setting decode_times=False because the calendar goes to 2300 so I'm decoding the times manually afterwards. There are two files in this directory. One that goes from 2015-2100 and one that goes from 2101-2300. For some reason when I do this, it is only reading the second file. I'm not sure if it has something to do with the fact that the time attributes for the first file are "days since 2015-01-01" while those for the second one are "days since 2100-01-01", so the values of time in both files start from 0. So if it doesn't account for the attributes it'll see the dates in the first and second file as being the same. Can anyone help me with this? Thanks!
Deepak Cherian (Oct 14 2020 at 14:17):
I think join="override"
results in overwriting here. Does decode_times=True, use_cftime=True
not work with this range of dates?
Isla Simpson (Oct 14 2020 at 14:29):
Thanks Deepak. Yes, indeed decode_times = True, use_cftime = True does work. When I was first trying to read it with decoding the time axis I had tried dat = xr.open_mfdataset(filepath+"*.nc", coords="minimal", join="override") and this didn't work. But it is working now if I set decode_times = True and use_cftime = True. Thanks a lot!
Deepak Cherian (Oct 14 2020 at 14:30):
yeah use_cftime=True
was the trick there, decode_times=True
is the default
Isla Simpson (Oct 14 2020 at 14:49):
Excellent, thanks a lot.
Last updated: Jan 30 2022 at 12:01 UTC