You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Next »

Problem

You downloaded data from the ECMWF data server or another ECMWF repository in NetCDF format.

Then you are trying to read the data with the NCAR Command Language (NCL) , GrADS or Ferret, but get an error message, for example for NCL:

ncl 0> f = addfile("ECMWF-data.nc","r")
ncl 1> print (getfilevarnames (f))     
(0)     longitude
(1)     latitude
(2)     time
(3)     p83.162
(4)     p86.162
 q
ncl 3> x = f->p83.162  
fatal:syntax error: line 3 before or near .162
x = f->p83.162
-------------^
ncl 4> x = f->"p83.162"  
fatal:syntax error: line 4 before or near >
x = f->
------^

Cause

NCL, GrADS and Ferret do not support dots in variable names.

Solution for NCL

Enclose the variable name in double quotes and Dollar signs:

ncl 0> f = addfile("ECMWF-data.nc","r")
ncl 1> print (getfilevarnames (f))     
(0)     longitude
(1)     latitude
(2)     time
(3)     p83.162
(4)     p86.162
 q
ncl 2> x = f->$"p83.162"$
ncl 3> print (x)
Variable: x
Type: short
Total Size: 7172160 bytes
            3586080 values
Number of Dimensions: 3
Dimensions and sizes:   [time | 31] x [latitude | 241] x [longitude | 480]
Coordinates:
            time: [1024872..1025592]
            latitude: [90..-90]
            longitude: [ 0..359.25]
Number Of Attributes: 6
  scale_factor :        0.6170104064936749
  add_offset :  -3072.290927078247
  _FillValue :  -32767
  missing_value :       -32767
  units :       W m**-2
  long_name :   Vertical integral of divergence of thermal energy flux

Workaround

Rename the variable so the name contains only allowed character:

This document has been produced in the context of the Copernicus Atmosphere Monitoring Service (CAMS) and the Copernicus Climate Change Service (C3S).

The activities leading to these results have been contracted by the European Centre for Medium-Range Weather Forecasts, operator of CAMS and C3S on behalf of the European Union (Delegation Agreement signed on 11/11/2014). All information in this document is provided "as is" and no guarantee or warranty is given that the information is fit for any particular purpose.

The users thereof use the information at their sole risk and liability. For the avoidance of all doubt, the European Commission and the European Centre for Medium-Range Weather Forecasts have no liability in respect of this document, which is merely representing the author's view.


  • No labels