Regrid netcdf files

Help
Enhao Du
2013-11-12
2013-11-12
  • Enhao Du
    Enhao Du
    2013-11-12

    Hi I have two netcdf precipitation files with different spatial and temporal resolutions:
    precip1
    ny = 192
    nx = 288
    time = 248

    precip2
    lat = 94
    lon = 192
    time = 124

    I'd like to regrid precip1 to the resolution of precip2, then sum up every two time steps in precip1 to reach the temporal resolution of precip2.

    I've found an example of regriding MODIS data, but is rather specific:
    http://nco.sourceforge.net/nco.html#Regrid-MODIS-Data

    Is it possible to achieve these with NCO. Many thanks.

     
  • Charlie Zender
    Charlie Zender
    2013-11-12

    In general regridding is a difficult problem.
    NCO supports bilinear interpolation. See manual.
    Summing every two timesteps can be done with
    is done with the duration feature of ncra:

    ncra -O -v one_dmn_rec_var -y ttl -d time,,,2,2 --mro -p ~/nco/data in.nc ~/foo.nc

     
    • Enhao Du
      Enhao Du
      2013-11-12

      Thanks Charlie for the lightening fast help! Two issues:
      1.I've tried the summing method you mentioned above, which ended up with: ncra: unrecognized option '--mro'
      The nco version we have on Nersc supercomputer is 4.0.8

      2.I've also tried ncap2 with bilinear_interp
      ncap2 -v -s "precip=bilinear_interp(precip,precip,lat_in,lon_in,lat_out,lon_out)" in.nc out.nc
      But the ncap2 is unable to find variable lat_in in in.nc or out.nc. I suspect if I need to create a out.nc upfront with the same lat_in and lon_out.

       
      Last edit: Enhao Du 2013-11-12
  • Charlie Zender
    Charlie Zender
    2013-11-12

    1. Upgrade your NCO
    2. Replace "lat_in" with the name your latitude variable in the input file.
      etc.