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

Add oblique mercator to create_bounds and other improvements to the regridding function #467

Merged
merged 30 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c6489bf
add oblique_mercator to conservative regridding
RondeauG Sep 24, 2024
dea4d7c
tests
RondeauG Sep 24, 2024
4462fa5
deprecate old function
RondeauG Sep 24, 2024
0175b23
Merge branch 'main' into oblique_mercator_bounds
RondeauG Sep 24, 2024
eb69cc0
upd changelog
RondeauG Sep 24, 2024
e1af6d4
add a bunch of tests, refactor create_mask, reinforce security for re…
RondeauG Sep 26, 2024
cec007a
upd changelog
RondeauG Sep 26, 2024
ff1a0a9
fix notebook
RondeauG Sep 26, 2024
e59a100
try remove space
RondeauG Sep 26, 2024
faf700b
fix typo
RondeauG Sep 26, 2024
ce661d9
fix notebook again
RondeauG Sep 26, 2024
9b49f07
Update environment-dev.yml
RondeauG Sep 26, 2024
094b811
Update environment.yml
RondeauG Sep 26, 2024
5999643
Update pyproject.toml
RondeauG Sep 26, 2024
72c163c
pin micromamba temporarily
Zeitsperre Sep 26, 2024
0740f26
pin micromamba temporarily
Zeitsperre Sep 26, 2024
1842684
Update src/xscen/regrid.py
RondeauG Sep 26, 2024
9aa4002
more optional attributes
RondeauG Sep 26, 2024
09a24bd
Merge remote-tracking branch 'origin/oblique_mercator_bounds' into ob…
RondeauG Sep 26, 2024
cf371fb
try lower pin
RondeauG Sep 26, 2024
f1e98d4
fix pin
RondeauG Sep 26, 2024
f9194d3
comment pin, wait for a fix
RondeauG Sep 26, 2024
bb19d4e
nuclear option
RondeauG Sep 26, 2024
4a348f1
retry with pin and no cache
RondeauG Sep 26, 2024
8beb6a5
cache downloads back to true
RondeauG Sep 26, 2024
f44561c
binary path
RondeauG Sep 26, 2024
226ee47
retry 2.0.0-1
RondeauG Sep 26, 2024
4194b25
nope
RondeauG Sep 26, 2024
cfd2d6d
try to see if micromamba is fixed
RondeauG Sep 27, 2024
6bbae4d
pin micromamba until fixed
RondeauG Sep 30, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ New features and enhancements
* New argument ``compute_indicators``: ``rechunk_input`` to rechunk the inputs to resample-appropriate chunks before calling xclim. (:pull:`431`).
* New ``xs.indicators.get_indicator_outputs`` to retrieve what variable name(s) and frequency to expect from an xclim indicator. (:pull:`431`).
* `xscen` now supports launches tests from `pytest` with the `--numprocesses` option. See the `pytest-xdist documentation <https://pytest-xdist.readthedocs.io/en/stable/>`_ for more information. (:pull:`464`).
* Conservative regridding now supports oblique mercator projections. (:pull:`467`).
* The automatic name for the weight file in ``regrid_dataset`` is now more explicit to avoid errors, but now requires `cat:id` and `cat:domain` arguments for both the source and target datasets. (:pull:`467`).

Bug fixes
^^^^^^^^^
Expand All @@ -48,6 +50,9 @@ Breaking changes
* Python 3.9 is no longer supported. (:pull:`456`).
* Functions and arguments that were deprecated in `xscen` v0.8.0 or earlier have been removed. (:pull:`461`).
* `pytest-xdist` is now a development dependency. (:pull:`464`).
* ``xs.regrid.create_bounds_rotated_pole`` has been renamed to ``xs.regrid.create_bounds_gridmapping``. (:pull:`467`).
* The `weights_location` argument in ``regrid_dataset`` is no longer positional. (:pull:`467`).
* The ``xs.regrid.create_mask`` function now requires explicit arguments instead of a dictionary. (:pull:`467`).

Internal changes
^^^^^^^^^^^^^^^^
Expand Down
24 changes: 6 additions & 18 deletions docs/notebooks/2_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,7 @@
"\n",
"Masks can be used on both the original grid and the destination grid to ignore certain grid cells during the regridding process. These masks follow the `ESMF` convention, meaning that the mask is a variable within the Dataset, named *mask* and comprised of 0 and 1.\n",
"\n",
"`xs.create_mask` will create an adequate DataArray, following the instructions given by *mask_args*. In the case of variables that have a time component, the first timestep will be chosen.\n",
"\n",
" mask_args:\n",
" - 'variable' (optional)\n",
" - 'where_operator' (optional)\n",
" - 'where_threshold' (optional)\n",
" - 'mask_nans': bool"
"`xs.create_mask` will create an adequate DataArray, following the instructions given to the function. In the case of variables that have a time component, the first timestep will be chosen."
]
},
{
Expand All @@ -567,23 +561,17 @@
},
"outputs": [],
"source": [
"# Will mask all pixels that do not match these requirements (at least 25% land)\n",
"mask_args = {\n",
" \"variable\": \"sftlf\",\n",
" \"where_operator\": \">\",\n",
" \"where_threshold\": 25,\n",
" \"mask_nans\": True,\n",
"}\n",
"\n",
"# to_dataset() will open the dataset, as long as the search() gave a single result.\n",
"ds_example = pcat.search(\n",
" id=\"CMIP6_ScenarioMIP_NCC_NorESM2-MM_ssp245_r1i1p1f1_example-region\",\n",
" processing_level=\"extracted\",\n",
" variable=\"sftlf\",\n",
").to_dataset()\n",
"\n",
"# Masking function\n",
"ds_example[\"mask\"] = xs.create_mask(ds_example, mask_args=mask_args)"
"# Will mask all pixels that do not match these requirements (at least 25% land)\n",
"ds_example[\"mask\"] = xs.create_mask(\n",
" ds_example, variable=\"sftlf\", where_operator=\">\", where_threshold=25, mask_nans=True\n",
")"
]
},
{
Expand Down Expand Up @@ -716,7 +704,7 @@
" pcat.search(\n",
" id=ds.attrs[\"cat:id\"], processing_level=\"extracted\", variable=\"sftlf\"\n",
" ).to_dataset(),\n",
" mask_args=mask_args,\n",
" **mask_args,\n",
" )\n",
"\n",
" # Regridding function\n",
Expand Down
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ dependencies:
- shapely >=2.0
- sparse
- toolz
- xarray >=2023.11.0, !=2024.6.0
- xclim >=0.52.2, <0.53
- xarray >=2023.11.0,!=2024.6.0
- xclim >=0.52.2,<0.53
RondeauG marked this conversation as resolved.
Show resolved Hide resolved
- xesmf >=0.7
- zarr >=2.13
# Opt
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ dependencies:
- shapely >=2.0
- sparse
- toolz
- xarray >=2023.11.0, !=2024.6.0
- xclim >=0.52.2, <0.53
- xarray >=2023.11.0,!=2024.6.0
- xclim >=0.52.2,<0.53
RondeauG marked this conversation as resolved.
Show resolved Hide resolved
- xesmf >=0.7
- zarr >=2.13
# To install from source
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ dependencies = [
"shapely >=2.0",
"sparse",
"toolz",
"xarray >=2023.11.0, !=2024.6.0",
"xclim >=0.52.2, <0.53",
"xarray >=2023.11.0,!=2024.6.0",
"xclim >=0.52.2,<0.53",
RondeauG marked this conversation as resolved.
Show resolved Hide resolved
"zarr >=2.13"
]

Expand Down
Loading
Loading