SourceForge has been redesigned. Learn more.
Close

resampling data with NCO?

Help
Ricky Chu
2012-05-22
2013-10-17
  • Ricky Chu

    Ricky Chu - 2012-05-22

    Hello All,

    I have a global precipitation dataset with spatial resolution of 0.25 degree (.nc format). The time dimessoion is 1200 months. I need to downscale the data to a spatial resolution of 0.5 degree. Is it possible to make this done using NCO?

    Thanks very much!

    Ricky

     
  • Ricky Chu

    Ricky Chu - 2012-05-26

    Thanks. I'm trying to build the recent version of NCO with ncap2.

     
  • augusto

    augusto - 2012-05-28

    Hi Ricky,

    I wonder if you solved your enquiry. I have the same problem and have not been able to make any progress on this. The NCO tools manual only talks about the command 'bilinear_interp' but doesn't explain how to call this command. Will you please share your solution with me? Thanks.

    Regards,

    Augusto

     
  • henry Butowsky

    henry Butowsky - 2012-05-29

    Hi there,
    you just call the function in the normal ncap way :
    The syntax of the command is:
    var_out=bilinear_interp(grid_in,grid_out,grid_out_x,grid_out_y,grid_in_x,grid_in_y)
    and to call it (without writing a script:

    ncap2 -v -O -s 'var_out=bilinear_interp(grid_in,grid_out,grid_out_x,grid_out_y,grid_in_x,grid_in_y)' in.nc foo.nc
    

    … Henry

     
  • augusto

    augusto - 2012-05-31

    Henry,

    Thanks a lot for your help.

    Regards,

    Augusto

     
  • Ricky Chu

    Ricky Chu - 2012-07-02

    Hi, Henry and Augusto,

    I used the command posted by Henry and it seemed not success.

    ncap2 -v -O -s 'deltat=bilinear_interp(deltat,deltat,longitude,latitude,longitude,latitude)' deltat0.25d.nc deltat0.5d.nc

    "deltat" is the variable I want to deal with. deltat0.25d.nc is the original file with resolution of 0.25 degree.  deltat0.5d.nc is the destination file with resolution of 0.5 degree which I made in advance, and all the values of variable deltat in this file is 0.0.  I got the  result with resolution of 0.25 degree instead of  0.5 degree after this command. The new file is the same as the original one.

    I'm wondering I made some mistake while using this command. Can you give me some tips?

    Thanks,

    Ricky

     
  • henry Butowsky

    henry Butowsky - 2012-07-02

    Hi ricky,
      ncap2 works differently from other operators -  In the usual run of things all the vars need to be in the input file.
    1)  If you rename the vars in delta0.5d.nc so that they are different to the var names in delta0.25d.nc
    2)  Then add the new vars in delta0.5d to delta0.25d.nc using ncks -A
    3) then call the bilinear_interp with the new variable names

    1)
        

    ncrename  -v detlat,deltat_out -v longitude,longitude_out -v latitude,latitude_out delta0.5d.nc
         ncks -A delta0.25d.nc delta0.5d.nc
         
         ncap2 -v -O -s 'deltat=bilinear_interp(deltat,deltat_out,longitude_out,latitude_out,longitude,latitude)'  deltat0.5d.nc delta_out.nc
    

    … Henry

     
  • Ricky Chu

    Ricky Chu - 2012-07-03

    Hi Henry,

    Thanks a lot.

    Here is my steps according your tips:

    ncrename -v deltat,deltat_out -v longitude,longitude_out -v latitude,latitude_out -d longitude,longitude_out -d latitude,latitude_out deltat0.5d.nc

    ncks -A deltat0.25d.nc deltat0.5d.nc

    ncap2 -v -O -s 'deltat_out=bilinear_interp(deltat,deltat_out,longitude_out,latitude_out,longitude,latitude)' deltat0.5d.nc deltat0.5d_out.nc

    I got a new file (deltat0.5d_out.nc) with resolution of 0.5 degree. But the result seems not good.  The original one is a global map. The generated one seems too fuzzy and it's not a world profile.

    Do you have any idea?

    Thanks,

    Ricky

     
  • henry Butowsky

    henry Butowsky - 2012-07-03

    Hi Ricky,
    At the moment the bilinear_interp function doesn't take account  of missing values.
    I am considering adding this ; but it may case some drama as a single missing value - would translate to  8 missing values on the input grid - I will do some more thinking  on this.

    … Henry

     
  • Ricky Chu

    Ricky Chu - 2012-07-03

    Hi Henry,

    OK, I see …

    thanks,

    Ricky

     
  • Charlie Zender

    Charlie Zender - 2012-07-09

    Henry,
    In the general case the bilinear interpolation should reduce not amplify the number of missing values.
    So long as there is at least one valid point contributing to the interpolant, all the missing values should be ignored.
    However, doing this requires tweaking the interpolation algorithm to tolerate loss of up to N-1 input point where N is usually four for linear interpolation, which relies on the four closest neighbors (two bounds on X, and two bound on Y).
    cz

     
  • luc

    luc - 2013-03-05

    Hi,
    I'm a beginner with NCO and I would like to use ncap2 bilinear_interp.
    I have a snow cover dataset with spatial resolution of 250m.  I need to downscale the data to a spatial resolution of 500 m.

    with your help, I tried your advices:

    1) If you rename the vars in delta0.5d.nc so that they are different to the var names in delta0.25d.nc
    2) Then add the new vars in delta0.5d to delta0.25d.nc using ncks -A
    3) then call the bilinear_interp with the new variable names

    but I get this error:
    ncap2: ERROR bilinear_interp(): Dimension size mismatch with input variables

    I think my problem is when I use ncks between my 2 files.nc because my files don't have the same dimensions..

    Have you got an idea?

    Thanks a lot
    Luc

     

Log in to post a comment.