eo-tides 0.7.6.dev1__py3-none-any.whl → 0.7.6.dev2__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
@@ -81,13 +81,15 @@ def _model_tides(
81
81
  crop,
82
82
  crop_buffer,
83
83
  append_node,
84
+ extra_databases,
84
85
  ):
85
86
  """Worker function applied in parallel by `model_tides`. Handles the
86
87
  extraction of tide modelling constituents and tide modelling using
87
88
  `pyTMD`.
88
89
  """
89
- # Obtain model details
90
- pytmd_model = pyTMD.io.model(directory).elevation(model)
90
+ # Load models from pyTMD database
91
+ extra_databases = [] if extra_databases is None else extra_databases
92
+ pytmd_model = pyTMD.io.model(directory=directory, extra_databases=extra_databases).elevation(model)
91
93
 
92
94
  # Reproject x, y to latitude/longitude
93
95
  transformer = pyproj.Transformer.from_crs(crs, "EPSG:4326", always_xy=True)
@@ -437,6 +439,7 @@ def model_tides(
437
439
  parallel_splits: int | str = "auto",
438
440
  parallel_max: int | None = None,
439
441
  ensemble_models: list[str] | None = None,
442
+ extra_databases: str | os.PathLike | list | None = None,
440
443
  **ensemble_kwargs,
441
444
  ) -> pd.DataFrame:
442
445
  """
@@ -575,6 +578,11 @@ def model_tides(
575
578
  `["EOT20", "FES2012", "FES2014_extrapolated", "FES2022_extrapolated",
576
579
  "GOT4.10", "GOT5.5_extrapolated", "GOT5.6_extrapolated",
577
580
  "TPXO10-atlas-v2-nc", "TPXO8-atlas-nc", "TPXO9-atlas-v5-nc"]`.
581
+ extra_databases : str or path or list, optional
582
+ Additional custom tide model definitions to load, provided as
583
+ dictionaries or paths to JSON database files. Use this to
584
+ enable custom tide models not included with `pyTMD`.
585
+ See: https://pytmd.readthedocs.io/en/latest/getting_started/Getting-Started.html#model-database
578
586
  **ensemble_kwargs :
579
587
  Keyword arguments used to customise the generation of optional
580
588
  ensemble tide models if "ensemble" modelling are requested.
@@ -621,11 +629,13 @@ def model_tides(
621
629
  # provided, try global environment variable.
622
630
  directory = _set_directory(directory)
623
631
 
624
- # Standardise model list, handling "all" and "ensemble" functionality
632
+ # Standardise model list, handling "all" and "ensemble" functionality,
633
+ # and any custom tide model definitions
625
634
  models_to_process, models_requested, ensemble_models = _standardise_models(
626
635
  model=model,
627
636
  directory=directory,
628
637
  ensemble_models=ensemble_models,
638
+ extra_databases=extra_databases,
629
639
  )
630
640
 
631
641
  # Update tide modelling func to add default keyword arguments that
@@ -642,6 +652,7 @@ def model_tides(
642
652
  crop=crop,
643
653
  crop_buffer=crop_buffer,
644
654
  append_node=append_node,
655
+ extra_databases=extra_databases,
645
656
  )
646
657
 
647
658
  # If automatic parallel splits, calculate optimal value
eo_tides/utils.py CHANGED
@@ -12,11 +12,11 @@ from typing import TypeAlias
12
12
  import numpy as np
13
13
  import odc.geo
14
14
  import pandas as pd
15
+ import pyTMD
15
16
  import xarray as xr
16
17
  from colorama import Style, init
17
18
  from odc.geo.geom import BoundingBox
18
19
  from pyTMD.io.model import load_database
19
- from pyTMD.io.model import model as pytmd_model
20
20
  from scipy.spatial import cKDTree as KDTree
21
21
  from tqdm import tqdm
22
22
 
@@ -80,6 +80,7 @@ def _standardise_models(
80
80
  model: str | list[str],
81
81
  directory: str | os.PathLike,
82
82
  ensemble_models: list[str] | None = None,
83
+ extra_databases: str | os.PathLike | list | None = None,
83
84
  ) -> tuple[list[str], list[str], list[str] | None]:
84
85
  """
85
86
  Take an input model name or list of names, and return a list
@@ -89,7 +90,7 @@ def _standardise_models(
89
90
  Handles two special values passed to `model`: "all", which
90
91
  will model tides for all models available in `directory`, and
91
92
  "ensemble", which will model tides for all models in a list
92
- of custom ensemble models.
93
+ of ensemble models.
93
94
  """
94
95
 
95
96
  # Turn inputs into arrays for consistent handling
@@ -100,9 +101,13 @@ def _standardise_models(
100
101
  if len(duplicates) > 0:
101
102
  raise ValueError(f"The model parameter contains duplicate values: {duplicates}")
102
103
 
103
- # Get full list of supported models from pyTMD database
104
+ # Load supported models from pyTMD database
104
105
  available_models, valid_models = list_models(
105
- directory, show_available=False, show_supported=False, raise_error=True
106
+ directory,
107
+ show_available=False,
108
+ show_supported=False,
109
+ raise_error=True,
110
+ extra_databases=extra_databases,
106
111
  )
107
112
  custom_options = ["ensemble", "all"]
108
113
 
@@ -433,8 +438,10 @@ def clip_models(
433
438
  nc_clipped.to_netcdf(output_directory / file, mode="w")
434
439
 
435
440
  # Verify that models are ready
436
- pytmd_model(directory=output_directory).elevation(m=m).verify
437
- print(" ✅ Clipped model exported and verified")
441
+ if pyTMD.io.model(directory=output_directory).elevation(m=m).verify:
442
+ print(" ✅ Clipped model exported and verified")
443
+ else:
444
+ print(" ❌ Clipped model exported but unable to be verified")
438
445
 
439
446
  print(f"\nOutputs exported to {output_directory}")
440
447
  list_models(directory=output_directory, show_available=True, show_supported=False)
@@ -445,6 +452,7 @@ def list_models(
445
452
  show_available: bool = True,
446
453
  show_supported: bool = True,
447
454
  raise_error: bool = False,
455
+ extra_databases: str | os.PathLike | list | None = None,
448
456
  ) -> tuple[list[str], list[str]]:
449
457
  """
450
458
  List all tide models available for tide modelling.
@@ -474,6 +482,11 @@ def list_models(
474
482
  raise_error : bool, optional
475
483
  If True, raise an error if no available models are found.
476
484
  If False, raise a warning.
485
+ extra_databases : str or path or list, optional
486
+ Additional custom tide model definitions to load, provided as
487
+ dictionaries or paths to JSON database files. Use this to
488
+ enable custom tide models not included with `pyTMD`.
489
+ See: https://pytmd.readthedocs.io/en/latest/getting_started/Getting-Started.html#model-database
477
490
 
478
491
  Returns
479
492
  -------
@@ -488,8 +501,11 @@ def list_models(
488
501
  # provided, try global environment variable.
489
502
  directory = _set_directory(directory)
490
503
 
491
- # Get full list of supported models from pyTMD database
492
- model_database = load_database()["elevation"]
504
+ # Load supported models from pyTMD database, adding extras if required
505
+ extra_databases = [] if extra_databases is None else extra_databases
506
+ model_database = load_database(extra_databases=extra_databases)["elevation"]
507
+
508
+ # Get full list of supported models
493
509
  supported_models = list(model_database.keys())
494
510
 
495
511
  # Extract expected model paths
@@ -503,7 +519,7 @@ def list_models(
503
519
  else:
504
520
  model_file = model_file[0] if isinstance(model_file, list) else model_file
505
521
 
506
- # Add path to dict
522
+ # Add expected path to dict, adding directory prefix
507
523
  expected_paths[m] = str(directory / pathlib.Path(model_file).expanduser().parent)
508
524
 
509
525
  # Define column widths
@@ -522,13 +538,17 @@ def list_models(
522
538
  available_models = []
523
539
  for m in supported_models:
524
540
  try:
525
- model_file = pytmd_model(directory=directory).elevation(m=m)
541
+ # Load model
542
+ model_file = pyTMD.io.model(directory=directory, extra_databases=extra_databases).elevation(m=m)
543
+
544
+ # Append model to list of available model
526
545
  available_models.append(m)
527
546
 
528
547
  if show_available:
529
548
  # Mark available models with a green tick
530
549
  status = "✅"
531
550
  print(f"{status:^{status_width}}│ {m:<{name_width}} │ {expected_paths[m]:<{path_width}}")
551
+
532
552
  except FileNotFoundError:
533
553
  if show_supported:
534
554
  # Mark unavailable models with a red cross
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eo-tides
3
- Version: 0.7.6.dev1
3
+ Version: 0.7.6.dev2
4
4
  Summary: Tide modelling tools for large-scale satellite earth observation analysis
5
5
  Project-URL: Homepage, https://GeoscienceAustralia.github.io/eo-tides/
6
6
  Project-URL: Repository, https://github.com/GeoscienceAustralia/eo-tides
@@ -32,7 +32,7 @@ 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.5,>=2.2.2
35
+ Requires-Dist: pytmd>=2.2.5
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
@@ -0,0 +1,10 @@
1
+ eo_tides/__init__.py,sha256=LLvX-IipE209LbYLObShRLO5vxQQYBaIP1d3TMHix24,1802
2
+ eo_tides/eo.py,sha256=geXMd9roM7UmZCHK7l7bUUXai2pXGDJdzgAw4GBJ_58,23944
3
+ eo_tides/model.py,sha256=RrR6552FDF3ZzYD38q_1J8uJo8nLAh2HUrrPoXxr6ic,38169
4
+ eo_tides/stats.py,sha256=lvl9-0k20ffLQh8Y1kAC_afhjQviK11_3_saRUtX3ws,23009
5
+ eo_tides/utils.py,sha256=TjAT7LcUqf4hIKXG724wcKhzXdWz-YRrZI9drax4JjU,27523
6
+ eo_tides/validation.py,sha256=6ugPwhNglIovOVTaozZnAiLaIBqU5acOiVmFPHvFDHE,12657
7
+ eo_tides-0.7.6.dev2.dist-info/METADATA,sha256=_A6NXJ50Dnuf7oVhtHyCqRtIoukeiNzOYb0zhePDwvc,9319
8
+ eo_tides-0.7.6.dev2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ eo_tides-0.7.6.dev2.dist-info/licenses/LICENSE,sha256=owxWsXViCL2J6Ks3XYhot7t4Y93nstmXAT95Zf030Cc,11350
10
+ eo_tides-0.7.6.dev2.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- eo_tides/__init__.py,sha256=LLvX-IipE209LbYLObShRLO5vxQQYBaIP1d3TMHix24,1802
2
- eo_tides/eo.py,sha256=geXMd9roM7UmZCHK7l7bUUXai2pXGDJdzgAw4GBJ_58,23944
3
- eo_tides/model.py,sha256=SWqBr0ajin1gw37nYa8ukHHzeiebK5h8XvkXO9LMX4E,37480
4
- eo_tides/stats.py,sha256=lvl9-0k20ffLQh8Y1kAC_afhjQviK11_3_saRUtX3ws,23009
5
- eo_tides/utils.py,sha256=wfzJFjWrJVgN8TqRqvwE8Tbtb2WPUQRwmCsihb5j3jc,26625
6
- eo_tides/validation.py,sha256=6ugPwhNglIovOVTaozZnAiLaIBqU5acOiVmFPHvFDHE,12657
7
- eo_tides-0.7.6.dev1.dist-info/METADATA,sha256=Xv-Yg8N-7ZY6DljJFXro-w6JjUEAK75SszzogU_wHNE,9326
8
- eo_tides-0.7.6.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- eo_tides-0.7.6.dev1.dist-info/licenses/LICENSE,sha256=owxWsXViCL2J6Ks3XYhot7t4Y93nstmXAT95Zf030Cc,11350
10
- eo_tides-0.7.6.dev1.dist-info/RECORD,,