ncplot 0.4.1__py3-none-any.whl → 0.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ncplot/plot.py CHANGED
@@ -28,7 +28,7 @@ import copy
28
28
  import numpy as np
29
29
  import os
30
30
 
31
- from ncplot.utils import get_dims, check_lon, check_lat
31
+ from ncplot.utils import get_dims, check_lon, check_lat, normalise_lon
32
32
 
33
33
  hv.extension("bokeh")
34
34
  hv.Store.renderers
@@ -579,6 +579,10 @@ def view(x, vars=None, autoscale=True, out=None, **kwargs):
579
579
  if "lon" not in lon_name:
580
580
  coastline = False
581
581
 
582
+ # coastlines are drawn on a -180-180 map, so longitudes must follow that convention
583
+ if coastline:
584
+ ds = normalise_lon(ds, lon_name)
585
+
582
586
  ff_dims = list(ds.coords)
583
587
 
584
588
  possible_others = [x for x in ff_dims if x not in df_dims.columns]
ncplot/utils.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import subprocess
2
2
 
3
+ import numpy as np
3
4
  import xarray as xr
4
5
  import pandas as pd
5
6
  import logging
@@ -9,6 +10,31 @@ metpy_log = logging.getLogger("metpy")
9
10
  metpy_log.setLevel(logging.CRITICAL)
10
11
 
11
12
 
13
+ def normalise_lon(ds, lon_name):
14
+ """
15
+ Convert longitudes running 0-360 to -180-180 (sorted), as coastlines are drawn on a -180-180 map.
16
+ The dataset is returned unchanged if the longitudes cannot be converted to a contiguous axis,
17
+ e.g. a regional subset that straddles 180 degrees.
18
+ """
19
+ if lon_name is None or lon_name not in ds.dims:
20
+ return ds
21
+
22
+ lons = ds[lon_name].values
23
+ if lons.ndim != 1 or len(lons) < 2 or not lons.max() > 180:
24
+ return ds
25
+
26
+ attrs = ds[lon_name].attrs
27
+ new_ds = ds.assign_coords({lon_name: ((ds[lon_name] + 180) % 360) - 180})
28
+ new_ds = new_ds.sortby(lon_name)
29
+ new_ds[lon_name].attrs = attrs
30
+
31
+ steps = np.diff(new_ds[lon_name].values.astype("float64"))
32
+ if len(steps) > 0 and steps.max() > 1.5 * np.median(steps):
33
+ return ds
34
+
35
+ return new_ds
36
+
37
+
12
38
  def check_lon(x, ds):
13
39
  """
14
40
  A function to change the lon coord identified in case it cannot be represented by hvplot
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ncplot
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Interactive viewing of NetCDF data
5
5
  Home-page: https://github.com/pmlmodelling/ncplot
6
6
  Author: Robert Wilson
@@ -51,7 +51,7 @@ Dynamic: summary
51
51
  </p>
52
52
 
53
53
  > [!TIP]
54
- > 📖 **New here?** The NCPlot website — installing, a quickstart, the API reference, and more — lives at **[pmlmodelling.github.io/ncplot](https://pmlmodelling.github.io/ncplot/)**.
54
+ > 📖 **New here?** The NCPlot website — installing, a quickstart, the API reference, and more — lives at **[plymouthmarinelaboratory.github.io/ncplot](https://plymouthmarinelaboratory.github.io/ncplot/)**.
55
55
 
56
56
  [![pypi](https://img.shields.io/pypi/v/ncplot.svg)](https://pypi.python.org/pypi/ncplot/)
57
57
  [![Documentation Status](https://readthedocs.org/projects/ncplot/badge/?version=latest)](https://ncplot.readthedocs.io/en/latest/?badge=latest)
@@ -150,7 +150,7 @@ ncplot example.nc
150
150
 
151
151
  # Reference and tutorials
152
152
 
153
- A full API reference, and a how-to guide are available at the [NCPlot website](https://pmlmodelling.github.io/ncplot/) and on [readthedocs](https://ncplot.readthedocs.io/en/latest/).
153
+ A full API reference, and a how-to guide are available at the [NCPlot website](https://plymouthmarinelaboratory.github.io/ncplot/) and on [readthedocs](https://ncplot.readthedocs.io/en/latest/).
154
154
 
155
155
 
156
156
 
@@ -0,0 +1,12 @@
1
+ ncplot/__init__.py,sha256=Y7JgOH_AwvTpuvmX3rnp0LBeIaEjEZkXxCEQjSpq2mc,29
2
+ ncplot/command_line.py,sha256=L4JRPyYv9clgU35H9xSmyp3A4AAiC8Zm0W1ciTYv06A,835
3
+ ncplot/deprecated.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ ncplot/plot.py,sha256=NHQzJ-jKt5nF1JDeMfZ_Jz9rt5jbuqNnH8uGteMXQvU,40052
5
+ ncplot/utils.py,sha256=pvFahoxeuc26DtdEIp28MkyvDik8NR0aSqdHbBupQr8,6005
6
+ ncplot/xarray.py,sha256=F-kGEufuE8ZvIdWsNpuLGjhn4Tn6aM1UNUWvHIaiOvA,535
7
+ ncplot-0.4.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
8
+ ncplot-0.4.2.dist-info/METADATA,sha256=mjSRD4vxjKR6Ch9VBVAapHaBIaozSGX1KgjbA3Bk2mY,3603
9
+ ncplot-0.4.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
10
+ ncplot-0.4.2.dist-info/entry_points.txt,sha256=8CIFyTPZn49GsrojImqnJpkYIbxxZHAP_rHqA-256Eo,52
11
+ ncplot-0.4.2.dist-info/top_level.txt,sha256=hCfsI7KZNMRpk8FI5lwz_PFTyzJl91Iy2TSPAGEu9WI,7
12
+ ncplot-0.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- ncplot/__init__.py,sha256=Y7JgOH_AwvTpuvmX3rnp0LBeIaEjEZkXxCEQjSpq2mc,29
2
- ncplot/command_line.py,sha256=L4JRPyYv9clgU35H9xSmyp3A4AAiC8Zm0W1ciTYv06A,835
3
- ncplot/deprecated.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- ncplot/plot.py,sha256=YZDkANCJss7azv2wbx6RPpCtp9GgFTSCjf7B0w96FJ0,39889
5
- ncplot/utils.py,sha256=iR-4_KqovkqhSYRlGMUZBykwUG3W2cXxs5GTayghF3c,5149
6
- ncplot/xarray.py,sha256=F-kGEufuE8ZvIdWsNpuLGjhn4Tn6aM1UNUWvHIaiOvA,535
7
- ncplot-0.4.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
8
- ncplot-0.4.1.dist-info/METADATA,sha256=pNHWuOEQ_EYG2ZSj9GJNKoNYAOlJ1X57IvJGXVJ9JJQ,3567
9
- ncplot-0.4.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
10
- ncplot-0.4.1.dist-info/entry_points.txt,sha256=8CIFyTPZn49GsrojImqnJpkYIbxxZHAP_rHqA-256Eo,52
11
- ncplot-0.4.1.dist-info/top_level.txt,sha256=hCfsI7KZNMRpk8FI5lwz_PFTyzJl91Iy2TSPAGEu9WI,7
12
- ncplot-0.4.1.dist-info/RECORD,,