html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/1467#issuecomment-465760182,https://api.github.com/repos/pydata/xarray/issues/1467,465760182,MDEyOklzc3VlQ29tbWVudDQ2NTc2MDE4Mg==,14314623,2019-02-20T21:25:01Z,2019-02-20T21:25:01Z,CONTRIBUTOR,"I have run into this problem multiple times. The latest example I found were some [CORE ocean model runs] (https://rda.ucar.edu/datasets/ds262.0/index.html#!description).
The time dimension of some (they mix units) of these files is given as
```
netcdf MRI-A_sigma0_monthly {
dimensions:
level = 51 ;
latitude = 368 ;
longitude = 364 ;
time = UNLIMITED ; // (720 currently)
time_bnds = 2 ;
variables:
double latitude(latitude) ;
latitude:units = ""degrees_north "" ;
latitude:axis = ""Y"" ;
double longitude(longitude) ;
longitude:units = ""degrees_east "" ;
longitude:axis = ""X"" ;
double level(level) ;
level:units = ""m "" ;
level:axis = ""Z"" ;
double time(time) ;
time:units = ""years since 1948-1-1 00:00:00 "" ;
time:axis = ""T"" ;
time:bounds = ""time_bnds"" ;
time:calendar = ""noleap"" ;
double time_bnds(time, time_bnds) ;
float sigma0(time, level, latitude, longitude) ;
sigma0:units = ""kg/m^3 "" ;
sigma0:long_name = ""Monthly-mean potential density (sigma-0) "" ;
sigma0:missing_value = -9.99e+33f ;
}
```
I understand that 'fully' supporting to decode this unit is hard and should probably addressed upstream.
But I think it might be useful to have a utility function that converts a dataset with these units into someting quickly useable with xarray?
E.g. one could load the dataset with `ds = xr.open_dataset(..., decode_times=False)` and then maybe call `xr.decode_funky_units(ds, units='calendaryears', ...)`, which could default to the first day of a year (or the first day of a month for units of `months since`.
This way the user is aware that something is not decoded exactly, but can work with the data.
Is this something that people could see useful here? Id be happy to give an implementation a shot if there is interest.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,238990919
https://github.com/pydata/xarray/issues/1467#issuecomment-311621960,https://api.github.com/repos/pydata/xarray/issues/1467,311621960,MDEyOklzc3VlQ29tbWVudDMxMTYyMTk2MA==,743508,2017-06-28T10:33:33Z,2017-06-28T10:33:33Z,CONTRIBUTOR,"I think I do mean 'years' in the CF convention sense, in this case the time dimension is:
```
double time(time=145);
:standard_name = ""time"";
:units = ""years since 1860-1-1 12:00:00"";
:calendar = ""proleptic_gregorian"";
```
This is correctly interpreted by the NASA Panoply NetCDF file viewer. From glancing at the `xarray` code, it seems it depends on the pandas Timedelta object which in turn doesn't support years as delta objects (although date ranges can be generated at year intervals so it should be possible to implement).
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,238990919