Project

General

Profile

Fail to remap after convert ascii to nc

Added by Yijun Yang about 1 year ago

Hi all,

I tried to remap the file 'heff.H1993' on the EASE-Grids ('outgrid1.txt'). First, I convert 'heff.H1993' to nc format '1993.nc' by python. Here is the information in '1993.nc':

Dimensions:
           t = 12
           x = 120
           y = 360
Variables:
    thickness
           Size:       360x120x12
           Dimensions: y,x,t
           Datatype:   double
           Attributes:
                       _FillValue  = NaN
                       coordinates = 'longitude latitude month'
    longitude
           Size:       360x120
           Dimensions: y,x
           Datatype:   double
           Attributes:
                       _FillValue = NaN
    latitude 
           Size:       360x120
           Dimensions: y,x
           Datatype:   double
           Attributes:
                       _FillValue = NaN
    month    
           Size:       12x1
           Dimensions: t
           Datatype:   int32

Next, I remap the data as follows:

$ cdo remapbil,outgrid1.txt -selname,thickness 1993.nc output.nc
cdo(1) selname: Process started
Warning (cdfInqContents): Coordinates variable longitude can't be assigned!
Warning (cdfInqContents): Coordinates variable latitude can't be assigned!
Warning (cdfInqContents): Coordinates variable month can't be assigned!
cdo    remapbil (Abort): Unsupported generic coordinates (Variable: thickness)!
terminate called without an active exception
Aborted (core dumped)

The files are all attached. Many thanks in advance for your help!


Replies (4)

RE: Fail to remap after convert ascii to nc - Added by Uwe Schulzweida about 1 year ago

The units of the coordinates are missing. You can add them with:

ncatted -a units,latitude,c,c,"degrees_north" -a units,longitude,c,c,"degrees_east" 1993.nc 

RE: Fail to remap after convert ascii to nc - Added by Yijun Yang about 1 year ago

Hi Uwe,

Thanks so much for your prompt reply! This problem is fixed by adding the units of the coordinates and also resetting the time.

Unfortunately, I got the same warning for the 'time' variable when remap and cat the CS2SMOS data, which I would like to ask for your kind help.

Here is what I have done:

$ cdo remapbil,outgrid1.txt -selname,analysis_sea_ice_thickness W_XX-ESA,SMOS_CS2,NH_25KM_EASE2_20101229_20110104_r_v204_01_l4sit.nc out.nc
cdo(1) selname: Process started
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
cdo    remapbil: Bilinear weights from curvilinear (432x432) to curvilinear (361x361) grid, with source mask (20929)
cdo(1) selname: Processed 10 variables over 1 timestep.
cdo    remapbil: Processed 186624 values from 1 variable over 1 timestep [4.26s 81MB].

$ cdo cat W_XX-ESA,SMOS_CS2,NH_25KM_EASE2_20101229_20110104_r_v204_01_l4sit.nc W_XX-ESA,SMOS_CS2,NH_25KM_EASE2_20101230_20110105_r_v204_01_l4sit.nc out.nc
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
cdo    cat:  50%Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
Warning (cdfInqContents): Coordinates variable time can't be assigned!
cdo    cat: Processed 20 variables over 2 timesteps [4.15s 76MB].

Firstly I thought that the coordinates of time caused this problem, so I removed the time bounds of the coordinates for time, but it didn't work.
I also tried to select the variable firstly by 'cdo selvar,analysis_sea_ice_thickness W_XX-ESA,SMOS_CS2,NH_25KM_EASE2_20101229_20110104_r_v204_01_l4sit.nc sel.nc', but I got the same warning as remapping.

The head information of this file is:

$ ncdump -h W_XX-ESA,SMOS_CS2,NH_25KM_EASE2_20101229_20110104_r_v204_01_l4sit.nc
netcdf W_XX-ESA\,SMOS_CS2\,NH_25KM_EASE2_20101229_20110104_r_v204_01_l4sit {
dimensions:
        xc = 432 ;
        yc = 432 ;
        time = UNLIMITED ; // (1 currently)
        nv = 2 ;
variables:
        int Lambert_Azimuthal_Grid ;
                Lambert_Azimuthal_Grid:grid_mapping_name = "lambert_azimuthal_equal_area" ;
                Lambert_Azimuthal_Grid:longitude_of_projection_origin = 0. ;
                Lambert_Azimuthal_Grid:latitude_of_projection_origin = 90. ;
                Lambert_Azimuthal_Grid:false_easting = 0. ;
                Lambert_Azimuthal_Grid:false_northing = 0. ;
                Lambert_Azimuthal_Grid:semi_major_axis = 6378137. ;
                Lambert_Azimuthal_Grid:inverse_flattening = 298.257232666016 ;
                Lambert_Azimuthal_Grid:proj4_string = "+proj=laea +lon_0=0 +datum=WGS84 +ellps=WGS84 +lat_0=90.0" ;
        double time(time) ;
                time:units = "seconds since 1978-01-01 00:00:00" ;
                time:long_name = "reference time of product" ;
                time:standard_name = "time" ;
                time:axis = "T" ;
                time:calendar = "standard" ;
                time:bounds = "time_bnds" ;
        double time_bnds(time, nv) ;
                time_bnds:units = "seconds since 1978-01-01 00:00:00" ;
        float xc(xc) ;
                xc:units = "km" ;
                xc:long_name = "x coordinate of projection (eastings)" ;
                xc:standard_name = "projection_x_coordinate" ;
        float yc(yc) ;
                yc:units = "km" ;
                yc:long_name = "y coordinate of projection (northings)" ;
                yc:standard_name = "projection_y_coordinate" ;
        float lon(yc, xc) ;
                lon:units = "degrees_east" ;
                lon:long_name = "longitude coordinate" ;
                lon:standard_name = "longitude" ;
        float lat(yc, xc) ;
                lat:units = "degrees_north" ;
                lat:long_name = "latitude coordinate" ;
                lat:standard_name = "latitude" ;
        int analysis_sea_ice_thickness(time, yc, xc) ;
                analysis_sea_ice_thickness:units = "m" ;
                analysis_sea_ice_thickness:long_name = "CS2SMOS merged sea ice thickness" ;
                analysis_sea_ice_thickness:standard_name = "sea_ice_thickness" ;
                analysis_sea_ice_thickness:grid_mapping = "Lambert_Azimuthal_Grid" ;
                analysis_sea_ice_thickness:coordinates = "time lat lon" ;
                analysis_sea_ice_thickness:scale_factor = 0.001 ;
                analysis_sea_ice_thickness:_FillValue = -2147483647 ;
        ...

I am attaching the files for your kind persual.
Thanks!

Best,
Yijun

RE: Fail to remap after convert ascii to nc - Added by Uwe Schulzweida about 1 year ago

Dear Yijun,

The error message is caused by the coordinates attributes:

          *:coordinates = "time lat lon" ;
The time coordinate is not supported in the coordinates attribute by CDO. You can ignore the error message or you have to remove the time coordinate:
   ncatted -a coordinates,,m,c,"lat lon" W_XX-ESA,SMOS_CS2,NH_25KM_EASE2_20101229_20110104_r_v204_01_l4sit.nc
In newer CDO version > 2.1.0 this error message is not generated anymore.
Cheers,
Uwe

RE: Fail to remap after convert ascii to nc - Added by Yijun Yang about 1 year ago

Dear Uwe,

Thanks so much for your prompt reply and detailed explanation! Your suggestion perfectly solves my problem.
Thanks again!

All the best,
Yijun

    (1-4/4)