roms-tools 2.3.0__py3-none-any.whl → 2.5.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.
- ci/environment.yml +1 -0
- roms_tools/__init__.py +2 -1
- roms_tools/analysis/roms_output.py +81 -98
- roms_tools/plot.py +4 -2
- roms_tools/setup/boundary_forcing.py +207 -208
- roms_tools/setup/datasets.py +149 -33
- roms_tools/setup/grid.py +35 -102
- roms_tools/setup/initial_conditions.py +179 -132
- roms_tools/setup/nesting.py +239 -86
- roms_tools/setup/river_forcing.py +266 -128
- roms_tools/setup/surface_forcing.py +137 -76
- roms_tools/setup/tides.py +10 -36
- roms_tools/setup/topography.py +25 -2
- roms_tools/setup/utils.py +52 -82
- roms_tools/tests/test_analysis/test_roms_output.py +233 -70
- roms_tools/tests/test_setup/test_boundary_forcing.py +283 -57
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +3 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +3 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zmetadata +8 -7
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/abs_time/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/dust/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/dust_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/iron/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/iron_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nhy/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nhy_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nox/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nox_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air_alt/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +2 -2
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zattrs +5 -3
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zmetadata +156 -121
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/.zarray +2 -2
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/.zattrs +2 -1
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/bry_time/.zarray +2 -2
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/bry_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/bry_time/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +2 -2
- roms_tools/tests/test_setup/test_data/grid.zarr/angle/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/angle_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/f/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/h/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/h/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_rho/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/pm/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +4 -4
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +4 -4
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/f/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_rho/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_rho/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_rho/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pm/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pn/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zattrs +2 -1
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zmetadata +6 -4
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Cs_r/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Cs_w/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/abs_time/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ocean_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zeta/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zmetadata +56 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/.zmetadata +56 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/0.0 +0 -0
- roms_tools/tests/test_setup/test_grid.py +0 -13
- roms_tools/tests/test_setup/test_initial_conditions.py +220 -66
- roms_tools/tests/test_setup/test_nesting.py +139 -118
- roms_tools/tests/test_setup/test_river_forcing.py +583 -293
- roms_tools/tests/test_setup/test_surface_forcing.py +149 -73
- roms_tools/tests/test_setup/test_tides.py +4 -16
- roms_tools/tests/test_setup/test_utils.py +1 -0
- roms_tools/tests/test_setup/test_validation.py +34 -2
- roms_tools/tests/{test_utils.py → test_tiling/test_partition.py} +1 -1
- roms_tools/tiling/partition.py +338 -0
- roms_tools/utils.py +66 -333
- roms_tools/vertical_coordinate.py +54 -133
- {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/METADATA +1 -1
- {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/RECORD +303 -290
- {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/WHEEL +1 -1
- {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/LICENSE +0 -0
- {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/top_level.txt +0 -0
roms_tools/setup/datasets.py
CHANGED
|
@@ -35,10 +35,11 @@ class Dataset:
|
|
|
35
35
|
The path to the data file(s). Can be a single string (with or without wildcards), a single Path object,
|
|
36
36
|
or a list of strings or Path objects containing multiple files.
|
|
37
37
|
start_time : Optional[datetime], optional
|
|
38
|
-
|
|
38
|
+
Start time for selecting relevant data. If not provided, no time-based filtering is applied.
|
|
39
39
|
end_time : Optional[datetime], optional
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
End time for selecting relevant data. If not provided, the dataset selects the time entry
|
|
41
|
+
closest to `start_time` within the range `[start_time, start_time + 24 hours]`.
|
|
42
|
+
If `start_time` is also not provided, no time-based filtering is applied.
|
|
42
43
|
dim_names: Dict[str, str], optional
|
|
43
44
|
Dictionary specifying the names of dimensions in the dataset.
|
|
44
45
|
var_names: Dict[str, str]
|
|
@@ -355,6 +356,47 @@ class Dataset:
|
|
|
355
356
|
# Set the computed resolution as an attribute
|
|
356
357
|
object.__setattr__(self, "resolution", resolution)
|
|
357
358
|
|
|
359
|
+
def compute_minimal_grid_spacing(self, ds: xr.Dataset):
|
|
360
|
+
"""Compute the minimal grid spacing in a dataset based on latitude and longitude
|
|
361
|
+
spacing, considering Earth's radius.
|
|
362
|
+
|
|
363
|
+
Parameters
|
|
364
|
+
----------
|
|
365
|
+
ds : xr.Dataset
|
|
366
|
+
Dataset containing latitude and longitude dimensions.
|
|
367
|
+
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
minimal_spacing : float
|
|
371
|
+
The smallest horizontal grid spacing derived from the latitude
|
|
372
|
+
and longitude differences, in meters.
|
|
373
|
+
"""
|
|
374
|
+
|
|
375
|
+
r_earth = 6371315.0
|
|
376
|
+
lat_dim = self.dim_names["latitude"]
|
|
377
|
+
lon_dim = self.dim_names["longitude"]
|
|
378
|
+
|
|
379
|
+
# Get latitude and longitude values from the dataset
|
|
380
|
+
latitudes = ds[lat_dim].values
|
|
381
|
+
longitudes = ds[lon_dim].values
|
|
382
|
+
|
|
383
|
+
# Compute differences along latitude and longitude
|
|
384
|
+
lat_diff = np.abs(np.diff(latitudes)).min() # Minimal latitude spacing
|
|
385
|
+
lon_diff = np.abs(np.diff(longitudes)).min() # Minimal longitude spacing
|
|
386
|
+
|
|
387
|
+
# Latitude spacing is constant at all longitudes
|
|
388
|
+
min_lat_spacing = (2 * np.pi * r_earth * lat_diff) / 360
|
|
389
|
+
|
|
390
|
+
# Longitude spacing varies with latitude
|
|
391
|
+
min_lon_spacing = (
|
|
392
|
+
2 * np.pi * r_earth * lon_diff * np.cos(np.radians(latitudes.min()))
|
|
393
|
+
) / 360
|
|
394
|
+
|
|
395
|
+
# The minimal spacing is the smaller of the two
|
|
396
|
+
minimal_spacing = min(min_lat_spacing, min_lon_spacing)
|
|
397
|
+
|
|
398
|
+
return minimal_spacing
|
|
399
|
+
|
|
358
400
|
def check_if_global(self, ds) -> bool:
|
|
359
401
|
"""Checks if the dataset covers the entire globe in the longitude dimension.
|
|
360
402
|
|
|
@@ -469,8 +511,32 @@ class Dataset:
|
|
|
469
511
|
"""
|
|
470
512
|
pass
|
|
471
513
|
|
|
514
|
+
def convert_to_float64(self) -> None:
|
|
515
|
+
"""Convert all data variables in the dataset to float64.
|
|
516
|
+
|
|
517
|
+
This method updates the dataset by converting all of its data variables to the
|
|
518
|
+
`float64` data type, ensuring consistency for numerical operations that require
|
|
519
|
+
high precision. The dataset is modified in place.
|
|
520
|
+
|
|
521
|
+
Parameters
|
|
522
|
+
----------
|
|
523
|
+
None
|
|
524
|
+
|
|
525
|
+
Returns
|
|
526
|
+
-------
|
|
527
|
+
None
|
|
528
|
+
This method modifies the dataset in place and does not return anything.
|
|
529
|
+
"""
|
|
530
|
+
ds = self.ds.astype({var: "float64" for var in self.ds.data_vars})
|
|
531
|
+
object.__setattr__(self, "ds", ds)
|
|
532
|
+
|
|
472
533
|
def choose_subdomain(
|
|
473
|
-
self,
|
|
534
|
+
self,
|
|
535
|
+
target_coords,
|
|
536
|
+
buffer_points=20,
|
|
537
|
+
return_copy=False,
|
|
538
|
+
return_coords_only=False,
|
|
539
|
+
verbose=False,
|
|
474
540
|
):
|
|
475
541
|
"""Selects a subdomain from the xarray Dataset based on specified target
|
|
476
542
|
coordinates, extending the selection by a defined buffer. Adjusts longitude
|
|
@@ -488,6 +554,9 @@ class Dataset:
|
|
|
488
554
|
return_subdomain : bool, optional
|
|
489
555
|
If True, returns the subset of the original dataset representing the chosen
|
|
490
556
|
subdomain. If False, assigns the subset to `self.ds`. Defaults to False.
|
|
557
|
+
return_coords_only : bool, optional
|
|
558
|
+
If True, returns a new xarray.Dataset containing only the latitude and longitude
|
|
559
|
+
of the subdomain. Defaults to False.
|
|
491
560
|
verbose : bool, optional
|
|
492
561
|
If True, print message if dataset is concatenated along longitude dimension.
|
|
493
562
|
Defaults to False.
|
|
@@ -592,6 +661,13 @@ class Dataset:
|
|
|
592
661
|
else:
|
|
593
662
|
subdomain[self.dim_names["longitude"]] = xr.where(lon < 0, lon + 360, lon)
|
|
594
663
|
|
|
664
|
+
if return_coords_only:
|
|
665
|
+
# Create and return a dataset with only latitudes and longitudes
|
|
666
|
+
coords_ds = subdomain[
|
|
667
|
+
[self.dim_names["latitude"], self.dim_names["longitude"]]
|
|
668
|
+
]
|
|
669
|
+
return coords_ds
|
|
670
|
+
|
|
595
671
|
if return_copy:
|
|
596
672
|
return Dataset.from_ds(self, subdomain)
|
|
597
673
|
else:
|
|
@@ -1787,15 +1863,10 @@ class RiverDataset:
|
|
|
1787
1863
|
|
|
1788
1864
|
Returns
|
|
1789
1865
|
-------
|
|
1790
|
-
indices : dict
|
|
1866
|
+
indices : dict[str, list[tuple]]
|
|
1791
1867
|
A dictionary containing the indices of the rivers that are within the threshold distance from
|
|
1792
|
-
the target coordinates. The dictionary keys
|
|
1793
|
-
|
|
1794
|
-
The indices of the rivers that satisfy the distance threshold.
|
|
1795
|
-
- "eta_rho" : numpy.ndarray
|
|
1796
|
-
The indices of the `eta_rho` dimension corresponding to the selected stations.
|
|
1797
|
-
- "xi_rho" : numpy.ndarray
|
|
1798
|
-
The indices of the `xi_rho` dimension corresponding to the selected stations.
|
|
1868
|
+
the target coordinates. The dictionary structure consists of river names as keys, and each value is a list of tuples. Each tuple represents
|
|
1869
|
+
a pair of indices corresponding to the `eta_rho` and `xi_rho` grid coordinates of the river.
|
|
1799
1870
|
"""
|
|
1800
1871
|
|
|
1801
1872
|
# Retrieve longitude and latitude of river mouths
|
|
@@ -1822,30 +1893,75 @@ class RiverDataset:
|
|
|
1822
1893
|
|
|
1823
1894
|
# Find the indices of the closest grid cell to the river mouth
|
|
1824
1895
|
indices = np.where(dist == dist_min)
|
|
1896
|
+
stations = indices[0]
|
|
1897
|
+
eta_rho_values = indices[1]
|
|
1898
|
+
xi_rho_values = indices[2]
|
|
1825
1899
|
names = (
|
|
1826
|
-
|
|
1827
|
-
.isel({self.dim_names["station"]:
|
|
1900
|
+
ds[self.var_names["name"]]
|
|
1901
|
+
.isel({self.dim_names["station"]: stations})
|
|
1828
1902
|
.values
|
|
1829
1903
|
)
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
}
|
|
1904
|
+
river_indices = {}
|
|
1905
|
+
for i in range(len(stations)):
|
|
1906
|
+
river_name = names[i]
|
|
1907
|
+
river_indices[river_name] = [
|
|
1908
|
+
(int(eta_rho_values[i]), int(xi_rho_values[i]))
|
|
1909
|
+
] # list of tuples
|
|
1837
1910
|
else:
|
|
1838
1911
|
ds = xr.Dataset()
|
|
1839
|
-
|
|
1840
|
-
"station": [],
|
|
1841
|
-
"eta_rho": [],
|
|
1842
|
-
"xi_rho": [],
|
|
1843
|
-
"name": [],
|
|
1844
|
-
}
|
|
1912
|
+
river_indices = {}
|
|
1845
1913
|
|
|
1846
1914
|
object.__setattr__(self, "ds", ds)
|
|
1847
1915
|
|
|
1848
|
-
return
|
|
1916
|
+
return river_indices
|
|
1917
|
+
|
|
1918
|
+
def extract_named_rivers(self, indices):
|
|
1919
|
+
"""Extracts a subset of the dataset based on the provided river names in the
|
|
1920
|
+
indices dictionary.
|
|
1921
|
+
|
|
1922
|
+
This method filters the dataset to include only the rivers specified in the `indices` dictionary.
|
|
1923
|
+
The resulting subset is stored in the `ds` attribute of the class.
|
|
1924
|
+
|
|
1925
|
+
Parameters
|
|
1926
|
+
----------
|
|
1927
|
+
indices : dict
|
|
1928
|
+
A dictionary where the keys are river names (strings) and the values are dictionaries
|
|
1929
|
+
containing river-related data (e.g., river indices, coordinates).
|
|
1930
|
+
|
|
1931
|
+
Returns
|
|
1932
|
+
-------
|
|
1933
|
+
None
|
|
1934
|
+
The method modifies the `self.ds` attribute in place, setting it to the filtered dataset
|
|
1935
|
+
containing only the data related to the specified rivers.
|
|
1936
|
+
|
|
1937
|
+
Raises
|
|
1938
|
+
------
|
|
1939
|
+
ValueError
|
|
1940
|
+
- If `indices` is not a dictionary.
|
|
1941
|
+
- If any of the requested river names are not found in the dataset.
|
|
1942
|
+
"""
|
|
1943
|
+
|
|
1944
|
+
if not isinstance(indices, dict):
|
|
1945
|
+
raise ValueError("`indices` must be a dictionary.")
|
|
1946
|
+
|
|
1947
|
+
river_names = list(indices.keys())
|
|
1948
|
+
|
|
1949
|
+
# Ensure the dataset is filtered based on the provided river names
|
|
1950
|
+
ds_filtered = self.ds.where(
|
|
1951
|
+
self.ds[self.var_names["name"]].isin(river_names), drop=True
|
|
1952
|
+
)
|
|
1953
|
+
|
|
1954
|
+
# Check that all requested rivers exist in the dataset
|
|
1955
|
+
filtered_river_names = set(ds_filtered[self.var_names["name"]].values)
|
|
1956
|
+
missing_rivers = set(river_names) - filtered_river_names
|
|
1957
|
+
|
|
1958
|
+
if missing_rivers:
|
|
1959
|
+
raise ValueError(
|
|
1960
|
+
f"The following rivers were not found in the dataset: {missing_rivers}"
|
|
1961
|
+
)
|
|
1962
|
+
|
|
1963
|
+
# Set the filtered dataset as the new `ds`
|
|
1964
|
+
object.__setattr__(self, "ds", ds_filtered)
|
|
1849
1965
|
|
|
1850
1966
|
|
|
1851
1967
|
@dataclass(frozen=True, kw_only=True)
|
|
@@ -1994,7 +2110,7 @@ def _check_dataset(
|
|
|
1994
2110
|
|
|
1995
2111
|
|
|
1996
2112
|
def _select_relevant_times(
|
|
1997
|
-
ds, time_dim, start_time
|
|
2113
|
+
ds, time_dim, start_time, end_time=None, climatology=False
|
|
1998
2114
|
) -> xr.Dataset:
|
|
1999
2115
|
"""Select a subset of the dataset based on the specified time range.
|
|
2000
2116
|
|
|
@@ -2011,11 +2127,10 @@ def _select_relevant_times(
|
|
|
2011
2127
|
The input dataset to be filtered. Must contain a time dimension.
|
|
2012
2128
|
time_dim: str
|
|
2013
2129
|
Name of time dimension.
|
|
2014
|
-
start_time :
|
|
2015
|
-
The start time for selecting relevant data.
|
|
2130
|
+
start_time : datetime
|
|
2131
|
+
The start time for selecting relevant data.
|
|
2016
2132
|
end_time : Optional[datetime], optional
|
|
2017
|
-
The end time for selecting relevant data. If not provided, only data at the start_time is selected if start_time is provided
|
|
2018
|
-
or no filtering is applied if start_time is not provided.
|
|
2133
|
+
The end time for selecting relevant data. If not provided, only data at the start_time is selected if start_time is provided.
|
|
2019
2134
|
climatology : bool
|
|
2020
2135
|
Indicates whether the dataset is climatological. Defaults to False.
|
|
2021
2136
|
|
|
@@ -2058,6 +2173,7 @@ def _select_relevant_times(
|
|
|
2058
2173
|
)
|
|
2059
2174
|
if not end_time:
|
|
2060
2175
|
# Interpolate from climatology for initial conditions
|
|
2176
|
+
ds["time"] = ds["time"].dt.days
|
|
2061
2177
|
ds = interpolate_from_climatology(ds, time_dim, start_time)
|
|
2062
2178
|
else:
|
|
2063
2179
|
time_type = get_time_type(ds[time_dim])
|
roms_tools/setup/grid.py
CHANGED
|
@@ -8,21 +8,19 @@ import matplotlib.pyplot as plt
|
|
|
8
8
|
import yaml
|
|
9
9
|
import importlib.metadata
|
|
10
10
|
from typing import Dict, Union, List
|
|
11
|
+
from roms_tools.utils import save_datasets
|
|
11
12
|
from roms_tools.setup.topography import _add_topography
|
|
12
13
|
from roms_tools.setup.mask import _add_mask, _add_velocity_masks
|
|
13
|
-
from roms_tools.vertical_coordinate import
|
|
14
|
-
sigma_stretch,
|
|
15
|
-
compute_depth,
|
|
16
|
-
add_depth_coordinates_to_dataset,
|
|
17
|
-
)
|
|
14
|
+
from roms_tools.vertical_coordinate import compute_depth_coordinates, sigma_stretch
|
|
18
15
|
from roms_tools.plot import _plot, _section_plot
|
|
19
16
|
from roms_tools.setup.utils import (
|
|
20
17
|
interpolate_from_rho_to_u,
|
|
21
18
|
interpolate_from_rho_to_v,
|
|
22
19
|
get_target_coords,
|
|
23
20
|
gc_dist,
|
|
21
|
+
_pop_grid_data,
|
|
24
22
|
)
|
|
25
|
-
from roms_tools.setup.utils import extract_single_value
|
|
23
|
+
from roms_tools.setup.utils import extract_single_value
|
|
26
24
|
from pathlib import Path
|
|
27
25
|
|
|
28
26
|
|
|
@@ -115,7 +113,7 @@ class Grid:
|
|
|
115
113
|
# Coarsen the dataset if needed
|
|
116
114
|
self._coarsen()
|
|
117
115
|
|
|
118
|
-
# Topography
|
|
116
|
+
# Topography
|
|
119
117
|
self.update_topography(
|
|
120
118
|
topography_source=self.topography_source,
|
|
121
119
|
hmin=self.hmin,
|
|
@@ -208,7 +206,7 @@ class Grid:
|
|
|
208
206
|
f"=== Generating the topography using {topography_source['name']} data and hmin = {hmin} meters ==="
|
|
209
207
|
)
|
|
210
208
|
|
|
211
|
-
# Add topography
|
|
209
|
+
# Add topography to the dataset
|
|
212
210
|
ds = _add_topography(
|
|
213
211
|
ds=self.ds,
|
|
214
212
|
target_coords=target_coords,
|
|
@@ -396,14 +394,14 @@ class Grid:
|
|
|
396
394
|
object.__setattr__(self, "ds", ds)
|
|
397
395
|
|
|
398
396
|
def plot(
|
|
399
|
-
self, bathymetry: bool =
|
|
397
|
+
self, bathymetry: bool = True, title: str = None, with_dim_names: bool = False
|
|
400
398
|
) -> None:
|
|
401
399
|
"""Plot the grid.
|
|
402
400
|
|
|
403
401
|
Parameters
|
|
404
402
|
----------
|
|
405
403
|
bathymetry : bool, optional
|
|
406
|
-
Whether or not to plot the bathymetry. Default is
|
|
404
|
+
Whether or not to plot the bathymetry. Default is True.
|
|
407
405
|
title : str, optional
|
|
408
406
|
The title of the plot. If not provided, it will be set to a default.
|
|
409
407
|
with_dim_names : bool, optional
|
|
@@ -446,41 +444,6 @@ class Grid:
|
|
|
446
444
|
field=field, title=title, with_dim_names=with_dim_names, plot_data=False
|
|
447
445
|
)
|
|
448
446
|
|
|
449
|
-
def compute_depth_coordinates(
|
|
450
|
-
self, depth_type: str, locations: list[str] = ["rho", "u", "v"]
|
|
451
|
-
):
|
|
452
|
-
"""Compute and update vertical depth coordinates.
|
|
453
|
-
|
|
454
|
-
Calculates vertical depth coordinates (layer or interface) for specified locations (e.g., rho, u, v points)
|
|
455
|
-
and updates them in the dataset (`self.ds`).
|
|
456
|
-
|
|
457
|
-
Parameters
|
|
458
|
-
----------
|
|
459
|
-
depth_type : str
|
|
460
|
-
The type of depth coordinate to compute. Valid options:
|
|
461
|
-
- "layer": Compute layer depth coordinates.
|
|
462
|
-
- "interface": Compute interface depth coordinates.
|
|
463
|
-
locations : list[str], optional
|
|
464
|
-
Locations for which to compute depth coordinates. Default is ["rho", "u", "v"].
|
|
465
|
-
Valid options include:
|
|
466
|
-
- "rho": Depth coordinates at rho points.
|
|
467
|
-
- "u": Depth coordinates at u points.
|
|
468
|
-
- "v": Depth coordinates at v points.
|
|
469
|
-
|
|
470
|
-
Updates
|
|
471
|
-
-------
|
|
472
|
-
self.ds : xarray.Dataset
|
|
473
|
-
The dataset (`self.ds`) is updated with the following depth coordinate variables:
|
|
474
|
-
- f"{depth_type}_depth_rho": Depth coordinates at rho points.
|
|
475
|
-
- f"{depth_type}_depth_u": Depth coordinates at u points (if included in `locations`).
|
|
476
|
-
- f"{depth_type}_depth_v": Depth coordinates at v points (if included in `locations`).
|
|
477
|
-
|
|
478
|
-
Notes
|
|
479
|
-
-----
|
|
480
|
-
This method uses the `compute_and_update_depth_coordinates` function to perform calculations and updates.
|
|
481
|
-
"""
|
|
482
|
-
add_depth_coordinates_to_dataset(self.ds, self.ds, depth_type, locations)
|
|
483
|
-
|
|
484
447
|
def plot_vertical_coordinate(
|
|
485
448
|
self,
|
|
486
449
|
s=None,
|
|
@@ -511,56 +474,48 @@ class Grid:
|
|
|
511
474
|
If not exactly one of s, eta, xi is specified.
|
|
512
475
|
"""
|
|
513
476
|
|
|
514
|
-
title = "Layer depth at rho-points"
|
|
515
|
-
|
|
516
477
|
if sum(s is not None for s in [s, eta, xi]) != 1:
|
|
517
478
|
raise ValueError("Exactly one of s, eta, or xi must be specified.")
|
|
518
479
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
if self.straddle:
|
|
523
|
-
lon_deg = xr.where(lon_deg > 180, lon_deg - 360, lon_deg)
|
|
524
|
-
h = h.assign_coords({"lon": lon_deg, "lat": lat_deg})
|
|
480
|
+
depth = compute_depth_coordinates(
|
|
481
|
+
self.ds, zeta=0, depth_type="layer", location="rho", eta=eta, xi=xi
|
|
482
|
+
)
|
|
525
483
|
|
|
526
|
-
|
|
484
|
+
title = "Layer depth at rho-points"
|
|
527
485
|
if eta is not None:
|
|
528
|
-
title = title + f", eta_rho = {
|
|
529
|
-
h = h.isel(eta_rho=eta)
|
|
486
|
+
title = title + f", eta_rho = {self.ds.eta_rho[eta].item()}"
|
|
530
487
|
if xi is not None:
|
|
531
|
-
title = title + f", xi_rho = {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
layer_depth = compute_depth(0, h, self.hc, self.ds.Cs_r, self.ds.sigma_r)
|
|
536
|
-
title = title + f", s_rho = {layer_depth.s_rho[s].item()}"
|
|
537
|
-
layer_depth = layer_depth.isel(s_rho=s)
|
|
488
|
+
title = title + f", xi_rho = {self.ds.xi_rho[xi].item()}"
|
|
489
|
+
if s is not None:
|
|
490
|
+
title = title + f", s_rho = {depth.s_rho[s].item()}"
|
|
491
|
+
depth = depth.isel(s_rho=s)
|
|
538
492
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
vmax = layer_depth.max().values
|
|
543
|
-
vmin = layer_depth.min().values
|
|
493
|
+
vmax = depth.max().values
|
|
494
|
+
vmin = depth.min().values
|
|
544
495
|
cmap = plt.colormaps.get_cmap("YlGnBu")
|
|
545
496
|
cmap.set_bad(color="gray")
|
|
546
497
|
kwargs = {"vmax": vmax, "vmin": vmin, "cmap": cmap}
|
|
547
498
|
|
|
499
|
+
lat_deg = self.ds.lat_rho
|
|
500
|
+
lon_deg = self.ds.lon_rho
|
|
501
|
+
if self.straddle:
|
|
502
|
+
lon_deg = xr.where(lon_deg > 180, lon_deg - 360, lon_deg)
|
|
503
|
+
depth = depth.assign_coords({"lon": lon_deg, "lat": lat_deg})
|
|
504
|
+
|
|
548
505
|
_plot(
|
|
549
|
-
field=
|
|
506
|
+
field=depth.where(self.ds.mask_rho),
|
|
550
507
|
depth_contours=False,
|
|
551
508
|
title=title,
|
|
552
509
|
kwargs=kwargs,
|
|
553
510
|
)
|
|
554
511
|
else:
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
interface_depth = compute_depth(
|
|
562
|
-
0, h, self.hc, self.ds.Cs_w, self.ds.sigma_w
|
|
512
|
+
field = xr.zeros_like(depth)
|
|
513
|
+
field = field.assign_coords({"layer_depth": depth})
|
|
514
|
+
|
|
515
|
+
interface_depth = compute_depth_coordinates(
|
|
516
|
+
self.ds, zeta=0, depth_type="interface", eta=eta, xi=xi
|
|
563
517
|
)
|
|
518
|
+
|
|
564
519
|
cmap = plt.colormaps.get_cmap("YlGnBu")
|
|
565
520
|
cmap.set_bad(color="gray")
|
|
566
521
|
kwargs = {"vmax": 0.0, "vmin": 0.0, "cmap": cmap, "add_colorbar": False}
|
|
@@ -572,31 +527,13 @@ class Grid:
|
|
|
572
527
|
kwargs=kwargs,
|
|
573
528
|
)
|
|
574
529
|
|
|
575
|
-
def save(
|
|
576
|
-
self, filepath: Union[str, Path], np_eta: int = None, np_xi: int = None
|
|
577
|
-
) -> None:
|
|
530
|
+
def save(self, filepath: Union[str, Path]) -> None:
|
|
578
531
|
"""Save the grid information to a netCDF4 file.
|
|
579
532
|
|
|
580
|
-
This method supports saving the dataset in two modes:
|
|
581
|
-
|
|
582
|
-
1. **Single File Mode (default)**:
|
|
583
|
-
|
|
584
|
-
If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single netCDF4 file
|
|
585
|
-
with the base filename specified by `filepath.nc`.
|
|
586
|
-
|
|
587
|
-
2. **Partitioned Mode**:
|
|
588
|
-
|
|
589
|
-
- If either `np_eta` or `np_xi` is specified, the dataset is divided into spatial tiles along the eta-axis and xi-axis.
|
|
590
|
-
- Each spatial tile is saved as a separate netCDF4 file.
|
|
591
|
-
|
|
592
533
|
Parameters
|
|
593
534
|
----------
|
|
594
535
|
filepath : Union[str, Path]
|
|
595
536
|
The base path or filename where the dataset should be saved.
|
|
596
|
-
np_eta : int, optional
|
|
597
|
-
The number of partitions along the `eta` direction. If `None`, no spatial partitioning is performed.
|
|
598
|
-
np_xi : int, optional
|
|
599
|
-
The number of partitions along the `xi` direction. If `None`, no spatial partitioning is performed.
|
|
600
537
|
|
|
601
538
|
Returns
|
|
602
539
|
-------
|
|
@@ -614,9 +551,7 @@ class Grid:
|
|
|
614
551
|
dataset_list = [self.ds.load()]
|
|
615
552
|
output_filenames = [str(filepath)]
|
|
616
553
|
|
|
617
|
-
saved_filenames = save_datasets(
|
|
618
|
-
dataset_list, output_filenames, np_eta=np_eta, np_xi=np_xi
|
|
619
|
-
)
|
|
554
|
+
saved_filenames = save_datasets(dataset_list, output_filenames)
|
|
620
555
|
|
|
621
556
|
return saved_filenames
|
|
622
557
|
|
|
@@ -754,9 +689,7 @@ class Grid:
|
|
|
754
689
|
filepath = Path(filepath)
|
|
755
690
|
|
|
756
691
|
data = asdict(self)
|
|
757
|
-
data
|
|
758
|
-
data.pop("straddle", None)
|
|
759
|
-
data.pop("verbose", None)
|
|
692
|
+
data = _pop_grid_data(data)
|
|
760
693
|
|
|
761
694
|
# Include the version of roms-tools
|
|
762
695
|
try:
|