roms-tools 1.6.2__py3-none-any.whl → 2.0.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 -1
- roms_tools/__init__.py +1 -0
- roms_tools/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +266 -256
- roms_tools/setup/datasets.py +986 -231
- roms_tools/setup/download.py +41 -15
- roms_tools/setup/grid.py +561 -512
- roms_tools/setup/initial_conditions.py +162 -106
- roms_tools/setup/mask.py +69 -0
- roms_tools/setup/plot.py +81 -23
- roms_tools/setup/regrid.py +4 -2
- roms_tools/setup/river_forcing.py +589 -0
- roms_tools/setup/surface_forcing.py +21 -130
- roms_tools/setup/tides.py +15 -79
- roms_tools/setup/topography.py +92 -128
- roms_tools/setup/utils.py +307 -25
- roms_tools/setup/vertical_coordinate.py +5 -16
- roms_tools/tests/test_setup/test_boundary_forcing.py +10 -7
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +157 -130
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/abs_time/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/bry_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/month/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/month/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/month/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +39 -12
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/abs_time/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/month/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/month/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/month/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +0 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +56 -201
- roms_tools/tests/test_setup/test_data/grid.zarr/Cs_r/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/Cs_w/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/{interface_depth_rho → sigma_r}/.zarray +2 -6
- roms_tools/tests/test_setup/test_data/grid.zarr/sigma_r/.zattrs +7 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/sigma_r/0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/{interface_depth_u → sigma_w}/.zarray +2 -6
- roms_tools/tests/test_setup/test_data/grid.zarr/sigma_w/.zattrs +7 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/sigma_w/0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +1 -2
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +58 -203
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/Cs_r/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/Cs_w/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/.zattrs +1 -1
- 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/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.zarr/interface_depth_v → grid_that_straddles_dateline.zarr/sigma_r}/.zarray +2 -6
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_r/.zattrs +7 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_r/0 +0 -0
- roms_tools/tests/test_setup/test_data/{grid.zarr/layer_depth_rho → grid_that_straddles_dateline.zarr/sigma_w}/.zarray +2 -6
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_w/.zattrs +7 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_w/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/.zattrs +3 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/.zgroup +3 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/.zmetadata +214 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/abs_time/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/abs_time/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/abs_time/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/month/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/month/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/month/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_name/.zarray +24 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_name/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_name/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_time/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_time/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_time/0 +0 -0
- roms_tools/tests/test_setup/test_data/{grid.zarr/layer_depth_v → river_forcing.zarr/river_tracer}/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_tracer/.zattrs +10 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_tracer/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_volume/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_volume/.zattrs +9 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_volume/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/{grid.zarr/layer_depth_u → river_forcing.zarr/tracer_name}/.zarray +2 -6
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/tracer_name/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing.zarr/tracer_name/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zgroup +3 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zmetadata +185 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/abs_time/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/abs_time/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/abs_time/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_name/.zarray +24 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_name/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_name/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_time/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_time/.zattrs +7 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_time/0 +0 -0
- roms_tools/tests/test_setup/test_data/{grid_that_straddles_dateline.zarr/interface_depth_v → river_forcing_no_climatology.zarr/river_tracer}/.zarray +4 -4
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_tracer/.zattrs +10 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_tracer/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_volume/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_volume/.zattrs +9 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_volume/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/{grid_that_straddles_dateline.zarr/interface_depth_u → river_forcing_no_climatology.zarr/tracer_name}/.zarray +2 -6
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/tracer_name/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/tracer_name/0 +0 -0
- roms_tools/tests/test_setup/test_grid.py +110 -12
- roms_tools/tests/test_setup/test_initial_conditions.py +2 -3
- roms_tools/tests/test_setup/test_river_forcing.py +367 -0
- roms_tools/tests/test_setup/test_surface_forcing.py +2 -24
- roms_tools/tests/test_setup/test_tides.py +2 -3
- roms_tools/tests/test_setup/test_topography.py +106 -1
- roms_tools/tests/test_setup/test_validation.py +4 -0
- roms_tools/utils.py +12 -10
- {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/LICENSE +1 -1
- {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/METADATA +6 -5
- {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/RECORD +254 -225
- {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/WHEEL +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_rho/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_rho/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_u/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_u/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_v/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_v/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_rho/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_rho/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_u/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_u/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_v/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_v/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_rho/.zarray +0 -24
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_rho/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_rho/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_u/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_u/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_v/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_v/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_rho/.zarray +0 -24
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_rho/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_rho/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_u/.zarray +0 -24
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_u/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_u/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_v/.zarray +0 -24
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_v/.zattrs +0 -9
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_v/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_vertical_coordinate.py +0 -91
- {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import xarray as xr
|
|
2
|
-
import pandas as pd
|
|
3
|
-
import yaml
|
|
4
2
|
import importlib.metadata
|
|
5
|
-
from dataclasses import dataclass, field
|
|
3
|
+
from dataclasses import dataclass, field
|
|
6
4
|
from roms_tools.setup.grid import Grid
|
|
7
5
|
from datetime import datetime
|
|
8
6
|
import numpy as np
|
|
@@ -14,14 +12,17 @@ from roms_tools.setup.datasets import (
|
|
|
14
12
|
CESMBGCSurfaceForcingDataset,
|
|
15
13
|
)
|
|
16
14
|
from roms_tools.setup.utils import (
|
|
15
|
+
get_target_coords,
|
|
17
16
|
nan_check,
|
|
18
17
|
substitute_nans_by_fillvalue,
|
|
19
18
|
interpolate_from_climatology,
|
|
20
19
|
get_variable_metadata,
|
|
21
20
|
group_dataset,
|
|
22
21
|
save_datasets,
|
|
23
|
-
get_target_coords,
|
|
24
22
|
rotate_velocities,
|
|
23
|
+
convert_to_roms_time,
|
|
24
|
+
_to_yaml,
|
|
25
|
+
_from_yaml,
|
|
25
26
|
)
|
|
26
27
|
from roms_tools.setup.plot import _plot
|
|
27
28
|
import matplotlib.pyplot as plt
|
|
@@ -104,8 +105,8 @@ class SurfaceForcing:
|
|
|
104
105
|
|
|
105
106
|
data.apply_lateral_fill()
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
var_names = variable_info.keys()
|
|
108
|
+
self._set_variable_info(data)
|
|
109
|
+
var_names = self.variable_info.keys()
|
|
109
110
|
|
|
110
111
|
processed_fields = {}
|
|
111
112
|
# lateral regridding
|
|
@@ -117,7 +118,7 @@ class SurfaceForcing:
|
|
|
117
118
|
)
|
|
118
119
|
|
|
119
120
|
# rotation of velocities and interpolation to u/v points
|
|
120
|
-
if "uwnd" in variable_info and "vwnd" in variable_info:
|
|
121
|
+
if "uwnd" in self.variable_info and "vwnd" in self.variable_info:
|
|
121
122
|
processed_fields["uwnd"], processed_fields["vwnd"] = rotate_velocities(
|
|
122
123
|
processed_fields["uwnd"],
|
|
123
124
|
processed_fields["vwnd"],
|
|
@@ -133,7 +134,7 @@ class SurfaceForcing:
|
|
|
133
134
|
|
|
134
135
|
ds = self._write_into_dataset(processed_fields, data, d_meta)
|
|
135
136
|
|
|
136
|
-
self._validate(ds
|
|
137
|
+
self._validate(ds)
|
|
137
138
|
|
|
138
139
|
# substitute NaNs over land by a fill value to avoid blow-up of ROMS
|
|
139
140
|
for var_name in ds.data_vars:
|
|
@@ -212,9 +213,8 @@ class SurfaceForcing:
|
|
|
212
213
|
|
|
213
214
|
Returns
|
|
214
215
|
-------
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
about each variable, including 'location', 'is_vector', 'vector_pair', and 'is_3d'.
|
|
216
|
+
None
|
|
217
|
+
This method updates the instance attribute `variable_info` with the metadata dictionary for the variables.
|
|
218
218
|
"""
|
|
219
219
|
default_info = {
|
|
220
220
|
"location": "rho",
|
|
@@ -255,7 +255,7 @@ class SurfaceForcing:
|
|
|
255
255
|
else:
|
|
256
256
|
variable_info[var_name] = {**default_info, "validate": False}
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
object.__setattr__(self, "variable_info", variable_info)
|
|
259
259
|
|
|
260
260
|
def _apply_correction(self, processed_fields, data):
|
|
261
261
|
|
|
@@ -302,38 +302,9 @@ class SurfaceForcing:
|
|
|
302
302
|
ds = self._add_global_metadata(ds)
|
|
303
303
|
|
|
304
304
|
# Convert the time coordinate to the format expected by ROMS
|
|
305
|
-
|
|
306
|
-
ds.
|
|
307
|
-
|
|
308
|
-
ds = ds.assign_coords(
|
|
309
|
-
{"abs_time": np.datetime64(self.model_reference_date) + ds["time"]}
|
|
310
|
-
)
|
|
311
|
-
# Convert to pandas TimedeltaIndex
|
|
312
|
-
timedelta_index = pd.to_timedelta(ds["time"].values)
|
|
313
|
-
|
|
314
|
-
# Determine the start of the year for the base_datetime
|
|
315
|
-
start_of_year = datetime(self.model_reference_date.year, 1, 1)
|
|
316
|
-
|
|
317
|
-
# Calculate the offset from midnight of the new year
|
|
318
|
-
offset = self.model_reference_date - start_of_year
|
|
319
|
-
|
|
320
|
-
# Convert the timedelta to nanoseconds first, then to days
|
|
321
|
-
sfc_time = xr.DataArray(
|
|
322
|
-
(timedelta_index - offset).view("int64") / 3600 / 24 * 1e-9,
|
|
323
|
-
dims="time",
|
|
324
|
-
)
|
|
325
|
-
else:
|
|
326
|
-
# Preserve absolute time coordinate for readability
|
|
327
|
-
ds = ds.assign_coords({"abs_time": ds["time"]})
|
|
328
|
-
|
|
329
|
-
sfc_time = (
|
|
330
|
-
(ds["time"] - np.datetime64(self.model_reference_date)).astype(
|
|
331
|
-
"float64"
|
|
332
|
-
)
|
|
333
|
-
/ 3600
|
|
334
|
-
/ 24
|
|
335
|
-
* 1e-9
|
|
336
|
-
)
|
|
305
|
+
ds, sfc_time = convert_to_roms_time(
|
|
306
|
+
ds, self.model_reference_date, data.climatology
|
|
307
|
+
)
|
|
337
308
|
|
|
338
309
|
if self.type == "physics":
|
|
339
310
|
time_coords = ["time"]
|
|
@@ -347,14 +318,6 @@ class SurfaceForcing:
|
|
|
347
318
|
]
|
|
348
319
|
for time_coord in time_coords:
|
|
349
320
|
ds = ds.assign_coords({time_coord: sfc_time})
|
|
350
|
-
ds[time_coord].attrs[
|
|
351
|
-
"long_name"
|
|
352
|
-
] = f"days since {str(self.model_reference_date)}"
|
|
353
|
-
ds[time_coord].encoding["units"] = "days"
|
|
354
|
-
ds[time_coord].attrs["units"] = "days"
|
|
355
|
-
if data.climatology:
|
|
356
|
-
ds[time_coord].attrs["cycle_length"] = 365.25
|
|
357
|
-
ds.encoding["unlimited_dims"] = "time"
|
|
358
321
|
|
|
359
322
|
if self.type == "bgc":
|
|
360
323
|
ds = ds.drop_vars(["time"])
|
|
@@ -365,7 +328,7 @@ class SurfaceForcing:
|
|
|
365
328
|
|
|
366
329
|
return ds
|
|
367
330
|
|
|
368
|
-
def _validate(self, ds
|
|
331
|
+
def _validate(self, ds):
|
|
369
332
|
"""Validates the dataset by checking for NaN values at wet points, which would
|
|
370
333
|
indicate missing raw data coverage over the target domain.
|
|
371
334
|
|
|
@@ -373,12 +336,6 @@ class SurfaceForcing:
|
|
|
373
336
|
----------
|
|
374
337
|
ds : xarray.Dataset
|
|
375
338
|
The dataset to validate.
|
|
376
|
-
mask : xarray.DataArray
|
|
377
|
-
Land mask (1=ocean, 0=land) to determine wet points in the domain.
|
|
378
|
-
variable_info : dict
|
|
379
|
-
A dictionary containing metadata about each variable (e.g., location,
|
|
380
|
-
whether it's a 3D variable, etc.). Used to retrieve information for
|
|
381
|
-
validating each variable.
|
|
382
339
|
|
|
383
340
|
Raises
|
|
384
341
|
------
|
|
@@ -393,8 +350,8 @@ class SurfaceForcing:
|
|
|
393
350
|
|
|
394
351
|
for var_name in ds.data_vars:
|
|
395
352
|
# Only validate variables based on "validate" flag if use_dask is False
|
|
396
|
-
if not self.use_dask or variable_info[var_name]["validate"]:
|
|
397
|
-
nan_check(ds[var_name].isel(time=0), mask)
|
|
353
|
+
if not self.use_dask or self.variable_info[var_name]["validate"]:
|
|
354
|
+
nan_check(ds[var_name].isel(time=0), self.target_coords["mask"])
|
|
398
355
|
|
|
399
356
|
def _add_global_metadata(self, ds=None):
|
|
400
357
|
|
|
@@ -579,49 +536,8 @@ class SurfaceForcing:
|
|
|
579
536
|
filepath : Union[str, Path]
|
|
580
537
|
The path to the YAML file where the parameters will be saved.
|
|
581
538
|
"""
|
|
582
|
-
filepath = Path(filepath)
|
|
583
|
-
|
|
584
|
-
# Serialize Grid data
|
|
585
|
-
grid_data = asdict(self.grid)
|
|
586
|
-
grid_data.pop("ds", None) # Exclude non-serializable fields
|
|
587
|
-
grid_data.pop("straddle", None)
|
|
588
|
-
|
|
589
|
-
# Include the version of roms-tools
|
|
590
|
-
try:
|
|
591
|
-
roms_tools_version = importlib.metadata.version("roms-tools")
|
|
592
|
-
except importlib.metadata.PackageNotFoundError:
|
|
593
|
-
roms_tools_version = "unknown"
|
|
594
|
-
|
|
595
|
-
# Create header
|
|
596
|
-
header = f"---\nroms_tools_version: {roms_tools_version}\n---\n"
|
|
597
|
-
|
|
598
|
-
# Create YAML data for Grid and optional attributes
|
|
599
|
-
grid_yaml_data = {"Grid": grid_data}
|
|
600
|
-
|
|
601
|
-
# Combine all sections
|
|
602
|
-
surface_forcing_data = {
|
|
603
|
-
"SurfaceForcing": {
|
|
604
|
-
"start_time": self.start_time.isoformat(),
|
|
605
|
-
"end_time": self.end_time.isoformat(),
|
|
606
|
-
"source": self.source,
|
|
607
|
-
"type": self.type,
|
|
608
|
-
"correct_radiation": self.correct_radiation,
|
|
609
|
-
"use_coarse_grid": self.use_coarse_grid,
|
|
610
|
-
"model_reference_date": self.model_reference_date.isoformat(),
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
539
|
|
|
614
|
-
|
|
615
|
-
yaml_data = {
|
|
616
|
-
**grid_yaml_data,
|
|
617
|
-
**surface_forcing_data,
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
with filepath.open("w") as file:
|
|
621
|
-
# Write header
|
|
622
|
-
file.write(header)
|
|
623
|
-
# Write YAML data
|
|
624
|
-
yaml.dump(yaml_data, file, default_flow_style=False, sort_keys=False)
|
|
540
|
+
_to_yaml(self, filepath)
|
|
625
541
|
|
|
626
542
|
@classmethod
|
|
627
543
|
def from_yaml(
|
|
@@ -642,33 +558,8 @@ class SurfaceForcing:
|
|
|
642
558
|
An instance of the SurfaceForcing class.
|
|
643
559
|
"""
|
|
644
560
|
filepath = Path(filepath)
|
|
645
|
-
# Read the entire file content
|
|
646
|
-
with filepath.open("r") as file:
|
|
647
|
-
file_content = file.read()
|
|
648
|
-
|
|
649
|
-
# Split the content into YAML documents
|
|
650
|
-
documents = list(yaml.safe_load_all(file_content))
|
|
651
|
-
|
|
652
|
-
surface_forcing_data = None
|
|
653
|
-
|
|
654
|
-
# Process the YAML documents
|
|
655
|
-
for doc in documents:
|
|
656
|
-
if doc is None:
|
|
657
|
-
continue
|
|
658
|
-
if "SurfaceForcing" in doc:
|
|
659
|
-
surface_forcing_data = doc["SurfaceForcing"]
|
|
660
|
-
|
|
661
|
-
if surface_forcing_data is None:
|
|
662
|
-
raise ValueError("No SurfaceForcing configuration found in the YAML file.")
|
|
663
|
-
|
|
664
|
-
# Convert from string to datetime
|
|
665
|
-
for date_string in ["model_reference_date", "start_time", "end_time"]:
|
|
666
|
-
surface_forcing_data[date_string] = datetime.fromisoformat(
|
|
667
|
-
surface_forcing_data[date_string]
|
|
668
|
-
)
|
|
669
561
|
|
|
670
|
-
# Create Grid instance from the YAML file
|
|
671
562
|
grid = Grid.from_yaml(filepath)
|
|
563
|
+
params = _from_yaml(cls, filepath)
|
|
672
564
|
|
|
673
|
-
|
|
674
|
-
return cls(grid=grid, **surface_forcing_data, use_dask=use_dask)
|
|
565
|
+
return cls(grid=grid, **params, use_dask=use_dask)
|
roms_tools/setup/tides.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
import xarray as xr
|
|
3
3
|
import numpy as np
|
|
4
|
-
import yaml
|
|
5
|
-
import importlib.metadata
|
|
6
4
|
from typing import Dict, Union, List
|
|
7
|
-
|
|
8
|
-
from dataclasses import dataclass, field
|
|
5
|
+
import importlib.metadata
|
|
6
|
+
from dataclasses import dataclass, field
|
|
9
7
|
from roms_tools.setup.grid import Grid
|
|
10
8
|
from roms_tools.setup.plot import _plot
|
|
11
9
|
from roms_tools.setup.datasets import TPXODataset
|
|
@@ -19,6 +17,8 @@ from roms_tools.setup.utils import (
|
|
|
19
17
|
get_target_coords,
|
|
20
18
|
rotate_velocities,
|
|
21
19
|
get_vector_pairs,
|
|
20
|
+
_to_yaml,
|
|
21
|
+
_from_yaml,
|
|
22
22
|
)
|
|
23
23
|
from roms_tools.setup.regrid import LateralRegrid
|
|
24
24
|
import matplotlib.pyplot as plt
|
|
@@ -85,8 +85,8 @@ class TidalForcing:
|
|
|
85
85
|
|
|
86
86
|
data.apply_lateral_fill()
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
var_names = variable_info.keys()
|
|
88
|
+
self._set_variable_info()
|
|
89
|
+
var_names = self.variable_info.keys()
|
|
90
90
|
|
|
91
91
|
processed_fields = {}
|
|
92
92
|
# lateral regridding
|
|
@@ -98,7 +98,7 @@ class TidalForcing:
|
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
# rotation of velocities and interpolation to u/v points
|
|
101
|
-
vector_pairs = get_vector_pairs(variable_info)
|
|
101
|
+
vector_pairs = get_vector_pairs(self.variable_info)
|
|
102
102
|
for pair in vector_pairs:
|
|
103
103
|
u_component = pair[0]
|
|
104
104
|
v_component = pair[1]
|
|
@@ -129,7 +129,7 @@ class TidalForcing:
|
|
|
129
129
|
|
|
130
130
|
ds = self._add_global_metadata(ds)
|
|
131
131
|
|
|
132
|
-
self._validate(ds
|
|
132
|
+
self._validate(ds)
|
|
133
133
|
|
|
134
134
|
# substitute NaNs over land by a fill value to avoid blow-up of ROMS
|
|
135
135
|
for var_name in ds.data_vars:
|
|
@@ -163,9 +163,8 @@ class TidalForcing:
|
|
|
163
163
|
|
|
164
164
|
Returns
|
|
165
165
|
-------
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
about each variable, including 'location', 'is_vector', 'vector_pair', and 'is_3d'.
|
|
166
|
+
None
|
|
167
|
+
This method updates the instance attribute `variable_info` with the metadata dictionary for the variables.
|
|
169
168
|
"""
|
|
170
169
|
default_info = {
|
|
171
170
|
"location": "rho",
|
|
@@ -210,7 +209,7 @@ class TidalForcing:
|
|
|
210
209
|
},
|
|
211
210
|
}
|
|
212
211
|
|
|
213
|
-
|
|
212
|
+
object.__setattr__(self, "variable_info", variable_info)
|
|
214
213
|
|
|
215
214
|
def _write_into_dataset(self, processed_fields, d_meta):
|
|
216
215
|
|
|
@@ -243,7 +242,7 @@ class TidalForcing:
|
|
|
243
242
|
|
|
244
243
|
return ds
|
|
245
244
|
|
|
246
|
-
def _validate(self, ds
|
|
245
|
+
def _validate(self, ds):
|
|
247
246
|
"""Validates the dataset by checking for NaN values at wet points for specified
|
|
248
247
|
variables, which would indicate missing raw data coverage over the target
|
|
249
248
|
domain.
|
|
@@ -252,8 +251,6 @@ class TidalForcing:
|
|
|
252
251
|
----------
|
|
253
252
|
ds : xarray.Dataset
|
|
254
253
|
The dataset to validate, containing tidal variables and a mask for wet points.
|
|
255
|
-
variable_info : dict
|
|
256
|
-
A dictionary containing metadata about the variables, including whether to validate them.
|
|
257
254
|
|
|
258
255
|
Raises
|
|
259
256
|
------
|
|
@@ -268,7 +265,7 @@ class TidalForcing:
|
|
|
268
265
|
"""
|
|
269
266
|
for var_name in ds.data_vars:
|
|
270
267
|
# only validate variables based on "validate" flag if use_dask is false
|
|
271
|
-
if not self.use_dask or variable_info[var_name]["validate"]:
|
|
268
|
+
if not self.use_dask or self.variable_info[var_name]["validate"]:
|
|
272
269
|
nan_check(ds[var_name].isel(ntides=0), self.grid.ds.mask_rho)
|
|
273
270
|
|
|
274
271
|
def plot(self, var_name, ntides=0) -> None:
|
|
@@ -418,42 +415,8 @@ class TidalForcing:
|
|
|
418
415
|
filepath : Union[str, Path]
|
|
419
416
|
The path to the YAML file where the parameters will be saved.
|
|
420
417
|
"""
|
|
421
|
-
filepath = Path(filepath)
|
|
422
418
|
|
|
423
|
-
|
|
424
|
-
grid_data.pop("ds", None) # Exclude non-serializable fields
|
|
425
|
-
grid_data.pop("straddle", None)
|
|
426
|
-
|
|
427
|
-
# Include the version of roms-tools
|
|
428
|
-
try:
|
|
429
|
-
roms_tools_version = importlib.metadata.version("roms-tools")
|
|
430
|
-
except importlib.metadata.PackageNotFoundError:
|
|
431
|
-
roms_tools_version = "unknown"
|
|
432
|
-
|
|
433
|
-
# Create header
|
|
434
|
-
header = f"---\nroms_tools_version: {roms_tools_version}\n---\n"
|
|
435
|
-
|
|
436
|
-
# Extract grid data
|
|
437
|
-
grid_yaml_data = {"Grid": grid_data}
|
|
438
|
-
|
|
439
|
-
# Extract tidal forcing data
|
|
440
|
-
tidal_forcing_data = {
|
|
441
|
-
"TidalForcing": {
|
|
442
|
-
"source": self.source,
|
|
443
|
-
"ntides": self.ntides,
|
|
444
|
-
"allan_factor": self.allan_factor,
|
|
445
|
-
"model_reference_date": self.model_reference_date.isoformat(),
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
# Combine both sections
|
|
450
|
-
yaml_data = {**grid_yaml_data, **tidal_forcing_data}
|
|
451
|
-
|
|
452
|
-
with filepath.open("w") as file:
|
|
453
|
-
# Write header
|
|
454
|
-
file.write(header)
|
|
455
|
-
# Write YAML data
|
|
456
|
-
yaml.dump(yaml_data, file, default_flow_style=False, sort_keys=False)
|
|
419
|
+
_to_yaml(self, filepath)
|
|
457
420
|
|
|
458
421
|
@classmethod
|
|
459
422
|
def from_yaml(
|
|
@@ -474,36 +437,9 @@ class TidalForcing:
|
|
|
474
437
|
An instance of the TidalForcing class.
|
|
475
438
|
"""
|
|
476
439
|
filepath = Path(filepath)
|
|
477
|
-
# Read the entire file content
|
|
478
|
-
with filepath.open("r") as file:
|
|
479
|
-
file_content = file.read()
|
|
480
|
-
|
|
481
|
-
# Split the content into YAML documents
|
|
482
|
-
documents = list(yaml.safe_load_all(file_content))
|
|
483
|
-
|
|
484
|
-
tidal_forcing_data = None
|
|
485
|
-
|
|
486
|
-
# Process the YAML documents
|
|
487
|
-
for doc in documents:
|
|
488
|
-
if doc is None:
|
|
489
|
-
continue
|
|
490
|
-
if "TidalForcing" in doc:
|
|
491
|
-
tidal_forcing_data = doc["TidalForcing"]
|
|
492
|
-
break
|
|
493
|
-
|
|
494
|
-
if tidal_forcing_data is None:
|
|
495
|
-
raise ValueError("No TidalForcing configuration found in the YAML file.")
|
|
496
|
-
|
|
497
|
-
# Convert the model_reference_date from string to datetime
|
|
498
|
-
tidal_forcing_params = tidal_forcing_data
|
|
499
|
-
tidal_forcing_params["model_reference_date"] = datetime.fromisoformat(
|
|
500
|
-
tidal_forcing_params["model_reference_date"]
|
|
501
|
-
)
|
|
502
440
|
|
|
503
|
-
# Create Grid instance from the YAML file
|
|
504
441
|
grid = Grid.from_yaml(filepath)
|
|
505
|
-
|
|
506
|
-
# Create and return an instance of TidalForcing
|
|
442
|
+
tidal_forcing_params = _from_yaml(cls, filepath)
|
|
507
443
|
return cls(grid=grid, **tidal_forcing_params, use_dask=use_dask)
|
|
508
444
|
|
|
509
445
|
def _correct_tides(self, data):
|