-
Notifications
You must be signed in to change notification settings - Fork 65
Add diagnostic metadata property to constituents object; use existing diagnostic name metadata attribute #695
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
base: develop
Are you sure you want to change the base?
Changes from all commits
aab4a9e
9d8fe6a
549e2ac
2d189fc
e73a7bc
4601a0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -128,6 +128,52 @@ def find_vertical_dimension(dims): | |||||||||||||||||||||
| # end for | ||||||||||||||||||||||
| return (var_vdim, vindex) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ######################################################################## | ||||||||||||||||||||||
| def local_name_to_diag_name(prop_dict, context=None): | ||||||||||||||||||||||
| ######################################################################## | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
| Translate a local_name to its default diagnostic name. | ||||||||||||||||||||||
| Currently, this is just equal to the local name. If no local name | ||||||||||||||||||||||
| exists in the property dictionary, a truncation of the standard | ||||||||||||||||||||||
| name is used. (256 characters = max length of NetCDF variable name) | ||||||||||||||||||||||
| >>> local_name_to_diag_name({'local_name':'foo', 'standard_name':'cloud_optical_depth'}) | ||||||||||||||||||||||
| 'foo' | ||||||||||||||||||||||
| >>> local_name_to_diag_name({'standard_name':'cloud_optical_depth_layers_from_0p55mu_to_0p99mu'}) | ||||||||||||||||||||||
| 'cloud_optical_depth_layers_from_0p55mu_to_0p99mu' | ||||||||||||||||||||||
| >>> local_name_to_diag_name({'units':'km'}) #doctest: +ELLIPSIS | ||||||||||||||||||||||
| Traceback (most recent call last): | ||||||||||||||||||||||
| ... | ||||||||||||||||||||||
| parse_source.CCPPError: No standard name or local name to convert to diagnostic name | ||||||||||||||||||||||
| >>> local_name_to_diag_name({'local_name':'', 'standard_name':'cloud_optical_depth'}) #doctest: +ELLIPSIS | ||||||||||||||||||||||
| Traceback (most recent call last): | ||||||||||||||||||||||
| ... | ||||||||||||||||||||||
| parse_source.CCPPError: No standard name or local name to convert to diagnostic name | ||||||||||||||||||||||
| >>> local_name_to_diag_name({'standard_name':''}) #doctest: +ELLIPSIS | ||||||||||||||||||||||
| Traceback (most recent call last): | ||||||||||||||||||||||
| ... | ||||||||||||||||||||||
| parse_source.CCPPError: No standard name or local name to convert to diagnostic name | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might add a couple of tests for more complete code coverage:
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the extra doctests! added! |
||||||||||||||||||||||
| diag_name = None | ||||||||||||||||||||||
| if 'local_name' in prop_dict: | ||||||||||||||||||||||
| locname = prop_dict['local_name'] | ||||||||||||||||||||||
| if locname: | ||||||||||||||||||||||
| diag_name = prop_dict['local_name'] | ||||||||||||||||||||||
| # end if | ||||||||||||||||||||||
| elif 'standard_name' in prop_dict: | ||||||||||||||||||||||
| stdname = prop_dict['standard_name'] | ||||||||||||||||||||||
| if stdname: | ||||||||||||||||||||||
| maxlen = 256 | ||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if hardcoding this value in this particular place is a good idea. I would be surprised if we didn't have a parameter for the maximum length of a standard name somewhere else already. |
||||||||||||||||||||||
| diag_name = stdname[:maxlen] | ||||||||||||||||||||||
| # end if | ||||||||||||||||||||||
| # end if | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if not diag_name: | ||||||||||||||||||||||
| emsg = 'No standard name or local name to convert to diagnostic name' | ||||||||||||||||||||||
| raise CCPPError(emsg) | ||||||||||||||||||||||
| # end if | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return diag_name | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ######################################################################## | ||||||||||||||||||||||
| def standard_name_to_long_name(prop_dict, context=None): | ||||||||||||||||||||||
| ######################################################################## | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.