eo-tides 0.3.0__tar.gz → 0.3.1__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.
- {eo_tides-0.3.0 → eo_tides-0.3.1}/PKG-INFO +3 -3
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides/model.py +8 -54
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides/utils.py +94 -1
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides.egg-info/PKG-INFO +3 -3
- {eo_tides-0.3.0 → eo_tides-0.3.1}/pyproject.toml +4 -3
- {eo_tides-0.3.0 → eo_tides-0.3.1}/tests/test_utils.py +44 -1
- {eo_tides-0.3.0 → eo_tides-0.3.1}/LICENSE +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/README.md +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides/__init__.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides/eo.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides/stats.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides/validation.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides.egg-info/SOURCES.txt +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides.egg-info/dependency_links.txt +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides.egg-info/requires.txt +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/eo_tides.egg-info/top_level.txt +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/setup.cfg +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/tests/test_eo.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/tests/test_model.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/tests/test_stats.py +0 -0
- {eo_tides-0.3.0 → eo_tides-0.3.1}/tests/test_validation.py +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: eo-tides
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.1
|
4
4
|
Summary: Tide modelling tools for large-scale satellite earth observation analysis
|
5
|
-
Author: Stephen Sagar, Claire Phillips, Vanessa Newey
|
6
|
-
Author-email: Robbi
|
5
|
+
Author: Robbi Bishop-Taylor, Stephen Sagar, Claire Phillips, Vanessa Newey
|
6
|
+
Author-email: Robbi.BishopTaylor@ga.gov.au
|
7
7
|
Project-URL: Homepage, https://GeoscienceAustralia.github.io/eo-tides/
|
8
8
|
Project-URL: Repository, https://github.com/GeoscienceAustralia/eo-tides
|
9
9
|
Project-URL: Documentation, https://GeoscienceAustralia.github.io/eo-tides/
|
@@ -21,7 +21,7 @@ import pyproj
|
|
21
21
|
import pyTMD
|
22
22
|
from tqdm import tqdm
|
23
23
|
|
24
|
-
from .utils import DatetimeLike, _set_directory, _standardise_time, idw, list_models
|
24
|
+
from .utils import DatetimeLike, _set_directory, _standardise_models, _standardise_time, idw, list_models
|
25
25
|
|
26
26
|
|
27
27
|
def _ensemble_model(
|
@@ -276,6 +276,7 @@ def _model_tides(
|
|
276
276
|
)
|
277
277
|
|
278
278
|
# TODO: Return constituents
|
279
|
+
# print(model, amp.shape)
|
279
280
|
# print(amp.shape, ph.shape, c)
|
280
281
|
# print(pd.DataFrame({"amplitude": amp}))
|
281
282
|
|
@@ -511,7 +512,6 @@ def model_tides(
|
|
511
512
|
|
512
513
|
"""
|
513
514
|
# Turn inputs into arrays for consistent handling
|
514
|
-
models_requested = list(np.atleast_1d(model))
|
515
515
|
x = np.atleast_1d(x)
|
516
516
|
y = np.atleast_1d(y)
|
517
517
|
time = _standardise_time(time)
|
@@ -540,58 +540,12 @@ def model_tides(
|
|
540
540
|
# provided, try global environment variable.
|
541
541
|
directory = _set_directory(directory)
|
542
542
|
|
543
|
-
#
|
544
|
-
|
545
|
-
|
546
|
-
directory
|
543
|
+
# Standardise model list, handling "all" and "ensemble" functionality
|
544
|
+
models_to_process, models_requested, ensemble_models = _standardise_models(
|
545
|
+
model=model,
|
546
|
+
directory=directory,
|
547
|
+
ensemble_models=ensemble_models,
|
547
548
|
)
|
548
|
-
# TODO: This is hacky, find a better way. Perhaps a kwarg that
|
549
|
-
# turns ensemble functionality on, and checks that supplied
|
550
|
-
# models match models expected for ensemble?
|
551
|
-
available_models = available_models + ["ensemble"]
|
552
|
-
valid_models = valid_models + ["ensemble"]
|
553
|
-
|
554
|
-
# Error if any models are not supported
|
555
|
-
if not all(m in valid_models for m in models_requested):
|
556
|
-
error_text = (
|
557
|
-
f"One or more of the requested models are not valid:\n"
|
558
|
-
f"{models_requested}\n\n"
|
559
|
-
"The following models are supported:\n"
|
560
|
-
f"{valid_models}"
|
561
|
-
)
|
562
|
-
raise ValueError(error_text)
|
563
|
-
|
564
|
-
# Error if any models are not available in `directory`
|
565
|
-
if not all(m in available_models for m in models_requested):
|
566
|
-
error_text = (
|
567
|
-
f"One or more of the requested models are valid, but not available in `{directory}`:\n"
|
568
|
-
f"{models_requested}\n\n"
|
569
|
-
f"The following models are available in `{directory}`:\n"
|
570
|
-
f"{available_models}"
|
571
|
-
)
|
572
|
-
raise ValueError(error_text)
|
573
|
-
|
574
|
-
# If ensemble modelling is requested, use a custom list of models
|
575
|
-
# for subsequent processing
|
576
|
-
if "ensemble" in models_requested:
|
577
|
-
print("Running ensemble tide modelling")
|
578
|
-
models_to_process = (
|
579
|
-
ensemble_models
|
580
|
-
if ensemble_models is not None
|
581
|
-
else [
|
582
|
-
"FES2014",
|
583
|
-
"TPXO9-atlas-v5",
|
584
|
-
"EOT20",
|
585
|
-
"HAMTIDE11",
|
586
|
-
"GOT4.10",
|
587
|
-
"FES2012",
|
588
|
-
"TPXO8-atlas-v1",
|
589
|
-
]
|
590
|
-
)
|
591
|
-
|
592
|
-
# Otherwise, models to process are the same as those requested
|
593
|
-
else:
|
594
|
-
models_to_process = models_requested
|
595
549
|
|
596
550
|
# Update tide modelling func to add default keyword arguments that
|
597
551
|
# are used for every iteration during parallel processing
|
@@ -685,7 +639,7 @@ def model_tides(
|
|
685
639
|
|
686
640
|
# Optionally compute ensemble model and add to dataframe
|
687
641
|
if "ensemble" in models_requested:
|
688
|
-
ensemble_df = _ensemble_model(tide_df, crs,
|
642
|
+
ensemble_df = _ensemble_model(tide_df, crs, ensemble_models, **ensemble_kwargs)
|
689
643
|
|
690
644
|
# Update requested models with any custom ensemble models, then
|
691
645
|
# filter the dataframe to keep only models originally requested
|
@@ -68,6 +68,92 @@ def _standardise_time(
|
|
68
68
|
return np.atleast_1d(time)
|
69
69
|
|
70
70
|
|
71
|
+
def _standardise_models(
|
72
|
+
model: str | list[str],
|
73
|
+
directory: str | os.PathLike,
|
74
|
+
ensemble_models: list[str] | None = None,
|
75
|
+
) -> tuple[list[str], list[str], list[str] | None]:
|
76
|
+
"""
|
77
|
+
Take an input model name or list of names, and return a list
|
78
|
+
of models to process, requested models, and ensemble models,
|
79
|
+
as required by the `model_tides` function.
|
80
|
+
|
81
|
+
Handles two special values passed to `model`: "all", which
|
82
|
+
will model tides for all models available in `directory`, and
|
83
|
+
"ensemble", which will model tides for all models in a list
|
84
|
+
of custom ensemble models.
|
85
|
+
"""
|
86
|
+
|
87
|
+
# Turn inputs into arrays for consistent handling
|
88
|
+
models_requested = list(np.atleast_1d(model))
|
89
|
+
|
90
|
+
# Get full list of supported models from pyTMD database
|
91
|
+
available_models, valid_models = list_models(
|
92
|
+
directory, show_available=False, show_supported=False, raise_error=True
|
93
|
+
)
|
94
|
+
custom_options = ["ensemble", "all"]
|
95
|
+
|
96
|
+
# Error if any models are not supported
|
97
|
+
if not all(m in valid_models + custom_options for m in models_requested):
|
98
|
+
error_text = (
|
99
|
+
f"One or more of the requested models are not valid:\n"
|
100
|
+
f"{models_requested}\n\n"
|
101
|
+
"The following models are supported:\n"
|
102
|
+
f"{valid_models}"
|
103
|
+
)
|
104
|
+
raise ValueError(error_text)
|
105
|
+
|
106
|
+
# Error if any models are not available in `directory`
|
107
|
+
if not all(m in available_models + custom_options for m in models_requested):
|
108
|
+
error_text = (
|
109
|
+
f"One or more of the requested models are valid, but not available in `{directory}`:\n"
|
110
|
+
f"{models_requested}\n\n"
|
111
|
+
f"The following models are available in `{directory}`:\n"
|
112
|
+
f"{available_models}"
|
113
|
+
)
|
114
|
+
raise ValueError(error_text)
|
115
|
+
|
116
|
+
# If "all" models are requested, update requested list to include available models
|
117
|
+
if "all" in models_requested:
|
118
|
+
models_requested = available_models + [m for m in models_requested if m != "all"]
|
119
|
+
|
120
|
+
# If "ensemble" modeling is requested, use custom list of ensemble models
|
121
|
+
if "ensemble" in models_requested:
|
122
|
+
print("Running ensemble tide modelling")
|
123
|
+
ensemble_models = (
|
124
|
+
ensemble_models
|
125
|
+
if ensemble_models is not None
|
126
|
+
else [
|
127
|
+
"FES2014",
|
128
|
+
"TPXO9-atlas-v5",
|
129
|
+
"EOT20",
|
130
|
+
"HAMTIDE11",
|
131
|
+
"GOT4.10",
|
132
|
+
"FES2012",
|
133
|
+
"TPXO8-atlas-v1",
|
134
|
+
]
|
135
|
+
)
|
136
|
+
|
137
|
+
# Error if any ensemble models are not available in `directory`
|
138
|
+
if not all(m in available_models for m in ensemble_models):
|
139
|
+
error_text = (
|
140
|
+
f"One or more of the requested ensemble models are not available in `{directory}`:\n"
|
141
|
+
f"{ensemble_models}\n\n"
|
142
|
+
f"The following models are available in `{directory}`:\n"
|
143
|
+
f"{available_models}"
|
144
|
+
)
|
145
|
+
raise ValueError(error_text)
|
146
|
+
|
147
|
+
# Return set of all ensemble plus any other requested models
|
148
|
+
models_to_process = sorted(list(set(ensemble_models + [m for m in models_requested if m != "ensemble"])))
|
149
|
+
|
150
|
+
# Otherwise, models to process are the same as those requested
|
151
|
+
else:
|
152
|
+
models_to_process = models_requested
|
153
|
+
|
154
|
+
return models_to_process, models_requested, ensemble_models
|
155
|
+
|
156
|
+
|
71
157
|
def _clip_model_file(
|
72
158
|
nc: xr.Dataset,
|
73
159
|
bbox: BoundingBox,
|
@@ -393,7 +479,14 @@ def list_models(
|
|
393
479
|
expected_paths = {}
|
394
480
|
for m in supported_models:
|
395
481
|
model_file = model_database[m]["model_file"]
|
396
|
-
|
482
|
+
|
483
|
+
# Handle GOT5.6 differently to ensure we test for presence of GOT5.6 constituents
|
484
|
+
if m in ("GOT5.6", "GOT5.6_extrapolated"):
|
485
|
+
model_file = [file for file in model_file if "GOT5.6" in file][0]
|
486
|
+
else:
|
487
|
+
model_file = model_file[0] if isinstance(model_file, list) else model_file
|
488
|
+
|
489
|
+
# Add path to dict
|
397
490
|
expected_paths[m] = str(directory / pathlib.Path(model_file).expanduser().parent)
|
398
491
|
|
399
492
|
# Define column widths
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: eo-tides
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.1
|
4
4
|
Summary: Tide modelling tools for large-scale satellite earth observation analysis
|
5
|
-
Author: Stephen Sagar, Claire Phillips, Vanessa Newey
|
6
|
-
Author-email: Robbi
|
5
|
+
Author: Robbi Bishop-Taylor, Stephen Sagar, Claire Phillips, Vanessa Newey
|
6
|
+
Author-email: Robbi.BishopTaylor@ga.gov.au
|
7
7
|
Project-URL: Homepage, https://GeoscienceAustralia.github.io/eo-tides/
|
8
8
|
Project-URL: Repository, https://github.com/GeoscienceAustralia/eo-tides
|
9
9
|
Project-URL: Documentation, https://GeoscienceAustralia.github.io/eo-tides/
|
@@ -1,12 +1,13 @@
|
|
1
1
|
[project]
|
2
2
|
name = "eo-tides"
|
3
|
-
version = "0.3.
|
3
|
+
version = "0.3.1"
|
4
4
|
description = "Tide modelling tools for large-scale satellite earth observation analysis"
|
5
5
|
authors = [
|
6
|
-
{ name = "Robbi Bishop-Taylor"
|
6
|
+
{ name = "Robbi Bishop-Taylor" },
|
7
7
|
{ name = "Stephen Sagar" },
|
8
8
|
{ name = "Claire Phillips" },
|
9
|
-
{ name = "Vanessa Newey" }
|
9
|
+
{ name = "Vanessa Newey" },
|
10
|
+
{ email = "Robbi.BishopTaylor@ga.gov.au"}
|
10
11
|
]
|
11
12
|
readme = "README.md"
|
12
13
|
keywords = [
|
@@ -6,7 +6,50 @@ import numpy as np
|
|
6
6
|
import pandas as pd
|
7
7
|
import pytest
|
8
8
|
|
9
|
-
from eo_tides.utils import _standardise_time, clip_models, idw, list_models
|
9
|
+
from eo_tides.utils import _standardise_models, _standardise_time, clip_models, idw, list_models
|
10
|
+
|
11
|
+
|
12
|
+
@pytest.mark.parametrize(
|
13
|
+
"model, ensemble_models, exp_process, exp_request, exp_ensemble",
|
14
|
+
[
|
15
|
+
# Case 1, 2: Specific model in str and list format
|
16
|
+
("EOT20", None, ["EOT20"], ["EOT20"], None),
|
17
|
+
(["EOT20"], None, ["EOT20"], ["EOT20"], None),
|
18
|
+
# Case 3, 4: Using "all" to request all available models
|
19
|
+
("all", None, ["EOT20", "GOT5.5", "HAMTIDE11"], ["EOT20", "GOT5.5", "HAMTIDE11"], None),
|
20
|
+
(["all"], None, ["EOT20", "GOT5.5", "HAMTIDE11"], ["EOT20", "GOT5.5", "HAMTIDE11"], None),
|
21
|
+
# Case 5, 6: Using "ensemble" to model tides for specific set of ensemble models
|
22
|
+
("ensemble", ["EOT20", "HAMTIDE11"], ["EOT20", "HAMTIDE11"], ["ensemble"], ["EOT20", "HAMTIDE11"]),
|
23
|
+
(["ensemble"], ["EOT20", "HAMTIDE11"], ["EOT20", "HAMTIDE11"], ["ensemble"], ["EOT20", "HAMTIDE11"]),
|
24
|
+
# Case 7: Modelling tides using ensemble set and an additional model
|
25
|
+
(
|
26
|
+
["ensemble", "GOT5.5"],
|
27
|
+
["EOT20", "HAMTIDE11"],
|
28
|
+
["EOT20", "GOT5.5", "HAMTIDE11"],
|
29
|
+
["ensemble", "GOT5.5"],
|
30
|
+
["EOT20", "HAMTIDE11"],
|
31
|
+
),
|
32
|
+
# Case 8: Modelling tides for all available models, AND ensemble set
|
33
|
+
(
|
34
|
+
["all", "ensemble"],
|
35
|
+
["EOT20", "HAMTIDE11"],
|
36
|
+
["EOT20", "GOT5.5", "HAMTIDE11"],
|
37
|
+
["EOT20", "GOT5.5", "HAMTIDE11", "ensemble"],
|
38
|
+
["EOT20", "HAMTIDE11"],
|
39
|
+
),
|
40
|
+
],
|
41
|
+
)
|
42
|
+
def test_standardise_models(model, ensemble_models, exp_process, exp_request, exp_ensemble):
|
43
|
+
# Return lists of models
|
44
|
+
models_to_process, models_requested, ensemble_models = _standardise_models(
|
45
|
+
model=model,
|
46
|
+
directory="tests/data/tide_models",
|
47
|
+
ensemble_models=ensemble_models,
|
48
|
+
)
|
49
|
+
|
50
|
+
assert models_to_process == exp_process
|
51
|
+
assert models_requested == exp_request
|
52
|
+
assert (sorted(ensemble_models) if ensemble_models else None) == (sorted(exp_ensemble) if exp_ensemble else None)
|
10
53
|
|
11
54
|
|
12
55
|
def test_clip_models():
|
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
|