Skip to content

Commit 524c1c8

Browse files
Nan threshold for conservative regridding (continuation of #39) (#41)
* add nan_threshold option * track nan frac across dims, use xr.dot, consolidate ds/da paths, tests * fixes and cleanup plus initial notebook cell * speed up by only tracking the max of nonnull points over non_regrid_dims * fix tests for newer dependency versions * Improve typing of call_on_dataset * Fix typing in updated conservative routines * Apply code formatting * Ensure hashable is a valid input for coordinate identifier * Make tests & typing pass * Make `create_regridding_dataset` a method of `Grid` #38 * Update notebooks and dependencies * Allow xesmf test to run if it's available * Add @slevang to the contributors list * Update changelog * Ignore linter in test * Update readme with badges and "why use..." text --------- Co-authored-by: Sam Levang <[email protected]>
1 parent 970d07d commit 524c1c8

File tree

15 files changed

+628
-301
lines changed

15 files changed

+628
-301
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
66

77
## Unreleased
88

9+
New contributors:
10+
- @slevang
11+
12+
Fixed:
13+
- conservative regridding now can be constructed fully lazily [#39](https://github.com/EXCITED-CO2/xarray-regrid/pull/39).
14+
915
Added:
10-
- Documentation for the package, including readthedocs integration ([#40](https://github.com/EXCITED-CO2/xarray-regrid/pull/40)).
16+
- documentation for the package, including readthedocs integration ([#40](https://github.com/EXCITED-CO2/xarray-regrid/pull/40)).
17+
- better handling of NaNs to the conservative regridding routine, with a `nan_threshold` keyword argument. For more information see the notebooks on the documentation [#39](https://github.com/EXCITED-CO2/xarray-regrid/pull/39) \& [#41](https://github.com/EXCITED-CO2/xarray-regrid/pull/41).
18+
- `create_regridding_dataset` as a method of the `xarray_regrid.Grid` dataclass [#41](https://github.com/EXCITED-CO2/xarray-regrid/pull/41).
1119

1220
## v0.2.3 (2024-02-29)
1321

CITATION.cff

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ authors:
1818
family-names: Doore
1919
orcid: 'https://orcid.org/0000-0001-5035-4016'
2020
affiliation: United States Geological Survey
21-
21+
- given-names: Sam
22+
family-names: Levang
23+
affiliation: Salient Predictions
24+
2225
repository-code: 'https://github.com/EXCITED-CO2/xarray-regrid'
2326
keywords:
2427
- xarray
2528
- geospatial
2629
- regridding
2730
- conservative regridding
2831
license: Apache-2.0
29-
version: 0.2.3
30-
date-released: '2023-11-24'
3132
abstract: >
3233
xarray-regrid can regrid (geospatial) data to a new
3334
coordinate system.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<img align="right" width="100" alt="Logo" src="./docs/assets/logo.png">
44

5+
56
With xarray-regrid it is possible to regrid between two rectilinear grids. The following methods are supported:
67
- Linear
78
- Nearest-neighbor
@@ -11,7 +12,13 @@ With xarray-regrid it is possible to regrid between two rectilinear grids. The f
1112

1213
Note that "Most common value" is designed to regrid categorical data to a coarse resolution. For regridding categorical data to a finer resolution, please use "nearest-neighbor" regridder.
1314

15+
[![PyPI](https://img.shields.io/pypi/v/xarray-regrid.svg?style=flat)](https://pypi.python.org/pypi/xarray-regrid/)
1416
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10203304.svg)](https://doi.org/10.5281/zenodo.10203304)
17+
[![Docs](https://readthedocs.org/projects/xarray-regrid/badge/?version=latest&style=flat)](https://xarray-regrid.readthedocs.org/)
18+
19+
## Why xarray-regrid?
20+
21+
Regridding is a common operation in earth science and other fields. While xarray does have some interpolation methods available, these are not always straightforward to use. Additionally, methods such as conservative regridding, or taking the most common value, are not available in xarray.
1522

1623
## Installation
1724

docs/notebooks/benchmarks/benchmarking_bilinear.ipynb

Lines changed: 15 additions & 26 deletions
Large diffs are not rendered by default.

docs/notebooks/benchmarks/benchmarking_conservative.ipynb

Lines changed: 82 additions & 59 deletions
Large diffs are not rendered by default.

docs/notebooks/benchmarks/benchmarking_nearest.ipynb

Lines changed: 21 additions & 42 deletions
Large diffs are not rendered by default.
0 Bytes
Binary file not shown.

docs/notebooks/demos/demo_conservative_nan_threshold.ipynb

Lines changed: 176 additions & 0 deletions
Large diffs are not rendered by default.

docs/notebooks/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ Most notebooks compare the methods implemented in xarray-regrid against more sta
1919
:caption: Demos
2020

2121
demos/demo_most_common.ipynb
22+
demos/demo_conservative_nan_threshold.ipynb

environment.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ name: xarray-regrid
33
channels:
44
- conda-forge
55
dependencies:
6-
- python==3.10
6+
- python==3.12
77
- xESMF
88
- cdo
99
- pip:
10-
- "xarray-regrid"
10+
- "xarray-regrid"
11+
- "cftime"
12+
- "matplotlib"
13+
- "dask[distributed]"

0 commit comments

Comments
 (0)