Menu

Clip area in netcdf with irregular polygon coordinates

Help
SM
2016-03-14
2016-03-15
  • SM

    SM - 2016-03-14

    I have a netcdf file with two separate lat and lon variables for area within an irrgular basin. I want to use these lat and lon to clip the corresponding area from another netcdf file and save it as netcdf.

    I have tried to understand mask condition in NCO but have failed. I am new to NCO so having a hard time working with it.

    Thanks

     
  • Charlie Zender

    Charlie Zender - 2016-03-14

    try the ncap2 'where' clause documented at http://nco.sf.net/nco.html#where
    cz

     
    • SM

      SM - 2016-03-15

      Side note: I am using NCO in Windows10/CYGWIN environment and the ncap2 binary is missing. Double checked it to see if I had any issue in installation.

      So I have appended the mask lat and lon variables to the original file and am using the following;
      ncap -O -v -S GPCP_clipped.nc TEST.nc where((lat == latmask) && (lon == lonmask)) prec_mask=PREC; elsewhere prec_mask=PREC@_FillValue;

      and get the error;
      syntax error near unexpected token ('

      I might have misunderstood the statement but I am trying the replace the values with nan where lat and lon do not match the mask area lat and lon.
      (I have attached a sample test file)

       

      Last edit: SM 2016-03-15
  • Charlie Zender

    Charlie Zender - 2016-03-15

    It is possible, though perhaps arduous, to build ncap2 for cygwin. I have no Windows machines and have not done this for some time. You are using ncap (i.e., ncap1) which does not have the where() clause implemented. where() only works for ncap2. Perhaps someone reading this will volunteer to make cygwin NCO binaries available via the NCO homepage :)
    cz

     
  • SM

    SM - 2016-03-15

    I see, I might try to build ncap2 but am still trying to figure out the basics.
    In the meanwhile, is there a way to replace all the values not matching with the mask lat and lon with nans in the sample file.

     

Log in to post a comment.

MongoDB Logo MongoDB