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

Custom Grid Vars & Extra Variables for llcreader #308

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test for custom_grid_variables
  • Loading branch information
timothyas committed Aug 5, 2022
commit 554565cbde5759af65a7facc46a7b815ab6a7b87
35 changes: 35 additions & 0 deletions xmitgcm/test/test_mds_store.py
Original file line number Diff line number Diff line change
@@ -608,6 +608,41 @@ def test_extra_variables(all_mds_datadirs):
mate = ds[var].attrs['mate']
assert ds[mate].attrs['mate'] == var

def test_custom_grid_variables(all_mds_datadirs):
"""Test that open_mdsdataset reads custom grid variables (i.e. no time stamp) correctly"""
dirname, expected = all_mds_datadirs

custom_grid_variables = {
"iamgridC" : {
"dims" : ["k", "j", "i"], "attrs": {},
},
"iamgridW" : {
"dims" : ["k", "j", "i_g"], "attrs": {},
},
"iamgridS" : {
"dims" : ["k", "j_g", "i"], "attrs": {},
},
}

# copy hFac to our new grid variable ...
for suffix in ["C", "W", "S"]:
for ext in [".meta", ".data"]:
fname_in = os.path.join(dirname, f"hFac{suffix}{ext}")
fname_out= os.path.join(dirname, f"iamgrid{suffix}{ext}")
copyfile(fname_in, fname_out)

ds = xmitgcm.open_mdsdataset(
dirname,
read_grid=True,
iters=None,
geometry=expected["geometry"],
prefix=list(custom_grid_variables.keys()),
custom_grid_variables=custom_grid_variables)

for var in custom_grid_variables.keys():
assert var in ds
assert var in ds.coords

def test_mask_values(all_mds_datadirs):
"""Test that open_mdsdataset generates binary masks with correct values"""