NCDF_variable GetInfo() breaks when _FillValue and missing_value occur together
achho opened this issue · 1 comments
Hi all,
I have a netCDF file with a variable which has both attributes _FillValue and missing_value.
In the GetInfo() function for ncdf_variables, lines 622-634, the info is constructed in such a way, that the _FillValue tag is added to the info structure whenever _FillValue or missing_value is found as a variable attribute. This is what the code looks like:
attrNames = self -> GetAttrNames()
attrIndex = Where(attrNames EQ 'scale_factor', count)
IF count GT 0 THEN info = Create_Struct(info, 'scale_factor', $
self -> GetAttrValue('scale_factor'))
attrIndex = Where(attrNames EQ 'add_offset', count)
IF count GT 0 THEN info = Create_Struct(info, 'add_offset', $
self -> GetAttrValue('add_offset'))
attrIndex = Where(attrNames EQ 'missing_value', count)
IF count GT 0 THEN info = Create_Struct(info, '_FillValue', $
self -> GetAttrValue('missing_value'))
attrIndex = Where(attrNames EQ '_FillValue', count)
IF count GT 0 THEN info = Create_Struct(info, '_FillValue', $
self -> GetAttrValue('_FillValue'))
However, that will create a "Conflicting or duplicate structure tag definition" error if both attributes are there.
I think, one could either put both attributes into the info structure, or avoid the error by filling the _FillValue tag in the info structure with the _FillValue attribute value as the priority, doing something like this:
attrNames = self -> GetAttrNames()
attrIndex = Where(attrNames EQ 'scale_factor', count)
IF count GT 0 THEN info = Create_Struct(info, 'scale_factor', $
self -> GetAttrValue('scale_factor'))
attrIndex = Where(attrNames EQ 'add_offset', count)
IF count GT 0 THEN info = Create_Struct(info, 'add_offset', $
self -> GetAttrValue('add_offset'))
attrIndex = Where(attrNames EQ 'missing_value', count_fill)
attrIndex = Where(attrNames EQ '_FillValue', count_miss)
IF count_fill GT 0 THEN info = Create_Struct(info, '_FillValue', $
self -> GetAttrValue('_FillValue'))
IF count_miss GT 0 AND count_fill EQ 0 THEN info = Create_Struct(info, '_FillValue', $
self -> GetAttrValue('missing_value'))
Thanks for the support, cheers
Achim
Does this issue have something to do with this library?