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

modify condition to get t_bounds variable #122

Merged
merged 7 commits into from
Sep 11, 2024
Merged

Conversation

noemieplanat
Copy link
Contributor

Some CDFTOOLs do not conserve the t_bounds variable but conserves the attribute, and thus xnemogcm fails when trying to get it.

xnemogcm/nemo.py Outdated Show resolved Hide resolved
@rcaneill
Copy link
Owner

Could you add a test for this new feature?
You can duplicate this test and change it so before preprocessing you delete the ds["time_counter"].attrs.get("bounds") variable
https://github.com/noemieplanat/xnemogcm_1/blob/e6cfd6c961415172e059ae2ac8550d1a3530aef4/xnemogcm/test/test_nemo.py#L139C1-L148C21

@rcaneill
Copy link
Owner

rcaneill commented Sep 11, 2024

def test_use_preprocess_no_time_bound(data_path):
    """Test that if the time_bound variable does not exist, no error is raised"""
    domcfg = open_domain_cfg(
        datadir=data_path / "mesh_mask_1_file",
    )
    ds_raw = xr.open_dataset(data_path / "nemo/GYRE_1y_00010101_00011230_grid_T.nc")
    ds_raw.encoding["source"] = "GYRE_1y_00010101_00011230_grid_T.nc"
    ds_raw = ds_raw.drop_vars(ds_raw["time_counter"].attrs.get("bounds"))
    ds = nemo_preprocess(ds_raw, domcfg)
    assert "x_c" in ds
    assert "t" in ds
   assert ds["t"].attrs.get("bounds") is None

@rcaneill
Copy link
Owner

(untested function)

noemieplanat and others added 3 commits September 11, 2024 13:21
Co-authored-by: Romain Caneill <romain.caneill@ens-lyon.org>
@rcaneill
Copy link
Owner

The precommit error comes from the number of spaces around the new function

@@ -146,7 +146,19 @@ def test_use_preprocess(data_path):
ds = nemo_preprocess(ds_raw, domcfg)
assert "x_c" in ds
assert "t" in ds


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

ds = nemo_preprocess(ds_raw, domcfg)
assert "x_c" in ds
assert "t" in ds
assert ds["t"].attrs.get("bounds") is None

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@rcaneill rcaneill merged commit 2bcca35 into rcaneill:main Sep 11, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants