MITgcm/xmitgcm

interpreted values of 'time' by open_mdsdataset overflow

Opened this issue · 1 comments

If I run sth like
ds = open_mdsdataset(data_dir, delta_t=1200, prefix=['U','V','T','PTRACER01'], iters=range(6220800,6220800+9592160,2160)
,ignore_unknown_vars=True, geometry='cartesian', default_dtype='>f8')
open_mdsdataset will interpret 'time' by calculating iters times delta_t and so in this case ds.time.values begins with 6220800
1200 = 7464960000 s = 7464960000000000000 ns. Up to iteration 7685281, this 'time' value will overflow and has value -9221816073709551616 ns, so does any iteration after that. More importantly, it seems open_mdsdataset order data by this 'time' value instead of the iteration number so now it will place this data with negative 'time' in front of data with positive 'time' value, even though in this order the iteration is not monotonically increasing. So now ds.isel(time=0) will correspond to data with iteration number 7685281 instead of 6220800.
Is there thing I should do to avoid this issue?

I can confirm that I have this problem as well with xmitgcm 0.5.1 and xarray 0.18.2. As a temporary fix you can sort everything by iteration rather than time: ds2 = ds.sortby(ds.iter). The time variable will still be wrong, but at least the rest of the data will be in the right order.