shambakey1
shambakey1

Reputation: 47

wrong cftime value from a netcdf file

I'm opening a netcdf file with xarray. 'exp_date' is one of the dimensions in the NETCDF, and its description in the netcdf as follows:

double exp_date(exp_date) ;
        exp_date:calendar = "noleap" ;
        exp_date:long_name = "time" ;
        exp_date:standard_name = "time" ;
        exp_date:units = "days since 2021-09-30 00:00:00" ;

"exp_date" has only one value: 153675

The problem is, when the file is parsed with xarray, it gives the following cftime value for the exp_date:

<xarray.DataArray 'exp_date' (exp_date: 1)>
array([cftime.DatetimeNoLeap(2442, 10, 10, 0, 0, 0, 0)], dtype=object)
Coordinates:
  * exp_date  (exp_date) object 2442-10-10 00:00:00
Attributes:
    long_name:      time
    standard_name:  time

The "exp_date" value in the parsed xarray (i.e., 2442, 10, 10) is not the result of adding 153675 days to 2021-9-30. I don't know how to solve this.

Regards

Upvotes: 0

Views: 138

Answers (1)

Robert Wilson
Robert Wilson

Reputation: 3397

xarray appears to be doing the right thing here. Note that the calendar is "noleap". My guess is you are working with model output where each year has 365 days.

In a standard calendar 153675 day after 2021-9-30 is 2442-6-30, but every 4 years this is counting a day in a leap year that should not be counted. Once you adjust for that the result is 2442-10-10.

Upvotes: 2

Related Questions