Skip to content

Commit

Permalink
Assume longitude is cyclic in _interp_nominal_lon (#296)
Browse files Browse the repository at this point in the history
* assume longitude is cyclic

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix scaffolding

* Update whats-new.rst

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Julius Busecke <julius@ldeo.columbia.edu>
  • Loading branch information
3 people committed Jun 25, 2024
1 parent f31885e commit a6248b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Internal Changes
- Added 'nvertices' -> 'vertex' to renaming preprocessor (:pull:`357`). By `Julius Busecke <https://github.com/jbusecke>`
- Updated mamba CI + testing py311/py312 (:issue:`360`, :pull:`362`). By `Julius Busecke <https://github.com/jbusecke>`

Bugfixes
~~~~~~~~
- Fixed cyclic interpolation in `_interp_nominal_lon` (:issue:`295`, :pull:`296`). By `Joran Angevaare <https://github.com/JoranAngevaare>`

.. _whats-new.0.7.2:

v0.7.3 (unreleased)
Expand Down
3 changes: 2 additions & 1 deletion xmip/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def broadcast_lonlat(ds, verbose=True):
def _interp_nominal_lon(lon_1d):
x = np.arange(len(lon_1d))
idx = np.isnan(lon_1d)
return np.interp(x, x[~idx], lon_1d[~idx], period=360)
# Assume that longitudes are cyclic (i.e. that the period equals the length of lon)
return np.interp(x, x[~idx], lon_1d[~idx], period=len(lon_1d))


def replace_x_y_nominal_lat_lon(ds):
Expand Down

0 comments on commit a6248b9

Please sign in to comment.