-
Notifications
You must be signed in to change notification settings - Fork 168
Adding Field._land_value property #2451
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
base: v4-dev
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -159,6 +159,20 @@ def invalid_interpolator_wrong_signature(particle_positions, grid_positions, inv | |
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("fill_value", [-999.99, 0.0, 42, None]) | ||
| def test_field_land_value(fill_value): | ||
| ds = datasets_structured["ds_2d_left"].copy() | ||
| if fill_value is not None: | ||
| ds["data_g"].attrs["_FillValue"] = fill_value | ||
|
Contributor
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. I think here we're kind of overloading and conflicting with how xarray ingests this https://docs.xarray.dev/en/stable/user-guide/io.html#scaling-and-type-conversions i.e., the user merely opening a dataset with decoding enabled might cause the I think a more informative test would be to look at reading in a dataset from disk rather than using this example dataset |
||
| grid = XGrid.from_dataset(ds, mesh="flat") | ||
|
|
||
| field = Field(name="test_field", data=ds["data_g"], grid=grid, interp_method=XLinear) | ||
| if fill_value is None: | ||
| assert field.land_value == 0.0 | ||
| else: | ||
| assert field.land_value == fill_value | ||
|
Comment on lines
+171
to
+173
Contributor
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. I guess this would be a very oceanography specific part of the API? |
||
|
|
||
|
|
||
| def test_vectorfield_invalid_interpolator(): | ||
| ds = datasets_structured["ds_2d_left"] | ||
| grid = XGrid.from_dataset(ds, mesh="flat") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Need to explicitly set the
_FillValueon these fields below to avoid errors on thetest_fieldset_from_copernicusmarine_no_logsunit test in test_fieldset.py; because without these _FillValues the Field creation throws a log message