All, I am trying to read the time coordinate from Berkley Earth in the following temperature file. The time spans from 1850 to 2022. The time unit is in the year A.D. (1850.041667, 1850.125, 1850.208333, ..., 2022.708333, 2022.791667,2022.875).
The pandas.to_datetime
cannot correctly interpret the time array because I think I need to state the origin of the time coordinate and the unit. I tried
to use pd.to_datetime(dti,unit='D',origin='julian’)
, but it did not work (out of bounds). Also, I think I have to use a unit of years instead of Days.
The file is located here http://berkeleyearth.lbl.gov/auto/Global/Gridded/Land_and_Ocean_LatLong1.nc
import xarray as xr
import numpy as np
import pandas as pd
# read data into memory
flname="Land_and_Ocean_LatLon1.nc"
ds = xr.open_dataset("./"+flname)
dti = ds['time']
pd.to_datetime(dti,unit='D',origin='julian')
np.diff(dti)