cedadev/cf-checker

Bug: ERROR: (lon): Invalid attribute name: %s [fixed]

Closed this issue · 2 comments

When checking a NetCDF file, I could not easily track down the cause of the error messages. Potentially they are a bug due to the representation of data structures in Python.

This is the (shortened) output from cfchecks (version 3.0.5 installed today using pip):

CHECKING NetCDF FILE: c_gls_ALDH_201405130000_GLOBE_VGT_V1.4.1.nc
=====================
Using CF Checker Version 3.0.5
Checking against CF Version CF-1.6
Using Standard Name Table Version 65 (2019-04-09T13:32:32Z)
Using Area Type Table Version 9 (07 August 2018)


------------------
Checking variable: lon
------------------
ERROR: (lon): Invalid attribute name: %s

------------------
Checking variable: lat
------------------
ERROR: (lat): Invalid attribute name: %s

------------------
Checking variable: crs
------------------
ERROR: (crs): Invalid attribute name: %s
ERROR: (crs): Invalid attribute name: %s

------------------
Checking variable: time
------------------

------------------
Checking variable: AL_DH_BB
------------------
INFO: Unknown Type for attribute: _FillValue <type 'numpy.uint16'>
INFO: Unknown Type for attribute: missing_value <type 'numpy.uint16'>
ERROR: (8.1): must be of type byte, short or int

[ ... ... ]

ERRORS detected: 11
WARNINGS given: 0
INFORMATION messages: 20

This is the (shortened) output from ncdump -h:

netcdf c_gls_ALDH_201405130000_GLOBE_VGT_V1.4.1 {
dimensions:
	lon = 40320 ;
	lat = 15680 ;
	time = UNLIMITED ; // (1 currently)
variables:
	double lon(lon) ;
		lon:standard_name = "longitude" ;
		lon:long_name = "longitude" ;
		lon:DIMENSION_LABELS = "lon" ;
		lon:units = "degrees_east" ;
		lon:_CoordinateAxisType = "Lon" ;
		lon:axis = "X" ;
	double lat(lat) ;
		lat:standard_name = "latitude" ;
		lat:long_name = "latitude" ;
		lat:DIMENSION_LABELS = "lat" ;
		lat:units = "degrees_north" ;
		lat:_CoordinateAxisType = "Lat" ;
		lat:axis = "Y" ;
	char crs ;
		crs:semi_major_axis = 6378137. ;
		crs:inverse_flattening = 298.257223563 ;
		crs:longitude_of_prime_meridian = 0. ;
		crs:long_name = "coordinate reference system" ;
		crs:spatial_ref = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4326\"]]" ;
		crs:grid_mapping_name = "latitude_longitude" ;
		crs:_CoordinateTransformType = "Projection" ;
		crs:_CoordinateAxisTypes = "GeoX GeoY" ;
		crs:GeoTransform = "-180.0000000000 0.0089285714 0.0 80.0000000000 0.0 -0.0089285714" ;
	double time(time) ;
		time:units = "days since 1970-01-01 00:00:00" ;
		time:long_name = "Time" ;
		time:calendar = "standard" ;
		time:axis = "T" ;
	ushort AL_DH_BB(time, lat, lon) ;
		AL_DH_BB:_FillValue = 65535US ;
		AL_DH_BB:scale_factor = 0.0001f ;
		AL_DH_BB:add_offset = 0.f ;
		AL_DH_BB:valid_range = 0US, 10000US ;
		AL_DH_BB:flag_values = 65533US, 65534US ;
		AL_DH_BB:missing_value = 65535US ;
		AL_DH_BB:grid_mapping = "crs" ;
		AL_DH_BB:flag_meanings = "Out_of_range_superior_to_physical_max Out_of_range_inferior_to_physical_min" ;
		AL_DH_BB:long_name = "Broadband directional albedo over total spectrum" ;
		AL_DH_BB:standard_name = "surface_albedo" ;
		AL_DH_BB:units = "1" ;

[ ... ... ] 

// global attributes:
		:_NCProperties = "version=1|netcdflibversion=4.4.1|hdf5libversion=1.8.18" ;
		:Conventions = "CF-1.6" ;
		:product_version = "V1.4.1" ;
		:long_name = "Broadband Directional Surface Albedo" ;
		:processing_mode = "Reprocessing" ;
		:references = "http://land.copernicus.eu/global/products/sa" ;
		:copyright = "Copernicus Service information 2017" ;
		:title = "10-daily Broadband Directional Surface Albedo 1KM: GLOBE 2014-05-13T00:00:00Z" ;
		:platform = "SPOT_5" ;
		:archive_facility = "VITO" ;
		:sensor = "VEGETATION_2" ;
		:processing_level = "L3" ;
		:time_coverage_start = "2014-04-25T00:00:00Z" ;
		:institution = "VITO NV" ;
		:source = "Derived from EO satellite imagery" ;
		:parent_identifier = "urn:cgls:global:aldh_v1_1km" ;
		:time_coverage_end = "2014-05-25T23:59:59Z" ;
		:orbit_type = "LEO" ;
		:identifier = "urn:cgls:global:aldh_v1_1km:ALDH_201405130000_GLOBE_VGT_V1.4.1" ;
		:history = "2017-09-22 Processing line GEO1 Albedo 1km" ;

The message that I do not understand is the following:
ERROR: (lon): Invalid attribute name: %s

Is this a bug in the cfchecker? It tries to print the name of the invalid attribute name, but it fails to do so?

This has already been fixed at a later version. I should be releasing a new version of the checker on PyPI later this week.

I can confirm that the error has been fixed after running pip install --upgrade cfchecker :) Thanks!!