I have global datasets in netcdf file. Time information on data file is:
<type 'netCDF4._netCDF4.Variable'>
int32 time(time)
units: hours since 1900-01-01 00:00:0.0
long_name: time
calendar: gregorian
unlimited dimensions: time
current shape = (5875,)
filling off
when I extracted time from file, I got this array:
array([ 876600, 876624, 876648, ..., 1017528, 1017552, 1017576], dtype=int32)
my question is how to convert this array into proper date format? [Note: This is a daily data sets and number in an array is corresponding to an hours from 1900-01-01]
The ideal way to do this is using netCDF4 num2date
import netCDF4
ncfile = netCDF4.Dataset('./foo.nc', 'r')
time = ncfile.variables['time']
dates = netCDF4.num2date(time[:], time.units, time.calendar)