Opened 10 years ago

Closed 10 years ago

#39 closed defect (fixed)

Error in check of units attribute for coordinate variables

Reported by: ros Owned by: cf-checker@…
Priority: medium Milestone:
Component: cf-checker Version:
Keywords: units Cc:

Description

3.1 of the convention states that "The units attribute is required for all variables that represent dimensional quantities."

Yet a Netcdf file like the following does not generate errors indicating that the units attribute is missing for any of the coordinate variables.

dimensions:
       longitude = 144 ;
       latitude = 91 ;
       press = 10 ;
       species = 6 ;
       rec = UNLIMITED ; // (12 currently)
       word = 13 ;

variables:
       float concentrations(rec, species, press, latitude, longitude) ;
             concentrations:long_name = "CFC concentrations" ;
             concentrations:Units = "pptv" ;
       float longitude(longitude) ;
       float latitude(latitude) ;
       float press(press) ;
       float species(species) ;
             species:long_name = "species" ;
             species:coord_labels = "species" ;
             species:selection_category = "NULL" ;
       float rec(rec) ;
             rec:long_name = "month" ;
             rec:coord_labels = "month" ;
             rec:selection_category = "NULL" ;
       char const_labels(species, word) ;
             const_labels:selection_category = "NULL" ;
       char month(rec, word) ;
             month:selection_category = "NULL" ;
} 

Change History (1)

comment:1 Changed 10 years ago by ros

  • Resolution set to fixed
  • Status changed from new to closed

It seems that in cdms all coordinate variables automatically have the 'units' attribute set, albeit to the empty string.

E.g.

Python 2.5 (r25:51908, Nov 27 2006, 19:14:46)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cdms
>>> f=cdms.open('/home/ros/shea.nc','r')
>>> var=f['latitude']
>>> var.attributes.has_key('units')
1
>>> var.attributes['units']
''
>>>

So chkUnits was passing any variable for which var.attributes.has_key('units') is true. Modified this routine to check for the empty string.

Fix lodged at r81

Test cases updated for standard_name table 11 too.

Note: See TracTickets for help on using tickets.