Project

General

Profile

Lambert conic projection support

Added by François Roberge about 6 years ago

Is LCC projection supported in CDO? I noticed that LCC information inside netcdf files disappear after using any CDO operators.

As example, a Daymet dataset file. When doing ncdump -h before using a cdo operator I get :

[[netcdf daymet_v3_tmax_2006_na {
dimensions:
    x = 7814 ;
    y = 8075 ;
    time = UNLIMITED ; // (365 currently)
    nv = 2 ;
variables:
    float x(x) ;
        x:units = "m" ;
        x:long_name = "x coordinate of projection" ;
        x:standard_name = "projection_x_coordinate" ;
    float y(y) ;
        y:units = "m" ;
        y:long_name = "y coordinate of projection" ;
        y:standard_name = "projection_y_coordinate" ;
    float lat(y, x) ;
        lat:units = "degrees_north" ;
        lat:long_name = "latitude coordinate" ;
        lat:standard_name = "latitude" ;
    float lon(y, x) ;
        lon:units = "degrees_east" ;
        lon:long_name = "longitude coordinate" ;
        lon:standard_name = "longitude" ;
    float time(time) ;
        time:long_name = "time" ;
        time:calendar = "standard" ;
        time:units = "days since 1980-01-01 00:00:00 UTC" ;
        time:bounds = "time_bnds" ;
    short yearday(time) ;
        yearday:long_name = "yearday" ;
    float time_bnds(time, nv) ;
    short lambert_conformal_conic ;
        lambert_conformal_conic:grid_mapping_name = "lambert_conformal_conic" ;
        lambert_conformal_conic:longitude_of_central_meridian = -100. ;
        lambert_conformal_conic:latitude_of_projection_origin = 42.5 ;
        lambert_conformal_conic:false_easting = 0. ;
        lambert_conformal_conic:false_northing = 0. ;
        lambert_conformal_conic:standard_parallel = 25., 60. ;
        lambert_conformal_conic:semi_major_axis = 6378137. ;
        lambert_conformal_conic:inverse_flattening = 298.257223563 ;
    float tmax(time, y, x) ;
        tmax:_FillValue = -9999.f ;
        tmax:long_name = "daily maximum temperature" ;
        tmax:units = "degrees C" ;
        tmax:missing_value = -9999.f ;
        tmax:coordinates = "lat lon" ;
        tmax:grid_mapping = "lambert_conformal_conic" ;
        tmax:cell_methods = "area: mean time: maximum" ;

// global attributes:
        :start_year = 2006s ;
        :source = "Daymet Software Version 3.0" ;
        :Version_software = "Daymet Software Version 3.0" ;
        :Version_data = "Daymet Data Version 3.0" ;
        :Conventions = "CF-1.6" ;
        :citation = "Please see http://daymet.ornl.gov/ for current Daymet data citation information" ;
        :references = "Please see http://daymet.ornl.gov/ for current information on Daymet references" ;]]

After using a cdo operator timmean, I get : 
[[
netcdf daymet_v3_tmax_2006_na_timmean {
dimensions:
    x = 7814 ;
    y = 8075 ;
    time = UNLIMITED ; // (1 currently)
    bnds = 2 ;
variables:
    float lon(y, x) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "longitude coordinate" ;
        lon:units = "degrees_east" ;
        lon:_CoordinateAxisType = "Lon" ;
    float lat(y, x) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "latitude coordinate" ;
        lat:units = "degrees_north" ;
        lat:_CoordinateAxisType = "Lat" ;
    double time(time) ;
        time:standard_name = "time" ;
        time:long_name = "time" ;
        time:bounds = "time_bnds" ;
        time:units = "days since 1980-1-1 00:00:00" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
    double time_bnds(time, bnds) ;
    float yearday(time) ;
        yearday:long_name = "yearday" ;
    float tmax(time, y, x) ;
        tmax:long_name = "daily maximum temperature" ;
        tmax:units = "degrees C" ;
        tmax:coordinates = "lat lon" ;
        tmax:_FillValue = -9999.f ;
        tmax:missing_value = -9999.f ;
        tmax:cell_methods = "area: mean time: maximum" ;

// global attributes:
        :CDI = "Climate Data Interface version 1.7.0 (http://mpimet.mpg.de/cdi)" ;
        :history = "Mon Jan 29 17:19:12 2018: cdo -b F32 timmean /HOME/data/Validation/Daymet/Daily/daymet_v3_tmax_2006_na.nc4 ./daymet_v3_tmax_2006_na_timmean.nc4" ;
        :source = "Daymet Software Version 3.0" ;
        :Conventions = "CF-1.6" ;
        :start_year = 2006s ;
        :Version_software = "Daymet Software Version 3.0" ;
        :Version_data = "Daymet Data Version 3.0" ;
        :citation = "Please see http://daymet.ornl.gov/ for current Daymet data citation information" ;
        :references = "Please see http://daymet.ornl.gov/ for current information on Daymet references" ;
        :CDO = "Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo)" ;
}]]

The latitudes get inverted in the final output. I have to use the operator invertlat to get it back correctly.

Is this normal?

Thank you,

- François


Replies (9)

RE: Lambert conic projection support - Added by Karin Meier-Fleischer about 6 years ago

Hi François,

please, upload the file (if it is too big, 1 timestep and 1 variable is enough).

-Karin

RE: Lambert conic projection support - Added by François Roberge about 6 years ago

Daymet is very large and even one timestep is too large to be posted here. By simply using seltimestep, the LCC information disappeared.

However, this also happens with NARR data which is way smaller. I included here as example one original file and the file after I did timmean. The LCC information doesn't appear after using timmean when using ncdump -h.

air.2m.1979_timmean.nc (5.14 MB) air.2m.1979_timmean.nc After using timmean
air.2m.1979.nc (47.4 MB) air.2m.1979.nc Original NARR file

RE: Lambert conic projection support - Added by Ralf Mueller about 6 years ago

for files too large to upload here you can use our ftp server: ftp.zmaw.de:/incoming

RE: Lambert conic projection support - Added by François Roberge about 6 years ago

Hi Ralf,

I uploaded two files in /incoming/FRoberge_310118/

1 . daymet_v3_tmax_monavg_1997_na.nc4 : original daymet file
2. daymet_v3_tmax_monavg_1997_na_timmean.nc4 : after using the cdo operator timmean

in file #2, LCC information is lost and the latitudes are reversed.

Thank you.

RE: Lambert conic projection support - Added by Karin Meier-Fleischer about 6 years ago

Hi Françoise,

you are using an old version CDO 1.7.0. Upgrade to the new version ([[https://code.mpimet.mpg.de/projects/cdo/wiki#Installation-and-Supported-Platforms]]).

I've used version 1.9.2 without loosing the grid mapping:

cdo -b F32 timmean daymet_v3_tmax_monavg_1997_na.nc4 outfile.nc4

ncdump -h outfile.nc4

netcdf outfile {
dimensions:
    time = UNLIMITED ; // (1 currently)
    bnds = 2 ;
    x = 7814 ;
    y = 8075 ;
variables:
    float time(time) ;
        time:standard_name = "time" ;
        time:long_name = "time" ;
        time:bounds = "time_bnds" ;
        time:units = "days since 1980-01-01 00:00:00 UTC" ;
        time:calendar = "standard" ;
        time:axis = "T" ;
    double time_bnds(time, bnds) ;
    float lon(y, x) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "longitude coordinate" ;
        lon:units = "degrees_east" ;
        lon:_CoordinateAxisType = "Lon" ;
    float lat(y, x) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "latitude coordinate" ;
        lat:units = "degrees_north" ;
        lat:_CoordinateAxisType = "Lat" ;
    float x(x) ;
        x:standard_name = "projection_x_coordinate" ;
        x:long_name = "x coordinate of projection" ;
        x:units = "m" ;
        x:axis = "X" ;
    float y(y) ;
        y:standard_name = "projection_y_coordinate" ;
        y:long_name = "y coordinate of projection" ;
        y:units = "m" ;
        y:axis = "Y" ;
    int lambert_conformal_conic ;
        lambert_conformal_conic:grid_mapping_name = "lambert_conformal_conic" ;
        lambert_conformal_conic:longitude_of_central_meridian = -100. ;
        lambert_conformal_conic:latitude_of_projection_origin = 42.5 ;
        lambert_conformal_conic:false_easting = 0. ;
        lambert_conformal_conic:false_northing = 0. ;
        lambert_conformal_conic:standard_parallel = 25., 60. ;
        lambert_conformal_conic:semi_major_axis = 6378137. ;
        lambert_conformal_conic:inverse_flattening = 298.257223563 ;
    float tmax(time, y, x) ;
        tmax:long_name = "monthly average of daily maximum temperature" ;
        tmax:units = "degrees C" ;
        tmax:grid_mapping = "lambert_conformal_conic" ;
        tmax:coordinates = "lat lon" ;
        tmax:_FillValue = -9999.f ;
        tmax:missing_value = -9999.f ;
        tmax:cell_methods = "area: mean time: maximum within days time: mean over days" ;

// global attributes:
        :CDI = "Climate Data Interface version 1.9.2 (http://mpimet.mpg.de/cdi)" ;
        :history = "Thu Feb 01 11:42:21 2018: cdo -b F32 timmean daymet_v3_tmax_monavg_1997_na.nc4 outfile.nc4" ;
        :source = "Daymet Software Version 3.0" ;
        :Conventions = "CF-1.6" ;
        :start_year = 1997s ;
        :Version_software = "Daymet Software Version 3.0" ;
        :Version_data = "Daymet Data Version 3.0" ;
        :citation = "Please see http://daymet.ornl.gov/ for current Daymet data citation information" ;
        :references = "Please see http://daymet.ornl.gov/ for current information on Daymet references" ;
        :NCO = "\"4.5.3\"" ;
        :CDO = "Climate Data Operators version 1.9.2 (http://mpimet.mpg.de/cdo)" ;
}

-Karin

RE: Lambert conic projection support - Added by François Roberge over 4 years ago

Hello Karin,

It works much better using the new cdo version 1.9.5 with daymet files. The projection grid mapping doesn't get lost while using cdo.

However, is there a way in cdo to compute grid cell corners using based with LCC so what conservative remapping (remapcon) could be used?

Thank you,

François

RE: Lambert conic projection support - Added by Uwe Schulzweida over 4 years ago

The grid cell corners and the grid cell center will be computed from the LCC projection parameters if no geographic coordinates are available.
That means you have to remove the grid cell center coordinates to activate this feature. There is no way to remove these coordinates with CDO.
The geographical coordinates are computed from the LCC projection by the proj4 library. Please note that this will give wrong results if one of the LCC projection parameter is wrong or missing.

RE: Lambert conic projection support - Added by François Roberge over 4 years ago

Hello Uwe,

I have used this commande to ignore grid cell center coordinates :

export IGNORE_ATT_COORDINATES=1

However Yes I am getting errors with Daymet files when trying to use remapcon.

cdo remapcon (Warning): lambert_conformal_conic mapping parameter inverse_flattening out of bounds!

cdo remapcon (Abort): proj error: major axis or radius = 0 or not given

Error (cdf_close): NetCDF: HDF error

Is there something missing in the projection definition?

Thank you,

François

RE: Lambert conic projection support - Added by Uwe Schulzweida over 4 years ago

Dear François,

This is a bug in CDO, sorry.
CDO has to pass all relevant attributes of the projection to the proj4 library. This procedure is very error-prone, because CDO doesn't support all proj4 parameter.
I would recommend to assign the attribute proj4_params with all necessary proj4 parameters. Here is an example, to set this attribute with the NCO tool ncatted:

ncatted -a proj4_params,lambert_conformal_conic,c,c,"+proj=stere +lon_0=-107 +lat_0=50 +lat_1=50 +lat_2=50 +x_0=5632642.22547 +y_0=4612545.65137" infile outfile
Cheers,
Uwe

    (1-9/9)