roms-tools 1.3.0__py3-none-any.whl → 1.4.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.
- ci/environment.yml +1 -8
- roms_tools/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +1 -1
- roms_tools/setup/datasets.py +278 -105
- roms_tools/setup/download.py +5 -0
- roms_tools/setup/fill.py +266 -331
- roms_tools/setup/grid.py +92 -8
- roms_tools/setup/initial_conditions.py +10 -11
- roms_tools/setup/mixins.py +29 -21
- roms_tools/setup/surface_forcing.py +3 -5
- roms_tools/setup/tides.py +44 -46
- roms_tools/setup/topography.py +30 -4
- roms_tools/setup/utils.py +41 -23
- roms_tools/tests/test_setup/test_boundary_forcing.py +1 -1
- 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/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/.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/coarse_surface_forcing.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/.zmetadata +8 -8
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/Tair/.zarray +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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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 +8 -8
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/Tair/.zarray +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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/vwnd/0.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 +62 -2
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_u/0.0 +0 -0
- 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 +62 -2
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zattrs +8 -0
- 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/lat_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zarray +22 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zattrs +8 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_u/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_v/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/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_data/surface_forcing.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/.zmetadata +8 -8
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/Tair/.zarray +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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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/.zarray +1 -1
- 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 +2 -4
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/omega/.zattrs +1 -3
- 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 +280 -211
- roms_tools/tests/test_setup/test_fill.py +177 -0
- roms_tools/tests/test_setup/test_grid.py +56 -0
- roms_tools/tests/test_setup/test_initial_conditions.py +5 -3
- roms_tools/tests/test_setup/test_surface_forcing.py +4 -4
- roms_tools/tests/test_setup/test_tides.py +5 -2
- roms_tools/tests/test_setup/test_topography.py +40 -0
- roms_tools/tests/test_setup/test_validation.py +1 -1
- roms_tools/tests/test_utils.py +30 -0
- roms_tools/utils.py +39 -3
- roms_tools-1.4.1.dist-info/LICENSE +201 -0
- {roms_tools-1.3.0.dist-info → roms_tools-1.4.1.dist-info}/METADATA +13 -3
- {roms_tools-1.3.0.dist-info → roms_tools-1.4.1.dist-info}/RECORD +326 -334
- {roms_tools-1.3.0.dist-info → roms_tools-1.4.1.dist-info}/WHEEL +1 -1
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/Tair/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/lwrad/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/qair/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/rain/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/swrad/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/uwnd/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/vwnd/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/Tair/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/lwrad/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/qair/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/rain/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/swrad/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/uwnd/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/vwnd/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/Tair/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/lwrad/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/qair/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/rain/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/swrad/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/uwnd/1.0.0 +0 -0
- roms_tools/tests/test_setup/test_data/surface_forcing.zarr/vwnd/1.0.0 +0 -0
- roms_tools-1.3.0.dist-info/LICENSE +0 -674
- {roms_tools-1.3.0.dist-info → roms_tools-1.4.1.dist-info}/top_level.txt +0 -0
roms_tools/setup/fill.py
CHANGED
|
@@ -1,376 +1,311 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import xarray as xr
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
mask,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
3
|
+
import pyamg
|
|
4
|
+
from scipy import sparse
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LateralFill:
|
|
8
|
+
def __init__(self, mask, dims, tol=1.0e-4):
|
|
9
|
+
"""
|
|
10
|
+
Initializes the LateralFill class, which fills NaN values in a DataArray
|
|
11
|
+
by iteratively solving a Poisson equation using a lateral diffusion approach.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
mask : xarray.DataArray or ndarray of bool
|
|
16
|
+
A 2D boolean mask indicating valid points (True) and land points (False).
|
|
17
|
+
Boundary points are automatically set to land (True).
|
|
18
|
+
dims : list of str
|
|
19
|
+
Dimensions along which to perform the lateral fill. Defaults to ["latitude", "longitude"].
|
|
20
|
+
tol : float, optional
|
|
21
|
+
Tolerance for the iterative solver, determining convergence. Default is 1.0e-4.
|
|
22
|
+
|
|
23
|
+
Raises
|
|
24
|
+
------
|
|
25
|
+
NotImplementedError
|
|
26
|
+
If the input mask has more than two dimensions, which is not supported by the current implementation.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
if len(mask.shape) > 2:
|
|
30
|
+
raise NotImplementedError("LateralFill currently supports only 2D masks.")
|
|
31
|
+
|
|
32
|
+
self.mask = mask
|
|
33
|
+
|
|
34
|
+
# Ensure the mask is 2D, copy it and set boundary values to True
|
|
35
|
+
mask = mask.copy()
|
|
36
|
+
mask[0, :] = True
|
|
37
|
+
mask[-1, :] = True
|
|
38
|
+
mask[:, 0] = True
|
|
39
|
+
mask[:, -1] = True
|
|
40
|
+
|
|
41
|
+
# Flatten the mask for use in the sparse matrix solver
|
|
42
|
+
mask_flat = mask.values.flatten()
|
|
43
|
+
|
|
44
|
+
# Create a sparse matrix representing the Laplacian operator for the diffusion process
|
|
45
|
+
A = laplacian(mask.shape, mask_flat, format="csr")
|
|
46
|
+
|
|
47
|
+
# Use algebraic multigrid solver for solving the Poisson equation with set seed to ensure reproducibility
|
|
48
|
+
np.random.seed(123089)
|
|
49
|
+
self.ml = pyamg.smoothed_aggregation_solver(A, max_coarse=10)
|
|
50
|
+
self.dims = dims
|
|
51
|
+
self.tol = tol
|
|
52
|
+
|
|
53
|
+
def apply(self, var):
|
|
54
|
+
"""
|
|
55
|
+
Fills NaN values in an xarray DataArray using iterative lateral diffusion.
|
|
56
|
+
|
|
57
|
+
Parameters
|
|
58
|
+
----------
|
|
59
|
+
var : xarray.DataArray
|
|
60
|
+
Input DataArray with NaN values to be filled. The fill is performed
|
|
61
|
+
across the dimensions specified by `dims`.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
var_filled : xarray.DataArray
|
|
66
|
+
A DataArray with NaN values filled by iterative smoothing, while preserving
|
|
67
|
+
non-NaN values.
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
# Apply fill to anomaly field
|
|
71
|
+
mean = var.mean(dim=self.dims, skipna=True)
|
|
72
|
+
var = var - mean
|
|
73
|
+
|
|
74
|
+
# Setup the right-hand side (RHS): ocean points take their original values, land points are set to 0
|
|
75
|
+
b = xr.where(self.mask, var, 0)
|
|
76
|
+
|
|
77
|
+
# Initial guess: ocean points take their original values, land points are set to 0
|
|
78
|
+
x0 = xr.where(self.mask, var, 0)
|
|
79
|
+
|
|
80
|
+
# Apply the iterative solver using a custom NumPy function
|
|
81
|
+
var_filled = xr.apply_ufunc(
|
|
82
|
+
_lateral_fill_np_array,
|
|
83
|
+
x0,
|
|
84
|
+
b,
|
|
85
|
+
input_core_dims=[self.dims, self.dims],
|
|
86
|
+
output_core_dims=[self.dims],
|
|
87
|
+
output_dtypes=[x0.dtype],
|
|
88
|
+
dask="parallelized",
|
|
89
|
+
vectorize=True,
|
|
90
|
+
kwargs={"ml": self.ml, "tol": self.tol},
|
|
87
91
|
)
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
field = field.where(mask)
|
|
91
|
-
|
|
92
|
-
# Propagate ocean values into land interior before interpolation
|
|
93
|
-
field = lateral_fill(field, 1 - mask, fill_dims, fillvalue_fill)
|
|
93
|
+
var_filled = var_filled + mean
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
coords, method=method, kwargs={"fill_value": fillvalue_interp}
|
|
97
|
-
).drop_vars(list(coords.keys()))
|
|
95
|
+
return var_filled
|
|
98
96
|
|
|
99
|
-
return field_interpolated
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
def lateral_fill(var, land_mask, dims=["latitude", "longitude"], fillvalue=0.0):
|
|
98
|
+
def _lateral_fill_np_array(x0, b, ml, tol=1.0e-4):
|
|
103
99
|
"""
|
|
104
|
-
|
|
100
|
+
Fills all NaN values in a 2D NumPy array using an iterative solver,
|
|
101
|
+
while preserving the existing non-NaN values.
|
|
102
|
+
The filling process uses an AMG solver to efficiently perform smoothing
|
|
103
|
+
based on the Laplace operator.
|
|
105
104
|
|
|
106
105
|
Parameters
|
|
107
106
|
----------
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
107
|
+
x0 : numpy.ndarray
|
|
108
|
+
Initial guess for the fill operation.
|
|
109
|
+
b : numpy.ndarray
|
|
110
|
+
Right-hand side (RHS) of the equation representing the data values
|
|
111
|
+
to be used in the fill process. Non-NaN values in `b` correspond to
|
|
112
|
+
valid points, and zeros are used for masked (invalid) points.
|
|
113
|
+
ml : pyamg.MultilevelSolver
|
|
114
|
+
An algebraic multigrid (AMG) solver used to iteratively fill NaNs
|
|
115
|
+
via a smoothing process.
|
|
116
|
+
tol : float, optional, default=1.0e-4
|
|
117
|
+
Convergence tolerance for the iterative solver. The filling process
|
|
118
|
+
stops when the relative residual (change in values) is less than or
|
|
119
|
+
equal to `tol`. Specifically, the process iterates until:
|
|
120
|
+
``||Ax - b|| / ||Ax0 - b|| < tol``, where `A` is the system matrix,
|
|
121
|
+
`x` is the solution, and `x0` is the initial guess.
|
|
121
122
|
|
|
122
123
|
Returns
|
|
123
124
|
-------
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
x_2d : numpy.ndarray
|
|
126
|
+
The filled 2D array where NaN values have been replaced with iteratively
|
|
127
|
+
computed values, and non-NaN values remain unchanged.
|
|
128
128
|
"""
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
input_core_dims=[dims, dims],
|
|
135
|
-
output_core_dims=[dims],
|
|
136
|
-
output_dtypes=[var.dtype],
|
|
137
|
-
dask="parallelized",
|
|
138
|
-
vectorize=True,
|
|
139
|
-
kwargs={"fillvalue": fillvalue},
|
|
140
|
-
)
|
|
130
|
+
b_flat = b.flatten()
|
|
131
|
+
x0_flat = x0.flatten()
|
|
132
|
+
x = ml.solve(b_flat, x0_flat, tol=tol)
|
|
133
|
+
x_2d = x.reshape(b.shape)
|
|
141
134
|
|
|
142
|
-
return
|
|
135
|
+
return x_2d
|
|
143
136
|
|
|
144
137
|
|
|
145
|
-
def
|
|
146
|
-
var, isvalid_mask, fillvalue=0.0, tol=1.0e-4, rc=1.8, max_iter=10000
|
|
147
|
-
):
|
|
138
|
+
def laplacian(grid, mask, dtype=float, format=None):
|
|
148
139
|
"""
|
|
149
|
-
|
|
140
|
+
Return a sparse matrix for solving a 2-dimensional Poisson problem.
|
|
150
141
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Two-dimensional array on which to fill NaNs.Only NaNs where `isvalid_mask` is
|
|
155
|
-
True will be filled.
|
|
142
|
+
This function generates a finite difference approximation of the Laplacian operator
|
|
143
|
+
on a 2-dimensional grid with unit grid spacing and Dirichlet boundary conditions.
|
|
144
|
+
The matrix can be used to solve Poisson-like equations in grid-based numerical methods.
|
|
156
145
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
as `var`.
|
|
146
|
+
The computation iterates over the last dimension first (z, then y, then x), and
|
|
147
|
+
the output matrix should be compatible with `np.mgrid()` or `np.ndenumerate()`.
|
|
160
148
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
is near optimal. Valid bounds are (1.0, 2.0).
|
|
174
|
-
|
|
175
|
-
max_iter : int, optional, default=10000
|
|
176
|
-
Maximum number of iterations to perform before giving up if the tolerance
|
|
177
|
-
is not reached.
|
|
149
|
+
Parameters
|
|
150
|
+
----------
|
|
151
|
+
grid : tuple of int
|
|
152
|
+
Dimensions of the grid, e.g., (100, 100).
|
|
153
|
+
mask : 2D array of bool
|
|
154
|
+
A boolean mask of the same size as the grid, indicating valid grid points
|
|
155
|
+
(True for valid points, False for masked points).
|
|
156
|
+
dtype : data-type, optional
|
|
157
|
+
The desired data type of the resulting matrix. Default is `float`.
|
|
158
|
+
format : str, optional
|
|
159
|
+
The format of the sparse matrix to return, such as "csr", "coo", etc.
|
|
160
|
+
Default is None.
|
|
178
161
|
|
|
179
162
|
Returns
|
|
180
163
|
-------
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
164
|
+
sparse matrix
|
|
165
|
+
A sparse matrix representing the finite difference Laplacian operator for
|
|
166
|
+
the given grid.
|
|
185
167
|
|
|
186
|
-
Example
|
|
187
|
-
-------
|
|
188
|
-
>>> import numpy as np
|
|
189
|
-
>>> var = np.array([[1, 2, np.nan], [4, np.nan, 6]])
|
|
190
|
-
>>> isvalid_mask = np.array([[True, True, True], [True, True, True]])
|
|
191
|
-
>>> filled_var = lateral_fill_np_array(var, isvalid_mask)
|
|
192
|
-
>>> print(filled_var)
|
|
193
168
|
"""
|
|
194
|
-
|
|
195
|
-
var = var.copy()
|
|
169
|
+
grid = tuple(grid)
|
|
196
170
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
171
|
+
# create 2-dimensional Laplacian stencil
|
|
172
|
+
N = 2
|
|
173
|
+
stencil = np.zeros((3,) * N, dtype=dtype)
|
|
174
|
+
for i in range(N):
|
|
175
|
+
stencil[(1,) * i + (0,) + (1,) * (N - i - 1)] = 1
|
|
176
|
+
stencil[(1,) * i + (2,) + (1,) * (N - i - 1)] = 1
|
|
177
|
+
stencil[(1,) * N] = -2 * N
|
|
201
178
|
|
|
202
|
-
return
|
|
179
|
+
return stencil_grid_mod(stencil, grid, mask, format=format)
|
|
203
180
|
|
|
204
181
|
|
|
205
|
-
|
|
206
|
-
def _iterative_fill_sor(nlat, nlon, var, fillmask, tol, rc, max_iter, fillvalue=0.0):
|
|
182
|
+
def stencil_grid_mod(S, grid, msk, dtype=None, format=None):
|
|
207
183
|
"""
|
|
208
|
-
|
|
209
|
-
|
|
184
|
+
Construct a sparse matrix from a local matrix stencil.
|
|
185
|
+
|
|
186
|
+
This function generates a sparse matrix that represents an operator
|
|
187
|
+
by applying the given stencil `S` at each vertex of a regular grid with
|
|
188
|
+
the specified dimensions. The matrix is modified according to the provided
|
|
189
|
+
mask to ensure that masked points are not affected during matrix operations.
|
|
210
190
|
|
|
211
191
|
Parameters
|
|
212
192
|
----------
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
rc : float
|
|
230
|
-
Over-relaxation coefficient used in the SOR algorithm. Must be between 1.0 and 2.0.
|
|
231
|
-
|
|
232
|
-
max_iter : int
|
|
233
|
-
Maximum number of iterations allowed before the process is terminated.
|
|
234
|
-
|
|
235
|
-
fillvalue: float
|
|
236
|
-
Value to use if the full field is NaNs. Default is 0.0.
|
|
193
|
+
S : ndarray
|
|
194
|
+
An N-dimensional array representing the local matrix stencil.
|
|
195
|
+
All dimensions of `S` must be odd.
|
|
196
|
+
grid : tuple of int
|
|
197
|
+
A tuple specifying the dimensions of the grid. The length of the tuple
|
|
198
|
+
should match the number of dimensions of the stencil `S`.
|
|
199
|
+
msk : ndarray of bool
|
|
200
|
+
A 1D boolean array where `True` indicates points that are masked
|
|
201
|
+
(i.e., should not be affected by the matrix).
|
|
202
|
+
dtype : data-type, optional
|
|
203
|
+
The data type of the resulting sparse matrix. Default is `None`, which
|
|
204
|
+
will infer the type from `S`.
|
|
205
|
+
format : str, optional
|
|
206
|
+
The sparse matrix format to return, such as "csr", "coo", etc. If not
|
|
207
|
+
specified, the default is DIA (diagonal) format.
|
|
237
208
|
|
|
238
209
|
Returns
|
|
239
210
|
-------
|
|
240
|
-
|
|
241
|
-
|
|
211
|
+
A : sparse matrix
|
|
212
|
+
A sparse matrix representing the operator formed by applying the stencil
|
|
213
|
+
`S` at each grid vertex. The matrix is modified based on the mask so that
|
|
214
|
+
masked points are unaffected by the operator.
|
|
242
215
|
|
|
243
216
|
Notes
|
|
244
217
|
-----
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
tolerance `tol` is reached or the maximum number of iterations `max_iter` is exceeded.
|
|
218
|
+
The grid vertices are enumerated as `arange(prod(grid)).reshape(grid)`.
|
|
219
|
+
This means the last grid dimension cycles fastest, while the first dimension
|
|
220
|
+
cycles slowest. For example, if `grid=(2,3)`, then the grid vertices are ordered
|
|
221
|
+
as (0,0), (0,1), (0,2), (1,0), (1,1), (1,2).
|
|
250
222
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
>>> fillmask = np.isnan(var)
|
|
256
|
-
>>> tol = 1.0e-4
|
|
257
|
-
>>> rc = 1.8
|
|
258
|
-
>>> max_iter = 10000
|
|
259
|
-
>>> _iterative_fill_sor(nlat, nlon, var, fillmask, tol, rc, max_iter)
|
|
223
|
+
This ordering is consistent with the NumPy functions `ndenumerate()` and `mgrid()`.
|
|
224
|
+
|
|
225
|
+
The stencil is applied in all directions, and boundary conditions are
|
|
226
|
+
respected by zeroing out connections to boundary points.
|
|
260
227
|
"""
|
|
261
228
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
for
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
var[j, i] = var[j, i] + rc * 0.5 * res[j, i]
|
|
346
|
-
|
|
347
|
-
# four corners
|
|
348
|
-
for j in [0, nlat - 1]:
|
|
349
|
-
if j == 0:
|
|
350
|
-
jp1 = j + 1
|
|
351
|
-
jm1 = j
|
|
352
|
-
elif j == nlat - 1:
|
|
353
|
-
jp1 = j
|
|
354
|
-
jm1 = j - 1
|
|
355
|
-
|
|
356
|
-
for i in [0, nlon - 1]:
|
|
357
|
-
if i == 0:
|
|
358
|
-
ip1 = i + 1
|
|
359
|
-
im1 = i
|
|
360
|
-
elif i == nlon - 1:
|
|
361
|
-
ip1 = i
|
|
362
|
-
im1 = i - 1
|
|
363
|
-
|
|
364
|
-
res[j, i] = (
|
|
365
|
-
var[j, ip1]
|
|
366
|
-
+ var[j, im1]
|
|
367
|
-
+ var[jm1, i]
|
|
368
|
-
+ var[jp1, i]
|
|
369
|
-
- 4.0 * var[j, i]
|
|
370
|
-
)
|
|
371
|
-
var[j, i] = var[j, i] + rc * 0.25 * res[j, i]
|
|
372
|
-
|
|
373
|
-
res_max = np.max(np.fabs(res)) / np.max(np.fabs(var))
|
|
374
|
-
iter_cnt += 1
|
|
375
|
-
|
|
376
|
-
return var
|
|
229
|
+
S = np.asarray(S, dtype=dtype)
|
|
230
|
+
grid = tuple(grid)
|
|
231
|
+
|
|
232
|
+
if not (np.asarray(S.shape) % 2 == 1).all():
|
|
233
|
+
raise ValueError("all stencil dimensions must be odd")
|
|
234
|
+
|
|
235
|
+
if len(grid) != np.ndim(S):
|
|
236
|
+
raise ValueError(
|
|
237
|
+
"stencil dimension must equal number of grid\
|
|
238
|
+
dimensions"
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
if min(grid) < 1:
|
|
242
|
+
raise ValueError("grid dimensions must be positive")
|
|
243
|
+
|
|
244
|
+
N_v = np.prod(grid) # number of vertices in the mesh
|
|
245
|
+
N_s = (S != 0).sum() # number of nonzero stencil entries
|
|
246
|
+
|
|
247
|
+
# diagonal offsets
|
|
248
|
+
diags = np.zeros(N_s, dtype=int)
|
|
249
|
+
|
|
250
|
+
# compute index offset of each dof within the stencil
|
|
251
|
+
strides = np.cumprod([1] + list(reversed(grid)))[:-1] # noqa: RUF005
|
|
252
|
+
indices = tuple(i.copy() for i in S.nonzero())
|
|
253
|
+
for i, s in zip(indices, S.shape):
|
|
254
|
+
i -= s // 2
|
|
255
|
+
|
|
256
|
+
for stride, coords in zip(strides, reversed(indices)):
|
|
257
|
+
diags += stride * coords
|
|
258
|
+
|
|
259
|
+
data = S[S != 0].repeat(N_v).reshape(N_s, N_v)
|
|
260
|
+
|
|
261
|
+
indices = np.vstack(indices).T
|
|
262
|
+
|
|
263
|
+
# zero boundary connections
|
|
264
|
+
for index, diag in zip(indices, data):
|
|
265
|
+
diag = diag.reshape(grid)
|
|
266
|
+
for n, i in enumerate(index):
|
|
267
|
+
if i > 0:
|
|
268
|
+
s = [slice(None)] * len(grid)
|
|
269
|
+
s[n] = slice(0, i)
|
|
270
|
+
s = tuple(s)
|
|
271
|
+
diag[s] = 0
|
|
272
|
+
elif i < 0:
|
|
273
|
+
s = [slice(None)] * len(grid)
|
|
274
|
+
s[n] = slice(i, None)
|
|
275
|
+
s = tuple(s)
|
|
276
|
+
diag[s] = 0
|
|
277
|
+
|
|
278
|
+
# remove diagonals that lie outside matrix
|
|
279
|
+
mask = abs(diags) < N_v
|
|
280
|
+
if not mask.all():
|
|
281
|
+
diags = diags[mask]
|
|
282
|
+
data = data[mask]
|
|
283
|
+
|
|
284
|
+
# sum duplicate diagonals
|
|
285
|
+
if len(np.unique(diags)) != len(diags):
|
|
286
|
+
new_diags = np.unique(diags)
|
|
287
|
+
new_data = np.zeros((len(new_diags), data.shape[1]), dtype=data.dtype)
|
|
288
|
+
|
|
289
|
+
for dia, dat in zip(diags, data):
|
|
290
|
+
n = np.searchsorted(new_diags, dia)
|
|
291
|
+
new_data[n, :] += dat
|
|
292
|
+
|
|
293
|
+
diags = new_diags
|
|
294
|
+
data = new_data
|
|
295
|
+
|
|
296
|
+
# Modify the data vectors so that masked points are not affected by the matrix solve.
|
|
297
|
+
# The modifications to the data vectors are offset by the elements of "diag" because
|
|
298
|
+
# of the way sparse.dia_matrix sets the diagonals
|
|
299
|
+
for i in range(N_v):
|
|
300
|
+
if msk[i]:
|
|
301
|
+
if (i + diags[0]) >= 0:
|
|
302
|
+
data[0, i + diags[0]] = 0
|
|
303
|
+
if (i + diags[1]) >= 0:
|
|
304
|
+
data[1, i + diags[1]] = 0
|
|
305
|
+
data[2, i] = 1
|
|
306
|
+
if (i + diags[3]) < (N_v):
|
|
307
|
+
data[3, i + diags[3]] = 0
|
|
308
|
+
if (i + diags[4]) < (N_v):
|
|
309
|
+
data[4, i + diags[4]] = 0
|
|
310
|
+
|
|
311
|
+
return sparse.dia_matrix((data, diags), shape=(N_v, N_v)).asformat(format)
|