eo-tides 0.6.0__py3-none-any.whl → 0.6.1__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/model.py CHANGED
@@ -19,6 +19,7 @@ import numpy as np
19
19
  import pandas as pd
20
20
  import pyproj
21
21
  import pyTMD
22
+ import timescale.time
22
23
  from tqdm import tqdm
23
24
 
24
25
  from .utils import DatetimeLike, _set_directory, _standardise_models, _standardise_time, idw
@@ -95,7 +96,7 @@ def _model_tides(
95
96
  lon, lat = transformer.transform(x.flatten(), y.flatten())
96
97
 
97
98
  # Convert datetime
98
- timescale = pyTMD.time.timescale().from_datetime(time.flatten())
99
+ ts = timescale.time.Timescale().from_datetime(time.flatten())
99
100
 
100
101
  try:
101
102
  # Read tidal constants and interpolate to grid points
@@ -136,10 +137,10 @@ def _model_tides(
136
137
  # Compute delta times based on model
137
138
  if pytmd_model.corrections in ("OTIS", "ATLAS", "TMD3", "netcdf"):
138
139
  # Use delta time at 2000.0 to match TMD outputs
139
- deltat = np.zeros_like(timescale.tt_ut1)
140
+ deltat = np.zeros_like(ts.tt_ut1)
140
141
  else:
141
142
  # Use interpolated delta times
142
- deltat = timescale.tt_ut1
143
+ deltat = ts.tt_ut1
143
144
 
144
145
  # In "one-to-many" mode, extracted tidal constituents and timesteps
145
146
  # are repeated/multiplied out to match the number of input points and
@@ -149,7 +150,7 @@ def _model_tides(
149
150
  points_repeat = len(x) if mode == "one-to-many" else 1
150
151
  time_repeat = len(time) if mode == "one-to-many" else 1
151
152
  t, hc, deltat = (
152
- np.tile(timescale.tide, points_repeat),
153
+ np.tile(ts.tide, points_repeat),
153
154
  hc.repeat(time_repeat, axis=0),
154
155
  np.tile(deltat, points_repeat),
155
156
  )
eo_tides/utils.py CHANGED
@@ -181,9 +181,9 @@ def _clip_model_file(
181
181
  """
182
182
  Clips tide model netCDF datasets to a bounding box.
183
183
 
184
- If the bounding box crosses 0 degrees longitude (e.g. Greenwich),
185
- the function will clip the dataset into two parts and concatenate
186
- them along the x-dimension to create a continuous result.
184
+ If the bounding box crosses 0 degrees longitude (e.g. Greenwich prime
185
+ meridian), the dataset will be clipped into two parts and concatenated
186
+ along the x-dimension to create a continuous result.
187
187
 
188
188
  Parameters
189
189
  ----------
@@ -226,20 +226,22 @@ def _clip_model_file(
226
226
  xcoords = nc[xcoord].compute()
227
227
  ycoords = nc[ycoord].compute()
228
228
 
229
- # If data falls within 0-360 degree bounds, then clip directly
230
- if (bbox.left >= 0) & (bbox.right <= 360):
229
+ # Convert longitudes to 0-360 convention
230
+ left = bbox.left % 360
231
+ right = bbox.right % 360
232
+
233
+ # If left coordinate is smaller than right, bbox does not cross
234
+ # zero longitude and can be clipped directly
235
+ if left <= right: # bbox does not cross 0
231
236
  nc_clipped = nc.sel({
232
237
  ydim: (ycoords >= bbox.bottom) & (ycoords <= bbox.top),
233
- xdim: (xcoords >= bbox.left) & (xcoords <= bbox.right),
238
+ xdim: (xcoords >= left) & (xcoords <= right),
234
239
  })
235
240
 
236
- # If bbox crosses zero longitude, extract left and right
237
- # separately and then combine into one concatenated dataset
238
- elif (bbox.left < 0) & (bbox.right > 0):
239
- # Convert longitudes to 0-360 range
240
- left = bbox.left % 360
241
- right = bbox.right % 360
242
-
241
+ # If left coordinate is larger than right, bbox crosses zero longitude.
242
+ # If so, extract left and right separately and then combine into one
243
+ # concatenated dataset
244
+ elif left > right: # bbox crosses 0
243
245
  # Extract data from left of 0 longitude, and convert lon
244
246
  # coords to -180 to 0 range to enable continuous interpolation
245
247
  # across 0 boundary
@@ -357,7 +359,7 @@ def clip_models(
357
359
  model_files = model_database[m].get("model_file", [])
358
360
  grid_file = model_database[m].get("grid_file", [])
359
361
 
360
- # Convert to list if strings and combine
362
+ # Convert to list of strings and combine
361
363
  model_files = model_files if isinstance(model_files, list) else [model_files]
362
364
  grid_file = grid_file if isinstance(grid_file, list) else [grid_file]
363
365
  all_files = model_files + grid_file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: eo-tides
3
- Version: 0.6.0
3
+ Version: 0.6.1
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
@@ -32,10 +32,11 @@ Requires-Dist: pandas>=2.2.0
32
32
  Requires-Dist: psutil>=5.8.0
33
33
  Requires-Dist: pyogrio>=0.10.0
34
34
  Requires-Dist: pyproj>=3.7.0
35
- Requires-Dist: pyTMD==2.2.1
35
+ Requires-Dist: pyTMD>=2.2.2
36
36
  Requires-Dist: scikit-learn>=1.4.0
37
37
  Requires-Dist: scipy>=1.14.1
38
38
  Requires-Dist: shapely>=2.0.6
39
+ Requires-Dist: timescale>=0.0.3
39
40
  Requires-Dist: tqdm>=4.55.0
40
41
  Requires-Dist: xarray>=2022.3.0
41
42
  Provides-Extra: notebooks
@@ -0,0 +1,11 @@
1
+ eo_tides/__init__.py,sha256=pGvVlxMKiYjm_273G-oYcOgVuPra7uEdNZv0oN1i69c,1693
2
+ eo_tides/eo.py,sha256=TuFt9SSiO9Z2o8Kr1g-wFPzofp0HTcgkfhT83zu03kc,23983
3
+ eo_tides/model.py,sha256=XqgV3Arvkr3Z8PR6EvTMZbg8WnnpYCDOjFL2-sOXeF0,34695
4
+ eo_tides/stats.py,sha256=ELQpqIH86442IYgjrGrIK3mi0-pu2ZijFw53arA2FYg,23072
5
+ eo_tides/utils.py,sha256=T19OuPLHzaUKcovCVGANvmOiRu-L8VuDXSTzmNlA6Bo,26647
6
+ eo_tides/validation.py,sha256=KP8WLT5z7KLFjQ9oDla7VJOyLQAK4SVbcz2ySAbsbwI,11882
7
+ eo_tides-0.6.1.dist-info/LICENSE,sha256=owxWsXViCL2J6Ks3XYhot7t4Y93nstmXAT95Zf030Cc,11350
8
+ eo_tides-0.6.1.dist-info/METADATA,sha256=sl9C1TQIgpC6ZDLeHAJOm0Ea9tyDyZU4zvJg4fd2OBE,8184
9
+ eo_tides-0.6.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ eo_tides-0.6.1.dist-info/top_level.txt,sha256=lXZDUUM1DlLdKWHRn8zdmtW8Rx-eQOIWVvt0b8VGiyQ,9
11
+ eo_tides-0.6.1.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- eo_tides/__init__.py,sha256=pGvVlxMKiYjm_273G-oYcOgVuPra7uEdNZv0oN1i69c,1693
2
- eo_tides/eo.py,sha256=TuFt9SSiO9Z2o8Kr1g-wFPzofp0HTcgkfhT83zu03kc,23983
3
- eo_tides/model.py,sha256=C1KLX-Zd26tghGN-GcOo6J_EXYb6G6LDe_jFgV6dVNM,34697
4
- eo_tides/stats.py,sha256=ELQpqIH86442IYgjrGrIK3mi0-pu2ZijFw53arA2FYg,23072
5
- eo_tides/utils.py,sha256=9xJ1q-b-TVHg5zFyLy6AT_srrPQDvmFdWJmlGSPaJF0,26563
6
- eo_tides/validation.py,sha256=KP8WLT5z7KLFjQ9oDla7VJOyLQAK4SVbcz2ySAbsbwI,11882
7
- eo_tides-0.6.0.dist-info/LICENSE,sha256=owxWsXViCL2J6Ks3XYhot7t4Y93nstmXAT95Zf030Cc,11350
8
- eo_tides-0.6.0.dist-info/METADATA,sha256=nyHw0zHLG-a-gvk4WUf2KHLplabBH12LSN-8uOjTC0M,8152
9
- eo_tides-0.6.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- eo_tides-0.6.0.dist-info/top_level.txt,sha256=lXZDUUM1DlLdKWHRn8zdmtW8Rx-eQOIWVvt0b8VGiyQ,9
11
- eo_tides-0.6.0.dist-info/RECORD,,