Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NCDF_variable GetInfo() breaks when _FillValue and missing_value occur together #8

Open
achho opened this issue Sep 21, 2016 · 1 comment

Comments

@achho
Copy link

achho commented Sep 21, 2016

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

@sappjw
Copy link
Contributor

sappjw commented Jan 30, 2019

Does this issue have something to do with this library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants