roms-tools 1.5.0__py3-none-any.whl → 1.6.1__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 +263 -100
- roms_tools/setup/datasets.py +169 -39
- roms_tools/setup/fill.py +0 -36
- roms_tools/setup/grid.py +1 -1
- roms_tools/setup/initial_conditions.py +108 -73
- roms_tools/setup/regrid.py +43 -98
- roms_tools/setup/surface_forcing.py +104 -82
- roms_tools/setup/tides.py +76 -48
- roms_tools/setup/utils.py +25 -53
- roms_tools/tests/test_setup/test_boundary_forcing.py +84 -47
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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/dust/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/iron/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nhy/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nox/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air_alt/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_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/dust/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zmetadata +7 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/.zattrs +3 -0
- 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_south/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_south/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/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/.zattrs +1 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/.zmetadata +1 -1
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/Tair/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/lwrad/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/qair/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/rain/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/swrad/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/uwnd/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/vwnd/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/.zmetadata +1 -1
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/Tair/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/lwrad/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/qair/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/rain/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/swrad/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/uwnd/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/vwnd/0.0.0 +0 -0
- 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_data/surface_forcing.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/.zmetadata +1 -1
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/Tair/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/lwrad/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/qair/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/rain/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/swrad/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/uwnd/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/vwnd/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/.zmetadata +4 -2
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/omega/.zattrs +3 -1
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/pot_Im/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/pot_Re/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/ssh_Im/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/ssh_Re/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/0.0.0 +0 -0
- roms_tools/tests/test_setup/test_datasets.py +79 -21
- roms_tools/tests/test_setup/test_fill.py +18 -105
- roms_tools/tests/test_setup/test_initial_conditions.py +29 -25
- roms_tools/tests/test_setup/test_regrid.py +2 -8
- roms_tools/tests/test_setup/test_surface_forcing.py +49 -29
- roms_tools/tests/test_setup/test_tides.py +7 -5
- {roms_tools-1.5.0.dist-info → roms_tools-1.6.1.dist-info}/METADATA +13 -3
- {roms_tools-1.5.0.dist-info → roms_tools-1.6.1.dist-info}/RECORD +239 -239
- {roms_tools-1.5.0.dist-info → roms_tools-1.6.1.dist-info}/WHEEL +1 -1
- {roms_tools-1.5.0.dist-info → roms_tools-1.6.1.dist-info}/LICENSE +0 -0
- {roms_tools-1.5.0.dist-info → roms_tools-1.6.1.dist-info}/top_level.txt +0 -0
|
@@ -15,11 +15,9 @@ from roms_tools.setup.utils import (
|
|
|
15
15
|
get_target_coords,
|
|
16
16
|
rotate_velocities,
|
|
17
17
|
compute_barotropic_velocity,
|
|
18
|
-
_extrapolate_deepest_to_bottom,
|
|
19
18
|
transpose_dimensions,
|
|
20
19
|
)
|
|
21
|
-
from roms_tools.setup.
|
|
22
|
-
from roms_tools.setup.regrid import _lateral_regrid, _vertical_regrid
|
|
20
|
+
from roms_tools.setup.regrid import LateralRegrid, VerticalRegrid
|
|
23
21
|
from roms_tools.setup.plot import _plot, _section_plot, _profile_plot, _line_plot
|
|
24
22
|
import matplotlib.pyplot as plt
|
|
25
23
|
from pathlib import Path
|
|
@@ -92,31 +90,31 @@ class InitialConditions:
|
|
|
92
90
|
|
|
93
91
|
self._input_checks()
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
processed_fields = {}
|
|
94
|
+
processed_fields = self._process_data(processed_fields, type="physics")
|
|
97
95
|
|
|
98
96
|
if self.bgc_source is not None:
|
|
99
|
-
|
|
97
|
+
processed_fields = self._process_data(processed_fields, type="bgc")
|
|
100
98
|
|
|
101
|
-
for
|
|
102
|
-
|
|
99
|
+
for var_name in processed_fields.keys():
|
|
100
|
+
processed_fields[var_name] = transpose_dimensions(
|
|
101
|
+
processed_fields[var_name]
|
|
102
|
+
)
|
|
103
103
|
|
|
104
104
|
d_meta = get_variable_metadata()
|
|
105
|
-
ds = self._write_into_dataset(
|
|
105
|
+
ds = self._write_into_dataset(processed_fields, d_meta)
|
|
106
106
|
|
|
107
107
|
ds = self._add_global_metadata(ds)
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
# NaN values at wet points indicate that the raw data did not cover the domain, and the following will raise a ValueError
|
|
111
|
-
nan_check(ds["zeta"].squeeze(), self.grid.ds.mask_rho)
|
|
109
|
+
self._validate(ds)
|
|
112
110
|
|
|
113
111
|
# substitute NaNs over land by a fill value to avoid blow-up of ROMS
|
|
114
|
-
for
|
|
115
|
-
ds[
|
|
112
|
+
for var_name in ds.data_vars:
|
|
113
|
+
ds[var_name] = substitute_nans_by_fillvalue(ds[var_name])
|
|
116
114
|
|
|
117
115
|
object.__setattr__(self, "ds", ds)
|
|
118
116
|
|
|
119
|
-
def _process_data(self,
|
|
117
|
+
def _process_data(self, processed_fields, type="physics"):
|
|
120
118
|
|
|
121
119
|
target_coords = get_target_coords(self.grid)
|
|
122
120
|
|
|
@@ -126,35 +124,29 @@ class InitialConditions:
|
|
|
126
124
|
data = self._get_bgc_data()
|
|
127
125
|
|
|
128
126
|
data.choose_subdomain(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
target_coords["lat"].max().values,
|
|
132
|
-
],
|
|
133
|
-
longitude_range=[
|
|
134
|
-
target_coords["lon"].min().values,
|
|
135
|
-
target_coords["lon"].max().values,
|
|
136
|
-
],
|
|
137
|
-
margin=2,
|
|
138
|
-
straddle=target_coords["straddle"],
|
|
127
|
+
target_coords,
|
|
128
|
+
buffer_points=20, # lateral fill needs good buffer from data margin
|
|
139
129
|
)
|
|
140
130
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
data_vars = _extrapolate_deepest_to_bottom(data_vars, data)
|
|
131
|
+
data.extrapolate_deepest_to_bottom()
|
|
132
|
+
data.apply_lateral_fill()
|
|
144
133
|
|
|
145
|
-
|
|
134
|
+
variable_info = self._set_variable_info(data, type=type)
|
|
135
|
+
var_names = variable_info.keys()
|
|
146
136
|
|
|
147
137
|
# lateral regridding
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
lateral_regrid = LateralRegrid(target_coords, data.dim_names)
|
|
139
|
+
for var_name in var_names:
|
|
140
|
+
if var_name in data.var_names.keys():
|
|
141
|
+
processed_fields[var_name] = lateral_regrid.apply(
|
|
142
|
+
data.ds[data.var_names[var_name]]
|
|
143
|
+
)
|
|
152
144
|
|
|
153
145
|
# rotation of velocities and interpolation to u/v points
|
|
154
146
|
if "u" in variable_info and "v" in variable_info:
|
|
155
|
-
(
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
(processed_fields["u"], processed_fields["v"],) = rotate_velocities(
|
|
148
|
+
processed_fields["u"],
|
|
149
|
+
processed_fields["v"],
|
|
158
150
|
target_coords["angle"],
|
|
159
151
|
interpolate=True,
|
|
160
152
|
)
|
|
@@ -167,28 +159,32 @@ class InitialConditions:
|
|
|
167
159
|
if info["location"] == location and info["is_3d"]
|
|
168
160
|
]
|
|
169
161
|
if len(var_names) > 0:
|
|
170
|
-
|
|
171
|
-
data,
|
|
162
|
+
vertical_regrid = VerticalRegrid(
|
|
172
163
|
self.grid.ds[f"layer_depth_{location}"],
|
|
173
|
-
|
|
174
|
-
var_names,
|
|
164
|
+
data.ds[data.dim_names["depth"]],
|
|
175
165
|
)
|
|
166
|
+
for var_name in var_names:
|
|
167
|
+
if var_name in processed_fields:
|
|
168
|
+
processed_fields[var_name] = vertical_regrid.apply(
|
|
169
|
+
processed_fields[var_name]
|
|
170
|
+
)
|
|
176
171
|
|
|
177
172
|
# compute barotropic velocities
|
|
178
173
|
if "u" in variable_info and "v" in variable_info:
|
|
179
|
-
for
|
|
180
|
-
|
|
181
|
-
|
|
174
|
+
for var_name in ["u", "v"]:
|
|
175
|
+
processed_fields[f"{var_name}bar"] = compute_barotropic_velocity(
|
|
176
|
+
processed_fields[var_name],
|
|
177
|
+
self.grid.ds[f"interface_depth_{var_name}"],
|
|
182
178
|
)
|
|
183
179
|
|
|
184
180
|
if type == "bgc":
|
|
185
181
|
# Ensure time coordinate matches that of physical variables
|
|
186
|
-
for
|
|
187
|
-
|
|
188
|
-
{"time":
|
|
182
|
+
for var_name in variable_info.keys():
|
|
183
|
+
processed_fields[var_name] = processed_fields[var_name].assign_coords(
|
|
184
|
+
{"time": processed_fields["temp"]["time"]}
|
|
189
185
|
)
|
|
190
186
|
|
|
191
|
-
return
|
|
187
|
+
return processed_fields
|
|
192
188
|
|
|
193
189
|
def _input_checks(self):
|
|
194
190
|
|
|
@@ -314,24 +310,26 @@ class InitialConditions:
|
|
|
314
310
|
}
|
|
315
311
|
elif type == "bgc":
|
|
316
312
|
variable_info = {}
|
|
317
|
-
for
|
|
318
|
-
variable_info[
|
|
313
|
+
for var_name in data.var_names.keys():
|
|
314
|
+
variable_info[var_name] = default_info
|
|
319
315
|
|
|
320
316
|
return variable_info
|
|
321
317
|
|
|
322
|
-
def _write_into_dataset(self,
|
|
318
|
+
def _write_into_dataset(self, processed_fields, d_meta):
|
|
323
319
|
|
|
324
320
|
# save in new dataset
|
|
325
321
|
ds = xr.Dataset()
|
|
326
322
|
|
|
327
|
-
for
|
|
328
|
-
ds[
|
|
329
|
-
ds[
|
|
330
|
-
ds[
|
|
323
|
+
for var_name in processed_fields.keys():
|
|
324
|
+
ds[var_name] = processed_fields[var_name].astype(np.float32)
|
|
325
|
+
ds[var_name].attrs["long_name"] = d_meta[var_name]["long_name"]
|
|
326
|
+
ds[var_name].attrs["units"] = d_meta[var_name]["units"]
|
|
331
327
|
|
|
332
328
|
# initialize vertical velocity to zero
|
|
333
329
|
ds["w"] = xr.zeros_like(
|
|
334
|
-
self.grid.ds["interface_depth_rho"].expand_dims(
|
|
330
|
+
self.grid.ds["interface_depth_rho"].expand_dims(
|
|
331
|
+
time=processed_fields["u"].time
|
|
332
|
+
)
|
|
335
333
|
).astype(np.float32)
|
|
336
334
|
ds["w"].attrs["long_name"] = d_meta["w"]["long_name"]
|
|
337
335
|
ds["w"].attrs["units"] = d_meta["w"]["units"]
|
|
@@ -351,7 +349,7 @@ class InitialConditions:
|
|
|
351
349
|
"layer_depth_v",
|
|
352
350
|
"interface_depth_v",
|
|
353
351
|
]
|
|
354
|
-
existing_vars = [
|
|
352
|
+
existing_vars = [var_name for var_name in variables_to_drop if var_name in ds]
|
|
355
353
|
ds = ds.drop_vars(existing_vars)
|
|
356
354
|
|
|
357
355
|
ds["Cs_r"] = self.grid.ds["Cs_r"]
|
|
@@ -375,6 +373,29 @@ class InitialConditions:
|
|
|
375
373
|
|
|
376
374
|
return ds
|
|
377
375
|
|
|
376
|
+
def _validate(self, ds):
|
|
377
|
+
"""Validates the dataset by checking for NaN values in SSH at wet points, which
|
|
378
|
+
would indicate missing raw data coverage over the target domain.
|
|
379
|
+
|
|
380
|
+
Parameters
|
|
381
|
+
----------
|
|
382
|
+
ds : xarray.Dataset
|
|
383
|
+
The dataset to validate.
|
|
384
|
+
|
|
385
|
+
Raises
|
|
386
|
+
------
|
|
387
|
+
ValueError
|
|
388
|
+
If NaN values are found in any of the specified variables at wet points,
|
|
389
|
+
indicating incomplete data coverage.
|
|
390
|
+
|
|
391
|
+
Notes
|
|
392
|
+
-----
|
|
393
|
+
This check is only applied to the 2D variable SSH to improve performance.
|
|
394
|
+
"""
|
|
395
|
+
|
|
396
|
+
ds["zeta"].load()
|
|
397
|
+
nan_check(ds["zeta"].squeeze(), self.grid.ds.mask_rho)
|
|
398
|
+
|
|
378
399
|
def _add_global_metadata(self, ds):
|
|
379
400
|
|
|
380
401
|
ds.attrs["title"] = "ROMS initial conditions file created by ROMS-Tools"
|
|
@@ -398,7 +419,7 @@ class InitialConditions:
|
|
|
398
419
|
|
|
399
420
|
def plot(
|
|
400
421
|
self,
|
|
401
|
-
|
|
422
|
+
var_name,
|
|
402
423
|
s=None,
|
|
403
424
|
eta=None,
|
|
404
425
|
xi=None,
|
|
@@ -409,7 +430,7 @@ class InitialConditions:
|
|
|
409
430
|
|
|
410
431
|
Parameters
|
|
411
432
|
----------
|
|
412
|
-
|
|
433
|
+
var_name : str
|
|
413
434
|
The name of the initial conditions field to plot. Options include:
|
|
414
435
|
|
|
415
436
|
- "temp": Potential temperature.
|
|
@@ -480,25 +501,30 @@ class InitialConditions:
|
|
|
480
501
|
Raises
|
|
481
502
|
------
|
|
482
503
|
ValueError
|
|
483
|
-
If the specified `
|
|
484
|
-
If the field specified by `
|
|
485
|
-
If the field specified by `
|
|
504
|
+
If the specified `var_name` is not one of the valid options.
|
|
505
|
+
If the field specified by `var_name` is 3D and none of `s`, `eta`, or `xi` are specified.
|
|
506
|
+
If the field specified by `var_name` is 2D and both `eta` and `xi` are specified.
|
|
486
507
|
"""
|
|
487
508
|
|
|
488
|
-
if len(self.ds[
|
|
509
|
+
if len(self.ds[var_name].squeeze().dims) == 3 and not any(
|
|
489
510
|
[s is not None, eta is not None, xi is not None]
|
|
490
511
|
):
|
|
491
512
|
raise ValueError(
|
|
492
513
|
"For 3D fields, at least one of s, eta, or xi must be specified."
|
|
493
514
|
)
|
|
494
515
|
|
|
495
|
-
if len(self.ds[
|
|
516
|
+
if len(self.ds[var_name].squeeze().dims) == 2 and all(
|
|
496
517
|
[eta is not None, xi is not None]
|
|
497
518
|
):
|
|
498
519
|
raise ValueError("For 2D fields, specify either eta or xi, not both.")
|
|
499
520
|
|
|
500
|
-
self.
|
|
501
|
-
|
|
521
|
+
if self.use_dask:
|
|
522
|
+
from dask.diagnostics import ProgressBar
|
|
523
|
+
|
|
524
|
+
with ProgressBar():
|
|
525
|
+
self.ds[var_name].load()
|
|
526
|
+
|
|
527
|
+
field = self.ds[var_name].squeeze()
|
|
502
528
|
|
|
503
529
|
if all(dim in field.dims for dim in ["eta_rho", "xi_rho"]):
|
|
504
530
|
interface_depth = self.grid.ds.interface_depth_rho
|
|
@@ -553,7 +579,7 @@ class InitialConditions:
|
|
|
553
579
|
field = field.assign_coords({"layer_depth": layer_depth})
|
|
554
580
|
else:
|
|
555
581
|
raise ValueError(
|
|
556
|
-
f"None of the expected dimensions (eta_rho, eta_v) found in ds[{
|
|
582
|
+
f"None of the expected dimensions (eta_rho, eta_v) found in ds[{var_name}]."
|
|
557
583
|
)
|
|
558
584
|
if xi is not None:
|
|
559
585
|
if "xi_rho" in field.dims:
|
|
@@ -572,18 +598,18 @@ class InitialConditions:
|
|
|
572
598
|
field = field.assign_coords({"layer_depth": layer_depth})
|
|
573
599
|
else:
|
|
574
600
|
raise ValueError(
|
|
575
|
-
f"None of the expected dimensions (xi_rho, xi_u) found in ds[{
|
|
601
|
+
f"None of the expected dimensions (xi_rho, xi_u) found in ds[{var_name}]."
|
|
576
602
|
)
|
|
577
603
|
|
|
578
604
|
# chose colorbar
|
|
579
|
-
if
|
|
605
|
+
if var_name in ["u", "v", "w", "ubar", "vbar", "zeta"]:
|
|
580
606
|
vmax = max(field.max().values, -field.min().values)
|
|
581
607
|
vmin = -vmax
|
|
582
608
|
cmap = plt.colormaps.get_cmap("RdBu_r")
|
|
583
609
|
else:
|
|
584
610
|
vmax = field.max().values
|
|
585
611
|
vmin = field.min().values
|
|
586
|
-
if
|
|
612
|
+
if var_name in ["temp", "salt"]:
|
|
587
613
|
cmap = plt.colormaps.get_cmap("YlOrRd")
|
|
588
614
|
else:
|
|
589
615
|
cmap = plt.colormaps.get_cmap("YlGn")
|
|
@@ -660,7 +686,13 @@ class InitialConditions:
|
|
|
660
686
|
if filepath.suffix == ".nc":
|
|
661
687
|
filepath = filepath.with_suffix("")
|
|
662
688
|
|
|
663
|
-
|
|
689
|
+
if self.use_dask:
|
|
690
|
+
from dask.diagnostics import ProgressBar
|
|
691
|
+
|
|
692
|
+
with ProgressBar():
|
|
693
|
+
self.ds.load()
|
|
694
|
+
|
|
695
|
+
dataset_list = [self.ds]
|
|
664
696
|
output_filenames = [str(filepath)]
|
|
665
697
|
|
|
666
698
|
saved_filenames = save_datasets(
|
|
@@ -698,15 +730,18 @@ class InitialConditions:
|
|
|
698
730
|
|
|
699
731
|
initial_conditions_data = {
|
|
700
732
|
"InitialConditions": {
|
|
701
|
-
"source": self.source,
|
|
702
733
|
"ini_time": self.ini_time.isoformat(),
|
|
703
|
-
"
|
|
734
|
+
"source": self.source,
|
|
704
735
|
}
|
|
705
736
|
}
|
|
706
737
|
# Include bgc_source if it's not None
|
|
707
738
|
if self.bgc_source is not None:
|
|
708
739
|
initial_conditions_data["InitialConditions"]["bgc_source"] = self.bgc_source
|
|
709
740
|
|
|
741
|
+
initial_conditions_data["InitialConditions"][
|
|
742
|
+
"model_reference_date"
|
|
743
|
+
] = self.model_reference_date.isoformat()
|
|
744
|
+
|
|
710
745
|
yaml_data = {
|
|
711
746
|
**grid_yaml_data,
|
|
712
747
|
**initial_conditions_data,
|
|
@@ -716,7 +751,7 @@ class InitialConditions:
|
|
|
716
751
|
# Write header
|
|
717
752
|
file.write(header)
|
|
718
753
|
# Write YAML data
|
|
719
|
-
yaml.dump(yaml_data, file, default_flow_style=False)
|
|
754
|
+
yaml.dump(yaml_data, file, default_flow_style=False, sort_keys=False)
|
|
720
755
|
|
|
721
756
|
@classmethod
|
|
722
757
|
def from_yaml(
|
roms_tools/setup/regrid.py
CHANGED
|
@@ -2,45 +2,38 @@ import xarray as xr
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class LateralRegrid:
|
|
5
|
-
"""
|
|
5
|
+
"""Handles lateral regridding of data onto a new spatial grid."""
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
data : DataContainer
|
|
13
|
-
Container with variables to be interpolated, including a `mask` and dimension names.
|
|
14
|
-
lon : xarray.DataArray
|
|
15
|
-
Target longitude coordinates.
|
|
16
|
-
lat : xarray.DataArray
|
|
17
|
-
Target latitude coordinates.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
def __init__(self, data, lon, lat):
|
|
21
|
-
"""Initializes the lateral fill and target grid coordinates.
|
|
7
|
+
def __init__(self, target_coords, source_dim_names):
|
|
8
|
+
"""Initialize target grid coordinates and names for grid dimensions.
|
|
22
9
|
|
|
23
10
|
Parameters
|
|
24
11
|
----------
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
target_coords : dict
|
|
13
|
+
Dictionary containing 'lon' and 'lat' as xarray.DataArrays representing
|
|
14
|
+
the longitude and latitude values of the target grid.
|
|
15
|
+
source_dim_names : dict
|
|
16
|
+
Dictionary specifying names for the latitude and longitude dimensions,
|
|
17
|
+
typically using keys like "latitude" and "longitude" to align with the dataset conventions.
|
|
18
|
+
|
|
19
|
+
Attributes
|
|
20
|
+
----------
|
|
21
|
+
coords : dict
|
|
22
|
+
Maps the dimension names to the corresponding latitude and longitude
|
|
23
|
+
DataArrays, providing easy access to target grid coordinates.
|
|
31
24
|
"""
|
|
32
25
|
|
|
33
26
|
self.coords = {
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
source_dim_names["latitude"]: target_coords["lat"],
|
|
28
|
+
source_dim_names["longitude"]: target_coords["lon"],
|
|
36
29
|
}
|
|
37
30
|
|
|
38
|
-
def apply(self,
|
|
31
|
+
def apply(self, da):
|
|
39
32
|
"""Fills missing values and regrids the variable.
|
|
40
33
|
|
|
41
34
|
Parameters
|
|
42
35
|
----------
|
|
43
|
-
|
|
36
|
+
da : xarray.DataArray
|
|
44
37
|
Input data to fill and regrid.
|
|
45
38
|
|
|
46
39
|
Returns
|
|
@@ -48,38 +41,48 @@ class LateralRegrid:
|
|
|
48
41
|
xarray.DataArray
|
|
49
42
|
Regridded data with filled values.
|
|
50
43
|
"""
|
|
51
|
-
regridded =
|
|
44
|
+
regridded = da.interp(self.coords, method="linear").drop_vars(
|
|
52
45
|
list(self.coords.keys())
|
|
53
46
|
)
|
|
54
47
|
return regridded
|
|
55
48
|
|
|
56
49
|
|
|
57
50
|
class VerticalRegrid:
|
|
58
|
-
"""
|
|
51
|
+
"""Interpolates data onto new vertical (depth) coordinates.
|
|
59
52
|
|
|
60
53
|
Parameters
|
|
61
54
|
----------
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
target_depth_coords : xarray.DataArray
|
|
56
|
+
Depth coordinates for the target grid.
|
|
57
|
+
source_depth_coords : xarray.DataArray
|
|
58
|
+
Depth coordinates for the source grid.
|
|
66
59
|
"""
|
|
67
60
|
|
|
68
|
-
def __init__(self,
|
|
69
|
-
"""
|
|
61
|
+
def __init__(self, target_depth_coords, source_depth_coords):
|
|
62
|
+
"""Initialize regridding factors for interpolation.
|
|
70
63
|
|
|
71
64
|
Parameters
|
|
72
65
|
----------
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
target_depth_coords : xarray.DataArray
|
|
67
|
+
Depth coordinates for the target grid.
|
|
68
|
+
source_depth_coords : xarray.DataArray
|
|
69
|
+
Depth coordinates for the source grid.
|
|
70
|
+
|
|
71
|
+
Attributes
|
|
72
|
+
----------
|
|
73
|
+
coeff : xarray.Dataset
|
|
74
|
+
Dataset containing:
|
|
75
|
+
- `is_below` : Boolean mask for depths just below target.
|
|
76
|
+
- `is_above` : Boolean mask for depths just above target.
|
|
77
|
+
- `upper_mask`, `lower_mask` : Masks for valid interpolation bounds.
|
|
78
|
+
- `factor` : Weight for blending values between levels.
|
|
77
79
|
"""
|
|
78
80
|
|
|
79
|
-
self.depth_dim =
|
|
81
|
+
self.depth_dim = source_depth_coords.dims[0]
|
|
82
|
+
source_depth = source_depth_coords
|
|
80
83
|
dims = {"dim": self.depth_dim}
|
|
81
84
|
|
|
82
|
-
dlev =
|
|
85
|
+
dlev = source_depth - target_depth_coords
|
|
83
86
|
is_below = dlev == dlev.where(dlev >= 0).min(**dims)
|
|
84
87
|
is_above = dlev == dlev.where(dlev <= 0).max(**dims)
|
|
85
88
|
p_below = dlev.where(is_below).sum(**dims)
|
|
@@ -138,61 +141,3 @@ class VerticalRegrid:
|
|
|
138
141
|
)
|
|
139
142
|
|
|
140
143
|
return result
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
def _lateral_regrid(data, lon, lat, data_vars, var_names):
|
|
144
|
-
"""Laterally regrid specified variables onto new latitude and longitude coordinates.
|
|
145
|
-
|
|
146
|
-
Parameters
|
|
147
|
-
----------
|
|
148
|
-
data : Dataset
|
|
149
|
-
Input data containing the information about source dimensions.
|
|
150
|
-
lon : xarray.DataArray
|
|
151
|
-
Target longitude coordinates.
|
|
152
|
-
lat : xarray.DataArray
|
|
153
|
-
Target latitude coordinates.
|
|
154
|
-
data_vars : dict of str : xarray.DataArray
|
|
155
|
-
Dictionary of variables to regrid.
|
|
156
|
-
var_names : list of str
|
|
157
|
-
Names of variables to regrid.
|
|
158
|
-
|
|
159
|
-
Returns
|
|
160
|
-
-------
|
|
161
|
-
dict of str : xarray.DataArray
|
|
162
|
-
Updated data_vars with regridded variables.
|
|
163
|
-
"""
|
|
164
|
-
lateral_regrid = LateralRegrid(data, lon, lat)
|
|
165
|
-
|
|
166
|
-
for var_name in var_names:
|
|
167
|
-
if var_name in data_vars:
|
|
168
|
-
data_vars[var_name] = lateral_regrid.apply(data_vars[var_name])
|
|
169
|
-
|
|
170
|
-
return data_vars
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
def _vertical_regrid(data, target_depth, data_vars, var_names):
|
|
174
|
-
"""Vertically regrid specified variables onto new depth coordinates.
|
|
175
|
-
|
|
176
|
-
Parameters
|
|
177
|
-
----------
|
|
178
|
-
data : Dataset
|
|
179
|
-
Input dataset containing the variables and source depth information.
|
|
180
|
-
target_depth : xarray.DataArray
|
|
181
|
-
Target depth coordinates for regridding.
|
|
182
|
-
data_vars : dict of str : xarray.DataArray
|
|
183
|
-
Dictionary of variables to be regridded.
|
|
184
|
-
var_names : list of str
|
|
185
|
-
Names of variables to regrid.
|
|
186
|
-
|
|
187
|
-
Returns
|
|
188
|
-
-------
|
|
189
|
-
dict of str : xarray.DataArray
|
|
190
|
-
Updated data_vars with variables regridded onto the target depth coordinates.
|
|
191
|
-
"""
|
|
192
|
-
vertical_regrid = VerticalRegrid(data, target_depth)
|
|
193
|
-
|
|
194
|
-
for var_name in var_names:
|
|
195
|
-
if var_name in data_vars:
|
|
196
|
-
data_vars[var_name] = vertical_regrid.apply(data_vars[var_name])
|
|
197
|
-
|
|
198
|
-
return data_vars
|