Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

CESM2 historical output data "time" variable not matching time period indicated by file naming convention...

milunita

Michelle
New Member
Good afternoon!

I am kindly requesting insight into the "time" variable in CESM2 historical output data. While the filename ('psl_Amon_CESM2_historical_r4i1p1f1_gn_185001-201412.nc') indicates that the historical run extends from January 1850 to December 2014, my time conversion using Python's datetime module yields a start date of October 24, 1848. Has anyone else run into a similar issue? The historical file's metadata states that the "time" variable is days since 0001-01-01, which is what I use to calculate the date at each timestep. Any and all help is greatly appreciated. Thanks in advance!

Here's my code:

hist_file = nc.Dataset('psl_Amon_CESM2_historical_r4i1p1f1_gn_185001-201412.nc')
time = hist_file.variables['time'][:]

from datetime import date, timedelta

monthly_dates = []
start = date(1,1,1)
for i in time:
days = i
delta = timedelta(days)
offset = start + delta
monthly_dates.append(offset)
monthly_dates[0]

Output is: datetime.date(1848, 10, 24)
 
Solution
Good afternoon!

I am kindly requesting insight into the "time" variable in CESM2 historical output data. While the filename ('psl_Amon_CESM2_historical_r4i1p1f1_gn_185001-201412.nc') indicates that the historical run extends from January 1850 to December 2014, my time conversion using Python's datetime module yields a start date of October 24, 1848. Has anyone else run into a similar issue? The historical file's metadata states that the "time" variable is days since 0001-01-01, which is what I use to calculate the date at each timestep. Any and all help is greatly appreciated. Thanks in advance!

Here's my code:

hist_file = nc.Dataset('psl_Amon_CESM2_historical_r4i1p1f1_gn_185001-201412.nc')
time = hist_file.variables['time'][:]...

strandwg

Moderator
Staff member
Good afternoon!

I am kindly requesting insight into the "time" variable in CESM2 historical output data. While the filename ('psl_Amon_CESM2_historical_r4i1p1f1_gn_185001-201412.nc') indicates that the historical run extends from January 1850 to December 2014, my time conversion using Python's datetime module yields a start date of October 24, 1848. Has anyone else run into a similar issue? The historical file's metadata states that the "time" variable is days since 0001-01-01, which is what I use to calculate the date at each timestep. Any and all help is greatly appreciated. Thanks in advance!

Here's my code:

hist_file = nc.Dataset('psl_Amon_CESM2_historical_r4i1p1f1_gn_185001-201412.nc')
time = hist_file.variables['time'][:]

from datetime import date, timedelta

monthly_dates = []
start = date(1,1,1)
for i in time:
days = i
delta = timedelta(days)
offset = start + delta
monthly_dates.append(offset)
monthly_dates[0]

Output is: datetime.date(1848, 10, 24)

That version of CESM has a fixed 365 day calendar with no leap years, so your computation needs to take that into account.

The "time" coordinate variable has the attribute "noleap" to signify this property.
 
Vote Upvote 0 Downvote
Solution
Top