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/nesting.py
CHANGED
|
@@ -2,57 +2,59 @@ import numpy as np
|
|
|
2
2
|
import xarray as xr
|
|
3
3
|
from scipy.interpolate import griddata
|
|
4
4
|
from dataclasses import dataclass, field
|
|
5
|
-
from typing import Dict, Union
|
|
5
|
+
from typing import Dict, Union, Any, Tuple
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
import logging
|
|
8
8
|
from scipy.interpolate import interp1d
|
|
9
9
|
from roms_tools import Grid
|
|
10
10
|
from roms_tools.plot import _plot_nesting
|
|
11
|
+
from roms_tools.utils import save_datasets
|
|
12
|
+
from roms_tools.setup.topography import _clip_depth
|
|
11
13
|
from roms_tools.setup.utils import (
|
|
12
14
|
interpolate_from_rho_to_u,
|
|
13
15
|
interpolate_from_rho_to_v,
|
|
14
16
|
get_boundary_coords,
|
|
15
17
|
wrap_longitudes,
|
|
16
|
-
save_datasets,
|
|
17
18
|
_to_yaml,
|
|
18
19
|
_from_yaml,
|
|
19
20
|
)
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
@dataclass(frozen=True, kw_only=True)
|
|
23
|
-
class
|
|
24
|
-
"""Represents
|
|
25
|
-
|
|
26
|
-
the parent grid
|
|
27
|
-
|
|
24
|
+
class ChildGrid(Grid):
|
|
25
|
+
"""Represents a ROMS child grid that is compatible with the provided parent grid.
|
|
26
|
+
|
|
27
|
+
This class establishes the relationship between a parent grid and a child grid in ROMS simulations.
|
|
28
|
+
It generates two datasets:
|
|
29
|
+
|
|
30
|
+
1. `ds`: Contains child grid variables, ensuring compatibility with the parent grid.
|
|
31
|
+
The child grid’s topography and mask are adjusted to match the parent grid at the boundaries.
|
|
32
|
+
|
|
33
|
+
2. `ds_nesting`: Contains boundary mappings, linking the child grid’s boundaries
|
|
34
|
+
to the corresponding parent grid indices.
|
|
28
35
|
|
|
29
36
|
Parameters
|
|
30
37
|
----------
|
|
31
38
|
parent_grid : Grid
|
|
32
|
-
The parent grid object,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
child grid information. Defaults to "child".
|
|
42
|
-
period : float, optional
|
|
43
|
-
The temporal resolution or output period for boundary variables in the child grid.
|
|
44
|
-
Defaults to hourly.
|
|
39
|
+
The parent grid object, providing the reference for the child grid's topography and mask.
|
|
40
|
+
boundaries : Dict[str, bool]
|
|
41
|
+
Specifies which child grid boundaries (south, east, north, west) should be adjusted for topography/mask
|
|
42
|
+
and included in `ds_nesting`. Defaults to all `True`.
|
|
43
|
+
metadata : Dict[str, Any]
|
|
44
|
+
Dictionary configuring the boundary nesting process, including:
|
|
45
|
+
|
|
46
|
+
- `"prefix"` (str): Prefix for variable names in `ds_nesting`. Defaults to `"child"`.
|
|
47
|
+
- `"period"` (float): Temporal resolution for boundary outputs in seconds. Defaults to 3600 (hourly).
|
|
45
48
|
|
|
46
49
|
Attributes
|
|
47
50
|
----------
|
|
48
51
|
ds : xr.Dataset
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
Dataset containing child grid variables aligned with the parent grid’s topography and mask at the boundaries.
|
|
53
|
+
ds_nesting : xr.Dataset
|
|
54
|
+
Dataset containing boundary mappings, where child grid boundaries are mapped onto parent grid indices.
|
|
52
55
|
"""
|
|
53
56
|
|
|
54
57
|
parent_grid: Grid
|
|
55
|
-
child_grid: Grid
|
|
56
58
|
boundaries: Dict[str, bool] = field(
|
|
57
59
|
default_factory=lambda: {
|
|
58
60
|
"south": True,
|
|
@@ -61,40 +63,96 @@ class Nesting:
|
|
|
61
63
|
"west": True,
|
|
62
64
|
}
|
|
63
65
|
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
metadata: Dict[str, Any] = field(
|
|
67
|
+
default_factory=lambda: {"prefix": "child", "period": 3600.0}
|
|
68
|
+
)
|
|
66
69
|
|
|
67
70
|
def __post_init__(self):
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
super().__post_init__()
|
|
73
|
+
self._map_child_boundaries_onto_parent_grid_indices()
|
|
74
|
+
self._modify_child_topography_and_mask()
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
def _map_child_boundaries_onto_parent_grid_indices(self):
|
|
77
|
+
"""Maps child grid boundary points onto absolute indices of the parent grid."""
|
|
78
|
+
# Prepare parent and child grid datasets by adjusting longitudes for dateline crossing
|
|
79
|
+
parent_grid_ds, child_grid_ds = self._prepare_grid_datasets()
|
|
75
80
|
|
|
76
81
|
# Map child boundaries onto parent grid indices
|
|
77
|
-
|
|
82
|
+
ds_nesting = map_child_boundaries_onto_parent_grid_indices(
|
|
78
83
|
parent_grid_ds,
|
|
79
84
|
child_grid_ds,
|
|
80
85
|
self.boundaries,
|
|
81
|
-
self.
|
|
82
|
-
self.period,
|
|
86
|
+
self.metadata["prefix"],
|
|
87
|
+
self.metadata["period"],
|
|
83
88
|
)
|
|
84
|
-
object.__setattr__(self, "ds", ds)
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
object.__setattr__(self, "ds_nesting", ds_nesting)
|
|
91
|
+
|
|
92
|
+
def _modify_child_topography_and_mask(self):
|
|
93
|
+
"""Adjust the child grid's topography and mask to align with the parent grid.
|
|
94
|
+
|
|
95
|
+
Uses a weighted sum based on boundary distance and clips depth values to a
|
|
96
|
+
minimum.
|
|
97
|
+
"""
|
|
98
|
+
# Prepare parent and child grid datasets by adjusting longitudes for dateline crossing
|
|
99
|
+
parent_grid_ds, child_grid_ds = self._prepare_grid_datasets()
|
|
100
|
+
|
|
87
101
|
child_grid_ds = modify_child_topography_and_mask(
|
|
88
|
-
parent_grid_ds, child_grid_ds, self.boundaries
|
|
102
|
+
parent_grid_ds, child_grid_ds, self.boundaries, self.hmin
|
|
89
103
|
)
|
|
90
104
|
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
# Finalize grid datasets by adjusting longitudes back to [0, 360] range
|
|
106
|
+
parent_grid_ds, child_grid_ds = self._finalize_grid_datasets(
|
|
107
|
+
parent_grid_ds, child_grid_ds
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
object.__setattr__(self, "ds", child_grid_ds)
|
|
111
|
+
|
|
112
|
+
def update_topography(
|
|
113
|
+
self, topography_source=None, hmin=None, verbose=False
|
|
114
|
+
) -> None:
|
|
115
|
+
|
|
116
|
+
"""Update the child grid topography via the following steps:
|
|
117
|
+
|
|
118
|
+
- Regrids the topography based on the specified source.
|
|
119
|
+
- Applies global and local smoothing.
|
|
120
|
+
- Adjusts the child grid topography and mask to match the parent grid.
|
|
121
|
+
- Ensures the minimum depth constraint (`hmin`) is enforced.
|
|
122
|
+
- Updates the internal dataset (`self.ds`) with the processed topography.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
topography_source : dict, optional
|
|
127
|
+
A dictionary specifying the source of the topography data. Expected keys:
|
|
128
|
+
- `"name"` (str): Name of the topography dataset (e.g., `"SRTM15"`).
|
|
129
|
+
- `"path"` (str or Path): File path to the topography dataset.
|
|
130
|
+
|
|
131
|
+
If not provided, the existing topography source remains unchanged.
|
|
132
|
+
|
|
133
|
+
hmin : float, optional
|
|
134
|
+
The minimum allowable ocean depth (in meters). If not provided, the existing
|
|
135
|
+
value remains unchanged.
|
|
96
136
|
|
|
97
|
-
|
|
137
|
+
verbose : bool, optional
|
|
138
|
+
If `True`, prints detailed information about each processing step, including
|
|
139
|
+
timing and modifications. Defaults to `False`.
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
None
|
|
144
|
+
This method updates the internal dataset (`self.ds`) in place, modifying the
|
|
145
|
+
topography variable. It does not return a value.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
super().update_topography(
|
|
149
|
+
topography_source=topography_source, hmin=hmin, verbose=verbose
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Modify child topography and mask to match the parent grid
|
|
153
|
+
self._modify_child_topography_and_mask()
|
|
154
|
+
|
|
155
|
+
def plot_nesting(self, with_dim_names=False) -> None:
|
|
98
156
|
"""Plot the parent and child grids in a single figure.
|
|
99
157
|
|
|
100
158
|
Returns
|
|
@@ -105,45 +163,21 @@ class Nesting:
|
|
|
105
163
|
|
|
106
164
|
_plot_nesting(
|
|
107
165
|
self.parent_grid.ds,
|
|
108
|
-
self.
|
|
166
|
+
self.ds,
|
|
109
167
|
self.parent_grid.straddle,
|
|
110
168
|
with_dim_names,
|
|
111
169
|
)
|
|
112
170
|
|
|
113
|
-
def
|
|
171
|
+
def save_nesting(
|
|
114
172
|
self,
|
|
115
173
|
filepath: Union[str, Path],
|
|
116
|
-
filepath_child_grid: Union[str, Path],
|
|
117
|
-
np_eta: int = None,
|
|
118
|
-
np_xi: int = None,
|
|
119
174
|
) -> None:
|
|
120
|
-
"""Save the nesting
|
|
121
|
-
required because the topography and mask of the child grid has been modified.
|
|
122
|
-
|
|
123
|
-
This method allows saving the nesting and child grid data either each as a single file or each partitioned into multiple files, based on the provided options. The dataset can be saved in two modes:
|
|
124
|
-
|
|
125
|
-
1. **Single File Mode (default)**:
|
|
126
|
-
- If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single netCDF4 file.
|
|
127
|
-
- The file is named based on the provided `filepath`, with `.nc` automatically appended to the filename.
|
|
128
|
-
|
|
129
|
-
2. **Partitioned Mode**:
|
|
130
|
-
- If either `np_eta` or `np_xi` is specified, the dataset is partitioned spatially along the `eta` and `xi` axes into tiles.
|
|
131
|
-
- Each tile is saved as a separate netCDF4 file. Filenames will be modified with an index to represent each partition, e.g., `"filepath_YYYYMM.0.nc"`, `"filepath_YYYYMM.1.nc"`, etc.
|
|
175
|
+
"""Save the nesting information to netCDF4 files.
|
|
132
176
|
|
|
133
177
|
Parameters
|
|
134
178
|
----------
|
|
135
179
|
filepath : Union[str, Path]
|
|
136
180
|
The base path and filename for the output files. The filenames will include the specified path and the `.nc` extension.
|
|
137
|
-
If partitioning is used, additional indices will be appended to the filenames, e.g., `"filepath.0.nc"`, `"filepath.1.nc"`, etc.
|
|
138
|
-
|
|
139
|
-
filepath_child_grid : Union[str, Path]
|
|
140
|
-
The base path and filename for saving the childe grid file.
|
|
141
|
-
|
|
142
|
-
np_eta : int, optional
|
|
143
|
-
The number of partitions along the `eta` direction. If `None`, no spatial partitioning is performed along the `eta` axis.
|
|
144
|
-
|
|
145
|
-
np_xi : int, optional
|
|
146
|
-
The number of partitions along the `xi` direction. If `None`, no spatial partitioning is performed along the `xi` axis.
|
|
147
181
|
|
|
148
182
|
Returns
|
|
149
183
|
-------
|
|
@@ -153,20 +187,15 @@ class Nesting:
|
|
|
153
187
|
|
|
154
188
|
# Ensure filepath is a Path object
|
|
155
189
|
filepath = Path(filepath)
|
|
156
|
-
filepath_child_grid = Path(filepath_child_grid)
|
|
157
190
|
|
|
158
191
|
# Remove ".nc" suffix if present
|
|
159
192
|
if filepath.suffix == ".nc":
|
|
160
193
|
filepath = filepath.with_suffix("")
|
|
161
|
-
if filepath_child_grid.suffix == ".nc":
|
|
162
|
-
filepath_child_grid = filepath_child_grid.with_suffix("")
|
|
163
194
|
|
|
164
|
-
dataset_list = [self.
|
|
165
|
-
output_filenames = [str(filepath)
|
|
195
|
+
dataset_list = [self.ds_nesting]
|
|
196
|
+
output_filenames = [str(filepath)]
|
|
166
197
|
|
|
167
|
-
saved_filenames = save_datasets(
|
|
168
|
-
dataset_list, output_filenames, np_eta=np_eta, np_xi=np_xi
|
|
169
|
-
)
|
|
198
|
+
saved_filenames = save_datasets(dataset_list, output_filenames)
|
|
170
199
|
|
|
171
200
|
return saved_filenames
|
|
172
201
|
|
|
@@ -183,8 +212,8 @@ class Nesting:
|
|
|
183
212
|
_to_yaml(self, filepath)
|
|
184
213
|
|
|
185
214
|
@classmethod
|
|
186
|
-
def from_yaml(cls, filepath: Union[str, Path]) -> "
|
|
187
|
-
"""Create an instance of the
|
|
215
|
+
def from_yaml(cls, filepath: Union[str, Path]) -> "ChildGrid":
|
|
216
|
+
"""Create an instance of the ChildGrid class from a YAML file.
|
|
188
217
|
|
|
189
218
|
Parameters
|
|
190
219
|
----------
|
|
@@ -194,25 +223,115 @@ class Nesting:
|
|
|
194
223
|
Returns
|
|
195
224
|
-------
|
|
196
225
|
Nesting
|
|
197
|
-
An instance of the
|
|
226
|
+
An instance of the ChildGrid class.
|
|
198
227
|
"""
|
|
199
228
|
filepath = Path(filepath)
|
|
200
229
|
|
|
201
230
|
parent_grid = Grid.from_yaml(filepath, "ParentGrid")
|
|
202
|
-
child_grid = Grid.from_yaml(filepath, "ChildGrid")
|
|
203
231
|
params = _from_yaml(cls, filepath)
|
|
204
232
|
|
|
205
|
-
return cls(parent_grid=parent_grid,
|
|
233
|
+
return cls(parent_grid=parent_grid, **params)
|
|
234
|
+
|
|
235
|
+
def _prepare_grid_datasets(self) -> Tuple[xr.Dataset, xr.Dataset]:
|
|
236
|
+
"""Prepare parent and child grid datasets by adjusting longitudes for dateline
|
|
237
|
+
crossing.
|
|
238
|
+
|
|
239
|
+
This method ensures that longitudes are properly wrapped to avoid interpolation artifacts
|
|
240
|
+
and returns the updated parent and child grid datasets.
|
|
241
|
+
|
|
242
|
+
Returns
|
|
243
|
+
-------
|
|
244
|
+
Tuple[xr.Dataset, xr.Dataset]
|
|
245
|
+
A tuple containing:
|
|
246
|
+
- The modified parent grid dataset.
|
|
247
|
+
- The modified child grid dataset.
|
|
248
|
+
"""
|
|
249
|
+
parent_grid_ds = wrap_longitudes(
|
|
250
|
+
self.parent_grid.ds, straddle=self.parent_grid.straddle
|
|
251
|
+
)
|
|
252
|
+
child_grid_ds = wrap_longitudes(self.ds, straddle=self.parent_grid.straddle)
|
|
253
|
+
return parent_grid_ds, child_grid_ds
|
|
254
|
+
|
|
255
|
+
def _finalize_grid_datasets(
|
|
256
|
+
self, parent_grid_ds: xr.Dataset, child_grid_ds: xr.Dataset
|
|
257
|
+
) -> None:
|
|
258
|
+
"""Finalize the grid datasets by converting longitudes back to the [0, 360]
|
|
259
|
+
range.
|
|
260
|
+
|
|
261
|
+
Parameters
|
|
262
|
+
----------
|
|
263
|
+
parent_grid_ds : xr.Dataset
|
|
264
|
+
The parent grid dataset after modifications.
|
|
265
|
+
|
|
266
|
+
child_grid_ds : xr.Dataset
|
|
267
|
+
The child grid dataset after modifications.
|
|
268
|
+
"""
|
|
269
|
+
parent_grid_ds = wrap_longitudes(parent_grid_ds, straddle=False)
|
|
270
|
+
child_grid_ds = wrap_longitudes(child_grid_ds, straddle=False)
|
|
271
|
+
return parent_grid_ds, child_grid_ds
|
|
272
|
+
|
|
273
|
+
@classmethod
|
|
274
|
+
def from_file(
|
|
275
|
+
cls, filepath: Union[str, Path], verbose: bool = False
|
|
276
|
+
) -> "ChildGrid":
|
|
277
|
+
"""This method is disabled in this subclass.
|
|
278
|
+
|
|
279
|
+
.. noindex::
|
|
280
|
+
"""
|
|
281
|
+
raise NotImplementedError(
|
|
282
|
+
"The 'from_file' method is disabled in this subclass."
|
|
283
|
+
)
|
|
206
284
|
|
|
207
285
|
|
|
208
286
|
def map_child_boundaries_onto_parent_grid_indices(
|
|
209
287
|
parent_grid_ds,
|
|
210
288
|
child_grid_ds,
|
|
211
289
|
boundaries={"south": True, "east": True, "north": True, "west": True},
|
|
212
|
-
|
|
290
|
+
prefix="child",
|
|
213
291
|
period=3600.0,
|
|
214
292
|
update_land_indices=True,
|
|
215
293
|
):
|
|
294
|
+
"""Maps child grid boundary points onto absolute indices of the parent grid.
|
|
295
|
+
|
|
296
|
+
This function interpolates the spatial indices of the child grid boundaries onto
|
|
297
|
+
the parent grid, ensuring alignment between the two grids. It supports all four
|
|
298
|
+
boundaries (south, east, north, and west) and considers different grid locations
|
|
299
|
+
(`rho`, `u`, and `v`). Additionally, it updates land indices if they fall onto
|
|
300
|
+
land points in the parent grid.
|
|
301
|
+
|
|
302
|
+
Parameters
|
|
303
|
+
----------
|
|
304
|
+
parent_grid_ds : xarray.Dataset
|
|
305
|
+
The parent grid dataset containing longitude, latitude, and mask variables.
|
|
306
|
+
|
|
307
|
+
child_grid_ds : xarray.Dataset
|
|
308
|
+
The child grid dataset containing longitude, latitude, mask, and angle variables.
|
|
309
|
+
|
|
310
|
+
boundaries : dict, optional
|
|
311
|
+
A dictionary specifying which child boundaries should be mapped onto the parent grid.
|
|
312
|
+
Keys should be `"south"`, `"east"`, `"north"`, and `"west"`, with boolean values
|
|
313
|
+
indicating whether to process each boundary. Defaults to mapping all boundaries.
|
|
314
|
+
|
|
315
|
+
prefix : str, optional
|
|
316
|
+
A string prefix for naming the output variables in the resulting dataset.
|
|
317
|
+
Defaults to `"child"`.
|
|
318
|
+
|
|
319
|
+
period : float, optional
|
|
320
|
+
The output period (in seconds) to be assigned to the mapped boundary indices.
|
|
321
|
+
Defaults to `3600.0` (1 hour).
|
|
322
|
+
|
|
323
|
+
update_land_indices : bool, optional
|
|
324
|
+
If `True`, updates indices that fall on land in the parent grid to nearby ocean points.
|
|
325
|
+
Defaults to `True`.
|
|
326
|
+
|
|
327
|
+
Returns
|
|
328
|
+
-------
|
|
329
|
+
xarray.Dataset
|
|
330
|
+
A dataset containing the mapped boundary indices for `rho`, `u`, and `v` grid points.
|
|
331
|
+
- For `rho` points: Contains mapped `xi` and `eta` indices.
|
|
332
|
+
- For `u` and `v` points: Contains mapped `xi`, `eta`, and angle values.
|
|
333
|
+
- Attributes include long names, output variable names, units, and output period.
|
|
334
|
+
"""
|
|
216
335
|
|
|
217
336
|
bdry_coords_dict = get_boundary_coords()
|
|
218
337
|
|
|
@@ -255,7 +374,7 @@ def map_child_boundaries_onto_parent_grid_indices(
|
|
|
255
374
|
i_eta, i_xi, grid_location, parent_grid_ds
|
|
256
375
|
)
|
|
257
376
|
|
|
258
|
-
var_name = f"{
|
|
377
|
+
var_name = f"{prefix}_{direction}_{suffix}"
|
|
259
378
|
if grid_location == "rho":
|
|
260
379
|
ds[var_name] = xr.concat([i_xi, i_eta], dim="two")
|
|
261
380
|
ds[var_name].attrs[
|
|
@@ -286,7 +405,7 @@ def map_child_boundaries_onto_parent_grid_indices(
|
|
|
286
405
|
|
|
287
406
|
# Rename dimensions
|
|
288
407
|
dims_to_rename = {
|
|
289
|
-
dim: f"{
|
|
408
|
+
dim: f"{prefix}_{dim}" for dim in ds.dims if dim not in ["two", "three"]
|
|
290
409
|
}
|
|
291
410
|
ds = ds.rename(dims_to_rename)
|
|
292
411
|
|
|
@@ -466,7 +585,39 @@ def modify_child_topography_and_mask(
|
|
|
466
585
|
parent_grid_ds,
|
|
467
586
|
child_grid_ds,
|
|
468
587
|
boundaries={"south": True, "east": True, "north": True, "west": True},
|
|
588
|
+
hmin=5.0,
|
|
469
589
|
):
|
|
590
|
+
"""Adjust the child grid topography and mask to align with the parent grid.
|
|
591
|
+
|
|
592
|
+
The child grid's topography is adjusted using a weighted sum based on the boundary distance,
|
|
593
|
+
and the depth values are clipped to enforce a minimum depth constraint.
|
|
594
|
+
|
|
595
|
+
Parameters
|
|
596
|
+
----------
|
|
597
|
+
parent_grid_ds : xarray.Dataset
|
|
598
|
+
The parent grid dataset containing `h` (topography) and `mask_rho` (land-sea mask).
|
|
599
|
+
|
|
600
|
+
child_grid_ds : xarray.Dataset
|
|
601
|
+
The child grid dataset whose `h` and `mask_rho` will be modified.
|
|
602
|
+
|
|
603
|
+
boundaries : dict, optional
|
|
604
|
+
A dictionary specifying which boundaries should be modified. Expected keys:
|
|
605
|
+
- `"south"` (bool): Whether to adjust the southern boundary.
|
|
606
|
+
- `"east"` (bool): Whether to adjust the eastern boundary.
|
|
607
|
+
- `"north"` (bool): Whether to adjust the northern boundary.
|
|
608
|
+
- `"west"` (bool): Whether to adjust the western boundary.
|
|
609
|
+
Defaults to modifying all boundaries.
|
|
610
|
+
|
|
611
|
+
hmin : float, optional
|
|
612
|
+
The minimum allowable ocean depth (in meters). Depth values in the modified
|
|
613
|
+
child topography will be clipped to ensure they meet or exceed this value.
|
|
614
|
+
Defaults to `5.0` meters.
|
|
615
|
+
|
|
616
|
+
Returns
|
|
617
|
+
-------
|
|
618
|
+
xarray.Dataset
|
|
619
|
+
The updated child grid dataset with modified topography (`h`) and mask (`mask_rho`).
|
|
620
|
+
"""
|
|
470
621
|
|
|
471
622
|
# regrid parent topography and mask onto child grid
|
|
472
623
|
points = np.column_stack(
|
|
@@ -492,6 +643,8 @@ def modify_child_topography_and_mask(
|
|
|
492
643
|
child_grid_ds["h"] = (
|
|
493
644
|
alpha * child_grid_ds["h"] + (1 - alpha) * h_parent_interpolated
|
|
494
645
|
)
|
|
646
|
+
# Clip depth on modified child topography
|
|
647
|
+
child_grid_ds["h"] = _clip_depth(child_grid_ds["h"], hmin)
|
|
495
648
|
|
|
496
649
|
child_mask = (
|
|
497
650
|
alpha * child_grid_ds["mask_rho"] + (1 - alpha) * mask_parent_interpolated
|