Search code examples
pythonpython-3.xnetcdfnetcdf4nco

Copy select netCDF dimension n times and all variables to new netCDF


I'm having trouble thinking of a way to copy a netCDF file n times on dimension time. The file contains 8 time dates enter image description here but I need to copy the 4th, 5th, 6th, and 7th values of dimension time 6 times along with each of the variables and the 8th once to a new netCDF file. What I'm hoping to create is dimension time of 25.

Any help with this irrational way of thinking would be appreciative.


Solution

  • The meaning of all the options is in the manual:

    ncrcat -O -F -d time,4,7 in.nc out.nc
    ncrcat --rec_apn -F -d time,4,7 in.nc out.nc
    ncrcat --rec_apn -F -d time,4,7 in.nc out.nc
    ncrcat --rec_apn -F -d time,4,7 in.nc out.nc
    ncrcat --rec_apn -F -d time,4,7 in.nc out.nc
    ncrcat --rec_apn -F -d time,4,8 in.nc out.nc