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

Mapping of metadata-only CDL to field constructs #128

Open
sadielbartholomew opened this issue Mar 26, 2021 · 0 comments · Fixed by #129
Open

Mapping of metadata-only CDL to field constructs #128

sadielbartholomew opened this issue Mar 26, 2021 · 0 comments · Fixed by #129
Labels
netCDF read Relating to reading netCDF datasets

Comments

@sadielbartholomew
Copy link
Member

NCAS-CMS/cf-python#197 has highlighted that cfdm as-is is not able to interpret as definite field(s) some cases of CDL inputs which provide only schema and/or coordinate information, e.g. as produced from a ncdump -h or ncdump -c. We realised it may not in fact be possible given the nature of the CF data model to unambiguously map CDL with metadata but no data arrays provided onto fields, though we aren't certain.

The direct problem resulting from this is that such missing data is not accounted for so errors may emerge when such CDLis read-in.

Long-term solution

Ultimately we should:

  1. determine whether header- and coordinate-based CDL can be mapped conclusively to field constructs,
  2. a) if so, adapt the logic so that missing data is dealt with appropriately and does not emerge downstream as errors for reading of such CDL, both here in standalone cfdm or indeed in dependencies like cf-python, like as for NumPy MaskError with read-in of header-info CDL cf-python#197;
    b) if not so, decide on the best approach for a result of reading in such CDL, whether that is to provide some sensible "best guess" field encapsulating the known information, or to tell users via appropriate error message that the CDL can't be read-in as fields for these reasons.

Short-term fix

For the forthcoming release, to address NCAS-CMS/cf-python#197, I am catching the MaskErrors to raise them as a user-friendly message stating that the CDL metadata is insufficient for conversion to field constructs, i.e. assuming case (b) and raising a ValueError. This is sufficient for the release but should be re-evaluated in the longer term.

Even if we end up going with this approach after the review, I would like to create a custom error class to raise for related errors, rather than using a Python built-in Exception.

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

Successfully merging a pull request may close this issue.

2 participants