-
Notifications
You must be signed in to change notification settings - Fork 59
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
Improve cf conformance 5.6 grid mappings and projections #976
Improve cf conformance 5.6 grid mappings and projections #976
Conversation
related to issue#950 [ioos#950] updated the function get_grid_mapping_variables to parse the attribute variables when it contains more than one string.
related to issue # 950 [ioos#950] Mocked a new .nc file to test the grid_mapping requirements and recommendations
fixed the for loop of the get_grid_mapping_variables function
in cf_1_7.py - added "geographic_crs_name" to the function def _check_gmattr_existence_condition_ell_pmerid_hdatum(self, var): - Modified function def check_grid_mapping(self, ds): in cfutil.py - modified the function def grid_mapping_variables(ds) - added the function def get_grid_mapping_variables_coordinates(ds): in test_cf.py - modified the function def test_check_grid_mapping(self):
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #976 +/- ##
=======================================
Coverage ? 81.55%
=======================================
Files ? 24
Lines ? 5243
Branches ? 1262
=======================================
Hits ? 4276
Misses ? 655
Partials ? 312 ☔ View full report in Codecov by Sentry. |
@leilabbb, could you address the test failures? |
compliance_checker/tests/test_cf.py
Outdated
"§5.6 Horizontal Coordinate Reference Systems, Grid Mappings, Projections" | ||
) | ||
assert all(r.name == expected_name for r in results.values()) | ||
# def test_check_grid_mapping(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented function deleted.
@@ -501,6 +504,7 @@ def _check_gmattr_existence_condition_ell_pmerid_hdatum(self, var): | |||
"reference_ellipsoid_name", | |||
"prime_meridian_name", | |||
"horizontal_datum_name", | |||
"geographic_crs_name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test coverage for added functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in progress ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not understand " not covered by test" comment:
there is a test "_check_grid_mapping_attr_condition" that evaluates the 'geographic_crs_name' in the file
removed commented function
removed "print( )" to suppress output, it is needed only for debugging. removed the IF conditional statement and used the tests' results from _check_gmattr_existence_condition_ell_pmerid_hdatum and _check_gmattr_existence_condition_geoid_name_geoptl_datum_name
Can you check the test failures on this PR? |
using regex I have replaced an inner loop with: grid_mapping_variable_list.append(regex.findall(r"(\w+)",item.grid_mapping))
added the "else" clause to the "if not" statement on line 740
|
||
# [5/9] The grid mapping variables must have the grid_mapping_name attribute. | ||
# The legal values for the grid_mapping_name attribute are contained in Appendix F. | ||
if "grid_mapping_name" not in var.ncattrs(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not hasattr(var, "grid_mapping_name")
would be more Pythonic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed... changed
|
||
# [6/9] The data types of the attributes of the | ||
# grid mapping variable must be specified in Table 1 of Appendix F. | ||
type_map = {"S": "str" , "N": "float64"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typecheck for N
is likely too strong. N
simply means that the value has a numeric type, not just floating point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed.... changed to:
type_map = {"S": "str", "N": ["float64", "int"]}
test_ctx.score += 1 | ||
test_ctx.out_of += 1 | ||
|
||
test_ctx.out_of += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about hasattr
mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed ... changed
compliance_checker/cf/cf_1_7.py
Outdated
elif len_vdatum_name_attrs == 1: | ||
vert_datum_attrs = possible_vert_datum_attrs.intersection(var.ncattrs()) | ||
|
||
if exist_cond_1[0] == True and vert_datum_attrs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use if exist_cond_1[0] and vert_datum_attrs
if exist_cond[0]
is expected to be boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix and/or change unit tests as necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: already mentioned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all comments were resolved except one that i am not sure about "Add test coverage for added functionality."
compliance_checker/tests/test_cf.py
Outdated
"§5.6 Horizontal Coordinate Reference Systems, Grid Mappings, Projections" | ||
) | ||
assert all(r.name == expected_name for r in results.values()) | ||
# def test_check_grid_mapping(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented function deleted.
@@ -501,6 +504,7 @@ def _check_gmattr_existence_condition_ell_pmerid_hdatum(self, var): | |||
"reference_ellipsoid_name", | |||
"prime_meridian_name", | |||
"horizontal_datum_name", | |||
"geographic_crs_name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not understand " not covered by test" comment:
there is a test "_check_grid_mapping_attr_condition" that evaluates the 'geographic_crs_name' in the file
|
||
# [5/9] The grid mapping variables must have the grid_mapping_name attribute. | ||
# The legal values for the grid_mapping_name attribute are contained in Appendix F. | ||
if "grid_mapping_name" not in var.ncattrs(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed... changed
|
||
# [6/9] The data types of the attributes of the | ||
# grid mapping variable must be specified in Table 1 of Appendix F. | ||
type_map = {"S": "str" , "N": "float64"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed.... changed to:
type_map = {"S": "str", "N": ["float64", "int"]}
test_ctx.score += 1 | ||
test_ctx.out_of += 1 | ||
|
||
test_ctx.out_of += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed ... changed
No description provided.