-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add units and description to output netcdf files #232
Changes from 3 commits
bf26fe3
5975d71
cba415b
24b9eb0
47b13ab
4fabe9f
b1e68c8
071d761
cf94673
a4a3a4b
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
import shutil | ||
import unittest | ||
|
||
import xarray as xr | ||
|
||
from aospy.calc import Calc, CalcInterface | ||
from .data.objects.examples import ( | ||
example_proj, example_model, example_run, condensation_rain, | ||
|
@@ -37,6 +39,10 @@ def test_annual_mean(self): | |
calc.compute() | ||
assert isfile(calc.path_out['av']) | ||
assert isfile(calc.path_tar_out) | ||
data = xr.open_mfdataset(calc.path_out['av'], decode_times=False) | ||
for name, da in data.data_vars.items(): | ||
assert 'units' in da.attrs | ||
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. Instead of testing just that the attribute was added, I recommend testing that the value of the attribute is what you expect. This will test both that the attribute is in the dictionary, and make sure the proper value was encoded simultaneously. I think you can pick off the expected values of the units and description attributes from the expected_units = calc.var.units
expected_description = calc.var.description |
||
assert 'description' in da.attrs | ||
|
||
def test_annual_ts(self): | ||
calc_int = CalcInterface(intvl_out='ann', | ||
|
@@ -92,6 +98,10 @@ def test_simple_reg_av(self): | |
calc.compute() | ||
assert isfile(calc.path_out['reg.av']) | ||
assert isfile(calc.path_tar_out) | ||
data = xr.open_mfdataset(calc.path_out['reg.av'], decode_times=False) | ||
for name, da in data.data_vars.items(): | ||
assert 'units' in da.attrs | ||
assert 'description' in da.attrs | ||
|
||
def test_simple_reg_ts(self): | ||
calc_int = CalcInterface(intvl_out='ann', | ||
|
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.
I think
xr.open_dataset
should be all that is needed here. I suspectdecode_times=False
is also not needed as well.