eo-tides 0.3.1__py3-none-any.whl → 0.4.0__py3-none-any.whl

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/utils.py CHANGED
@@ -6,6 +6,7 @@ import os
6
6
  import pathlib
7
7
  import textwrap
8
8
  import warnings
9
+ from collections import Counter
9
10
  from typing import List, Union
10
11
 
11
12
  import numpy as np
@@ -23,6 +24,14 @@ from tqdm import tqdm
23
24
  DatetimeLike = Union[np.ndarray, pd.DatetimeIndex, pd.Timestamp, datetime.datetime, str, List[str]]
24
25
 
25
26
 
27
+ def _get_duplicates(array):
28
+ """
29
+ Return any duplicates in a list or array.
30
+ """
31
+ c = Counter(array)
32
+ return [k for k in c if c[k] > 1]
33
+
34
+
26
35
  def _set_directory(
27
36
  directory: str | os.PathLike | None = None,
28
37
  ) -> os.PathLike:
@@ -87,6 +96,11 @@ def _standardise_models(
87
96
  # Turn inputs into arrays for consistent handling
88
97
  models_requested = list(np.atleast_1d(model))
89
98
 
99
+ # Raise error if list contains duplications
100
+ duplicates = _get_duplicates(models_requested)
101
+ if len(duplicates) > 0:
102
+ raise ValueError(f"The model parameter contains duplicate values: {duplicates}")
103
+
90
104
  # Get full list of supported models from pyTMD database
91
105
  available_models, valid_models = list_models(
92
106
  directory, show_available=False, show_supported=False, raise_error=True
@@ -124,13 +138,15 @@ def _standardise_models(
124
138
  ensemble_models
125
139
  if ensemble_models is not None
126
140
  else [
127
- "FES2014",
128
- "TPXO9-atlas-v5",
129
141
  "EOT20",
130
- "HAMTIDE11",
131
- "GOT4.10",
132
142
  "FES2012",
133
- "TPXO8-atlas-v1",
143
+ "FES2014_extrapolated",
144
+ "FES2022_extrapolated",
145
+ "GOT4.10",
146
+ "GOT5.6_extrapolated",
147
+ "TPXO10-atlas-v2-nc",
148
+ "TPXO8-atlas-nc",
149
+ "TPXO9-atlas-v5-nc",
134
150
  ]
135
151
  )
136
152
 
@@ -264,7 +280,7 @@ def clip_models(
264
280
  output_directory: str | os.PathLike,
265
281
  bbox: tuple[float, float, float, float],
266
282
  model: list | None = None,
267
- buffer: float = 1,
283
+ buffer: float = 5,
268
284
  overwrite: bool = False,
269
285
  ):
270
286
  """
@@ -297,7 +313,7 @@ def clip_models(
297
313
  in the input directly.
298
314
  buffer : float, optional
299
315
  Buffer distance (in degrees) added to the bounding box to provide
300
- sufficient data on edges of study area. Defaults to 1 degree.
316
+ sufficient data on edges of study area. Defaults to 5 degrees.
301
317
  overwrite : bool, optional
302
318
  If True, overwrite existing files in the output directory.
303
319
  Defaults to False.
eo_tides/validation.py CHANGED
@@ -5,6 +5,7 @@ from numbers import Number
5
5
 
6
6
  import geopandas as gpd
7
7
  import pandas as pd
8
+ import tqdm
8
9
  from odc.geo.geom import BoundingBox
9
10
  from pandas.tseries.offsets import MonthBegin, MonthEnd, YearBegin, YearEnd
10
11
  from scipy import stats
@@ -152,21 +153,24 @@ def _load_gauge_metadata(metadata_path):
152
153
 
153
154
 
154
155
  def _load_gesla_dataset(site, path, na_value):
155
- with warnings.catch_warnings():
156
- warnings.simplefilter("ignore", FutureWarning)
157
- gesla_df = (
158
- pd.read_csv(
159
- path,
160
- skiprows=41,
161
- names=["date", "time", "sea_level", "qc_flag", "use_flag"],
162
- sep=r"\s+", # sep="\s+",
163
- parse_dates=[[0, 1]],
164
- index_col=0,
165
- na_values=na_value,
166
- )
167
- .rename_axis("time")
168
- .assign(site_code=site)
156
+ # Read dataset
157
+ gesla_df = pd.read_csv(
158
+ path,
159
+ skiprows=41,
160
+ names=["date", "time", "sea_level", "qc_flag", "use_flag"],
161
+ sep=r"\s+",
162
+ na_values=na_value,
163
+ )
164
+
165
+ # Combine two date fields
166
+ gesla_df = (
167
+ gesla_df.assign(
168
+ time=pd.to_datetime(gesla_df["date"] + " " + gesla_df["time"]),
169
+ site_code=site,
169
170
  )
171
+ .drop(columns=["date"])
172
+ .set_index("time")
173
+ )
170
174
 
171
175
  return gesla_df
172
176
 
@@ -301,13 +305,11 @@ def load_gauge_gesla(
301
305
  paths_na = metadata_df.loc[site_code, ["file_name", "null_value"]]
302
306
 
303
307
  # Load and combine into a single dataframe
304
- data_df = (
305
- pd.concat([_load_gesla_dataset(s, p, na_value=na) for s, p, na in paths_na.itertuples()])
306
- .sort_index()
307
- .loc[slice(start_time, end_time)]
308
- .reset_index()
309
- .set_index("site_code")
310
- )
308
+ gauge_list = [
309
+ _load_gesla_dataset(s, p, na_value=na)
310
+ for s, p, na in tqdm.tqdm(paths_na.itertuples(), total=len(paths_na), desc="Loading GESLA gauges")
311
+ ]
312
+ data_df = pd.concat(gauge_list).sort_index().loc[slice(start_time, end_time)].reset_index().set_index("site_code")
311
313
 
312
314
  # Optionally filter by use flag column
313
315
  if filter_use_flag:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eo-tides
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Tide modelling tools for large-scale satellite earth observation analysis
5
5
  Author: Robbi Bishop-Taylor, Stephen Sagar, Claire Phillips, Vanessa Newey
6
6
  Author-email: Robbi.BishopTaylor@ga.gov.au
@@ -24,26 +24,27 @@ Classifier: Programming Language :: Python :: 3.13
24
24
  Requires-Python: <4.0,>=3.9
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
- Requires-Dist: colorama >=0.4.3
28
- Requires-Dist: geopandas >=0.10.0
29
- Requires-Dist: matplotlib >=3.8.0
30
- Requires-Dist: numpy >=1.26.0
31
- Requires-Dist: odc-geo >=0.4.7
32
- Requires-Dist: pandas >=2.2.0
33
- Requires-Dist: psutil >=5.8.0
34
- Requires-Dist: pyproj >=3.6.1
35
- Requires-Dist: pyTMD ==2.1.8
36
- Requires-Dist: scikit-learn >=1.4.0
37
- Requires-Dist: scipy >=1.11.2
38
- Requires-Dist: shapely >=2.0.6
39
- Requires-Dist: tqdm >=4.55.0
40
- Requires-Dist: xarray >=2022.3.0
27
+ Requires-Dist: colorama>=0.4.3
28
+ Requires-Dist: geopandas>=0.10.0
29
+ Requires-Dist: matplotlib>=3.8.0
30
+ Requires-Dist: numpy>=1.26.0
31
+ Requires-Dist: odc-geo>=0.4.7
32
+ Requires-Dist: pandas>=2.2.0
33
+ Requires-Dist: psutil>=5.8.0
34
+ Requires-Dist: pyogrio>=0.7.0
35
+ Requires-Dist: pyproj>=3.6.1
36
+ Requires-Dist: pyTMD==2.2.0
37
+ Requires-Dist: scikit-learn>=1.4.0
38
+ Requires-Dist: scipy>=1.11.2
39
+ Requires-Dist: shapely>=2.0.6
40
+ Requires-Dist: tqdm>=4.55.0
41
+ Requires-Dist: xarray>=2022.3.0
41
42
  Provides-Extra: notebooks
42
- Requires-Dist: odc-stac >=0.3.10 ; extra == 'notebooks'
43
- Requires-Dist: odc-geo[tiff,warp] >=0.4.7 ; extra == 'notebooks'
44
- Requires-Dist: pystac-client >=0.8.3 ; extra == 'notebooks'
45
- Requires-Dist: folium >=0.16.0 ; extra == 'notebooks'
46
- Requires-Dist: planetary-computer >=1.0.0 ; extra == 'notebooks'
43
+ Requires-Dist: odc-stac>=0.3.10; extra == "notebooks"
44
+ Requires-Dist: odc-geo[tiff,warp]>=0.4.7; extra == "notebooks"
45
+ Requires-Dist: pystac-client>=0.8.3; extra == "notebooks"
46
+ Requires-Dist: folium>=0.16.0; extra == "notebooks"
47
+ Requires-Dist: planetary_computer>=1.0.0; extra == "notebooks"
47
48
 
48
49
  # `eo-tides`: Tide modelling tools for large-scale satellite earth observation analysis
49
50
 
@@ -0,0 +1,11 @@
1
+ eo_tides/__init__.py,sha256=pGvVlxMKiYjm_273G-oYcOgVuPra7uEdNZv0oN1i69c,1693
2
+ eo_tides/eo.py,sha256=d4zFs_uhuTekJDDqiX7oIzvS1iP6nEr0rG2Yy4xbsEU,22746
3
+ eo_tides/model.py,sha256=X_nuYkBbzq3cLgJc0dUknlL6w_90O9rz_2BOqX5uxsg,34585
4
+ eo_tides/stats.py,sha256=-nL6Ay6TvA5GSdnglHoLMu5JZf6-YjQKERBGLjAZs34,22993
5
+ eo_tides/utils.py,sha256=9xJ1q-b-TVHg5zFyLy6AT_srrPQDvmFdWJmlGSPaJF0,26563
6
+ eo_tides/validation.py,sha256=KP8WLT5z7KLFjQ9oDla7VJOyLQAK4SVbcz2ySAbsbwI,11882
7
+ eo_tides-0.4.0.dist-info/LICENSE,sha256=owxWsXViCL2J6Ks3XYhot7t4Y93nstmXAT95Zf030Cc,11350
8
+ eo_tides-0.4.0.dist-info/METADATA,sha256=cqO3zJGPj-l5Xzi-cfPtkd7pzUUTt5ENVvCRM16HXFQ,8045
9
+ eo_tides-0.4.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
10
+ eo_tides-0.4.0.dist-info/top_level.txt,sha256=lXZDUUM1DlLdKWHRn8zdmtW8Rx-eQOIWVvt0b8VGiyQ,9
11
+ eo_tides-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- eo_tides/__init__.py,sha256=rn6slQP0bAhqM9cL2W8omiEM8f0b7libt6WsQ5DvYTE,1655
2
- eo_tides/eo.py,sha256=Vc_AHqT0_IDqdwbOpNcONjHhiCtbCe8Osk2gvzUeNmU,22377
3
- eo_tides/model.py,sha256=abfwswxEgSCBveK0-kTN5L-jw-AceXz3-NXSCbYnalk,32747
4
- eo_tides/stats.py,sha256=lchWWJ5gBDuZWvaD8TF-12Xlo2qCWiNI2IcgAaKWy2U,22668
5
- eo_tides/utils.py,sha256=i7JoNAH41hWZ0-lIOa87i-zCPndzJl3ylXecMb1jHoQ,26056
6
- eo_tides/validation.py,sha256=UREsc0yWRO4x0PJXvyoIx8gYiBZiRSim4z6TmAz_VDM,11857
7
- eo_tides-0.3.1.dist-info/LICENSE,sha256=owxWsXViCL2J6Ks3XYhot7t4Y93nstmXAT95Zf030Cc,11350
8
- eo_tides-0.3.1.dist-info/METADATA,sha256=06d3l-KrXyKSvqGD-ku2CKORtWA1AHgA841i-iDw7_Q,8039
9
- eo_tides-0.3.1.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
10
- eo_tides-0.3.1.dist-info/top_level.txt,sha256=lXZDUUM1DlLdKWHRn8zdmtW8Rx-eQOIWVvt0b8VGiyQ,9
11
- eo_tides-0.3.1.dist-info/RECORD,,