Reputation: 457
I am working in nco and came across this difficult problem. I have to rearrange a 360 day calender into the normal gregorian calender of 365 days. In the 360 day calender each month has 30 days. My idea was to add one day to a month that should consist of 31 days in the gregorian calender and remove one or two days from February (leap or non-leap year). I know how to remove days (simply by copying what you need into another file with ncks).
Is there a simple way to copy the last day of a specific month and add it to the same month in the end?
My files are ranging through a year with 3hr resolution and I want to work with the variable called tas
(temperature). Below I have ncdump'ed the most important part:
dimensions:
rlon = 424 ;
rlat = 412 ;
time = UNLIMITED ; // (2880 currently)
variables:
double rlon(rlon) ;
rlon:standard_name = "grid_longitude" ;
rlon:long_name = "longitude in rotated pole grid" ;
rlon:units = "degrees" ;
rlon:axis = "X" ;
double rlat(rlat) ;
rlat:standard_name = "grid_latitude" ;
rlat:long_name = "latitude in rotated pole grid" ;
rlat:units = "degrees" ;
double time(time) ;
time:standard_name = "time" ;
time:units = "days since 1949-12-01 00:00:00" ;
time:calendar = "360_day" ;
time:long_name = "time" ;
time:axis = "T" ;
float tas(time, rlat, rlon) ;
tas:grid_mapping = "rotated_pole" ;
tas:_FillValue = 1.e+20f ;
tas:missing_value = 1.e+20f ;
tas:standard_name = "air_temperature" ;
tas:long_name = "Near-Surface Air Temperature" ;
tas:units = "K" ;
tas:coordinates = "lon lat height" ;
tas:cell_methods = "time: point" ;
I am looking forward to hear ideas.
Upvotes: 0
Views: 347
Reputation: 6352
If the 360 day data are stored in twelve monthly files, then you can use the ncrcat record append feature along with negative hyperslab indices to count backwards from the end and append the last record to itself
ncrcat --rec_apn -d time,-1 in.nc in.nc
Be sure to back-up your data first as this overwrites the input.
Upvotes: 1
Reputation: 457
I solved this problem by a longer method. First I split the yearly files into months. For each month I added and removed necessary days and then concatenated the resulting months.
If anyone has a faster method please share
Upvotes: 1