Skip to content

Commit

Permalink
Merge develop into main @ 0.2.7 (#30)
Browse files Browse the repository at this point in the history
* 12 support non latlon grib grids (#16)

* Adds support for non-lat-lon GRIB data points

* Re-enable automatic legend titles with proper fallback if no metadata found

* QA tweaks

* Rollback version of micromamba used with unit tests to v12

* Testing latest micromamba

* Migrate to new setup-micromamba

* Improve levels auto_range with proper symmetry (#17)

* Improve levels auto_range with proper symmetry

* Ensure symmetry around arbitrary divergence point

* Removes obsolete math import

---------

Co-authored-by: James Varndell <[email protected]>

* Fix datetime metadata for xarray for single-time datasets (#18)

* Only check for unstructured grid if normal plotting fails

* Adds convience save function at subplot level

* Fix earthkit mutably messing up an xarray's longitude (#22)

* Fix dimensionless unit formatting (#19)

* Fix dimensionless unit formatting

* Update src/earthkit/plots/metadata/units.py

Co-authored-by: James Varndell <[email protected]>

---------

Co-authored-by: James Varndell <[email protected]>

* Adds plugin support for Python 3.9 (#23)

* Feature/interactive plots (#25)

* Moves interactive plots into earthkit.plots.interactive

* Adds plotly to requirements

* Moves interactive plots into earthkit.plots.interactive

* Remove empty notebook

* QA tweaks

* Adds default style to improve look and feel with >5 quantiles

* Adds default style to improve look and feel with >5 quantiles

* Adds docstrings

* Adds tests for interactive plots

* QA tweaks

* Feature/vertical plots (#26)

* Moves interactive plots into earthkit.plots.interactive

* Adds plotly to requirements

* Moves interactive plots into earthkit.plots.interactive

* Remove empty notebook

* QA tweaks

* Adds default style to improve look and feel with >5 quantiles

* Adds default style to improve look and feel with >5 quantiles

* Adds docstrings

* Adds tests for interactive plots

* QA tweaks

* Adds better support for interactive vertical plots

* Bugfix/numpy input (#29)

* Adds numpy array plotting example

* Fixes bug when detecting z-values from numpy input

* Fixes bug when detecting x and y from irregular grid data

* Adds extra test for numpy z-detection from data argument

---------

Co-authored-by: Juniper Tyree <[email protected]>
  • Loading branch information
JamesVarndell and juntyr authored Nov 19, 2024
1 parent 7de602f commit 2042b33
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/examples/gallery/gallery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"* [Temperature and pressure](gridded-data/temperature-and-pressure.ipynb)\n",
"* [Time zones](gridded-data/time-zones.ipynb)\n",
"* [Weather forecast steps](gridded-data/weather-forecast-steps.ipynb)\n",
"* [Unstructured grids](gridded-data/unstructured-grids.ipynb)"
"* [Unstructured grids](gridded-data/unstructured-grids.ipynb)\n",
"* [Numpy arrays](gridded-data/numpy-arrays.ipynb)"
]
},
{
Expand Down
60 changes: 60 additions & 0 deletions docs/examples/gallery/gridded-data/numpy-arrays.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/earthkit/plots/sources/earthkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def extract_xy(self):
f"'{self.gridspec['grid']}' grid"
)
points = get_points(1)
x = points["x"]
y = points["y"]
else:
try:
points = self.data.to_points(flatten=False)
Expand Down
11 changes: 11 additions & 0 deletions src/earthkit/plots/sources/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ def extract_xyz(self):
xyz = np.arange(len(self.data)), self.data, None
elif len(self.data.shape) == 2:
xyz = np.arange(len(self.data[0])), np.arange(len(self.data)), self.data
elif self._z is None:
if self.data is not None and len(self.data.shape) == 1:
data = None
else:
data = self.data
if self._x is None:
xyz = np.arange(len(self._y)), self._y, data
elif self._y is None:
xyz = self._x, np.arange(len(self._x)), data
else:
xyz = self._x, self._y, data
return xyz

def extract_x(self):
Expand Down
7 changes: 7 additions & 0 deletions tests/sources/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def test_NumpySource_xy():
assert source.z_values is None


def test_NumpySource_xyz():
source = NumpySource([[1, 2], [4, 5]], x=[1, 2], y=[3, 4])
assert np.array_equal(source.x_values, [1, 2])
assert np.array_equal(source.y_values, [3, 4])
assert np.array_equal(source.z_values, [[1, 2], [4, 5]])


def test_NumpySource_3_args():
source = NumpySource([1, 2, 3], [3, 6, 4], [[1, 2, 3], [4, 5, 6]])
assert np.array_equal(source.x_values, [1, 2, 3])
Expand Down

0 comments on commit 2042b33

Please sign in to comment.