Menu

masking a netcdf file less than a threshold

Help
2017-06-28
2017-06-28
  • Lyndon Mark Olaguera

    Dear NCO-experts,
    I want to remove gridpoints in a netcdf file above a certain threshold.
    For example, I just to retain all points with rainfall below 20mm.

    I have not found any one line command in the nco example page. Is this possible in NCO?

    I found this:
    http://nco.sourceforge.net/nco.html#Mask-condition

    but it is accompanied by an ncwa command. I am not going to perform a weighted average.

    I'll appreciate any help.

     

    Last edit: Lyndon Mark Olaguera 2017-06-28
  • John

    John - 2017-06-28

    I do it like this:

    ncap2 -O -s 'where(rainfall>=20)rainfall=-9999' in.nc out.nc

    This assumes that your variable is named 'rainfall' and that the _FillValue attribute for it is set to -9999.

     

    Last edit: John 2017-06-28
  • Lyndon Mark Olaguera

    Many Thanks Sir John for the help!

     

Log in to post a comment.