0

I have a year of data as monthly NetCDF files, and I'd like to turn them into daily files. I know I can use ncks to extract 24 hours, like this

ncks -d time,0,23 -o output.nc input.nc

but I'd like to automatically chunk the whole month into days, without having to worry about the number of days in each month and whatnot. Is there an easy way to do this? (I could of course write a python script or similar that calls ncks, but it would be more elegant to avoid that.)

Tor
  • 658
  • 6
  • 19

2 Answers2

3

The NCO -d hyperslab switch understands dates in UDUnits format. If your input file contains well-formatted units attribute for time, there should be no problem in writing twelve commands each with a date hyperslab like

ncks -d time,1918-01-01,1918-01-31 in.nc jan.nc

Other than that, there is no more elegant method currently supported by NCO.

Charlie Zender
  • 5,929
  • 14
  • 19
  • That's good to know, I wasn't aware of that. Not quite what I was hoping for, though, as it still requires me to use some other tool to construct the commands. I was thinking of something that would let me say "split this file into chunks of 24 hours each, however many chunks that may be". – Tor Feb 02 '17 at 19:18
2

From the question it is not clear to me if your monthly files contain daily data. i.e. you have 12 files and each file contains daily (or finer) time resolution information. If this is the case then I think what you want to do is very easy with cdo using

cdo splitday input.nc output.nc 

you will end up with a number of files, each with a day of data, and the number of days in each month is handled automatically for you.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86