roms-tools 3.3.0__py3-none-any.whl → 3.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.
- roms_tools/__init__.py +1 -1
- roms_tools/analysis/cdr_ensemble.py +10 -13
- roms_tools/analysis/roms_output.py +5 -304
- roms_tools/{download.py → datasets/download.py} +1 -0
- roms_tools/{setup → datasets}/lat_lon_datasets.py +76 -64
- roms_tools/{setup → datasets}/river_datasets.py +9 -4
- roms_tools/datasets/roms_dataset.py +767 -0
- roms_tools/datasets/utils.py +475 -0
- roms_tools/{setup/fill.py → fill.py} +110 -13
- roms_tools/plot.py +4 -4
- roms_tools/setup/boundary_forcing.py +51 -43
- roms_tools/setup/cdr_release.py +2 -4
- roms_tools/setup/grid.py +29 -12
- roms_tools/setup/initial_conditions.py +19 -19
- roms_tools/setup/nesting.py +8 -4
- roms_tools/setup/river_forcing.py +4 -4
- roms_tools/setup/surface_forcing.py +14 -9
- roms_tools/setup/tides.py +1 -1
- roms_tools/setup/topography.py +10 -2
- roms_tools/setup/utils.py +72 -524
- roms_tools/tests/test_analysis/test_cdr_ensemble.py +4 -6
- roms_tools/tests/test_analysis/test_roms_output.py +1 -220
- roms_tools/tests/{test_setup → test_datasets}/test_lat_lon_datasets.py +4 -4
- roms_tools/tests/{test_setup → test_datasets}/test_river_datasets.py +1 -1
- roms_tools/tests/test_datasets/test_roms_dataset.py +539 -0
- roms_tools/tests/test_datasets/test_utils.py +527 -0
- roms_tools/tests/{test_setup/test_fill.py → test_fill.py} +72 -9
- roms_tools/tests/test_setup/test_boundary_forcing.py +57 -138
- roms_tools/tests/test_setup/test_cdr_release.py +4 -5
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zarr.json +293 -2021
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/zarr.json +294 -2022
- roms_tools/tests/test_setup/test_grid.py +42 -1
- roms_tools/tests/test_setup/test_initial_conditions.py +3 -94
- roms_tools/tests/test_setup/test_nesting.py +2 -1
- roms_tools/tests/test_setup/test_surface_forcing.py +1 -1
- roms_tools/tests/test_setup/test_tides.py +1 -1
- roms_tools/tests/test_setup/test_utils.py +100 -15
- roms_tools/tests/test_tiling/test_partition.py +63 -15
- roms_tools/tests/test_utils.py +78 -0
- roms_tools/tiling/partition.py +81 -211
- roms_tools/utils.py +193 -0
- {roms_tools-3.3.0.dist-info → roms_tools-3.4.0.dist-info}/METADATA +1 -1
- {roms_tools-3.3.0.dist-info → roms_tools-3.4.0.dist-info}/RECORD +46 -170
- {roms_tools-3.3.0.dist-info → roms_tools-3.4.0.dist-info}/WHEEL +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_ALT_CO2_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_ALT_CO2_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOCr_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DON_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DON_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DONr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DONr_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOPr_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Fe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Fe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Lig_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Lig_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NH4_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NH4_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NO3_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/O2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/O2_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/PO4_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/PO4_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/SiO3_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatChl_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatFe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatSi_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazChl_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazFe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spC_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spCaCO3_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spChl_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spFe_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spP_west/zarr.json +0 -54
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/zooC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/zooC_west/zarr.json +0 -54
- {roms_tools-3.3.0.dist-info → roms_tools-3.4.0.dist-info}/licenses/LICENSE +0 -0
- {roms_tools-3.3.0.dist-info → roms_tools-3.4.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
from datetime import datetime
|
|
4
1
|
from pathlib import Path
|
|
5
2
|
|
|
6
3
|
import matplotlib.pyplot as plt
|
|
@@ -9,7 +6,7 @@ import pytest
|
|
|
9
6
|
import xarray as xr
|
|
10
7
|
|
|
11
8
|
from roms_tools import Grid, ROMSOutput
|
|
12
|
-
from roms_tools.download import download_test_data
|
|
9
|
+
from roms_tools.datasets.download import download_test_data
|
|
13
10
|
|
|
14
11
|
try:
|
|
15
12
|
import xesmf # type: ignore
|
|
@@ -58,20 +55,6 @@ def roms_output_from_restart_file_with_straddling_grid(use_dask):
|
|
|
58
55
|
)
|
|
59
56
|
|
|
60
57
|
|
|
61
|
-
@pytest.mark.parametrize(
|
|
62
|
-
"roms_output_fixture",
|
|
63
|
-
[
|
|
64
|
-
"roms_output_from_restart_file",
|
|
65
|
-
"roms_output_from_restart_file_adjusted_for_zeta",
|
|
66
|
-
"roms_output_from_restart_file_with_straddling_grid",
|
|
67
|
-
],
|
|
68
|
-
)
|
|
69
|
-
def test_load_model_output_file(roms_output_fixture, request):
|
|
70
|
-
roms_output = request.getfixturevalue(roms_output_fixture)
|
|
71
|
-
|
|
72
|
-
assert isinstance(roms_output.ds, xr.Dataset)
|
|
73
|
-
|
|
74
|
-
|
|
75
58
|
@pytest.fixture
|
|
76
59
|
def roms_output_from_two_restart_files(use_dask):
|
|
77
60
|
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
@@ -83,208 +66,6 @@ def roms_output_from_two_restart_files(use_dask):
|
|
|
83
66
|
return ROMSOutput(grid=grid, path=[file1, file2], use_dask=use_dask)
|
|
84
67
|
|
|
85
68
|
|
|
86
|
-
def test_load_model_output_file_list(roms_output_from_two_restart_files):
|
|
87
|
-
assert isinstance(roms_output_from_two_restart_files.ds, xr.Dataset)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def test_load_model_output_with_wildcard(use_dask):
|
|
91
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
92
|
-
grid = Grid.from_file(fname_grid)
|
|
93
|
-
|
|
94
|
-
# Download at least two files, so these will be found within the pooch directory
|
|
95
|
-
Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
|
|
96
|
-
Path(download_test_data("eastpac25km_rst.19980126000000.nc"))
|
|
97
|
-
directory = Path(
|
|
98
|
-
os.path.dirname(download_test_data("eastpac25km_rst.19980106000000.nc"))
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
output = ROMSOutput(grid=grid, path=directory / "*rst*.nc", use_dask=use_dask)
|
|
102
|
-
assert isinstance(output.ds, xr.Dataset)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def test_invalid_path(use_dask):
|
|
106
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
107
|
-
grid = Grid.from_file(fname_grid)
|
|
108
|
-
|
|
109
|
-
# Non-existent file
|
|
110
|
-
with pytest.raises(FileNotFoundError):
|
|
111
|
-
ROMSOutput(
|
|
112
|
-
grid=grid,
|
|
113
|
-
path=Path("/path/to/nonexistent/file.nc"),
|
|
114
|
-
use_dask=use_dask,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def test_set_correct_model_reference_date(use_dask):
|
|
119
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
120
|
-
grid = Grid.from_file(fname_grid)
|
|
121
|
-
|
|
122
|
-
output = ROMSOutput(
|
|
123
|
-
grid=grid,
|
|
124
|
-
path=Path(download_test_data("eastpac25km_rst.19980106000000.nc")),
|
|
125
|
-
use_dask=use_dask,
|
|
126
|
-
)
|
|
127
|
-
assert output.model_reference_date == datetime(1995, 1, 1)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def test_model_reference_date_mismatch(use_dask):
|
|
131
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
132
|
-
grid = Grid.from_file(fname_grid)
|
|
133
|
-
|
|
134
|
-
# Create a ROMSOutput with a specified model_reference_date
|
|
135
|
-
model_ref_date = datetime(2020, 1, 1)
|
|
136
|
-
with pytest.raises(
|
|
137
|
-
ValueError, match="Mismatch between `self.model_reference_date`"
|
|
138
|
-
):
|
|
139
|
-
ROMSOutput(
|
|
140
|
-
grid=grid,
|
|
141
|
-
path=Path(download_test_data("eastpac25km_rst.19980106000000.nc")),
|
|
142
|
-
model_reference_date=model_ref_date,
|
|
143
|
-
use_dask=use_dask,
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def test_model_reference_date_no_metadata(use_dask, tmp_path, caplog):
|
|
148
|
-
# Helper function to handle the test logic for cases where metadata is missing or invalid
|
|
149
|
-
def test_no_metadata(faulty_ocean_time_attr, expected_exception, log_message=None):
|
|
150
|
-
ds = xr.open_dataset(fname)
|
|
151
|
-
ds["ocean_time"].attrs = faulty_ocean_time_attr
|
|
152
|
-
|
|
153
|
-
# Write modified dataset to a new file
|
|
154
|
-
fname_mod = tmp_path / "eastpac25km_rst.19980106000000_without_metadata.nc"
|
|
155
|
-
ds.to_netcdf(fname_mod)
|
|
156
|
-
|
|
157
|
-
# Test case 1: Expecting a ValueError when metadata is missing or invalid
|
|
158
|
-
with pytest.raises(
|
|
159
|
-
expected_exception,
|
|
160
|
-
match="Model reference date could not be inferred from the metadata",
|
|
161
|
-
):
|
|
162
|
-
ROMSOutput(grid=grid, path=fname_mod, use_dask=use_dask)
|
|
163
|
-
|
|
164
|
-
# Test case 2: When a model reference date is explicitly set, verify the warning
|
|
165
|
-
with caplog.at_level(logging.WARNING):
|
|
166
|
-
ROMSOutput(
|
|
167
|
-
grid=grid,
|
|
168
|
-
path=fname_mod,
|
|
169
|
-
model_reference_date=datetime(1995, 1, 1),
|
|
170
|
-
use_dask=use_dask,
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
if log_message:
|
|
174
|
-
# Verify the warning message in the log
|
|
175
|
-
assert log_message in caplog.text
|
|
176
|
-
|
|
177
|
-
fname_mod.unlink()
|
|
178
|
-
|
|
179
|
-
# Load grid and test data
|
|
180
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
181
|
-
grid = Grid.from_file(fname_grid)
|
|
182
|
-
fname = download_test_data("eastpac25km_rst.19980106000000.nc")
|
|
183
|
-
|
|
184
|
-
# Test 1: Ocean time attribute 'long_name' is missing
|
|
185
|
-
test_no_metadata({}, ValueError)
|
|
186
|
-
|
|
187
|
-
# Test 2: Ocean time attribute 'long_name' contains invalid information
|
|
188
|
-
test_no_metadata(
|
|
189
|
-
{"long_name": "some random text"},
|
|
190
|
-
ValueError,
|
|
191
|
-
"Could not infer the model reference date from the metadata.",
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
def test_compute_depth_coordinates(use_dask):
|
|
196
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
197
|
-
grid = Grid.from_file(fname_grid)
|
|
198
|
-
fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
|
|
199
|
-
|
|
200
|
-
for adjust_depth_for_sea_surface_height in [True, False]:
|
|
201
|
-
output = ROMSOutput(
|
|
202
|
-
grid=grid,
|
|
203
|
-
path=fname_restart1,
|
|
204
|
-
use_dask=use_dask,
|
|
205
|
-
adjust_depth_for_sea_surface_height=adjust_depth_for_sea_surface_height,
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
# Before calling get_vertical_coordinates, check if the dataset doesn't already have depth coordinates
|
|
209
|
-
assert "layer_depth_rho" not in output.ds_depth_coords.data_vars
|
|
210
|
-
|
|
211
|
-
# Call the method to get vertical coordinates
|
|
212
|
-
output._get_depth_coordinates(depth_type="layer")
|
|
213
|
-
|
|
214
|
-
# Check if the depth coordinates were added
|
|
215
|
-
assert "layer_depth_rho" in output.ds_depth_coords.data_vars
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
def test_missing_zeta_gets_raised(use_dask):
|
|
219
|
-
"""Test that a ValueError is raised when `zeta` is missing from the dataset and
|
|
220
|
-
`adjust_depth_for_sea_surface_height` is enabled.
|
|
221
|
-
"""
|
|
222
|
-
# Load the grid
|
|
223
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
224
|
-
grid = Grid.from_file(fname_grid)
|
|
225
|
-
|
|
226
|
-
# Load the ROMS output
|
|
227
|
-
fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
|
|
228
|
-
roms_output = ROMSOutput(
|
|
229
|
-
grid=grid,
|
|
230
|
-
path=fname_restart1,
|
|
231
|
-
use_dask=use_dask,
|
|
232
|
-
adjust_depth_for_sea_surface_height=True,
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
# Remove `zeta` from the dataset
|
|
236
|
-
object.__setattr__(
|
|
237
|
-
roms_output, "ds", roms_output.ds.drop_vars("zeta", errors="ignore")
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
# Expect ValueError when calling `_get_depth_coordinates`
|
|
241
|
-
with pytest.raises(
|
|
242
|
-
ValueError,
|
|
243
|
-
match="`zeta` is required in provided ROMS output when `adjust_depth_for_sea_surface_height` is enabled.",
|
|
244
|
-
):
|
|
245
|
-
roms_output._get_depth_coordinates()
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
def test_check_vertical_coordinate_mismatch(use_dask):
|
|
249
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
250
|
-
grid = Grid.from_file(fname_grid)
|
|
251
|
-
|
|
252
|
-
fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
|
|
253
|
-
output = ROMSOutput(grid=grid, path=fname_restart1, use_dask=use_dask)
|
|
254
|
-
|
|
255
|
-
# create a mock dataset with inconsistent vertical coordinate parameters
|
|
256
|
-
ds_mock = output.ds.copy()
|
|
257
|
-
|
|
258
|
-
# Modify one of the vertical coordinate attributes to cause a mismatch
|
|
259
|
-
ds_mock.attrs["theta_s"] = 999
|
|
260
|
-
|
|
261
|
-
# Check if ValueError is raised due to mismatch
|
|
262
|
-
with pytest.raises(ValueError, match="theta_s from grid"):
|
|
263
|
-
output._check_vertical_coordinate(ds_mock)
|
|
264
|
-
|
|
265
|
-
# create a mock dataset with inconsistent vertical coordinate parameters
|
|
266
|
-
ds_mock = output.ds.copy()
|
|
267
|
-
|
|
268
|
-
# Modify one of the vertical coordinate attributes to cause a mismatch
|
|
269
|
-
ds_mock.attrs["Cs_w"] = ds_mock.attrs["Cs_w"] + 0.01
|
|
270
|
-
|
|
271
|
-
# Check if ValueError is raised due to mismatch
|
|
272
|
-
with pytest.raises(ValueError, match="Cs_w from grid"):
|
|
273
|
-
output._check_vertical_coordinate(ds_mock)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
def test_that_coordinates_are_added(use_dask):
|
|
277
|
-
fname_grid = Path(download_test_data("epac25km_grd.nc"))
|
|
278
|
-
grid = Grid.from_file(fname_grid)
|
|
279
|
-
|
|
280
|
-
fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
|
|
281
|
-
output = ROMSOutput(grid=grid, path=fname_restart1, use_dask=use_dask)
|
|
282
|
-
|
|
283
|
-
assert "abs_time" in output.ds.coords
|
|
284
|
-
assert "lat_rho" in output.ds.coords
|
|
285
|
-
assert "lon_rho" in output.ds.coords
|
|
286
|
-
|
|
287
|
-
|
|
288
69
|
@pytest.mark.parametrize(
|
|
289
70
|
"roms_output_fixture",
|
|
290
71
|
[
|
|
@@ -8,8 +8,8 @@ import numpy as np
|
|
|
8
8
|
import pytest
|
|
9
9
|
import xarray as xr
|
|
10
10
|
|
|
11
|
-
from roms_tools.download import download_test_data
|
|
12
|
-
from roms_tools.
|
|
11
|
+
from roms_tools.datasets.download import download_test_data
|
|
12
|
+
from roms_tools.datasets.lat_lon_datasets import (
|
|
13
13
|
GLORYS_GLOBAL_GRID_PATH,
|
|
14
14
|
CESMBGCDataset,
|
|
15
15
|
ERA5ARCODataset,
|
|
@@ -604,14 +604,14 @@ def test_data_concatenation(use_dask):
|
|
|
604
604
|
def test_time_validation(use_dask):
|
|
605
605
|
fname = download_test_data("GLORYS_NA_2012.nc")
|
|
606
606
|
|
|
607
|
-
with pytest.raises(TypeError, match="start_time must be a datetime object"):
|
|
607
|
+
with pytest.raises(TypeError, match="`start_time` must be a datetime object"):
|
|
608
608
|
GLORYSDataset(
|
|
609
609
|
filename=fname,
|
|
610
610
|
start_time="dummy",
|
|
611
611
|
end_time=datetime(2013, 1, 1),
|
|
612
612
|
use_dask=use_dask,
|
|
613
613
|
)
|
|
614
|
-
with pytest.raises(TypeError, match="end_time must be a datetime object"):
|
|
614
|
+
with pytest.raises(TypeError, match="`end_time` must be a datetime object"):
|
|
615
615
|
GLORYSDataset(
|
|
616
616
|
filename=fname,
|
|
617
617
|
start_time=datetime(2012, 1, 1),
|