geo-parameters 0.1.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.
- geo_parameters-0.1.0/.gitignore +160 -0
- geo_parameters-0.1.0/LICENSE +21 -0
- geo_parameters-0.1.0/PKG-INFO +8 -0
- geo_parameters-0.1.0/README.md +134 -0
- geo_parameters-0.1.0/environment.yml +6 -0
- geo_parameters-0.1.0/geo_parameters/__init__.py +5 -0
- geo_parameters-0.1.0/geo_parameters/metaparameter.py +100 -0
- geo_parameters-0.1.0/geo_parameters/ocean.py +56 -0
- geo_parameters-0.1.0/geo_parameters/parameter_funcs.py +40 -0
- geo_parameters-0.1.0/geo_parameters/wave.py +384 -0
- geo_parameters-0.1.0/geo_parameters/wind.py +66 -0
- geo_parameters-0.1.0/pyproject.toml +15 -0
- geo_parameters-0.1.0/tests/test_doc.py +66 -0
- geo_parameters-0.1.0/tests/test_funcs.py +36 -0
- geo_parameters-0.1.0/tests/test_names.py +27 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jan-Victor Björkqvist
|
|
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.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: geo-parameters
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Metadata of geophysical (especially wave) parameters
|
|
5
|
+
Author-email: Jan-Victor Björkqvist <janvb@met.no>
|
|
6
|
+
Requires-Dist: numpy
|
|
7
|
+
Requires-Dist: pint
|
|
8
|
+
Project-URL: repository, http://github.com/bjorkqvi/geo-parameters
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# geo-parameters
|
|
2
|
+
Metadata of geophysical (especially wave) parameters. The main idea is to be able to use standard CF-names without having to remember or check the names.
|
|
3
|
+
|
|
4
|
+
## Names of parameters
|
|
5
|
+
|
|
6
|
+
The parameters are classes in sub-modules according to the physical property (wave, ocean, wind)
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
from geo_parameters.wave import Hs, Tp
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
These classes have information about the parameter:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
Hs.standard_name()
|
|
16
|
+
'sea_surface_wave_significant_height'
|
|
17
|
+
```
|
|
18
|
+
Every parameters has a pre-defined short_name
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
Hs.short_name()
|
|
22
|
+
'hs'
|
|
23
|
+
```
|
|
24
|
+
If you want to define some other names for the parameters, then you can create an instance. By default the name of the instance is the short name, but this can be changed:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
hsig = Hs()
|
|
28
|
+
hsig.name()
|
|
29
|
+
'hs'
|
|
30
|
+
|
|
31
|
+
hsig = Hs(name='hsig')
|
|
32
|
+
hsig.name()
|
|
33
|
+
'hsig'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The instance still contains the standard name (and some long name that doesn't follow any standard):
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
hsig.standard_name()
|
|
40
|
+
'sea_surface_wave_significant_height'
|
|
41
|
+
|
|
42
|
+
hsig.long_name()
|
|
43
|
+
'significant_wave_height'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If the parameter has several standard names, you can use the alias-keyword
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
hsig.standard_name(alias=True)
|
|
50
|
+
'significant_height_of_wind_and_swell_waves'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If the parameter has only one standard name, alias does nothing:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
Tp.standard_name()
|
|
57
|
+
'sea_surface_wave_period_at_variance_spectral_density_maximum'
|
|
58
|
+
|
|
59
|
+
Tp.standard_name(alias=True)
|
|
60
|
+
'sea_surface_wave_period_at_variance_spectral_density_maximum'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Finding parameters
|
|
64
|
+
|
|
65
|
+
The right class can be found from a name using the get function:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from geo_parameters import get as gpget
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The parameter can then be fetched using the standard name, the alias or the short name:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
gpget("sea_surface_wave_significant_height")
|
|
75
|
+
<class 'geo_parameters.geo_parameters.wave.Hs'>
|
|
76
|
+
|
|
77
|
+
gpget("significant_height_of_wind_and_swell_waves")
|
|
78
|
+
<class 'geo_parameters.geo_parameters.wave.Hs'>
|
|
79
|
+
|
|
80
|
+
gpget("hs")
|
|
81
|
+
<class 'geo_parameters.geo_parameters.wave.Hs'>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A dict of all available parameters can also be compiled:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from geo_parameters import dict_of_parameters
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
dop = dict_of_parameters()
|
|
92
|
+
dop = dict_of_parameters(alias=True)
|
|
93
|
+
dop = dict_of_parameters(short=True)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
where the keywords define what string will serve as key in the dictonary (the value is always the parameter class).
|
|
97
|
+
|
|
98
|
+
If an xarray Dataset has standard_name attributes, the correct key can be found using the class-method:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
ds
|
|
102
|
+
<xarray.Dataset> Size: 1kB
|
|
103
|
+
Dimensions: (lat: 11, lont: 6, lon: 6)
|
|
104
|
+
Coordinates:
|
|
105
|
+
* lon (lon) float64 48B 5.0 6.0 7.0 8.0 9.0 10.0
|
|
106
|
+
* lat (lat) float64 88B 50.0 51.0 52.0 ... 58.0 59.0 60.0
|
|
107
|
+
Dimensions without coordinates: lont
|
|
108
|
+
Data variables:
|
|
109
|
+
interesting_hs_name (lat, lon) float64 528B 0.0 0.0 0.0 ... 0.0 0.0 0.0
|
|
110
|
+
peak_period (lat, lon) float64 528B 1.0 1.0 1.0 1.0 ... 1.0 1.0 1.0
|
|
111
|
+
```
|
|
112
|
+
```python
|
|
113
|
+
ds.interesting_hs_name
|
|
114
|
+
<xarray.DataArray 'interesting_hs_name' (lat: 11, lon: 6)> Size: 528B
|
|
115
|
+
array([[0., 0., 0., 0., 0., 0.],
|
|
116
|
+
[0., 0., 0., 0., 0., 0.],
|
|
117
|
+
...
|
|
118
|
+
[0., 0., 0., 0., 0., 0.],
|
|
119
|
+
[0., 0., 0., 0., 0., 0.]])
|
|
120
|
+
Coordinates:
|
|
121
|
+
* lon (lon) float64 48B 5.0 6.0 7.0 8.0 9.0 10.0
|
|
122
|
+
* lat (lat) float64 88B 50.0 51.0 52.0 53.0 54.0 ... 57.0 58.0 59.0 60.0
|
|
123
|
+
Attributes:
|
|
124
|
+
standard_name: sea_surface_wave_significant_height
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
Hs.find_me_in_ds(ds)
|
|
129
|
+
'interesting_hs_name'
|
|
130
|
+
|
|
131
|
+
Tp.find_me_in_ds(ds)
|
|
132
|
+
'peak_period'
|
|
133
|
+
```
|
|
134
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from abc import ABC, abstractstaticmethod
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from pint import Unit
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MetaParameter(ABC):
|
|
8
|
+
_cf = True
|
|
9
|
+
|
|
10
|
+
def __init__(self, name: str = ""):
|
|
11
|
+
self._name = name or self.short_name()
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
@abstractstaticmethod
|
|
15
|
+
def _short_name() -> str:
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
@abstractstaticmethod
|
|
20
|
+
def _long_name() -> str:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
@abstractstaticmethod
|
|
25
|
+
def _standard_name() -> str:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
@abstractstaticmethod
|
|
30
|
+
def _unit() -> str:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def cf(cls) -> bool:
|
|
35
|
+
return cls._cf
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def short_name(cls) -> str:
|
|
39
|
+
return cls._short_name
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def long_name(cls) -> str:
|
|
43
|
+
return cls._long_name
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def standard_name(cls, strict: bool = False, alias: bool = False) -> str:
|
|
47
|
+
names = np.atleast_1d(cls._standard_name)
|
|
48
|
+
if cls.cf() or not strict:
|
|
49
|
+
if alias:
|
|
50
|
+
return names[-1]
|
|
51
|
+
return names[0]
|
|
52
|
+
|
|
53
|
+
return ""
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def standard_aliases(cls, strict=False) -> list[str]:
|
|
57
|
+
if cls.cf() or not strict:
|
|
58
|
+
return cls._standard_name
|
|
59
|
+
|
|
60
|
+
return [""]
|
|
61
|
+
|
|
62
|
+
@classmethod
|
|
63
|
+
def unit(cls) -> Unit:
|
|
64
|
+
return cls._unit
|
|
65
|
+
|
|
66
|
+
def quantify(self):
|
|
67
|
+
return self * self.unit()
|
|
68
|
+
|
|
69
|
+
def set_name(self, name: str = None) -> None:
|
|
70
|
+
if name is None:
|
|
71
|
+
self._name = self.short_name()
|
|
72
|
+
self._name = name
|
|
73
|
+
|
|
74
|
+
def name(self) -> str:
|
|
75
|
+
return self._name or self.short_name()
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def cf(cls) -> str:
|
|
79
|
+
return cls._cf
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def meta_dict(cls, alias: bool = False) -> dict:
|
|
83
|
+
return {
|
|
84
|
+
"short_name": cls.short_name(),
|
|
85
|
+
"long_name": cls.long_name(),
|
|
86
|
+
"standard_name": cls.standard_name(alias=alias),
|
|
87
|
+
"unit": str(cls.unit()),
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def find_me_in_ds(cls, ds) -> str | None:
|
|
92
|
+
"""Takes an Xarray Dataset and returns name of variable that matches the parameter based on standard_name"""
|
|
93
|
+
data_vars = list(ds.data_vars)
|
|
94
|
+
|
|
95
|
+
for var in data_vars:
|
|
96
|
+
if hasattr(ds.get(var), "standard_name"):
|
|
97
|
+
if ds.get(var).standard_name in cls.standard_aliases():
|
|
98
|
+
return var
|
|
99
|
+
|
|
100
|
+
return None
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from .metaparameter import MetaParameter
|
|
2
|
+
import pint
|
|
3
|
+
|
|
4
|
+
ureg = pint.UnitRegistry()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class WaterDepth(MetaParameter):
|
|
8
|
+
_short_name = "depth"
|
|
9
|
+
_long_name = "water_depth"
|
|
10
|
+
_standard_name = "sea_floor_depth_below_sea_surface"
|
|
11
|
+
_unit = ureg.m
|
|
12
|
+
|
|
13
|
+
class SeaLevel(MetaParameter):
|
|
14
|
+
_short_name = "eta"
|
|
15
|
+
_long_name = "sea_surface_height"
|
|
16
|
+
_standard_name = [
|
|
17
|
+
"sea_surface_elevation",
|
|
18
|
+
"sea_surface_elevation_anomaly",
|
|
19
|
+
"sea_surface_height_above_geoid",
|
|
20
|
+
]
|
|
21
|
+
_unit = ureg.m
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class XCurrent(MetaParameter):
|
|
25
|
+
_short_name = "x_current"
|
|
26
|
+
_long_name = "eastward_current_component"
|
|
27
|
+
_standard_name = [
|
|
28
|
+
"sea_water_x_velocity",
|
|
29
|
+
"x_sea_water_velocity",
|
|
30
|
+
]
|
|
31
|
+
_unit = ureg.m / ureg.s
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class YCurrent(MetaParameter):
|
|
35
|
+
_short_name = "y_current"
|
|
36
|
+
_long_name = "northward_current_component"
|
|
37
|
+
_standard_name = [
|
|
38
|
+
"sea_water_y_velocity",
|
|
39
|
+
"y_sea_water_velocity",
|
|
40
|
+
]
|
|
41
|
+
_unit = ureg.m / ureg.s
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class IceFraction(MetaParameter):
|
|
45
|
+
_short_name = "ice_fraction"
|
|
46
|
+
_long_name = "sea_ice_fraction"
|
|
47
|
+
_standard_name = "sea_ice_area_fraction"
|
|
48
|
+
_unit = ureg.percent
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class IceThickness(MetaParameter):
|
|
52
|
+
_short_name = "ice_thickness"
|
|
53
|
+
_long_name = "sea_ice_thickness"
|
|
54
|
+
_standard_name = "sea_ice_thickness"
|
|
55
|
+
_unit = ureg.m
|
|
56
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from . import wave, ocean, wind
|
|
2
|
+
import inspect
|
|
3
|
+
from .metaparameter import MetaParameter
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def list_of_parameters() -> list:
|
|
7
|
+
parameter_list = []
|
|
8
|
+
modules_to_inspect = [wave, ocean, wind]
|
|
9
|
+
for module in modules_to_inspect:
|
|
10
|
+
for __, obj in inspect.getmembers(module):
|
|
11
|
+
if inspect.isclass(obj):
|
|
12
|
+
if issubclass(obj, MetaParameter) and not obj == MetaParameter:
|
|
13
|
+
parameter_list.append(obj)
|
|
14
|
+
return parameter_list
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def dict_of_parameters(short: bool = False, alias: bool = False) -> dict:
|
|
18
|
+
if short:
|
|
19
|
+
return {c.short_name(): c for c in list_of_parameters()}
|
|
20
|
+
return {c.standard_name(alias=alias): c for c in list_of_parameters()}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get(key: str):
|
|
24
|
+
return (
|
|
25
|
+
dict_of_parameters().get(key)
|
|
26
|
+
or dict_of_parameters(alias=True).get(key)
|
|
27
|
+
or dict_of_parameters(short=True).get(key)
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def create_parameter_dict(parameter_strings: list[str]):
|
|
32
|
+
metaparameter_dict = {}
|
|
33
|
+
for param in parameter_strings:
|
|
34
|
+
val = get(param)
|
|
35
|
+
if val is not None:
|
|
36
|
+
metaparameter_dict[param] = val
|
|
37
|
+
return metaparameter_dict
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
from .metaparameter import MetaParameter
|
|
2
|
+
import pint
|
|
3
|
+
|
|
4
|
+
ureg = pint.UnitRegistry()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Wave heights
|
|
8
|
+
class Hs(MetaParameter):
|
|
9
|
+
_short_name = "hs"
|
|
10
|
+
_long_name = "significant_wave_height"
|
|
11
|
+
_standard_name = [
|
|
12
|
+
"sea_surface_wave_significant_height",
|
|
13
|
+
"significant_height_of_wind_and_swell_waves",
|
|
14
|
+
]
|
|
15
|
+
_unit = ureg.m
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class HsSwell(MetaParameter):
|
|
19
|
+
_short_name = "hs_swell"
|
|
20
|
+
_long_name = "significant_swell_height"
|
|
21
|
+
_standard_name = [
|
|
22
|
+
"sea_surface_swell_wave_significant_height",
|
|
23
|
+
"significant_height_of_swell_waves",
|
|
24
|
+
]
|
|
25
|
+
_unit = ureg.m
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class HsSwell1(MetaParameter):
|
|
29
|
+
_short_name = "hs_swell1"
|
|
30
|
+
_long_name = "significant_primary_swell_height"
|
|
31
|
+
_standard_name = "sea_surface_primary_swell_wave_significant_height"
|
|
32
|
+
_unit = ureg.m
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class HsSwell2(MetaParameter):
|
|
36
|
+
_short_name = "hs_swell12"
|
|
37
|
+
_long_name = "significant_secondary_swell_height"
|
|
38
|
+
_standard_name = "sea_surface_secondary_swell_wave_significant_height"
|
|
39
|
+
_unit = ureg.m
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class HsSwell3(MetaParameter):
|
|
43
|
+
_short_name = "hs_swell13"
|
|
44
|
+
_long_name = "significant_tertiary_swell_height"
|
|
45
|
+
_standard_name = "sea_surface_tertiary_swell_wave_significant_height"
|
|
46
|
+
_unit = ureg.m
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class HsSea(MetaParameter):
|
|
50
|
+
_short_name = "hs_sea"
|
|
51
|
+
_long_name = "significant_wind_sea_height"
|
|
52
|
+
_standard_name = [
|
|
53
|
+
"sea_surface_wind_wave_significant_height",
|
|
54
|
+
"significant_height_of_wind_waves",
|
|
55
|
+
]
|
|
56
|
+
_unit = ureg.m
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class HsIG(MetaParameter):
|
|
60
|
+
_short_name = "hs_ig"
|
|
61
|
+
_long_name = "significant_infragravity_wave_height"
|
|
62
|
+
_standard_name = "sea_surface_infragravity_wave_significant_height"
|
|
63
|
+
_unit = ureg.m
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class HsMax(MetaParameter):
|
|
67
|
+
_short_name = "hs_max"
|
|
68
|
+
_long_name = "maximum_wave_heigh"
|
|
69
|
+
_standard_name = "sea_surface_wave_maximum_height"
|
|
70
|
+
_unit = ureg.m
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class EtaMax(MetaParameter):
|
|
74
|
+
_short_name = "eta_max"
|
|
75
|
+
_long_name = "maximum_crest_heigh"
|
|
76
|
+
_standard_name = "sea_surface_wave_maximum_crest_height"
|
|
77
|
+
_unit = ureg.m
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Hs110(MetaParameter):
|
|
81
|
+
_short_name = "hs_110"
|
|
82
|
+
_long_name = "highest_tenth_wave_heigh"
|
|
83
|
+
_standard_name = "sea_surface_wave_mean_height_of_highest_tenth"
|
|
84
|
+
_unit = ureg.m
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## Wave periods
|
|
88
|
+
class Tp(MetaParameter):
|
|
89
|
+
_short_name = "tp"
|
|
90
|
+
_long_name = "peak_wave_period"
|
|
91
|
+
_standard_name = "sea_surface_wave_period_at_variance_spectral_density_maximum"
|
|
92
|
+
_unit = ureg.s
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Tz(MetaParameter):
|
|
96
|
+
_short_name = "tz"
|
|
97
|
+
_long_name = "zero_upcrossing_period"
|
|
98
|
+
_standard_name = [
|
|
99
|
+
"sea_surface_wave_mean_period",
|
|
100
|
+
"sea_surface_wave_zero_upcrossing_period",
|
|
101
|
+
]
|
|
102
|
+
_unit = ureg.s
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class T13(MetaParameter):
|
|
106
|
+
_short_name = "t13"
|
|
107
|
+
_long_name = "significant_wave_period"
|
|
108
|
+
_standard_name = "sea_surface_wave_significant_period"
|
|
109
|
+
_unit = ureg.s
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class T110(MetaParameter):
|
|
113
|
+
_short_name = "t110"
|
|
114
|
+
_long_name = "highest_tenth_wave_period"
|
|
115
|
+
_standard_name = "sea_surface_wave_mean_period_of_highest_tenth"
|
|
116
|
+
_unit = ureg.s
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class Tm01(MetaParameter):
|
|
120
|
+
_short_name = "tm01"
|
|
121
|
+
_long_name = "first_moment_mean_wave_period"
|
|
122
|
+
_standard_name = "sea_surface_wave_mean_period_from_variance_spectral_density_first_frequency_moment"
|
|
123
|
+
_unit = ureg.s
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class Tm_10(MetaParameter):
|
|
127
|
+
_short_name = "tm_10"
|
|
128
|
+
_long_name = "inverse_moment_mean_wave_period"
|
|
129
|
+
_standard_name = "sea_surface_wave_mean_period_from_variance_spectral_density_inverse_frequency_moment"
|
|
130
|
+
_unit = ureg.s
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class Tm02(MetaParameter):
|
|
134
|
+
_short_name = "tm02"
|
|
135
|
+
_long_name = "second_moment_mean_wave_period"
|
|
136
|
+
_standard_name = "sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment"
|
|
137
|
+
_unit = ureg.s
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class TpSwell(MetaParameter):
|
|
141
|
+
_short_name = "tp_swell"
|
|
142
|
+
_long_name = "peak_wave_period_of_swell"
|
|
143
|
+
_standard_name = (
|
|
144
|
+
"sea_surface_swell_wave_period_at_variance_spectral_density_maximum"
|
|
145
|
+
)
|
|
146
|
+
_unit = ureg.s
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class Tm01Swell(MetaParameter):
|
|
150
|
+
_short_name = "tm01_swell"
|
|
151
|
+
_long_name = "first_moment_mean_wave_period_of_swell"
|
|
152
|
+
_standard_name = "sea_surface_swell_wave_mean_period_from_variance_spectral_density_first_frequency_moment"
|
|
153
|
+
_unit = ureg.s
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class Tm_10Swell(MetaParameter):
|
|
157
|
+
_short_name = "tm_10_swell"
|
|
158
|
+
_long_name = "inverse_moment_mean_wave_period_of_swell"
|
|
159
|
+
_standard_name = "sea_surface_swell_wave_mean_period_from_variance_spectral_density_inverse_frequency_moment"
|
|
160
|
+
_unit = ureg.s
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class Tm02Swell(MetaParameter):
|
|
164
|
+
_short_name = "tm02_swell"
|
|
165
|
+
_long_name = "second_moment_mean_wave_period_of_swell"
|
|
166
|
+
_standard_name = "sea_surface_swell_wave_mean_period_from_variance_spectral_density_second_frequency_moment"
|
|
167
|
+
_unit = ureg.s
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class TpSwell1(MetaParameter):
|
|
171
|
+
_short_name = "tp_swell1"
|
|
172
|
+
_long_name = "peak_wave_period_of_primary_swell"
|
|
173
|
+
_standard_name = (
|
|
174
|
+
"sea_surface_primary_swell_wave_period_at_variance_spectral_density_maximum"
|
|
175
|
+
)
|
|
176
|
+
_unit = ureg.s
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class TpSwell2(MetaParameter):
|
|
180
|
+
_short_name = "tp_swell2"
|
|
181
|
+
_long_name = "peak_wave_period_of_secondary_swell"
|
|
182
|
+
_standard_name = (
|
|
183
|
+
"sea_surface_secondary_swell_wave_period_at_variance_spectral_density_maximum"
|
|
184
|
+
)
|
|
185
|
+
_unit = ureg.s
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class TpSwell3(MetaParameter):
|
|
189
|
+
_short_name = "tp_swell3"
|
|
190
|
+
_long_name = "peak_wave_period_of_tertiary_swell"
|
|
191
|
+
_standard_name = (
|
|
192
|
+
"sea_surface_tertiary_swell_wave_period_at_variance_spectral_density_maximum"
|
|
193
|
+
)
|
|
194
|
+
_unit = ureg.s
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class Tm01Sea(MetaParameter):
|
|
198
|
+
_short_name = "tm01_sea"
|
|
199
|
+
_long_name = "first_moment_mean_wave_period_of_wind_sea"
|
|
200
|
+
_standard_name = "sea_surface_wind_wave_mean_period_from_variance_spectral_density_first_frequency_moment"
|
|
201
|
+
_unit = ureg.s
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class Tm_10Sea(MetaParameter):
|
|
205
|
+
_short_name = "tm_10_sea"
|
|
206
|
+
_long_name = "inverse_moment_mean_wave_period_of_wind_sea"
|
|
207
|
+
_standard_name = "sea_surface_wind_wave_mean_period_from_variance_spectral_density_inverse_frequency_moment"
|
|
208
|
+
_unit = ureg.s
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class Tm02Sea(MetaParameter):
|
|
212
|
+
_short_name = "tm02_sea"
|
|
213
|
+
_long_name = "second_moment_mean_wave_period_of_wind_swa"
|
|
214
|
+
_standard_name = "sea_surface_wind_wave_mean_period_from_variance_spectral_density_second_frequency_moment"
|
|
215
|
+
_unit = ureg.s
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
## Directions
|
|
219
|
+
class Dirm(MetaParameter):
|
|
220
|
+
_short_name = "dirm"
|
|
221
|
+
_long_name = "mean_wave_direction"
|
|
222
|
+
_standard_name = "sea_surface_wave_from_direction"
|
|
223
|
+
_unit = ureg.deg
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class Dirp(MetaParameter):
|
|
227
|
+
_short_name = "dirp"
|
|
228
|
+
_long_name = "peak_wave_direction"
|
|
229
|
+
_standard_name = (
|
|
230
|
+
"sea_surface_wave_from_direction_at_variance_spectral_density_maximum"
|
|
231
|
+
)
|
|
232
|
+
_unit = ureg.deg
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class DirmSwell(MetaParameter):
|
|
236
|
+
_short_name = "dirm_swell"
|
|
237
|
+
_long_name = "mean_swell_direction"
|
|
238
|
+
_standard_name = "sea_surface_swell_wave_from_direction"
|
|
239
|
+
_unit = ureg.deg
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class DirpSwell(MetaParameter):
|
|
243
|
+
_short_name = "dirp_swell"
|
|
244
|
+
_long_name = "peak_swell_direction"
|
|
245
|
+
_standard_name = (
|
|
246
|
+
"sea_surface_swell_wave_from_direction_at_variance_spectral_density_maximum"
|
|
247
|
+
)
|
|
248
|
+
_unit = ureg.deg
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class DirmSea(MetaParameter):
|
|
252
|
+
_short_name = "dirm_sea"
|
|
253
|
+
_long_name = "mean_wind_sea_direction"
|
|
254
|
+
_standard_name = "sea_surface_wind_wave_from_direction"
|
|
255
|
+
_unit = ureg.deg
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class DirpSea(MetaParameter):
|
|
259
|
+
_short_name = "dirp_sea"
|
|
260
|
+
_long_name = "peak_wind_sea_direction"
|
|
261
|
+
_standard_name = (
|
|
262
|
+
"sea_surface_wind_wave_from_direction_at_variance_spectral_density_maximum"
|
|
263
|
+
)
|
|
264
|
+
_unit = ureg.deg
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class Spr(MetaParameter):
|
|
268
|
+
_short_name = "spr"
|
|
269
|
+
_long_name = "wave_directional_spread"
|
|
270
|
+
_standard_name = "sea_surface_wave_directional_spread"
|
|
271
|
+
_unit = ureg.deg
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
class SprP(MetaParameter):
|
|
275
|
+
_short_name = "sprp"
|
|
276
|
+
_long_name = "peak_wave_directional_spread"
|
|
277
|
+
_standard_name = (
|
|
278
|
+
"sea_surface_wave_directional_spread_at_variance_spectral_density_maximum"
|
|
279
|
+
)
|
|
280
|
+
_unit = ureg.deg
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
class SprSwell(MetaParameter):
|
|
284
|
+
_short_name = "spr_swell"
|
|
285
|
+
_long_name = "swell_directional_spread"
|
|
286
|
+
_standard_name = "sea_surface_swell_wave_directional_spread"
|
|
287
|
+
_unit = ureg.deg
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class SprPSwell(MetaParameter):
|
|
291
|
+
_short_name = "sprp_swell"
|
|
292
|
+
_long_name = "peak_swell_directional_spread"
|
|
293
|
+
_standard_name = (
|
|
294
|
+
"sea_surface_swell_wave_from_direction_at_variance_spectral_density_maximum"
|
|
295
|
+
)
|
|
296
|
+
_unit = ureg.deg
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
class SprSea(MetaParameter):
|
|
300
|
+
_short_name = "spr_sea"
|
|
301
|
+
_long_name = "wind_sea_directional_spread"
|
|
302
|
+
_standard_name = "sea_surface_wind_wave_directional_spread"
|
|
303
|
+
_unit = ureg.deg
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class SprPSea(MetaParameter):
|
|
307
|
+
_short_name = "sprp_sea"
|
|
308
|
+
_long_name = "peak_wind_sea_directional_spread"
|
|
309
|
+
_standard_name = (
|
|
310
|
+
"sea_surface_wind_wave_from_direction_at_variance_spectral_density_maximum"
|
|
311
|
+
)
|
|
312
|
+
_unit = ureg.deg
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
## Spectral
|
|
316
|
+
class Ef(MetaParameter):
|
|
317
|
+
_short_name = "ef"
|
|
318
|
+
_long_name = "spectral_density"
|
|
319
|
+
_standard_name = "sea_surface_wave_variance_spectral_density"
|
|
320
|
+
_unit = ureg.m * ureg.m * ureg.s
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class Efth(MetaParameter):
|
|
324
|
+
_short_name = "efth"
|
|
325
|
+
_long_name = "directional_spectral_density"
|
|
326
|
+
_standard_name = "sea_surface_wave_directional_variance_spectral_density"
|
|
327
|
+
_unit = ureg.m * ureg.m * ureg.s / ureg.rad
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
## Moments (non-standard)
|
|
331
|
+
class M0(MetaParameter):
|
|
332
|
+
_short_name = "m0"
|
|
333
|
+
_long_name = "zeroth_wave_moment"
|
|
334
|
+
_standard_name = "sea_surface_zeroth_wave_moment"
|
|
335
|
+
_unit = ureg.m**2
|
|
336
|
+
_cf = False
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class M1(MetaParameter):
|
|
340
|
+
_short_name = "m1"
|
|
341
|
+
_long_name = "first_wave_moment"
|
|
342
|
+
_standard_name = "sea_surface_first_wave_moment"
|
|
343
|
+
_unit = ureg.m**2 / ureg.s
|
|
344
|
+
_cf = False
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
class M_1(MetaParameter):
|
|
348
|
+
_short_name = "m_1"
|
|
349
|
+
_long_name = "first_inverse_wave_moment"
|
|
350
|
+
_standard_name = "sea_surface_first_inverse_wave_moment"
|
|
351
|
+
_unit = ureg.m**2 * ureg.s
|
|
352
|
+
_cf = False
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
class M2(MetaParameter):
|
|
356
|
+
_short_name = "m2"
|
|
357
|
+
_long_name = "second_wave_moment"
|
|
358
|
+
_standard_name = "sea_surface_second_wave_moment"
|
|
359
|
+
_unit = ureg.m**2 / ureg.s**2
|
|
360
|
+
_cf = False
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class M3(MetaParameter):
|
|
364
|
+
_short_name = "m3"
|
|
365
|
+
_long_name = "thirds_wave_moment"
|
|
366
|
+
_standard_name = "sea_surface_thirds_wave_moment"
|
|
367
|
+
_unit = ureg.m**2 / ureg.s**3
|
|
368
|
+
_cf = False
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
class M4(MetaParameter):
|
|
372
|
+
_short_name = "m4"
|
|
373
|
+
_long_name = "fourth_wave_moment"
|
|
374
|
+
_standard_name = "sea_surface_fourth_wave_moment"
|
|
375
|
+
_unit = ureg.m**2 / ureg.s**4
|
|
376
|
+
_cf = False
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class M5(MetaParameter):
|
|
380
|
+
_short_name = "m5"
|
|
381
|
+
_long_name = "fifth_wave_moment"
|
|
382
|
+
_standard_name = "sea_surface_fifth_wave_moment"
|
|
383
|
+
_unit = ureg.m**2 / ureg.s**5
|
|
384
|
+
_cf = False
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from .metaparameter import MetaParameter
|
|
2
|
+
import pint
|
|
3
|
+
|
|
4
|
+
ureg = pint.UnitRegistry()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class XWind(MetaParameter):
|
|
8
|
+
_short_name = "x_wind"
|
|
9
|
+
_long_name = "x_wind_component"
|
|
10
|
+
_standard_name = [
|
|
11
|
+
"x_wind",
|
|
12
|
+
"grid_eastward_wind",
|
|
13
|
+
]
|
|
14
|
+
_unit = ureg.m / ureg.s
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class YWind(MetaParameter):
|
|
18
|
+
_short_name = "y_wind"
|
|
19
|
+
_long_name = "y_wind_component"
|
|
20
|
+
_standard_name = [
|
|
21
|
+
"y_wind",
|
|
22
|
+
"grid_northward_wind",
|
|
23
|
+
]
|
|
24
|
+
_unit = ureg.m / ureg.s
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Wind(MetaParameter):
|
|
28
|
+
_short_name = "wind"
|
|
29
|
+
_long_name = "wind_speed"
|
|
30
|
+
_standard_name = "wind_speed"
|
|
31
|
+
_unit = ureg.m / ureg.s
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class WindDir(MetaParameter):
|
|
35
|
+
_short_name = "wind_dir"
|
|
36
|
+
_long_name = "wind_direction"
|
|
37
|
+
_standard_name = "wind_from_direction"
|
|
38
|
+
_unit = ureg.deg
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class XGust(MetaParameter):
|
|
42
|
+
_short_name = "x_gust"
|
|
43
|
+
_long_name = "x_gust_component"
|
|
44
|
+
_standard_name = "x_wind_gust"
|
|
45
|
+
_unit = ureg.m / ureg.s
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class YGust(MetaParameter):
|
|
49
|
+
_short_name = "y_gust"
|
|
50
|
+
_long_name = "y_gust_component"
|
|
51
|
+
_standard_name = "y_wind_gust"
|
|
52
|
+
_unit = ureg.m / ureg.s
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Gust(MetaParameter):
|
|
56
|
+
_short_name = "gust"
|
|
57
|
+
_long_name = "wind_gust"
|
|
58
|
+
_standard_name = "wind_speed_of_gust"
|
|
59
|
+
_unit = ureg.m / ureg.s
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class GustDir(MetaParameter):
|
|
63
|
+
_short_name = "gust_dir"
|
|
64
|
+
_long_name = "wind_gust_direction"
|
|
65
|
+
_standard_name = "wind_gust_from_direction"
|
|
66
|
+
_unit = ureg.deg
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "geo-parameters"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Metadata of geophysical (especially wave) parameters"
|
|
5
|
+
authors = [ { name = "Jan-Victor Björkqvist", email = "janvb@met.no" } ]
|
|
6
|
+
dependencies = [ "numpy", "pint" ]
|
|
7
|
+
|
|
8
|
+
#[project.optional-dependencies]
|
|
9
|
+
#tests = [ "numpy", "xarray", "pandas", "utm", "geopy"]
|
|
10
|
+
|
|
11
|
+
[project.urls]
|
|
12
|
+
repository = "http://github.com/bjorkqvi/geo-parameters"
|
|
13
|
+
|
|
14
|
+
# [project.scripts]
|
|
15
|
+
# "sfydata" = "sfy.cli.sfydata:sfy"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import xarray as xr
|
|
2
|
+
import numpy as np
|
|
3
|
+
from geo_parameters.geo_parameters.wave import Hs, Tp
|
|
4
|
+
from geo_parameters.geo_parameters import get as gpget
|
|
5
|
+
from geo_parameters.geo_parameters import dict_of_parameters
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_names():
|
|
9
|
+
assert Hs.standard_name() == "sea_surface_wave_significant_height"
|
|
10
|
+
assert Hs.short_name() == "hs"
|
|
11
|
+
hsig = Hs()
|
|
12
|
+
assert hsig.name() == "hs"
|
|
13
|
+
|
|
14
|
+
hsig = Hs(name="hsig")
|
|
15
|
+
assert hsig.name() == "hsig"
|
|
16
|
+
|
|
17
|
+
assert hsig.standard_name() == "sea_surface_wave_significant_height"
|
|
18
|
+
assert hsig.long_name() == "significant_wave_height"
|
|
19
|
+
|
|
20
|
+
assert (
|
|
21
|
+
hsig.standard_name(alias=True) == "significant_height_of_wind_and_swell_waves"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
assert (
|
|
25
|
+
Tp.standard_name(alias=True)
|
|
26
|
+
== "sea_surface_wave_period_at_variance_spectral_density_maximum"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
assert (
|
|
30
|
+
Tp.standard_name()
|
|
31
|
+
== "sea_surface_wave_period_at_variance_spectral_density_maximum"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_get():
|
|
36
|
+
assert gpget("sea_surface_wave_significant_height") == Hs
|
|
37
|
+
# <class 'geo_parameters.geo_parameters.wave.Hs'>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_dicts():
|
|
41
|
+
dict_of_parameters()
|
|
42
|
+
dict_of_parameters(short=True)
|
|
43
|
+
dict_of_parameters(alias=True)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_ds_find_me():
|
|
47
|
+
ds = xr.Dataset(
|
|
48
|
+
data_vars=dict(
|
|
49
|
+
interesting_hs_name=(["lat", "lon"], np.zeros((11, 6))),
|
|
50
|
+
peak_period=(["lat", "lon"], np.ones((11, 6))),
|
|
51
|
+
),
|
|
52
|
+
coords=dict(
|
|
53
|
+
lon=(["lon"], np.linspace(5, 10, 6)),
|
|
54
|
+
lat=(["lat"], np.linspace(50, 60, 11)),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
ds.interesting_hs_name.attrs = {
|
|
58
|
+
"standard_name": "sea_surface_wave_significant_height"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ds.peak_period.attrs = {
|
|
62
|
+
"standard_name": "sea_surface_wave_period_at_variance_spectral_density_maximum"
|
|
63
|
+
}
|
|
64
|
+
breakpoint()
|
|
65
|
+
assert Hs.find_me_in_ds(ds) == "interesting_hs_name"
|
|
66
|
+
assert Tp.find_me_in_ds(ds) == "peak_period"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from geo_parameters.geo_parameters import get, dict_of_parameters
|
|
2
|
+
from geo_parameters.geo_parameters.wave import Hs
|
|
3
|
+
from geo_parameters.geo_parameters.wind import XWind
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_get_wave():
|
|
7
|
+
assert get("hs") == Hs
|
|
8
|
+
assert get("significant_wave_height") is None
|
|
9
|
+
assert get("sea_surface_wave_significant_height") == Hs
|
|
10
|
+
assert get("significant_height_of_wind_and_swell_waves") == Hs
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_get_wind():
|
|
14
|
+
assert get("x_wind") == XWind
|
|
15
|
+
assert get("xwind") is None
|
|
16
|
+
assert get("eastward_wind_component") is None
|
|
17
|
+
assert get("x_wind") == XWind
|
|
18
|
+
assert get("grid_eastward_wind") == XWind
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_get_iteration_short_name():
|
|
22
|
+
params = dict_of_parameters(short=True)
|
|
23
|
+
for key, value in params.items():
|
|
24
|
+
assert get(key) == value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_get_iteration_standard_name():
|
|
28
|
+
params = dict_of_parameters()
|
|
29
|
+
for key, value in params.items():
|
|
30
|
+
assert get(key) == value
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_get_iteration_alias():
|
|
34
|
+
params = dict_of_parameters(alias=True)
|
|
35
|
+
for key, value in params.items():
|
|
36
|
+
assert get(key) == value
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from geo_parameters.geo_parameters.wave import Hs
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_name_of_class():
|
|
5
|
+
assert Hs.short_name() == "hs"
|
|
6
|
+
assert Hs.long_name() == "significant_wave_height"
|
|
7
|
+
assert Hs.standard_name() == "sea_surface_wave_significant_height"
|
|
8
|
+
assert Hs.standard_name(alias=True) == "significant_height_of_wind_and_swell_waves"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_units_of_class():
|
|
12
|
+
assert str(Hs.unit()) == "meter"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_name_of_instance():
|
|
16
|
+
assert Hs().short_name() == "hs"
|
|
17
|
+
assert Hs(name="hsig").name() == "hsig"
|
|
18
|
+
assert Hs("hsig").name() == "hsig"
|
|
19
|
+
assert Hs().long_name() == "significant_wave_height"
|
|
20
|
+
assert Hs().standard_name() == "sea_surface_wave_significant_height"
|
|
21
|
+
assert (
|
|
22
|
+
Hs().standard_name(alias=True) == "significant_height_of_wind_and_swell_waves"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_units_of_instance():
|
|
27
|
+
assert str(Hs().unit()) == "meter"
|