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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
try the ncap2 'where' clause documented at http://nco.sf.net/nco.html#where
cz
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
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
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.