wavyopen 0.1.4__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.
- wavyopen-0.1.4/LICENSE +21 -0
- wavyopen-0.1.4/PKG-INFO +34 -0
- wavyopen-0.1.4/pyproject.toml +67 -0
- wavyopen-0.1.4/wavy/GPfcts.py +119 -0
- wavyopen-0.1.4/wavy/__init__.py +0 -0
- wavyopen-0.1.4/wavy/collocmod.py +991 -0
- wavyopen-0.1.4/wavy/config/collocation_specs.yaml.default +18 -0
- wavyopen-0.1.4/wavy/config/d22_var_dicts.yaml.default +58 -0
- wavyopen-0.1.4/wavy/config/insitu_specs.yaml.default +1351 -0
- wavyopen-0.1.4/wavy/config/model_specs.yaml.default +159 -0
- wavyopen-0.1.4/wavy/config/quicklook_specs.yaml.default +31 -0
- wavyopen-0.1.4/wavy/config/region_specs.yaml.default +52 -0
- wavyopen-0.1.4/wavy/config/satellite_specs.yaml.default +197 -0
- wavyopen-0.1.4/wavy/config/validation_metrics.yaml.default +36 -0
- wavyopen-0.1.4/wavy/config/validation_specs.yaml.default +14 -0
- wavyopen-0.1.4/wavy/config/variable_info.yaml.default +145 -0
- wavyopen-0.1.4/wavy/config/variables_frost.yaml.default +38 -0
- wavyopen-0.1.4/wavy/consolidate.py +226 -0
- wavyopen-0.1.4/wavy/credentials.py +58 -0
- wavyopen-0.1.4/wavy/filtermod.py +928 -0
- wavyopen-0.1.4/wavy/grid_stats.py +305 -0
- wavyopen-0.1.4/wavy/gridder.py +233 -0
- wavyopen-0.1.4/wavy/insitu_readers.py +539 -0
- wavyopen-0.1.4/wavy/insitumod.py +269 -0
- wavyopen-0.1.4/wavy/modelmod.py +614 -0
- wavyopen-0.1.4/wavy/multiins.py +90 -0
- wavyopen-0.1.4/wavy/multisat.py +102 -0
- wavyopen-0.1.4/wavy/ncmod.py +1105 -0
- wavyopen-0.1.4/wavy/quicklookmod.py +985 -0
- wavyopen-0.1.4/wavy/sat_collectors.py +440 -0
- wavyopen-0.1.4/wavy/sat_readers.py +342 -0
- wavyopen-0.1.4/wavy/satmod.py +715 -0
- wavyopen-0.1.4/wavy/utils.py +643 -0
- wavyopen-0.1.4/wavy/validationmod.py +239 -0
- wavyopen-0.1.4/wavy/wconfig.py +63 -0
- wavyopen-0.1.4/wavy/writermod.py +59 -0
wavyopen-0.1.4/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 bohlinger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
wavyopen-0.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wavyopen
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: A package for processing wave measurements and wave model output.
|
|
5
|
+
Author: Patrik Bohlinger
|
|
6
|
+
Author-email: patrikb@met.no
|
|
7
|
+
Requires-Python: >=3.7.1,<3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Requires-Dist: Cartopy (>=0.20)
|
|
14
|
+
Requires-Dist: PyYAML (>=5.4.1,<6.0.0)
|
|
15
|
+
Requires-Dist: cmocean (>=2.0,<3.0)
|
|
16
|
+
Requires-Dist: dask (>=2022.01.0,<2023.0.0)
|
|
17
|
+
Requires-Dist: geojson (>=2.5.0,<3.0.0)
|
|
18
|
+
Requires-Dist: joblib (>=1.0.1,<2.0.0)
|
|
19
|
+
Requires-Dist: matplotlib (>=3.4.3,<4.0.0)
|
|
20
|
+
Requires-Dist: netCDF4 (>=1.5.7,<2.0.0)
|
|
21
|
+
Requires-Dist: numpy (>=1.21.2,<2.0.0)
|
|
22
|
+
Requires-Dist: pandas (>=1.3.3,<2.0.0)
|
|
23
|
+
Requires-Dist: pygam (>=0.8.0,<0.9.0)
|
|
24
|
+
Requires-Dist: pyproj (>=3.1)
|
|
25
|
+
Requires-Dist: pyresample (>=1.21.0,<2.0.0)
|
|
26
|
+
Requires-Dist: python-dotenv (>=0.19.0,<0.20.0)
|
|
27
|
+
Requires-Dist: roaring-landmask (>=0.5)
|
|
28
|
+
Requires-Dist: scikit-learn (>=0.24.2,<0.25.0)
|
|
29
|
+
Requires-Dist: scipy (>=1.7.1,<2.0.0)
|
|
30
|
+
Requires-Dist: sentinelsat (>=1.1.0,<2.0.0)
|
|
31
|
+
Requires-Dist: tqdm (>=4.62.2,<5.0.0)
|
|
32
|
+
Requires-Dist: xarray (>=0.19.0,<0.20.0)
|
|
33
|
+
Requires-Dist: xdg (>=5.1.1,<6.0.0)
|
|
34
|
+
Requires-Dist: zarr (>=2.9.5,<3.0.0)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "wavyopen"
|
|
3
|
+
version = "0.1.4"
|
|
4
|
+
description = "A package for processing wave measurements and wave model output."
|
|
5
|
+
authors = ["Patrik Bohlinger <patrikb@met.no>"]
|
|
6
|
+
packages = [
|
|
7
|
+
{include = "wavy"}
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
[tool.poetry.scripts]
|
|
11
|
+
wavyQuick = "apps.standalone.wavyQuick:main"
|
|
12
|
+
wavyDownload = "apps.standalone.download:main"
|
|
13
|
+
|
|
14
|
+
[tool.poetry.dependencies]
|
|
15
|
+
python = ">=3.7.1,<3.12"
|
|
16
|
+
matplotlib = "^3.4.3"
|
|
17
|
+
numpy = "^1.21.2"
|
|
18
|
+
scipy = "^1.7.1"
|
|
19
|
+
netCDF4 = "^1.5.7"
|
|
20
|
+
PyYAML = "^5.4.1"
|
|
21
|
+
pyproj = ">=3.1"
|
|
22
|
+
Cartopy = ">=0.20"
|
|
23
|
+
cmocean = "^2.0"
|
|
24
|
+
joblib = "^1.0.1"
|
|
25
|
+
scikit-learn = "^0.24.2"
|
|
26
|
+
pandas = "^1.3.3"
|
|
27
|
+
pygam = "^0.8.0"
|
|
28
|
+
xarray = "^0.19.0"
|
|
29
|
+
zarr = "^2.9.5"
|
|
30
|
+
pyresample = "^1.21.0"
|
|
31
|
+
dask = "^2022.01.0"
|
|
32
|
+
tqdm = "^4.62.2"
|
|
33
|
+
python-dotenv = "^0.19.0"
|
|
34
|
+
sentinelsat = "^1.1.0"
|
|
35
|
+
xdg = "^5.1.1"
|
|
36
|
+
roaring-landmask = ">=0.5"
|
|
37
|
+
geojson = "^2.5.0"
|
|
38
|
+
|
|
39
|
+
[tool.poetry.dev-dependencies]
|
|
40
|
+
pytest = "^6.2.5"
|
|
41
|
+
pytest-benchmark = "^3.4.1"
|
|
42
|
+
pylint = "^2.10.2"
|
|
43
|
+
yapf = "^0.31.0"
|
|
44
|
+
Sphinx = "^4.2.0"
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["poetry-core>=1.0.0"]
|
|
48
|
+
build-backend = "poetry.core.masonry.api"
|
|
49
|
+
|
|
50
|
+
[tool.pytest.ini_options]
|
|
51
|
+
minversion = "6.0"
|
|
52
|
+
addopts = "--benchmark-disable"
|
|
53
|
+
testpaths = [
|
|
54
|
+
"tests",
|
|
55
|
+
]
|
|
56
|
+
markers = [
|
|
57
|
+
"need_credentials:need credentials to run"
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
[tool.pylint.master]
|
|
62
|
+
extension-pkg-whitelist="netCDF4,numpy,scipy,roaring_landmask"
|
|
63
|
+
|
|
64
|
+
[tool.pylint.messages_control]
|
|
65
|
+
disable = "all"
|
|
66
|
+
enable = "F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701"
|
|
67
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from numpy.linalg import inv
|
|
3
|
+
from numpy.linalg import cholesky, det, lstsq
|
|
4
|
+
import scipy as sp
|
|
5
|
+
|
|
6
|
+
def kernel(X1, X2, l=1.0, sigma_f=1.0):
|
|
7
|
+
'''
|
|
8
|
+
Isotropic squared exponential kernel. Computes
|
|
9
|
+
a covariance matrix from points in X1 and X2.
|
|
10
|
+
Args:
|
|
11
|
+
X1: Array of m points (m x d).
|
|
12
|
+
X2: Array of n points (n x d).
|
|
13
|
+
Returns:
|
|
14
|
+
Covariance matrix (m x n).
|
|
15
|
+
'''
|
|
16
|
+
sqdist = np.sum(X1**2, 1).reshape(-1, 1) \
|
|
17
|
+
+ np.sum(X2**2, 1) - 2 * np.dot(X1, X2.T)
|
|
18
|
+
M = sigma_f**2 * np.exp(-0.5 / l**2 * sqdist)
|
|
19
|
+
return M
|
|
20
|
+
|
|
21
|
+
def posterior_predictive_nigp(X_s, X_train, Y_train,
|
|
22
|
+
l=None,sigma_f=None, sigma_y=None, sigma_x=None,
|
|
23
|
+
Grad_fmean=None):
|
|
24
|
+
'''
|
|
25
|
+
Computes statistics of the GP posterior predictive distribution
|
|
26
|
+
from m training data X_train and Y_train and n new inputs X_s.
|
|
27
|
+
Args:
|
|
28
|
+
X_s: New input locations (n x d)
|
|
29
|
+
X_train: Training locations (m x d)
|
|
30
|
+
Y_train: Training targets (m x 1)
|
|
31
|
+
l: length scale parameter
|
|
32
|
+
sigma_f: signal variance parameter
|
|
33
|
+
sigma_y: noise paramter on y
|
|
34
|
+
sigma_x: noise parameter on x
|
|
35
|
+
Returns:
|
|
36
|
+
Posterior mean vector (n x d) and covariance matrix (n x n)
|
|
37
|
+
'''
|
|
38
|
+
# Gradient at training points
|
|
39
|
+
Grad_fmean_train = np.interp(
|
|
40
|
+
X_train.ravel(), X_s.ravel(), Grad_fmean.ravel())
|
|
41
|
+
Grad_fmean_train = Grad_fmean_train.reshape(-1,1)
|
|
42
|
+
Grad_fmean_input = Grad_fmean.copy()
|
|
43
|
+
Grad_fmean_input = Grad_fmean_input.reshape(-1,1)
|
|
44
|
+
# constituents of equations for mean and covariance
|
|
45
|
+
K = kernel(X_train, X_train, l, sigma_f) + \
|
|
46
|
+
sigma_y**2 * np.eye(len(X_train)) + \
|
|
47
|
+
np.diag(np.diag(np.dot(Grad_fmean_train,
|
|
48
|
+
np.atleast_2d(Grad_fmean_train.ravel())))) * sigma_x**2
|
|
49
|
+
K_s = kernel(X_train, X_s, l, sigma_f)
|
|
50
|
+
K_ss = kernel(X_s, X_s, l, sigma_f) + \
|
|
51
|
+
sigma_y**2 * np.eye(len(X_s)) + \
|
|
52
|
+
np.diag(np.diag(np.dot(Grad_fmean_input,
|
|
53
|
+
np.atleast_2d(Grad_fmean_input.ravel())))) * sigma_x**2
|
|
54
|
+
### possible solutions:
|
|
55
|
+
## 1. classical
|
|
56
|
+
K_inv = inv(K)
|
|
57
|
+
# Equation (4)
|
|
58
|
+
mu_s = K_s.T.dot(K_inv).dot(Y_train)
|
|
59
|
+
# Equation (5)
|
|
60
|
+
cov_s = K_ss - K_s.T.dot(K_inv).dot(K_s)
|
|
61
|
+
# ## 2. use of cholesky decomposition
|
|
62
|
+
# L = sp.linalg.cholesky(K, lower=True)
|
|
63
|
+
# a1 = np.linalg.lstsq(L, Y_train, rcond=None)[0]
|
|
64
|
+
# alpha = np.linalg.lstsq(L.T, a1, rcond=None)[0]
|
|
65
|
+
# # Equation (4) of Krasser
|
|
66
|
+
# mu_s = K_s.T.dot(alpha)
|
|
67
|
+
# # Equation (5) of Krasser
|
|
68
|
+
# v = np.linalg.lstsq(L, K_s, rcond=None)[0]
|
|
69
|
+
# cov_s = K_ss - v.T.dot(v)
|
|
70
|
+
return mu_s, cov_s
|
|
71
|
+
|
|
72
|
+
def nll_fn_nigp(X_train,Y_train,Grad_fmean,naive=False):
|
|
73
|
+
'''
|
|
74
|
+
Returns a function that computes the negative log marginal
|
|
75
|
+
likelihood for training data X_train and Y_train and given
|
|
76
|
+
noise level.
|
|
77
|
+
Args:
|
|
78
|
+
X_train: training locations (m x d).
|
|
79
|
+
Y_train: training targets (m x 1).
|
|
80
|
+
noise: known noise level of Y_train.
|
|
81
|
+
naive: if True use a naive implementation of Eq. (7), if
|
|
82
|
+
False use a numerically more stable implementation.
|
|
83
|
+
Returns:
|
|
84
|
+
Minimization objective.
|
|
85
|
+
'''
|
|
86
|
+
def nll_naive(theta):
|
|
87
|
+
# Naive implementation of Eq. (7). Works well for the examples
|
|
88
|
+
# in this article but is numerically less stable compared to
|
|
89
|
+
# the implementation in nll_stable below.
|
|
90
|
+
K = kernel(X_train, X_train, l=theta[0], sigma_f=theta[1]) + \
|
|
91
|
+
theta[2]**2 * np.eye(len(X_train)) + \
|
|
92
|
+
np.diag(np.diag(np.dot(Grad_fmean,
|
|
93
|
+
np.atleast_2d(Grad_fmean.ravel())))) * theta[3]**2
|
|
94
|
+
F = 0.5 * np.log(det(K)) + \
|
|
95
|
+
0.5 * Y_train.T.dot(inv(K).dot(Y_train)) + \
|
|
96
|
+
0.5 * len(X_train) * np.log(2*np.pi)
|
|
97
|
+
return F.ravel()
|
|
98
|
+
def nll_stable(theta):
|
|
99
|
+
# Numerically more stable implementation of Eq. (7) as described
|
|
100
|
+
# in http://www.gaussianprocess.org/gpml/chapters/RW2.pdf, Section
|
|
101
|
+
# 2.2, Algorithm 2.1.
|
|
102
|
+
K = kernel(X_train, X_train, l=theta[0], sigma_f=theta[1]) + \
|
|
103
|
+
theta[2]**2 * np.eye(len(X_train)) + \
|
|
104
|
+
np.diag(np.diag(np.dot(Grad_fmean,
|
|
105
|
+
np.atleast_2d(Grad_fmean.ravel())))) * theta[3]**2
|
|
106
|
+
#L = cholesky(K)
|
|
107
|
+
L = sp.linalg.cholesky(K,lower=True)
|
|
108
|
+
F = np.sum(np.log(np.diagonal(L))) + \
|
|
109
|
+
0.5 * Y_train.T.dot(lstsq(
|
|
110
|
+
L.T, lstsq(
|
|
111
|
+
L, Y_train,rcond=None
|
|
112
|
+
)[0],rcond=None)[0]
|
|
113
|
+
) + \
|
|
114
|
+
0.5 * len(X_train) * np.log(2*np.pi)
|
|
115
|
+
return F.ravel()
|
|
116
|
+
if naive:
|
|
117
|
+
return nll_naive
|
|
118
|
+
else:
|
|
119
|
+
return nll_stable
|
|
File without changes
|