2

I have a netcdf file a such:

dimensions:
    time = 8760 ;
    lon_lat = 35047 ;
    temperature = 8760 ;
variables:
    float temp(temperature, lon_lat) ;
        temp:units = "C" ;
    float time(time) ;
    float longitude(lon_lat) ;
        longitude:units = "degrees east" ;
    float latitude(lon_lat) ;
        latitude:units = "degrees north" ;

The netcdf covers all United States. What I would like to do with nco is to delete a specific area, say a square.

So by giving certain coordinates for a certain area, I would remove "cut out" that area.

What I would get then, is a netcdf for the States with the three variables but without data for that specifc area. Say I would get the States with a hole.

I have tried it with Hyperslabs (http://nco.sourceforge.net/nco.html#hyp):

ncks -d lon,-106.,-102. -d lat, 20.,30. in.nc out.nc

However, it says that:

ncks: ERROR dimension longitude is not in input file

Right, because the dimension is (lon_lat). Is there a way to cut it by the variables?

tom
  • 125
  • 6
  • This file does not look right, why is `temperature` a dimension? And why is there a single space dimension `lat_lon`? The file likely should be 3D, `time` x `lat` x `lon`, and have `temperature` as a variable, not dimension. Once you get the file straightened out, you can use hyperslabs to extract a rectangle across `lat` and `lon`. – N1B4 Apr 20 '17 at 12:59

2 Answers2

1

I have the same question as N1B4 about the temperature dimension. The lat_lon dimension probably indicates an unstructured grid.

Try NCO's Auxiliary Coordinates feature. First add these standard_name attributes:

ncatted -a standard_name,latitude,o,c,latitude -a standard_name,longitude,o,c,longitude in.nc 

Then use -X to hyperslab the region you want, i.e., everything but the hole:

ncks -X 10,180,10,90 -X -180,0,-90,0 in.nc out.nc
Charlie Zender
  • 5,929
  • 14
  • 19
0

you can set an area to the netcdf missing value in CDO using:

 cdo setclonlatbox,missing_vlaue,lon1,lon2,lat1,lat2 infile outfile

Is this what you wanted to achieve?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86