wavespectra 4.1.0__tar.gz → 4.2.0__tar.gz
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.
- {wavespectra-4.1.0/wavespectra.egg-info → wavespectra-4.2.0}/PKG-INFO +1 -1
- {wavespectra-4.1.0 → wavespectra-4.2.0}/pyproject.toml +1 -1
- {wavespectra-4.1.0 → wavespectra-4.2.0}/setup.py +3 -3
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/__init__.py +1 -1
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/select.py +68 -38
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/partition/partition.py +7 -7
- wavespectra-4.1.0/wavespectra/partition/specpart/specpartc.c → wavespectra-4.2.0/wavespectra/partition/specpart/specpart.c +1 -1
- wavespectra-4.1.0/wavespectra/partition/specpart/specpartc_wrap.c → wavespectra-4.2.0/wavespectra/partition/specpart/specpart_wrap.c +10 -10
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/specdataset.py +0 -16
- {wavespectra-4.1.0 → wavespectra-4.2.0/wavespectra.egg-info}/PKG-INFO +1 -1
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra.egg-info/SOURCES.txt +3 -3
- {wavespectra-4.1.0 → wavespectra-4.2.0}/AUTHORS.rst +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/LICENSE.txt +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/README.rst +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/setup.cfg +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/tests/test_cli.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/tests/test_cookiecutter_template.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/tests/test_partition.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/tests/test_specarray.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/cli.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/construct/__init__.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/construct/direction.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/construct/frequency.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/__init__.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/attributes.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/attributes.yml +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/fitting.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/npstats.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/swan.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/utils.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/core/xrstats.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/__init__.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/awac.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/dataset.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/datawell.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/era5.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/funwave.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/json.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/ncswan.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/ndbc.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/ndbc_ascii.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/netcdf.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/obscape.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/octopus.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/spotter.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/swan.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/triaxys.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/wavespectra.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/ww3.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/ww3_station.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/wwm.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/input/xwaves.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/__init__.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/funwave.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/json.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/netcdf.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/octopus.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/orcaflex.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/swan.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/ww3.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/output/ww3.yml +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/partition/__init__.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/partition/hanson_and_phillips_2001.py +0 -0
- /wavespectra-4.1.0/wavespectra/partition/specpart/specpartc.h → /wavespectra-4.2.0/wavespectra/partition/specpart/specpart.h +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/partition/tracking.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/plot.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra/specarray.py +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra.egg-info/dependency_links.txt +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra.egg-info/entry_points.txt +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra.egg-info/requires.txt +0 -0
- {wavespectra-4.1.0 → wavespectra-4.2.0}/wavespectra.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wavespectra
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: Library for ocean wave spectra
|
|
5
5
|
Author-email: Wavespectra Developers <r.guedes@oceanum.science>
|
|
6
6
|
Maintainer-email: Rafael Guedes <r.guedes@oceanum.science>, Tom Durrant <t.durrant@oceanum.science>
|
|
@@ -97,7 +97,7 @@ docs = [
|
|
|
97
97
|
[tool.setuptools.package-data]
|
|
98
98
|
"wavespectra.core" = ["*.yml"]
|
|
99
99
|
"wavespectra.output" = ["*.yml"]
|
|
100
|
-
"wavespectra.partition.specpart" = ["
|
|
100
|
+
"wavespectra.partition.specpart" = ["specpart.c", "specpart.h", "specpart_wrap.c"]
|
|
101
101
|
|
|
102
102
|
[tool.setuptools.dynamic]
|
|
103
103
|
version = {attr = "wavespectra.__version__"}
|
|
@@ -5,10 +5,10 @@ setup(
|
|
|
5
5
|
name="wavespectra",
|
|
6
6
|
ext_modules=[
|
|
7
7
|
Extension(
|
|
8
|
-
name="wavespectra.partition.
|
|
8
|
+
name="wavespectra.partition.specpart",
|
|
9
9
|
sources=[
|
|
10
|
-
"wavespectra/partition/specpart/
|
|
11
|
-
"wavespectra/partition/specpart/
|
|
10
|
+
"wavespectra/partition/specpart/specpart_wrap.c",
|
|
11
|
+
"wavespectra/partition/specpart/specpart.c",
|
|
12
12
|
],
|
|
13
13
|
include_dirs=[get_numpy_include()],
|
|
14
14
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Interpolate stations."""
|
|
2
|
+
|
|
2
3
|
import logging
|
|
3
4
|
|
|
4
5
|
import numpy as np
|
|
@@ -16,24 +17,34 @@ class Coordinates:
|
|
|
16
17
|
dset (xr.Dataset): Dataset object to slice from.
|
|
17
18
|
lons (array): Longitudes to slice.
|
|
18
19
|
lats (array): Latitudes to slice.
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
sitename (str): Name of site dimension.
|
|
21
|
+
lonname (str): Name of longitude coordinate.
|
|
22
|
+
latname (str): Name of latitude coordinate.
|
|
21
23
|
|
|
22
24
|
"""
|
|
23
25
|
|
|
24
|
-
def __init__(
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
dset,
|
|
29
|
+
lons,
|
|
30
|
+
lats,
|
|
31
|
+
sitename=attrs.SITENAME,
|
|
32
|
+
lonname=attrs.LONNAME,
|
|
33
|
+
latname=attrs.LATNAME,
|
|
34
|
+
):
|
|
35
|
+
# Ensure arrays
|
|
36
|
+
lons = lons if not np.isscalar(lons) else [lons]
|
|
37
|
+
lats = lats if not np.isscalar(lats) else [lats]
|
|
38
|
+
|
|
25
39
|
self.dset = dset
|
|
26
40
|
self._lons = np.array(lons)
|
|
27
41
|
self.lats = np.array(lats)
|
|
42
|
+
self.sitename = sitename
|
|
43
|
+
self.lonname = lonname
|
|
44
|
+
self.latname = latname
|
|
28
45
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
else:
|
|
32
|
-
self.dset_lons = dset_lons
|
|
33
|
-
if dset_lats is None:
|
|
34
|
-
self.dset_lats = dset[attrs.LATNAME].values
|
|
35
|
-
else:
|
|
36
|
-
self.dset_lats = dset_lats
|
|
46
|
+
self.dset_lons = dset[self.lonname].values
|
|
47
|
+
self.dset_lats = dset[self.latname].values
|
|
37
48
|
|
|
38
49
|
self._validate()
|
|
39
50
|
|
|
@@ -46,9 +57,9 @@ class Coordinates:
|
|
|
46
57
|
"""Few input checks."""
|
|
47
58
|
assert len(self._lons) == len(self.lats), "lons and lats must have same size."
|
|
48
59
|
if (
|
|
49
|
-
|
|
50
|
-
or
|
|
51
|
-
or
|
|
60
|
+
self.lonname in self.dset.dims
|
|
61
|
+
or self.latname in self.dset.dims
|
|
62
|
+
or self.sitename not in self.dset.dims
|
|
52
63
|
):
|
|
53
64
|
raise NotImplementedError("sel only supports stations not gridded data.")
|
|
54
65
|
|
|
@@ -143,9 +154,10 @@ def sel_nearest(
|
|
|
143
154
|
tolerance=2.0,
|
|
144
155
|
unique=False,
|
|
145
156
|
exact=False,
|
|
146
|
-
dset_lons=None,
|
|
147
|
-
dset_lats=None,
|
|
148
157
|
missing="raise",
|
|
158
|
+
sitename=attrs.SITENAME,
|
|
159
|
+
lonname=attrs.LONNAME,
|
|
160
|
+
latname=attrs.LATNAME,
|
|
149
161
|
):
|
|
150
162
|
"""Select sites from nearest distance.
|
|
151
163
|
|
|
@@ -156,11 +168,12 @@ def sel_nearest(
|
|
|
156
168
|
tolerance (float): Maximum distance to use site for interpolation.
|
|
157
169
|
unique (bool): Only returns unique sites in case of repeated inexact matches.
|
|
158
170
|
exact (bool): Require exact matches.
|
|
159
|
-
dset_lons (array): Longitude of stations in dset.
|
|
160
|
-
dset_lats (array): Latitude of stations in dset.
|
|
161
171
|
missing (str): Action to take if no site is found within tolerance:
|
|
162
172
|
- 'raise': raise an error
|
|
163
173
|
- 'ignore': skip site
|
|
174
|
+
sitename (str): Name of site dimension.
|
|
175
|
+
lonname (str): Name of longitude coordinate.
|
|
176
|
+
latname (str): Name of latitude coordinate.
|
|
164
177
|
|
|
165
178
|
Returns:
|
|
166
179
|
Selected SpecDataset at locations defined by (lons, lats).
|
|
@@ -172,7 +185,7 @@ def sel_nearest(
|
|
|
172
185
|
|
|
173
186
|
"""
|
|
174
187
|
coords = Coordinates(
|
|
175
|
-
dset, lons=lons, lats=lats,
|
|
188
|
+
dset, lons=lons, lats=lats, sitename=sitename, lonname=lonname, latname=latname
|
|
176
189
|
)
|
|
177
190
|
|
|
178
191
|
station_ids = []
|
|
@@ -207,19 +220,26 @@ def sel_nearest(
|
|
|
207
220
|
f"No site in dataset found within tolerance={tolerance} deg of any site "
|
|
208
221
|
f"{list(zip(coords.lons, coords.lats))}"
|
|
209
222
|
)
|
|
210
|
-
dsout = dset.isel(**{
|
|
223
|
+
dsout = dset.isel(**{sitename: station_ids})
|
|
211
224
|
|
|
212
225
|
# Return longitudes in the convention provided
|
|
213
226
|
if coords.consistent is False:
|
|
214
227
|
dsout.lon.values = coords._swap_longitude_convention(dsout.lon.values)
|
|
215
228
|
|
|
216
|
-
dsout = dsout.assign_coords({
|
|
229
|
+
dsout = dsout.assign_coords({sitename: np.arange(len(station_ids))})
|
|
217
230
|
|
|
218
231
|
return dsout
|
|
219
232
|
|
|
220
233
|
|
|
221
234
|
def sel_idw(
|
|
222
|
-
dset,
|
|
235
|
+
dset,
|
|
236
|
+
lons,
|
|
237
|
+
lats,
|
|
238
|
+
tolerance=2.0,
|
|
239
|
+
max_sites=4,
|
|
240
|
+
sitename=attrs.SITENAME,
|
|
241
|
+
lonname=attrs.LONNAME,
|
|
242
|
+
latname=attrs.LATNAME,
|
|
223
243
|
):
|
|
224
244
|
"""Select sites from inverse distance weighting.
|
|
225
245
|
|
|
@@ -229,8 +249,9 @@ def sel_idw(
|
|
|
229
249
|
lats (array): Latitude of sites to interpolate spectra at.
|
|
230
250
|
tolerance (float): Maximum distance to use site for interpolation.
|
|
231
251
|
max_sites (int): Maximum number of neighbour sites to use for interpolation.
|
|
232
|
-
|
|
233
|
-
|
|
252
|
+
sitename (str): Name of site dimension.
|
|
253
|
+
lonname (str): Name of longitude coordinate.
|
|
254
|
+
latname (str): Name of latitude coordinate.
|
|
234
255
|
|
|
235
256
|
Returns:
|
|
236
257
|
Selected SpecDataset at locations defined by (lons, lats).
|
|
@@ -242,10 +263,10 @@ def sel_idw(
|
|
|
242
263
|
|
|
243
264
|
"""
|
|
244
265
|
coords = Coordinates(
|
|
245
|
-
dset, lons=lons, lats=lats,
|
|
266
|
+
dset, lons=lons, lats=lats, sitename=sitename, lonname=lonname, latname=latname
|
|
246
267
|
)
|
|
247
268
|
|
|
248
|
-
mask = dset.isel(
|
|
269
|
+
mask = dset.isel({sitename: 0}, drop=True) * np.nan
|
|
249
270
|
dsout = []
|
|
250
271
|
for lon, lat in zip(coords.lons, coords.lats):
|
|
251
272
|
closest_ids, closest_dist = coords.nearer(lon, lat, tolerance, max_sites)
|
|
@@ -271,23 +292,23 @@ def sel_idw(
|
|
|
271
292
|
sumfac = float(1.0 / sum(factors))
|
|
272
293
|
ind = indices.pop(0)
|
|
273
294
|
fac = factors.pop(0)
|
|
274
|
-
weighted = float(fac) * dset.isel(
|
|
295
|
+
weighted = float(fac) * dset.isel({sitename: ind}, drop=True)
|
|
275
296
|
for ind, fac in zip(indices, factors):
|
|
276
|
-
weighted += float(fac) * dset.isel(
|
|
297
|
+
weighted += float(fac) * dset.isel({sitename: ind}, drop=True)
|
|
277
298
|
if len(indices) > 0:
|
|
278
299
|
weighted *= sumfac
|
|
279
300
|
dsout.append(weighted)
|
|
280
301
|
|
|
281
302
|
# Concat sites into dataset
|
|
282
|
-
dsout = xr.concat(dsout, dim=
|
|
303
|
+
dsout = xr.concat(dsout, dim=sitename)
|
|
283
304
|
for dvar in dsout.data_vars:
|
|
284
305
|
if set(dsout[dvar].dims) == set(dset[dvar].dims):
|
|
285
306
|
dsout[dvar] = dsout[dvar].transpose(*dset[dvar].dims)
|
|
286
307
|
|
|
287
308
|
# Redefining coordinates and variables
|
|
288
|
-
dsout[
|
|
289
|
-
dsout[
|
|
290
|
-
dsout[
|
|
309
|
+
dsout[sitename] = np.arange(len(coords.lons))
|
|
310
|
+
dsout[lonname] = ((sitename), coords.lons)
|
|
311
|
+
dsout[latname] = ((sitename), coords.lats)
|
|
291
312
|
|
|
292
313
|
# Return longitudes in the convention provided
|
|
293
314
|
if coords.consistent is False:
|
|
@@ -299,7 +320,15 @@ def sel_idw(
|
|
|
299
320
|
return dsout
|
|
300
321
|
|
|
301
322
|
|
|
302
|
-
def sel_bbox(
|
|
323
|
+
def sel_bbox(
|
|
324
|
+
dset,
|
|
325
|
+
lons,
|
|
326
|
+
lats,
|
|
327
|
+
tolerance=0.0,
|
|
328
|
+
sitename=attrs.SITENAME,
|
|
329
|
+
lonname=attrs.LONNAME,
|
|
330
|
+
latname=attrs.LATNAME,
|
|
331
|
+
):
|
|
303
332
|
"""Select sites within bbox.
|
|
304
333
|
|
|
305
334
|
Args:
|
|
@@ -307,8 +336,9 @@ def sel_bbox(dset, lons, lats, tolerance=0.0, dset_lons=None, dset_lats=None):
|
|
|
307
336
|
lons (array): Longitude of sites to interpolate spectra at.
|
|
308
337
|
lats (array): Latitude of sites to interpolate spectra at.
|
|
309
338
|
tolerance (float): Extend bbox extents by.
|
|
310
|
-
|
|
311
|
-
|
|
339
|
+
sitename (str): Name of site dimension.
|
|
340
|
+
lonname (str): Name of longitude coordinate.
|
|
341
|
+
latname (str): Name of latitude coordinate.
|
|
312
342
|
|
|
313
343
|
Returns:
|
|
314
344
|
Selected SpecDataset within bbox defined by:
|
|
@@ -321,7 +351,7 @@ def sel_bbox(dset, lons, lats, tolerance=0.0, dset_lons=None, dset_lats=None):
|
|
|
321
351
|
|
|
322
352
|
"""
|
|
323
353
|
coords = Coordinates(
|
|
324
|
-
dset, lons=lons, lats=lats,
|
|
354
|
+
dset, lons=lons, lats=lats, sitename=sitename, lonname=lonname, latname=latname
|
|
325
355
|
)
|
|
326
356
|
|
|
327
357
|
minlon = min(coords.lons) - tolerance
|
|
@@ -359,12 +389,12 @@ def sel_bbox(dset, lons, lats, tolerance=0.0, dset_lons=None, dset_lats=None):
|
|
|
359
389
|
f"[{max(coords._lons) + tolerance}, {maxlat}])"
|
|
360
390
|
)
|
|
361
391
|
|
|
362
|
-
dsout = dset.isel(**{
|
|
392
|
+
dsout = dset.isel(**{sitename: station_ids})
|
|
363
393
|
|
|
364
394
|
# Return longitudes in the convention provided
|
|
365
395
|
if coords.consistent is False:
|
|
366
396
|
dsout.lon.values = coords._swap_longitude_convention(dsout.lon.values)
|
|
367
397
|
|
|
368
|
-
dsout = dsout.assign_coords({
|
|
398
|
+
dsout = dsout.assign_coords({sitename: np.arange(len(station_ids))})
|
|
369
399
|
|
|
370
400
|
return dsout
|
|
@@ -3,7 +3,7 @@ from itertools import combinations
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import xarray as xr
|
|
5
5
|
|
|
6
|
-
from wavespectra.partition import
|
|
6
|
+
from wavespectra.partition import specpart
|
|
7
7
|
from wavespectra.core.utils import (
|
|
8
8
|
set_spec_attributes,
|
|
9
9
|
regrid_spec,
|
|
@@ -829,7 +829,7 @@ def np_ptm1(
|
|
|
829
829
|
|
|
830
830
|
"""
|
|
831
831
|
# Use smooth spectrum to define morphological boundaries
|
|
832
|
-
watershed_map =
|
|
832
|
+
watershed_map = specpart.partition(spectrum_smooth.astype(np.float32), ihmax)
|
|
833
833
|
nparts = watershed_map.max()
|
|
834
834
|
|
|
835
835
|
# Wind sea mask
|
|
@@ -909,7 +909,7 @@ def np_ptm2(
|
|
|
909
909
|
|
|
910
910
|
"""
|
|
911
911
|
# Use smooth spectrum to define morphological boundaries
|
|
912
|
-
watershed_map =
|
|
912
|
+
watershed_map = specpart.partition(spectrum_smooth.astype(np.float32), ihmax)
|
|
913
913
|
nparts = watershed_map.max()
|
|
914
914
|
|
|
915
915
|
# Wind sea mask
|
|
@@ -979,7 +979,7 @@ def np_ptm3(
|
|
|
979
979
|
|
|
980
980
|
"""
|
|
981
981
|
# Use smooth spectrum to define morphological boundaries
|
|
982
|
-
watershed_map =
|
|
982
|
+
watershed_map = specpart.partition(spectrum_smooth.astype(np.float32), ihmax)
|
|
983
983
|
nparts = watershed_map.max()
|
|
984
984
|
|
|
985
985
|
# Assign partitioned arrays from raw spectrum and morphological boundaries
|
|
@@ -1051,7 +1051,7 @@ def np_hp01(
|
|
|
1051
1051
|
|
|
1052
1052
|
"""
|
|
1053
1053
|
# Use smooth spectrum to define morphological boundaries
|
|
1054
|
-
watershed_map =
|
|
1054
|
+
watershed_map = specpart.partition(spectrum_smooth.astype(np.float32), ihmax)
|
|
1055
1055
|
nparts = watershed_map.max()
|
|
1056
1056
|
|
|
1057
1057
|
# Assign partitioned arrays from raw spectrum and morphological boundaries
|
|
@@ -1144,7 +1144,7 @@ def np_hp01_wseabins(
|
|
|
1144
1144
|
|
|
1145
1145
|
"""
|
|
1146
1146
|
# Use smooth spectrum to define morphological boundaries
|
|
1147
|
-
watershed_map =
|
|
1147
|
+
watershed_map = specpart.partition(spectrum_smooth.astype(np.float32), ihmax)
|
|
1148
1148
|
nparts = watershed_map.max()
|
|
1149
1149
|
|
|
1150
1150
|
# Assign partitioned arrays from raw spectrum and morphological boundaries
|
|
@@ -1240,7 +1240,7 @@ def np_hp01_wseafrac_wseabins(
|
|
|
1240
1240
|
|
|
1241
1241
|
"""
|
|
1242
1242
|
# Use smooth spectrum to define morphological boundaries
|
|
1243
|
-
watershed_map =
|
|
1243
|
+
watershed_map = specpart.partition(spectrum_smooth.astype(np.float32), ihmax)
|
|
1244
1244
|
nparts = watershed_map.max()
|
|
1245
1245
|
|
|
1246
1246
|
# Assign partitioned arrays from raw spectrum and morphological boundaries
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
#include <Python.h>
|
|
2
2
|
#include "numpy/arrayobject.h"
|
|
3
|
-
#include "
|
|
3
|
+
#include "specpart.h"
|
|
4
4
|
|
|
5
|
-
static PyObject *
|
|
5
|
+
static PyObject * specpart(PyObject *self, PyObject *args);
|
|
6
6
|
|
|
7
7
|
/* ==== Set up the methods table ====================== */
|
|
8
|
-
static PyMethodDef
|
|
9
|
-
{"partition",
|
|
8
|
+
static PyMethodDef specpart_methods[] = {
|
|
9
|
+
{"partition", specpart, METH_VARARGS, "Description"},
|
|
10
10
|
{NULL, NULL, 0, NULL}
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
static struct PyModuleDef
|
|
13
|
+
static struct PyModuleDef specpart_definition = {
|
|
14
14
|
PyModuleDef_HEAD_INIT,
|
|
15
|
-
"
|
|
15
|
+
"specpart",
|
|
16
16
|
"A Python module that prints 'hello world' from C code.",
|
|
17
17
|
-1,
|
|
18
|
-
|
|
18
|
+
specpart_methods
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
PyMODINIT_FUNC
|
|
21
|
+
PyMODINIT_FUNC PyInit_specpart(void) {
|
|
22
22
|
Py_Initialize();
|
|
23
23
|
import_array();
|
|
24
|
-
return PyModule_Create(&
|
|
24
|
+
return PyModule_Create(&specpart_definition);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
static PyObject *
|
|
27
|
+
static PyObject * specpart(PyObject *self, PyObject *args)
|
|
28
28
|
{
|
|
29
29
|
PyArrayObject *specin, *ipartout; // The python objects to be extracted from the args
|
|
30
30
|
float * spec;
|
|
@@ -124,8 +124,6 @@ class SpecDataset(metaclass=Plugin):
|
|
|
124
124
|
lats,
|
|
125
125
|
method="idw",
|
|
126
126
|
tolerance=2.0,
|
|
127
|
-
dset_lons=None,
|
|
128
|
-
dset_lats=None,
|
|
129
127
|
**kwargs,
|
|
130
128
|
):
|
|
131
129
|
"""Select stations near or at locations defined by (lons, lats) vector.
|
|
@@ -140,10 +138,6 @@ class SpecDataset(metaclass=Plugin):
|
|
|
140
138
|
* None: Only exact matches.
|
|
141
139
|
- tolerance (float): Maximum distance between locations and original stations
|
|
142
140
|
for inexact matches.
|
|
143
|
-
- dset_lons (array): Longitude of stations in dset, not required but could
|
|
144
|
-
help improove speed.
|
|
145
|
-
- dset_lats (array): Latitude of stations in dset, not required but could
|
|
146
|
-
help improove speed.
|
|
147
141
|
- kwargs: Extra keywargs to pass to the respective sel function
|
|
148
142
|
(i.e., `sel_nearest`, `sel_idw`).
|
|
149
143
|
|
|
@@ -154,9 +148,6 @@ class SpecDataset(metaclass=Plugin):
|
|
|
154
148
|
- `tolerance` behaves differently with methods 'idw' and 'nearest'. In 'idw'
|
|
155
149
|
sites with no neighbours within `tolerance` are masked whereas in
|
|
156
150
|
'nearest' an exception is raised.
|
|
157
|
-
- `dset_lons`, `dset_lats` are not required but can improve performance when
|
|
158
|
-
`dset` is chunked with site=1 (expensive to access site coords) and
|
|
159
|
-
improve precision if projected coors are provided at high latitudes.
|
|
160
151
|
|
|
161
152
|
"""
|
|
162
153
|
funcs = {
|
|
@@ -173,18 +164,11 @@ class SpecDataset(metaclass=Plugin):
|
|
|
173
164
|
)
|
|
174
165
|
if method is None:
|
|
175
166
|
kwargs.update({"exact": True})
|
|
176
|
-
# Providing station coordinates is a lot more efficient for chunked datasets
|
|
177
|
-
if dset_lons is None:
|
|
178
|
-
dset_lons = self.dset[attrs.LONNAME].values
|
|
179
|
-
if dset_lats is None:
|
|
180
|
-
dset_lats = self.dset[attrs.LATNAME].values
|
|
181
167
|
dsout = func(
|
|
182
168
|
dset=self.dset,
|
|
183
169
|
lons=lons,
|
|
184
170
|
lats=lats,
|
|
185
171
|
tolerance=tolerance,
|
|
186
|
-
dset_lons=dset_lons,
|
|
187
|
-
dset_lats=dset_lats,
|
|
188
172
|
**kwargs,
|
|
189
173
|
)
|
|
190
174
|
return dsout
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wavespectra
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: Library for ocean wave spectra
|
|
5
5
|
Author-email: Wavespectra Developers <r.guedes@oceanum.science>
|
|
6
6
|
Maintainer-email: Rafael Guedes <r.guedes@oceanum.science>, Tom Durrant <t.durrant@oceanum.science>
|
|
@@ -65,6 +65,6 @@ wavespectra/partition/__init__.py
|
|
|
65
65
|
wavespectra/partition/hanson_and_phillips_2001.py
|
|
66
66
|
wavespectra/partition/partition.py
|
|
67
67
|
wavespectra/partition/tracking.py
|
|
68
|
-
wavespectra/partition/specpart/
|
|
69
|
-
wavespectra/partition/specpart/
|
|
70
|
-
wavespectra/partition/specpart/
|
|
68
|
+
wavespectra/partition/specpart/specpart.c
|
|
69
|
+
wavespectra/partition/specpart/specpart.h
|
|
70
|
+
wavespectra/partition/specpart/specpart_wrap.c
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|