roms-tools 1.4.1__py3-none-any.whl → 1.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.
- roms_tools/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +350 -166
- roms_tools/setup/datasets.py +57 -74
- roms_tools/setup/download.py +3 -6
- roms_tools/setup/fill.py +46 -18
- roms_tools/setup/grid.py +74 -113
- roms_tools/setup/initial_conditions.py +209 -76
- roms_tools/setup/regrid.py +198 -0
- roms_tools/setup/surface_forcing.py +167 -80
- roms_tools/setup/tides.py +135 -67
- roms_tools/setup/topography.py +9 -17
- roms_tools/setup/utils.py +251 -77
- roms_tools/setup/vertical_coordinate.py +4 -6
- roms_tools/tests/test_setup/test_boundary_forcing.py +6 -13
- 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 +1 -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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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_north/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 +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zmetadata +1 -1
- 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_from_climatology.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +1 -1
- 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 +1 -1
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zmetadata +1 -1
- 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/0.0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0 +0 -0
- 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/0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0.0 +0 -0
- 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/0.0 +0 -0
- 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/0.0 +0 -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_south/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +2 -62
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +2 -62
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zmetadata +1 -1
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/0.0.0.0 +0 -0
- 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/O2/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/SiO3/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/0.0.0.0 +0 -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/diazC/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/0.0.0.0 +0 -0
- 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/spChl/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/spP/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/initial_conditions_with_bgc_from_climatology.zarr/zooC/0.0.0.0 +0 -0
- roms_tools/tests/test_setup/test_datasets.py +8 -18
- roms_tools/tests/test_setup/test_fill.py +43 -14
- roms_tools/tests/test_setup/test_grid.py +9 -9
- roms_tools/tests/test_setup/test_initial_conditions.py +4 -7
- roms_tools/tests/test_setup/test_regrid.py +59 -0
- roms_tools/tests/test_setup/test_surface_forcing.py +74 -56
- roms_tools/tests/test_setup/test_tides.py +6 -10
- roms_tools/tests/test_setup/test_topography.py +2 -4
- roms_tools/tests/test_setup/test_vertical_coordinate.py +2 -6
- roms_tools/tests/test_utils.py +30 -30
- roms_tools/utils.py +6 -7
- {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/METADATA +2 -2
- {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/RECORD +239 -250
- roms_tools/setup/mixins.py +0 -231
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/0.0 +0 -0
- {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/LICENSE +0 -0
- {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/WHEEL +0 -0
- {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/top_level.txt +0 -0
roms_tools/setup/utils.py
CHANGED
|
@@ -8,8 +8,7 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def nan_check(field, mask) -> None:
|
|
11
|
-
"""
|
|
12
|
-
Checks for NaN values at wet points in the field.
|
|
11
|
+
"""Checks for NaN values at wet points in the field.
|
|
13
12
|
|
|
14
13
|
This function examines the interpolated input field for NaN values at positions indicated as wet points by the mask.
|
|
15
14
|
If any NaN values are found at these wet points, a ValueError is raised.
|
|
@@ -28,7 +27,6 @@ def nan_check(field, mask) -> None:
|
|
|
28
27
|
ValueError
|
|
29
28
|
If the field contains NaN values at any of the wet points indicated by the mask.
|
|
30
29
|
The error message will explain the potential cause and suggest ensuring the dataset's coverage.
|
|
31
|
-
|
|
32
30
|
"""
|
|
33
31
|
|
|
34
32
|
# Replace values in field with 0 where mask is not 1
|
|
@@ -44,8 +42,7 @@ def nan_check(field, mask) -> None:
|
|
|
44
42
|
|
|
45
43
|
|
|
46
44
|
def substitute_nans_by_fillvalue(field, fill_value=0.0) -> xr.DataArray:
|
|
47
|
-
"""
|
|
48
|
-
Replace NaN values in the field with a specified fill value.
|
|
45
|
+
"""Replace NaN values in the field with a specified fill value.
|
|
49
46
|
|
|
50
47
|
This function replaces any NaN values in the input field with the provided fill value.
|
|
51
48
|
|
|
@@ -66,9 +63,7 @@ def substitute_nans_by_fillvalue(field, fill_value=0.0) -> xr.DataArray:
|
|
|
66
63
|
|
|
67
64
|
|
|
68
65
|
def interpolate_from_rho_to_u(field, method="additive"):
|
|
69
|
-
|
|
70
|
-
"""
|
|
71
|
-
Interpolates the given field from rho points to u points.
|
|
66
|
+
"""Interpolates the given field from rho points to u points.
|
|
72
67
|
|
|
73
68
|
This function performs an interpolation from the rho grid (cell centers) to the u grid
|
|
74
69
|
(cell edges in the xi direction). Depending on the chosen method, it either averages
|
|
@@ -114,9 +109,7 @@ def interpolate_from_rho_to_u(field, method="additive"):
|
|
|
114
109
|
|
|
115
110
|
|
|
116
111
|
def interpolate_from_rho_to_v(field, method="additive"):
|
|
117
|
-
|
|
118
|
-
"""
|
|
119
|
-
Interpolates the given field from rho points to v points.
|
|
112
|
+
"""Interpolates the given field from rho points to v points.
|
|
120
113
|
|
|
121
114
|
This function performs an interpolation from the rho grid (cell centers) to the v grid
|
|
122
115
|
(cell edges in the eta direction). Depending on the chosen method, it either averages
|
|
@@ -164,8 +157,8 @@ def interpolate_from_rho_to_v(field, method="additive"):
|
|
|
164
157
|
|
|
165
158
|
|
|
166
159
|
def extrapolate_deepest_to_bottom(field: xr.DataArray, dim: str) -> xr.DataArray:
|
|
167
|
-
"""
|
|
168
|
-
|
|
160
|
+
"""Extrapolates the deepest non-NaN values to the bottom along the specified
|
|
161
|
+
dimension using forward fill.
|
|
169
162
|
|
|
170
163
|
This function assumes that the specified dimension is ordered from top to bottom (e.g., a vertical dimension like 'depth').
|
|
171
164
|
It fills `NaN` values below the deepest valid (non-NaN) entry along the given dimension by carrying forward the last valid value.
|
|
@@ -187,16 +180,43 @@ def extrapolate_deepest_to_bottom(field: xr.DataArray, dim: str) -> xr.DataArray
|
|
|
187
180
|
A new `xarray.DataArray` with the `NaN` values along the specified dimension
|
|
188
181
|
filled by forward filling the deepest valid values down to the bottom.
|
|
189
182
|
The original input data remains unmodified.
|
|
183
|
+
"""
|
|
184
|
+
if dim in field.dims:
|
|
185
|
+
return field.ffill(dim=dim)
|
|
186
|
+
else:
|
|
187
|
+
return field
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def _extrapolate_deepest_to_bottom(data_vars, data) -> dict:
|
|
191
|
+
"""Extrapolate the deepest value to the bottom for variables using the dataset's
|
|
192
|
+
depth dimension.
|
|
193
|
+
|
|
194
|
+
This function fills in missing values at the bottom of each variable by
|
|
195
|
+
carrying forward the deepest available value, ensuring a complete depth profile.
|
|
196
|
+
|
|
197
|
+
Parameters
|
|
198
|
+
----------
|
|
199
|
+
data_vars : dict
|
|
200
|
+
Existing dictionary of variables to be updated.
|
|
201
|
+
data : Dataset
|
|
202
|
+
Dataset containing variables and depth information.
|
|
190
203
|
|
|
204
|
+
Returns
|
|
205
|
+
-------
|
|
206
|
+
dict of str : xarray.DataArray
|
|
207
|
+
Dictionary of variables with the deepest value extrapolated to the bottom.
|
|
191
208
|
"""
|
|
192
|
-
field_interpolated = field.ffill(dim=dim)
|
|
193
209
|
|
|
194
|
-
|
|
210
|
+
for var in data.var_names.keys():
|
|
211
|
+
data_vars[var] = extrapolate_deepest_to_bottom(
|
|
212
|
+
data.ds[data.var_names[var]], data.dim_names["depth"]
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
return data_vars
|
|
195
216
|
|
|
196
217
|
|
|
197
218
|
def assign_dates_to_climatology(ds: xr.Dataset, time_dim: str) -> xr.Dataset:
|
|
198
|
-
"""
|
|
199
|
-
Assigns climatology dates to the dataset's time dimension.
|
|
219
|
+
"""Assigns climatology dates to the dataset's time dimension.
|
|
200
220
|
|
|
201
221
|
This function updates the dataset's time coordinates to reflect climatological dates.
|
|
202
222
|
It defines fixed day increments for each month and assigns these to the specified time dimension.
|
|
@@ -213,7 +233,6 @@ def assign_dates_to_climatology(ds: xr.Dataset, time_dim: str) -> xr.Dataset:
|
|
|
213
233
|
-------
|
|
214
234
|
xr.Dataset
|
|
215
235
|
The updated xarray Dataset with climatological dates assigned to the specified time dimension.
|
|
216
|
-
|
|
217
236
|
"""
|
|
218
237
|
# Define the days in each month and convert to timedelta
|
|
219
238
|
increments = [15, 30, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30]
|
|
@@ -229,8 +248,7 @@ def interpolate_from_climatology(
|
|
|
229
248
|
time_dim_name: str,
|
|
230
249
|
time: Union[xr.DataArray, pd.DatetimeIndex],
|
|
231
250
|
) -> Union[xr.DataArray, xr.Dataset]:
|
|
232
|
-
"""
|
|
233
|
-
Interpolates the given field temporally based on the specified time points.
|
|
251
|
+
"""Interpolates the given field temporally based on the specified time points.
|
|
234
252
|
|
|
235
253
|
If `field` is an xarray.Dataset, this function applies the interpolation to all data variables in the dataset.
|
|
236
254
|
|
|
@@ -305,8 +323,7 @@ def interpolate_from_climatology(
|
|
|
305
323
|
|
|
306
324
|
|
|
307
325
|
def get_time_type(data_array: xr.DataArray) -> str:
|
|
308
|
-
"""
|
|
309
|
-
Determines the type of time values in the xarray DataArray.
|
|
326
|
+
"""Determines the type of time values in the xarray DataArray.
|
|
310
327
|
|
|
311
328
|
Parameters
|
|
312
329
|
----------
|
|
@@ -354,8 +371,7 @@ def get_time_type(data_array: xr.DataArray) -> str:
|
|
|
354
371
|
|
|
355
372
|
|
|
356
373
|
def convert_cftime_to_datetime(data_array: np.ndarray) -> np.ndarray:
|
|
357
|
-
"""
|
|
358
|
-
Converts cftime datetime objects to numpy datetime64 objects in a numpy ndarray.
|
|
374
|
+
"""Converts cftime datetime objects to numpy datetime64 objects in a numpy ndarray.
|
|
359
375
|
|
|
360
376
|
Parameters
|
|
361
377
|
----------
|
|
@@ -391,8 +407,7 @@ def convert_cftime_to_datetime(data_array: np.ndarray) -> np.ndarray:
|
|
|
391
407
|
|
|
392
408
|
|
|
393
409
|
def get_variable_metadata():
|
|
394
|
-
"""
|
|
395
|
-
Retrieves metadata for commonly used variables in the dataset.
|
|
410
|
+
"""Retrieves metadata for commonly used variables in the dataset.
|
|
396
411
|
|
|
397
412
|
This function returns a dictionary containing the metadata for various variables, including long names
|
|
398
413
|
and units for each variable.
|
|
@@ -401,7 +416,6 @@ def get_variable_metadata():
|
|
|
401
416
|
-------
|
|
402
417
|
dict of str: dict
|
|
403
418
|
Dictionary where keys are variable names and values are dictionaries with "long_name" and "units" keys.
|
|
404
|
-
|
|
405
419
|
"""
|
|
406
420
|
|
|
407
421
|
d = {
|
|
@@ -518,49 +532,8 @@ def get_variable_metadata():
|
|
|
518
532
|
return d
|
|
519
533
|
|
|
520
534
|
|
|
521
|
-
def get_boundary_info():
|
|
522
|
-
|
|
523
|
-
"""
|
|
524
|
-
This function provides information about the boundary points for the rho, u, and v
|
|
525
|
-
variables on the grid, specifying the indices for the south, east, north, and west
|
|
526
|
-
boundaries.
|
|
527
|
-
|
|
528
|
-
Returns
|
|
529
|
-
-------
|
|
530
|
-
dict
|
|
531
|
-
A dictionary where keys are variable types ("rho", "u", "v"), and values
|
|
532
|
-
are nested dictionaries mapping directions ("south", "east", "north", "west")
|
|
533
|
-
to the corresponding boundary coordinates.
|
|
534
|
-
"""
|
|
535
|
-
|
|
536
|
-
# Boundary coordinates
|
|
537
|
-
bdry_coords = {
|
|
538
|
-
"rho": {
|
|
539
|
-
"south": {"eta_rho": 0},
|
|
540
|
-
"east": {"xi_rho": -1},
|
|
541
|
-
"north": {"eta_rho": -1},
|
|
542
|
-
"west": {"xi_rho": 0},
|
|
543
|
-
},
|
|
544
|
-
"u": {
|
|
545
|
-
"south": {"eta_rho": 0},
|
|
546
|
-
"east": {"xi_u": -1},
|
|
547
|
-
"north": {"eta_rho": -1},
|
|
548
|
-
"west": {"xi_u": 0},
|
|
549
|
-
},
|
|
550
|
-
"v": {
|
|
551
|
-
"south": {"eta_v": 0},
|
|
552
|
-
"east": {"xi_rho": -1},
|
|
553
|
-
"north": {"eta_v": -1},
|
|
554
|
-
"west": {"xi_rho": 0},
|
|
555
|
-
},
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return bdry_coords
|
|
559
|
-
|
|
560
|
-
|
|
561
535
|
def extract_single_value(data):
|
|
562
|
-
"""
|
|
563
|
-
Extracts a single value from an xarray.DataArray or numpy array.
|
|
536
|
+
"""Extracts a single value from an xarray.DataArray or numpy array.
|
|
564
537
|
|
|
565
538
|
Parameters
|
|
566
539
|
----------
|
|
@@ -589,8 +562,8 @@ def extract_single_value(data):
|
|
|
589
562
|
|
|
590
563
|
|
|
591
564
|
def group_dataset(ds, filepath):
|
|
592
|
-
"""
|
|
593
|
-
|
|
565
|
+
"""Group the dataset into monthly or yearly subsets based on the frequency of the
|
|
566
|
+
data.
|
|
594
567
|
|
|
595
568
|
Parameters
|
|
596
569
|
----------
|
|
@@ -643,8 +616,7 @@ def group_dataset(ds, filepath):
|
|
|
643
616
|
|
|
644
617
|
|
|
645
618
|
def group_by_month(ds, filepath):
|
|
646
|
-
"""
|
|
647
|
-
Group the dataset by month and generate filenames with 'YYYYMM' format.
|
|
619
|
+
"""Group the dataset by month and generate filenames with 'YYYYMM' format.
|
|
648
620
|
|
|
649
621
|
Parameters
|
|
650
622
|
----------
|
|
@@ -681,8 +653,7 @@ def group_by_month(ds, filepath):
|
|
|
681
653
|
|
|
682
654
|
|
|
683
655
|
def group_by_year(ds, filepath):
|
|
684
|
-
"""
|
|
685
|
-
Group the dataset by year and generate filenames with 'YYYY' format.
|
|
656
|
+
"""Group the dataset by year and generate filenames with 'YYYY' format.
|
|
686
657
|
|
|
687
658
|
Parameters
|
|
688
659
|
----------
|
|
@@ -715,8 +686,7 @@ def group_by_year(ds, filepath):
|
|
|
715
686
|
|
|
716
687
|
|
|
717
688
|
def save_datasets(dataset_list, output_filenames, np_eta=None, np_xi=None):
|
|
718
|
-
"""
|
|
719
|
-
Save the list of datasets to netCDF4 files, with optional spatial partitioning.
|
|
689
|
+
"""Save the list of datasets to netCDF4 files, with optional spatial partitioning.
|
|
720
690
|
|
|
721
691
|
Parameters
|
|
722
692
|
----------
|
|
@@ -766,3 +736,207 @@ def save_datasets(dataset_list, output_filenames, np_eta=None, np_xi=None):
|
|
|
766
736
|
saved_filenames.extend(Path(f) for f in partitioned_filenames)
|
|
767
737
|
|
|
768
738
|
return saved_filenames
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
def get_target_coords(grid, use_coarse_grid=False):
|
|
742
|
+
"""Retrieves longitude and latitude coordinates from the grid, adjusting them based
|
|
743
|
+
on longitude range.
|
|
744
|
+
|
|
745
|
+
Parameters
|
|
746
|
+
----------
|
|
747
|
+
grid : Grid
|
|
748
|
+
Object representing the grid information used for the model.
|
|
749
|
+
use_coarse_grid : bool, optional
|
|
750
|
+
Use coarse grid data if True. Defaults to False.
|
|
751
|
+
|
|
752
|
+
Returns
|
|
753
|
+
-------
|
|
754
|
+
dict
|
|
755
|
+
Dictionary containing the longitude, latitude, and angle arrays, along with a boolean indicating
|
|
756
|
+
if the grid straddles the meridian.
|
|
757
|
+
"""
|
|
758
|
+
# Select grid variables based on whether the coarse grid is used
|
|
759
|
+
if use_coarse_grid:
|
|
760
|
+
lat, lon, angle = (
|
|
761
|
+
grid.ds.lat_coarse,
|
|
762
|
+
grid.ds.lon_coarse,
|
|
763
|
+
grid.ds.angle_coarse,
|
|
764
|
+
)
|
|
765
|
+
lat_psi = grid.ds.get("lat_psi_coarse")
|
|
766
|
+
lon_psi = grid.ds.get("lon_psi_coarse")
|
|
767
|
+
else:
|
|
768
|
+
lat, lon, angle = (
|
|
769
|
+
grid.ds.lat_rho,
|
|
770
|
+
grid.ds.lon_rho,
|
|
771
|
+
grid.ds.angle,
|
|
772
|
+
)
|
|
773
|
+
lat_psi = grid.ds.get("lat_psi")
|
|
774
|
+
lon_psi = grid.ds.get("lon_psi")
|
|
775
|
+
|
|
776
|
+
# Operate on longitudes between -180 and 180 unless ROMS domain lies at least 5 degrees in lontitude away from Greenwich meridian
|
|
777
|
+
lon = xr.where(lon > 180, lon - 360, lon)
|
|
778
|
+
if lon_psi is not None:
|
|
779
|
+
lon_psi = xr.where(lon_psi > 180, lon_psi - 360, lon_psi)
|
|
780
|
+
|
|
781
|
+
straddle = True
|
|
782
|
+
if not grid.straddle and abs(lon).min() > 5:
|
|
783
|
+
lon = xr.where(lon < 0, lon + 360, lon)
|
|
784
|
+
if lon_psi is not None:
|
|
785
|
+
lon_psi = xr.where(lon_psi < 0, lon_psi + 360, lon_psi)
|
|
786
|
+
straddle = False
|
|
787
|
+
|
|
788
|
+
target_coords = {
|
|
789
|
+
"lat": lat,
|
|
790
|
+
"lon": lon,
|
|
791
|
+
"lat_psi": lat_psi,
|
|
792
|
+
"lon_psi": lon_psi,
|
|
793
|
+
"angle": angle,
|
|
794
|
+
"straddle": straddle,
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
return target_coords
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
def rotate_velocities(
|
|
801
|
+
u: xr.DataArray, v: xr.DataArray, angle: xr.DataArray, interpolate: bool = True
|
|
802
|
+
) -> tuple[xr.DataArray, xr.DataArray]:
|
|
803
|
+
"""Rotate and optionally interpolate velocity components to align with grid
|
|
804
|
+
orientation.
|
|
805
|
+
|
|
806
|
+
Parameters
|
|
807
|
+
----------
|
|
808
|
+
u : xarray.DataArray
|
|
809
|
+
Zonal (east-west) velocity component at u-points.
|
|
810
|
+
v : xarray.DataArray
|
|
811
|
+
Meridional (north-south) velocity component at v-points.
|
|
812
|
+
angle : xarray.DataArray
|
|
813
|
+
Grid angle values for rotation.
|
|
814
|
+
interpolate : bool, optional
|
|
815
|
+
If True, interpolates rotated velocities to grid points (default is True).
|
|
816
|
+
|
|
817
|
+
Returns
|
|
818
|
+
-------
|
|
819
|
+
tuple of xarray.DataArray
|
|
820
|
+
Rotated velocity components (u_rot, v_rot).
|
|
821
|
+
|
|
822
|
+
Notes
|
|
823
|
+
-----
|
|
824
|
+
- Rotation formulas:
|
|
825
|
+
- u_rot = u * cos(angle) + v * sin(angle)
|
|
826
|
+
- v_rot = v * cos(angle) - u * sin(angle)
|
|
827
|
+
"""
|
|
828
|
+
|
|
829
|
+
# Rotate velocities to grid orientation
|
|
830
|
+
u_rot = u * np.cos(angle) + v * np.sin(angle)
|
|
831
|
+
v_rot = v * np.cos(angle) - u * np.sin(angle)
|
|
832
|
+
|
|
833
|
+
# Interpolate to u- and v-points
|
|
834
|
+
if interpolate:
|
|
835
|
+
u_rot = interpolate_from_rho_to_u(u_rot)
|
|
836
|
+
v_rot = interpolate_from_rho_to_v(v_rot)
|
|
837
|
+
|
|
838
|
+
return u_rot, v_rot
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
def compute_barotropic_velocity(
|
|
842
|
+
vel: xr.DataArray, interface_depth: xr.DataArray
|
|
843
|
+
) -> xr.DataArray:
|
|
844
|
+
"""Compute barotropic (depth-averaged) velocity from 3D velocity.
|
|
845
|
+
|
|
846
|
+
Assumes `vel` and `interface_depth` are at the same horizontal grid location.
|
|
847
|
+
|
|
848
|
+
Parameters
|
|
849
|
+
----------
|
|
850
|
+
vel : xarray.DataArray
|
|
851
|
+
Velocity components (zonal and meridional) at u- and v-points.
|
|
852
|
+
interface_depth : xarray.DataArray
|
|
853
|
+
Depth values for computing layer thickness.
|
|
854
|
+
|
|
855
|
+
Returns
|
|
856
|
+
-------
|
|
857
|
+
xarray.DataArray
|
|
858
|
+
Depth-averaged velocity (`vel_bar`).
|
|
859
|
+
|
|
860
|
+
Notes
|
|
861
|
+
-----
|
|
862
|
+
Computed as:
|
|
863
|
+
- `vel_bar` = sum(dz * vel) / sum(dz)
|
|
864
|
+
"""
|
|
865
|
+
|
|
866
|
+
# Layer thickness
|
|
867
|
+
dz = -interface_depth.diff(dim="s_w")
|
|
868
|
+
dz = dz.rename({"s_w": "s_rho"})
|
|
869
|
+
|
|
870
|
+
vel_bar = (dz * vel).sum(dim="s_rho") / dz.sum(dim="s_rho")
|
|
871
|
+
|
|
872
|
+
return vel_bar
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
def transpose_dimensions(da: xr.DataArray) -> xr.DataArray:
|
|
876
|
+
"""Transpose the dimensions of an xarray.DataArray to ensure that 'time', any
|
|
877
|
+
dimension starting with 's_', 'eta_', and 'xi_' are ordered first, followed by the
|
|
878
|
+
remaining dimensions in their original order.
|
|
879
|
+
|
|
880
|
+
Parameters
|
|
881
|
+
----------
|
|
882
|
+
da : xarray.DataArray
|
|
883
|
+
The input DataArray whose dimensions are to be reordered.
|
|
884
|
+
|
|
885
|
+
Returns
|
|
886
|
+
-------
|
|
887
|
+
xarray.DataArray
|
|
888
|
+
The DataArray with dimensions reordered so that 'time', 's_*', 'eta_*',
|
|
889
|
+
and 'xi_*' are first, in that order, if they exist.
|
|
890
|
+
"""
|
|
891
|
+
|
|
892
|
+
# List of preferred dimension patterns
|
|
893
|
+
preferred_order = ["time", "s_", "eta_", "xi_"]
|
|
894
|
+
|
|
895
|
+
# Get the existing dimensions in the DataArray
|
|
896
|
+
dims = list(da.dims)
|
|
897
|
+
|
|
898
|
+
# Collect dimensions that match any of the preferred patterns
|
|
899
|
+
matched_dims = []
|
|
900
|
+
for pattern in preferred_order:
|
|
901
|
+
# Find dimensions that start with the pattern
|
|
902
|
+
matched_dims += [dim for dim in dims if dim.startswith(pattern)]
|
|
903
|
+
|
|
904
|
+
# Create a new order: first the matched dimensions, then the rest
|
|
905
|
+
remaining_dims = [dim for dim in dims if dim not in matched_dims]
|
|
906
|
+
new_order = matched_dims + remaining_dims
|
|
907
|
+
|
|
908
|
+
# Transpose the DataArray to the new order
|
|
909
|
+
transposed_da = da.transpose(*new_order)
|
|
910
|
+
|
|
911
|
+
return transposed_da
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
def get_vector_pairs(variable_info):
|
|
915
|
+
"""Extracts all unique vector pairs from the variable_info dictionary.
|
|
916
|
+
|
|
917
|
+
Parameters
|
|
918
|
+
----------
|
|
919
|
+
variable_info : dict
|
|
920
|
+
Dictionary containing variable information, including location,
|
|
921
|
+
whether it's a vector, and its vector pair.
|
|
922
|
+
|
|
923
|
+
Returns
|
|
924
|
+
-------
|
|
925
|
+
list of tuples
|
|
926
|
+
List of unique vector pairs, where each tuple contains the names of
|
|
927
|
+
the two vector components (e.g., ("u", "v")).
|
|
928
|
+
"""
|
|
929
|
+
vector_pairs = []
|
|
930
|
+
processed = set() # Track variables that have already been paired
|
|
931
|
+
|
|
932
|
+
for var_name, var_info in variable_info.items():
|
|
933
|
+
if var_info["is_vector"] and var_name not in processed:
|
|
934
|
+
vector_pair = var_info["vector_pair"]
|
|
935
|
+
|
|
936
|
+
# Ensure the vector_pair exists in the dictionary and has not been processed
|
|
937
|
+
if vector_pair and vector_pair in variable_info:
|
|
938
|
+
vector_pairs.append((var_name, vector_pair))
|
|
939
|
+
# Mark both the variable and its pair as processed
|
|
940
|
+
processed.update([var_name, vector_pair])
|
|
941
|
+
|
|
942
|
+
return vector_pairs
|
|
@@ -3,8 +3,8 @@ import xarray as xr
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def compute_cs(sigma, theta_s, theta_b):
|
|
6
|
-
"""
|
|
7
|
-
|
|
6
|
+
"""Compute the S-coordinate stretching curves according to Shchepetkin and
|
|
7
|
+
McWilliams (2009).
|
|
8
8
|
|
|
9
9
|
Parameters
|
|
10
10
|
----------
|
|
@@ -37,8 +37,7 @@ def compute_cs(sigma, theta_s, theta_b):
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def sigma_stretch(theta_s, theta_b, N, type):
|
|
40
|
-
"""
|
|
41
|
-
Compute sigma and stretching curves based on the type and parameters.
|
|
40
|
+
"""Compute sigma and stretching curves based on the type and parameters.
|
|
42
41
|
|
|
43
42
|
Parameters
|
|
44
43
|
----------
|
|
@@ -80,8 +79,7 @@ def sigma_stretch(theta_s, theta_b, N, type):
|
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
def compute_depth(zeta, h, hc, cs, sigma):
|
|
83
|
-
"""
|
|
84
|
-
Compute the depth at different sigma levels.
|
|
82
|
+
"""Compute the depth at different sigma levels.
|
|
85
83
|
|
|
86
84
|
Parameters
|
|
87
85
|
----------
|
|
@@ -8,9 +8,7 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def test_boundary_forcing_creation(boundary_forcing):
|
|
11
|
-
"""
|
|
12
|
-
Test the creation of the BoundaryForcing object.
|
|
13
|
-
"""
|
|
11
|
+
"""Test the creation of the BoundaryForcing object."""
|
|
14
12
|
|
|
15
13
|
fname = download_test_data("GLORYS_coarse_test_data.nc")
|
|
16
14
|
|
|
@@ -43,9 +41,7 @@ def test_boundary_forcing_creation(boundary_forcing):
|
|
|
43
41
|
|
|
44
42
|
|
|
45
43
|
def test_boundary_forcing_creation_with_bgc(bgc_boundary_forcing_from_climatology):
|
|
46
|
-
"""
|
|
47
|
-
Test the creation of the BoundaryForcing object.
|
|
48
|
-
"""
|
|
44
|
+
"""Test the creation of the BoundaryForcing object."""
|
|
49
45
|
|
|
50
46
|
fname_bgc = download_test_data("CESM_regional_coarse_test_data_climatology.nc")
|
|
51
47
|
|
|
@@ -80,9 +76,7 @@ def test_boundary_forcing_creation_with_bgc(bgc_boundary_forcing_from_climatolog
|
|
|
80
76
|
|
|
81
77
|
|
|
82
78
|
def test_boundary_forcing_plot_save(boundary_forcing, tmp_path):
|
|
83
|
-
"""
|
|
84
|
-
Test plot and save methods.
|
|
85
|
-
"""
|
|
79
|
+
"""Test plot and save methods."""
|
|
86
80
|
|
|
87
81
|
boundary_forcing.plot(varname="temp_south", layer_contours=True)
|
|
88
82
|
boundary_forcing.plot(varname="temp_east", layer_contours=True)
|
|
@@ -128,9 +122,7 @@ def test_boundary_forcing_plot_save(boundary_forcing, tmp_path):
|
|
|
128
122
|
def test_bgc_boundary_forcing_plot_save(
|
|
129
123
|
bgc_boundary_forcing_from_climatology, tmp_path
|
|
130
124
|
):
|
|
131
|
-
"""
|
|
132
|
-
Test plot and save methods.
|
|
133
|
-
"""
|
|
125
|
+
"""Test plot and save methods."""
|
|
134
126
|
|
|
135
127
|
bgc_boundary_forcing_from_climatology.plot(varname="ALK_south")
|
|
136
128
|
bgc_boundary_forcing_from_climatology.plot(varname="ALK_east")
|
|
@@ -176,7 +168,8 @@ def test_bgc_boundary_forcing_plot_save(
|
|
|
176
168
|
],
|
|
177
169
|
)
|
|
178
170
|
def test_roundtrip_yaml(bdry_forcing_fixture, request, tmp_path, use_dask):
|
|
179
|
-
"""Test that creating a BoundaryForcing object, saving its parameters to yaml file,
|
|
171
|
+
"""Test that creating a BoundaryForcing object, saving its parameters to yaml file,
|
|
172
|
+
and re-opening yaml file creates the same object."""
|
|
180
173
|
|
|
181
174
|
bdry_forcing = request.getfixturevalue(bdry_forcing_fixture)
|
|
182
175
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"end_time": "2021-06-30 00:00:00",
|
|
4
4
|
"hc": 250.0,
|
|
5
5
|
"model_reference_date": "2000-01-01 00:00:00",
|
|
6
|
-
"roms_tools_version": "0.1.
|
|
6
|
+
"roms_tools_version": "0.1.dev157+dirty",
|
|
7
7
|
"source": "CESM_REGRIDDED",
|
|
8
8
|
"start_time": "2021-06-29 00:00:00",
|
|
9
9
|
"theta_b": 2.0,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"end_time": "2021-06-30 00:00:00",
|
|
6
6
|
"hc": 250.0,
|
|
7
7
|
"model_reference_date": "2000-01-01 00:00:00",
|
|
8
|
-
"roms_tools_version": "0.1.
|
|
8
|
+
"roms_tools_version": "0.1.dev157+dirty",
|
|
9
9
|
"source": "CESM_REGRIDDED",
|
|
10
10
|
"start_time": "2021-06-29 00:00:00",
|
|
11
11
|
"theta_b": 2.0,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/0.0.0
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0
CHANGED
|
Binary file
|
roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0
CHANGED
|
Binary file
|