wavespectra 4.2.1__tar.gz → 4.3.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.2.1/wavespectra.egg-info → wavespectra-4.3.0}/PKG-INFO +1 -1
- {wavespectra-4.2.1 → wavespectra-4.3.0}/tests/test_cli.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/tests/test_specarray.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/__init__.py +2 -1
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/cli.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/construct/__init__.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/construct/frequency.py +2 -3
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/attributes.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/npstats.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/swan.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/utils.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/xrstats.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/__init__.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/dataset.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/era5.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/funwave.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/json.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/ncswan.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/ndbc.py +22 -5
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/ndbc_ascii.py +29 -13
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/netcdf.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/octopus.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/swan.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/wavespectra.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/ww3.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/ww3_station.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/wwm.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/xwaves.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/funwave.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/json.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/netcdf.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/octopus.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/orcaflex.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/swan.py +4 -1
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/ww3.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/partition.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/specarray.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/specdataset.py +1 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0/wavespectra.egg-info}/PKG-INFO +1 -1
- {wavespectra-4.2.1 → wavespectra-4.3.0}/AUTHORS.rst +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/LICENSE.txt +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/README.rst +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/pyproject.toml +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/setup.cfg +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/setup.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/tests/test_cookiecutter_template.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/tests/test_partition.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/construct/direction.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/__init__.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/attributes.yml +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/fitting.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/core/select.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/awac.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/datawell.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/obscape.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/spotter.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/input/triaxys.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/__init__.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/output/ww3.yml +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/__init__.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/hanson_and_phillips_2001.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/specpart/specpart.c +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/specpart/specpart.h +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/specpart/specpart_wrap.c +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/partition/tracking.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra/plot.py +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra.egg-info/SOURCES.txt +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra.egg-info/dependency_links.txt +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra.egg-info/entry_points.txt +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.0}/wavespectra.egg-info/requires.txt +0 -0
- {wavespectra-4.2.1 → wavespectra-4.3.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.3.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>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
- Making reading functions available at module level
|
|
5
5
|
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
import warnings
|
|
8
9
|
|
|
9
10
|
try:
|
|
@@ -13,7 +14,7 @@ except ImportError:
|
|
|
13
14
|
warnings.warn("Cannot import accessors at the main module level")
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
__version__ = "4.
|
|
17
|
+
__version__ = "4.3.0"
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def _import_functions(pkgname="input", prefix="read"):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Frequency spectral shapes."""
|
|
2
|
+
|
|
2
3
|
import numpy as np
|
|
3
4
|
import xarray as xr
|
|
4
5
|
from scipy.constants import g, pi
|
|
@@ -32,9 +33,7 @@ def pierson_moskowitz(freq, fp, alpha=0.0081, hs=None, **kwargs):
|
|
|
32
33
|
if not isinstance(freq, xr.DataArray):
|
|
33
34
|
freq = to_coords(freq, "freq")
|
|
34
35
|
|
|
35
|
-
dsout = (
|
|
36
|
-
alpha * g**2 / (2 * pi) ** 4 / freq**5 * np.exp(-1.25 * (freq / fp) ** -4)
|
|
37
|
-
)
|
|
36
|
+
dsout = alpha * g**2 / (2 * pi) ** 4 / freq**5 * np.exp(-1.25 * (freq / fp) ** -4)
|
|
38
37
|
|
|
39
38
|
if hs is not None:
|
|
40
39
|
dsout = scaled(dsout, hs)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
https://dods.ndbc.noaa.gov/
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
|
+
|
|
6
7
|
import logging
|
|
7
8
|
from xarray.backends import BackendEntrypoint
|
|
8
9
|
import xarray as xr
|
|
@@ -26,7 +27,7 @@ MAPPING = {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
def read_ndbc(url, directional=True, dd=10.0, chunks={}):
|
|
30
|
+
def read_ndbc(url, directional=True, dd=10.0, chunks={}, weight_coeff: bool = False):
|
|
30
31
|
"""Read Spectra from NDBC netCDF format.
|
|
31
32
|
|
|
32
33
|
Args:
|
|
@@ -35,6 +36,8 @@ def read_ndbc(url, directional=True, dd=10.0, chunks={}):
|
|
|
35
36
|
- dd (float): Directional resolution for 2D spectra (deg).
|
|
36
37
|
- chunks (dict): Chunk sizes for dimensions in dataset. By default
|
|
37
38
|
dataset is loaded using single chunk for all dimensions.
|
|
39
|
+
- weight_coef (bool): Weight the coefficient to avoid negative value
|
|
40
|
+
in spectrum.
|
|
38
41
|
|
|
39
42
|
Returns:
|
|
40
43
|
- dset (SpecDataset): spectra dataset object read from NDBC file.
|
|
@@ -48,22 +51,35 @@ def read_ndbc(url, directional=True, dd=10.0, chunks={}):
|
|
|
48
51
|
|
|
49
52
|
"""
|
|
50
53
|
dset = xr.open_dataset(url).chunk(chunks)
|
|
51
|
-
return from_ndbc(dset, directional=directional, dd=dd)
|
|
54
|
+
return from_ndbc(dset, directional=directional, dd=dd, weight_coeff=weight_coeff)
|
|
52
55
|
|
|
53
56
|
|
|
54
|
-
def _construct_spectra(ef, swd1, swd2, swr1, swr2, dir):
|
|
57
|
+
def _construct_spectra(ef, swd1, swd2, swr1, swr2, dir, weight_coeff: bool = False):
|
|
55
58
|
"""Construct 2D spectra."""
|
|
56
|
-
|
|
59
|
+
if weight_coeff:
|
|
60
|
+
d = (
|
|
61
|
+
0.5
|
|
62
|
+
+ 2 / 3 * swr1 * np.cos(D2R * (dir - swd1))
|
|
63
|
+
+ 1 / 6 * swr2 * np.cos(2 * D2R * (dir - swd2))
|
|
64
|
+
)
|
|
65
|
+
else:
|
|
66
|
+
d = (
|
|
67
|
+
0.5
|
|
68
|
+
+ swr1 * np.cos(D2R * (dir - swd1))
|
|
69
|
+
+ swr2 * np.cos(2 * D2R * (dir - swd2))
|
|
70
|
+
)
|
|
57
71
|
return ef * d * D2R / np.pi
|
|
58
72
|
|
|
59
73
|
|
|
60
|
-
def from_ndbc(dset, directional=True, dd=10.0):
|
|
74
|
+
def from_ndbc(dset, directional=True, dd=10.0, weight_coeff: bool = False):
|
|
61
75
|
"""Format NDBC netcdf dataset to implement the wavespectra accessor.
|
|
62
76
|
|
|
63
77
|
Args:
|
|
64
78
|
- dset (xr.Dataset): Dataset created from a NDBC netcdf file.
|
|
65
79
|
- directional (bool): Constructs 2D spectra if True, returns 1D if False.
|
|
66
80
|
- dd (float): Directional resolution for 2D spectra (deg).
|
|
81
|
+
- weight_coef (bool): Weight the coefficient to avoid negative value
|
|
82
|
+
in spectrum.
|
|
67
83
|
|
|
68
84
|
Returns:
|
|
69
85
|
- Formated dataset with the SpecDataset accessor in the `spec` namespace.
|
|
@@ -103,6 +119,7 @@ def from_ndbc(dset, directional=True, dd=10.0):
|
|
|
103
119
|
swr1=dset.wave_spectrum_r1,
|
|
104
120
|
swr2=dset.wave_spectrum_r2,
|
|
105
121
|
dir=xr.DataArray(dirs, dims=(attrs.DIRNAME,), coords={attrs.DIRNAME: dirs}),
|
|
122
|
+
weight_coeff=weight_coeff,
|
|
106
123
|
)
|
|
107
124
|
else:
|
|
108
125
|
dset = dset.spectral_wave_density
|
|
@@ -57,22 +57,35 @@ def read_file(filename):
|
|
|
57
57
|
return df
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def construct_spectra(
|
|
60
|
+
def construct_spectra(
|
|
61
|
+
spden, swdir1, swdir2, swr1, swr2, dirs, weight_coeff: bool = False
|
|
62
|
+
):
|
|
61
63
|
dirmat = dirs.reshape((1, 1, -1))
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if weight_coeff:
|
|
65
|
+
D_fd = (
|
|
66
|
+
IPI
|
|
67
|
+
* (
|
|
68
|
+
0.5
|
|
69
|
+
+ 2 / 3 * swr1 * np.cos(D2R * (dirmat - swdir1))
|
|
70
|
+
+ 1 / 6 * swr2 * np.cos(2 * D2R * (dirmat - swdir2))
|
|
71
|
+
)
|
|
72
|
+
* D2R
|
|
73
|
+
)
|
|
74
|
+
else:
|
|
75
|
+
D_fd = (
|
|
76
|
+
IPI
|
|
77
|
+
* (
|
|
78
|
+
0.5
|
|
79
|
+
+ swr1 * np.cos(D2R * (dirmat - swdir1))
|
|
80
|
+
+ swr2 * np.cos(2 * D2R * (dirmat - swdir2))
|
|
81
|
+
)
|
|
82
|
+
* D2R
|
|
68
83
|
)
|
|
69
|
-
* D2R
|
|
70
|
-
)
|
|
71
84
|
S = spden * D_fd
|
|
72
85
|
return S
|
|
73
86
|
|
|
74
87
|
|
|
75
|
-
def read_ndbc_ascii(filename, dirs=np.arange(0, 360, 10)):
|
|
88
|
+
def read_ndbc_ascii(filename, dirs=np.arange(0, 360, 10), weight_coeff: bool = False):
|
|
76
89
|
"""Read spectra from NDBC wave buoy ASCII files.
|
|
77
90
|
|
|
78
91
|
Both the history and realtime formats are supported. Realtime formats are decribed
|
|
@@ -87,6 +100,8 @@ def read_ndbc_ascii(filename, dirs=np.arange(0, 360, 10)):
|
|
|
87
100
|
automatically detected.
|
|
88
101
|
- dirs (array): vector of directional bins for spectral reconstruction.
|
|
89
102
|
- attrs (dict): additional global attributes.
|
|
103
|
+
- weight_coef (bool): Weight the coefficient to avoid negative value
|
|
104
|
+
in spectrum.
|
|
90
105
|
|
|
91
106
|
Returns:
|
|
92
107
|
- dset (SpecDataset): spectra dataset object read from NDBC buoy file(s).
|
|
@@ -133,6 +148,7 @@ def read_ndbc_ascii(filename, dirs=np.arange(0, 360, 10)):
|
|
|
133
148
|
df_swr1.values.reshape(spshape),
|
|
134
149
|
df_swr2.values.reshape(spshape),
|
|
135
150
|
dirs,
|
|
151
|
+
weight_coeff=weight_coeff,
|
|
136
152
|
)
|
|
137
153
|
coords = OrderedDict(
|
|
138
154
|
((attrs.TIMENAME, times), (attrs.FREQNAME, freqs), (attrs.DIRNAME, dirs))
|
|
@@ -148,9 +164,9 @@ def read_ndbc_ascii(filename, dirs=np.arange(0, 360, 10)):
|
|
|
148
164
|
dims=(attrs.TIMENAME),
|
|
149
165
|
name=attrs.SPECNAME,
|
|
150
166
|
)
|
|
151
|
-
dset[
|
|
152
|
-
|
|
153
|
-
|
|
167
|
+
dset["Sep_Freq"] = (
|
|
168
|
+
sfreq # Add the NDBC defined separation frequency for realtime diagnostics
|
|
169
|
+
)
|
|
154
170
|
dset = dset.sortby(
|
|
155
171
|
"time", ascending=True
|
|
156
172
|
) # Realtime data is in reversed time order
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""SWAN ASCII output plugin."""
|
|
2
|
+
|
|
2
3
|
import numpy as np
|
|
3
4
|
from wavespectra.core.attributes import attrs
|
|
4
5
|
from wavespectra.core.swan import SwanSpecFile
|
|
@@ -56,7 +57,9 @@ def to_swan(
|
|
|
56
57
|
# Ensure time dimension exists
|
|
57
58
|
is_time = attrs.TIMENAME in dset[attrs.SPECNAME].dims
|
|
58
59
|
if not is_time:
|
|
59
|
-
dset[attrs.SPECNAME] = dset[attrs.SPECNAME].expand_dims(
|
|
60
|
+
dset[attrs.SPECNAME] = dset[attrs.SPECNAME].expand_dims(
|
|
61
|
+
{attrs.TIMENAME: [None]}
|
|
62
|
+
)
|
|
60
63
|
times = dset[attrs.TIMENAME].values
|
|
61
64
|
else:
|
|
62
65
|
times = dset[attrs.TIMENAME].to_index().to_pydatetime()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wavespectra
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.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>
|
|
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
|