-
Notifications
You must be signed in to change notification settings - Fork 67
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
modified open_mdsdataset to add extra_variables #205
Conversation
Codecov Report
@@ Coverage Diff @@
## master #205 +/- ##
==========================================
- Coverage 88.07% 88.00% -0.08%
==========================================
Files 12 12
Lines 1644 1742 +98
Branches 337 358 +21
==========================================
+ Hits 1448 1533 +85
- Misses 158 168 +10
- Partials 38 41 +3
Continue to review full report at Codecov.
|
Presumably I should write a test in order to keep up code coverage? Any other feedback? |
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.
Looks great Spencer! Thanks for getting this started!
Your implementation seems perfect. W just need a test. My recommendation would be to copy one of existing example files to a new name and then use extra_ variables
to provide the metadata. An example of a test that uses file copying is here:
xmitgcm/xmitgcm/test/test_mds_store.py
Lines 493 to 504 in 3ab1fdb
def test_drc_length(all_mds_datadirs): | |
"""Test that open_mdsdataset is adding an extra level to drC if it has length nr""" | |
dirname, expected = all_mds_datadirs | |
# Only older versions of the gcm have len(drC) = nr, so force len(drC) = nr for the test | |
copyfile(os.path.join(dirname, 'DRF.data'), | |
os.path.join(dirname, 'DRC.data')) | |
copyfile(os.path.join(dirname, 'DRF.meta'), | |
os.path.join(dirname, 'DRC.meta')) | |
ds = xmitgcm.open_mdsdataset( | |
dirname, iters=None, read_grid=True, | |
geometry=expected['geometry']) | |
assert len(ds.drC) == (len(ds.drF)+1) |
ADJtheta = dict(dims=['k','j','i'], attrs=dict( | ||
standard_name='Sensitivity_to_theta', | ||
long_name='Sensitivity of cost function to theta', units='[J]/degC')) | ||
) |
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.
An example is great, but you should also formally state exactly which fields are required and what they should contain.
Hi, I tried to add a test and extend the docstring for this PR cspencerjones#2. |
Add extra variables: still some build issues
Hi @rabernat and @raphaeldussin, could you have a look on this PR? |
Thanks for your work Aaron. I generally prefer to review PRs after the tests are passing. Do you need some help figuring out the test failures? |
Hi @rabernat, thanks for your swift reply! Yes indeed I could need some help here, since the tests that fail seem to not fail locally on my machine and the assertion errors look totally unrelated to this PR. |
Unlikely the cause. The code being tested in the workflow is exactly the same commit (f26ef84) that you have locally. The one thing that might be different is the environment. What version of xarray do you have installed locally? |
Yes indeed. That makes sense. My local environment uses |
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.
Ok, so the new code and tests look great. No suggestions! Thanks so much for the work @cspencerjones and @AaronDavidSchneider.
I am fine with merging this. However, our CI has uncovered a bug in swap_dims
that needs to be fixed asap!
* modified open_mdsdataset to add extra_variables * Backwards compatible * modified open_mdsdataset to add extra_variables * Backwards compatible * add tests and extend docstring * only copy file if input is available. Co-authored-by: Spencer Jones <[email protected]> Co-authored-by: Aaron Schneider <[email protected]>
Fixes #185 . The user will be able to specify extra variables that are non-standard and don't exist in available_diagnostics.log.