ClimateUnboxed
ClimateUnboxed

Reputation: 8077

How to convert annual netCDF data to daily from the command line?

Before I resort to using Python, I would like to know if there is a simple way from the command line to convert an annual netCDF file into a file with daily data simply by duplication (including leap years), i.e. each annual value is duplicated 365 (366) times with the appropriate date stamp.

In the file each data value has the date stamped for the first day of each year:

cdo showdate population_ssp2soc_0p5deg_annual_2006-2100_density.nc4
2006-01-01  2007-01-01  2008-01-01  2009-01-01  2010-01-01  ...etc

I know it seems like a strange thing to do (the file size will be 365.25 times bigger!), but I want to read the data into a Fortran program that uses a daily timestep and do not want to mess around with dates in the Fortran code.

Upvotes: 1

Views: 581

Answers (1)

Robert Wilson
Robert Wilson

Reputation: 3397

There might be a more efficient way of doing this. But you could first merge the original file and then a second which is the first, but time shifted to the final day of the year. Then temporally interpolate:

cdo -mergetime population_ssp2soc_0p5deg_annual_2006-2100_density.nc4 -shifttime,-1day -shifttime,1year population_ssp2soc_0p5deg_annual_2006-2100_density.nc4 temp.nc

cdo inttime,2006-01-01,12:00:00,1day temp.nc outfile.nc

Upvotes: 2

Related Questions