Project

General

Profile

Question about remapcon

Added by YUU YAN over 5 years ago

Hi,

I want to use remapcon to interpolate the INPUT.nc with a spatial resolution of 0.25° to 0.025°(x10) with a conservative value.

I enter this command but got the error (cdo remapcon (Abort): Unsupported generic coordinates (Variable: lat)!). Could you please tell me how to solve this? Thanks.

cdo remapcon,output.txt INPUT.nc output.nc

Yu


Replies (6)

RE: Question about remapcon - Added by Jay Su over 5 years ago

ncdump or panoply does not recognize your file.

RE: Question about remapcon - Added by Ralf Mueller over 5 years ago

hi!

netcdf INPUT {
dimensions:
        y = 27 ;
        x = 27 ;
        time_counter = UNLIMITED ; // (12 currently)
variables:
        float lat(y, x) ;
                lat:units = "degrees_east" ;
                lat:valid_min = -86. ;
                lat:valid_max = 90. ;
                lat:long_name = "Latitude" ;
        float lon(y, x) ;
                lon:units = "degrees_east" ;
                lon:valid_min = -180. ;
                lon:valid_max = 180. ;
                lon:long_name = "Longitude" ;
        float runoff(time_counter, y, x) ;
                runoff:units = "Kg/m2/s" ;
                runoff:long_name = "coastal runoff flux (except from antarctica iceshelves) (Dai and Trenberth) + iceberg meltwater flux (Merino I.)" ;
        int time_counter(time_counter) ;
your file does not follow the CF-conventions:

  1. lon,lat do not have a standard_name attribute
  2. runoff is not connected to these coordinates at all because the coordinates attribute if note set

you can repair the file with

cdo -setattribute,lon@standard_name=longitude,lat@standard_name=latitude,runoff@coordinates="lat lon" INPUT.nc in.nc

But conservative interpolation cannot be done, because the corners of the cells are missing. Since these are needed to compute the area of each cell, you

  • can use another method like bilinear or distance-weighted (please check the docu for more)
  • provide the corners as lat_bounds and lon_bounds fields and give these names as the bounds attribute of each coordinate fields (lon and lat), see here for more information about how to handle cell bounds.

cheers
ralf

in.nc (69.7 KB) in.nc

RE: Question about remapcon - Added by YUU YAN over 5 years ago

Hi Ralf,

Thanks so much. I need to use the conservative method rather than the bilnear. So I find another input data (friver_y2013.nc) which has bounds attribute. The variable 'friver' is also not connected to the coordinates. I have repaired this as you suggested with

cdo -setattribute,friver@coordinates="lat lon" friver_y2013.nc in.nc

(The size of in.nc is 1.5 GB, so I can't attach here.)

Then I can use remapcon operator successfully.
cdo remapcon,output.txt in.nc output.nc

However, the variable lat/lon in the output.nc is missing. Could you please kindly tell me how can I solve this?

Cheers,

Yu

RE: Question about remapcon - Added by Ralf Mueller over 5 years ago

output.nc looks ok

 netcdf output {
dimensions:
        time = UNLIMITED ; // (365 currently)
        bnds = 2 ;
        lon = 204 ;
        lat = 244 ;
variables:
        double time(time) ;
                time:standard_name = "time" ;
                time:long_name = "time" ;
                time:bounds = "time_bnds" ;
                time:units = "days since 1900-01-01 00:00:00" ;
                time:calendar = "gregorian" ;
                time:axis = "T" ;
        double time_bnds(time, bnds) ;
        float lon(lon) ;
                lon:standard_name = "longitude" ;
                lon:long_name = "longitude" ;
                lon:units = "degrees_east" ;
                lon:axis = "X" ;
        float lat(lat) ;
                lat:standard_name = "latitude" ;
                lat:long_name = "latitude" ;
                lat:units = "degrees_north" ;
                lat:axis = "Y" ;
        float friver(time, lat, lon) ;
                friver:standard_name = "water_flux_into_sea_water_from_rivers" ;
                friver:long_name = "Water Flux into Sea Water From Rivers" ;
                friver:units = "kg m-2 s-1" ;
                friver:_FillValue = 1.e+20f ;
                friver:missing_value = 1.e+20f ;
                friver:comment = "computed as the river flux of water into the ocean divided by the area of the ocean portion of the grid cell" ;
                friver:cell_methods = "area: mean where sea time: mean" ;
                friver:cell_measures = "area: areacello" ;

lon and lot are still present. you can check it with
cdo -sinfov output.nc
The fact that the coordinates are not listed as variables shouldn't bother you. CDO is designed to handle data variables - coordinates are just implicitly connected to data, so they are not directly accessible.

hth
ralf

RE: Question about remapcon - Added by YUU YAN over 5 years ago

Hi again,

Yes, the lat and lon are existed in the file. But except for the variable of 'friver', I also need to use the lat and lon for the calculation in the next step. Do you know how to list the lat/lon 'apparent'? Thanks

Yu

RE: Question about remapcon - Added by Ralf Mueller over 5 years ago

Dear YUU YAN!

CDO will not show coordinates in any listing as long as they are correctly linked to the data variable (like friver). you can still check the values with

  • % cdo sinfov output.nc
       File format : NetCDF4 classic
        -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
         1 : unknown  MRI      v instant       1   1     49776   1  F32  : friver        
       Grid coordinates :
         1 : lonlat                   : points=49776 (204x244)
                                  lon : 117.4347 to 122.5097 by 0.02499998 degrees_east
                                  lat : 36.91948 to 42.99448 by 0.025 degrees_north
       Vertical coordinates :
         1 : surface                  : levels=1
       Time coordinate :  365 steps
         RefTime =  1900-01-01 00:00:00  Units = days  Calendar = gregorian  Bounds = true
      YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
      2013-01-01 12:00:00  2013-01-02 12:00:00  2013-01-03 12:00:00  2013-01-04 12:00:00
  • % cdo griddes output.nc       
    #
    # gridID 1
    #
    gridtype  = lonlat
    gridsize  = 49776
    datatype  = float
    xsize     = 204
    ysize     = 244
    xname     = lon
    xlongname = "longitude" 
    xunits    = "degrees_east" 
    yname     = lat
    ylongname = "latitude" 
    yunits    = "degrees_north" 
    xfirst    = 117.4347
    xinc      = 0.02499998
    yfirst    = 36.91948
    yinc      = 0.025

So you will still be able to use lon and lat for later calculations. In case you want to use CDO for the calculations, you might have a look into the expr operators. They allow point-wise calculations written on the command line as simple formulas and you have access to locations, dates, times and so on:

hth
ralf

    (1-6/6)