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
|
@@ -7,8 +7,7 @@ from roms_tools.setup.grid import Grid
|
|
|
7
7
|
from datetime import datetime
|
|
8
8
|
import numpy as np
|
|
9
9
|
from typing import Dict, Union, List
|
|
10
|
-
from roms_tools.setup.
|
|
11
|
-
from roms_tools.setup.regrid import _lateral_regrid, LateralRegrid
|
|
10
|
+
from roms_tools.setup.regrid import LateralRegrid
|
|
12
11
|
from roms_tools.setup.datasets import (
|
|
13
12
|
ERA5Dataset,
|
|
14
13
|
ERA5Correction,
|
|
@@ -99,51 +98,40 @@ class SurfaceForcing:
|
|
|
99
98
|
|
|
100
99
|
data = self._get_data()
|
|
101
100
|
data.choose_subdomain(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
target_coords["lat"].max().values,
|
|
105
|
-
],
|
|
106
|
-
longitude_range=[
|
|
107
|
-
target_coords["lon"].min().values,
|
|
108
|
-
target_coords["lon"].max().values,
|
|
109
|
-
],
|
|
110
|
-
margin=2,
|
|
111
|
-
straddle=target_coords["straddle"],
|
|
101
|
+
target_coords,
|
|
102
|
+
buffer_points=20, # lateral fill needs some buffer from data margin
|
|
112
103
|
)
|
|
113
104
|
|
|
114
|
-
|
|
105
|
+
data.apply_lateral_fill()
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if var_name != "mask":
|
|
119
|
-
data_vars[var_name] = data.ds[data.var_names[var_name]]
|
|
120
|
-
|
|
121
|
-
data_vars = _lateral_fill(data_vars, data)
|
|
107
|
+
variable_info = self._set_variable_info(data)
|
|
108
|
+
var_names = variable_info.keys()
|
|
122
109
|
|
|
110
|
+
processed_fields = {}
|
|
123
111
|
# lateral regridding
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
112
|
+
lateral_regrid = LateralRegrid(target_coords, data.dim_names)
|
|
113
|
+
for var_name in var_names:
|
|
114
|
+
if var_name in data.var_names.keys():
|
|
115
|
+
processed_fields[var_name] = lateral_regrid.apply(
|
|
116
|
+
data.ds[data.var_names[var_name]]
|
|
117
|
+
)
|
|
128
118
|
|
|
129
119
|
# rotation of velocities and interpolation to u/v points
|
|
130
120
|
if "uwnd" in variable_info and "vwnd" in variable_info:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
121
|
+
processed_fields["uwnd"], processed_fields["vwnd"] = rotate_velocities(
|
|
122
|
+
processed_fields["uwnd"],
|
|
123
|
+
processed_fields["vwnd"],
|
|
134
124
|
target_coords["angle"],
|
|
135
125
|
interpolate=False,
|
|
136
126
|
)
|
|
137
127
|
|
|
138
128
|
# correct radiation
|
|
139
129
|
if self.type == "physics" and self.correct_radiation:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
object.__setattr__(data, "data_vars", data_vars)
|
|
130
|
+
processed_fields = self._apply_correction(processed_fields, data)
|
|
143
131
|
|
|
144
132
|
d_meta = get_variable_metadata()
|
|
145
133
|
|
|
146
|
-
ds = self._write_into_dataset(data, d_meta)
|
|
134
|
+
ds = self._write_into_dataset(processed_fields, data, d_meta)
|
|
147
135
|
|
|
148
136
|
if self.use_coarse_grid:
|
|
149
137
|
mask = self.grid.ds["mask_coarse"].rename(
|
|
@@ -152,13 +140,11 @@ class SurfaceForcing:
|
|
|
152
140
|
else:
|
|
153
141
|
mask = self.grid.ds["mask_rho"]
|
|
154
142
|
|
|
155
|
-
|
|
156
|
-
for var in ds.data_vars:
|
|
157
|
-
nan_check(ds[var].isel(time=0), mask)
|
|
143
|
+
self._validate(ds, mask)
|
|
158
144
|
|
|
159
145
|
# substitute NaNs over land by a fill value to avoid blow-up of ROMS
|
|
160
|
-
for
|
|
161
|
-
ds[
|
|
146
|
+
for var_name in ds.data_vars:
|
|
147
|
+
ds[var_name] = substitute_nans_by_fillvalue(ds[var_name])
|
|
162
148
|
|
|
163
149
|
object.__setattr__(self, "ds", ds)
|
|
164
150
|
|
|
@@ -272,7 +258,7 @@ class SurfaceForcing:
|
|
|
272
258
|
|
|
273
259
|
return variable_info
|
|
274
260
|
|
|
275
|
-
def _apply_correction(self,
|
|
261
|
+
def _apply_correction(self, processed_fields, data):
|
|
276
262
|
|
|
277
263
|
correction_data = self._get_correction_data()
|
|
278
264
|
# choose same subdomain as forcing data so that we can use same mask
|
|
@@ -285,44 +271,34 @@ class SurfaceForcing:
|
|
|
285
271
|
correction_data.choose_subdomain(
|
|
286
272
|
coords_correction, straddle=self.target_coords["straddle"]
|
|
287
273
|
)
|
|
288
|
-
|
|
274
|
+
correction_data.ds["mask"] = data.ds["mask"] # use mask from ERA5 data
|
|
275
|
+
correction_data.apply_lateral_fill()
|
|
289
276
|
# regrid
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
[
|
|
293
|
-
correction_data.dim_names["latitude"],
|
|
294
|
-
correction_data.dim_names["longitude"],
|
|
295
|
-
],
|
|
296
|
-
)
|
|
297
|
-
lateral_regrid = LateralRegrid(
|
|
298
|
-
correction_data, self.target_coords["lon"], self.target_coords["lat"]
|
|
299
|
-
)
|
|
300
|
-
|
|
301
|
-
filled = lateral_fill.apply(
|
|
277
|
+
lateral_regrid = LateralRegrid(self.target_coords, correction_data.dim_names)
|
|
278
|
+
corr_factor = lateral_regrid.apply(
|
|
302
279
|
correction_data.ds[correction_data.var_names["swr_corr"]]
|
|
303
280
|
)
|
|
304
|
-
corr_factor = lateral_regrid.apply(filled)
|
|
305
281
|
|
|
306
282
|
# temporal interpolation
|
|
307
283
|
corr_factor = interpolate_from_climatology(
|
|
308
284
|
corr_factor,
|
|
309
285
|
correction_data.dim_names["time"],
|
|
310
|
-
time=
|
|
286
|
+
time=processed_fields["swrad"].time,
|
|
311
287
|
)
|
|
312
288
|
|
|
313
|
-
|
|
289
|
+
processed_fields["swrad"] = processed_fields["swrad"] * corr_factor
|
|
314
290
|
|
|
315
|
-
return
|
|
291
|
+
return processed_fields
|
|
316
292
|
|
|
317
|
-
def _write_into_dataset(self, data, d_meta):
|
|
293
|
+
def _write_into_dataset(self, processed_fields, data, d_meta):
|
|
318
294
|
|
|
319
295
|
# save in new dataset
|
|
320
296
|
ds = xr.Dataset()
|
|
321
297
|
|
|
322
|
-
for
|
|
323
|
-
ds[
|
|
324
|
-
ds[
|
|
325
|
-
ds[
|
|
298
|
+
for var_name in processed_fields.keys():
|
|
299
|
+
ds[var_name] = processed_fields[var_name].astype(np.float32)
|
|
300
|
+
ds[var_name].attrs["long_name"] = d_meta[var_name]["long_name"]
|
|
301
|
+
ds[var_name].attrs["units"] = d_meta[var_name]["units"]
|
|
326
302
|
|
|
327
303
|
if self.use_coarse_grid:
|
|
328
304
|
ds = ds.rename({"eta_coarse": "eta_rho", "xi_coarse": "xi_rho"})
|
|
@@ -388,11 +364,36 @@ class SurfaceForcing:
|
|
|
388
364
|
ds = ds.drop_vars(["time"])
|
|
389
365
|
|
|
390
366
|
variables_to_drop = ["lat_rho", "lon_rho", "lat_coarse", "lon_coarse"]
|
|
391
|
-
existing_vars = [
|
|
367
|
+
existing_vars = [var_name for var_name in variables_to_drop if var_name in ds]
|
|
392
368
|
ds = ds.drop_vars(existing_vars)
|
|
393
369
|
|
|
394
370
|
return ds
|
|
395
371
|
|
|
372
|
+
def _validate(self, ds, mask):
|
|
373
|
+
"""Validates the dataset by checking for NaN values at wet points, which would
|
|
374
|
+
indicate missing raw data coverage over the target domain.
|
|
375
|
+
|
|
376
|
+
Parameters
|
|
377
|
+
----------
|
|
378
|
+
ds : xarray.Dataset
|
|
379
|
+
The dataset to validate.
|
|
380
|
+
mask : xarray.DataArray
|
|
381
|
+
Land mask (1=ocean, 0=land) to determine wet points in the domain.
|
|
382
|
+
|
|
383
|
+
Raises
|
|
384
|
+
------
|
|
385
|
+
ValueError
|
|
386
|
+
If NaN values are found in any of the specified variables at wet points,
|
|
387
|
+
indicating incomplete data coverage.
|
|
388
|
+
|
|
389
|
+
Notes
|
|
390
|
+
-----
|
|
391
|
+
This check is applied to the first time step (`time=0`) of each variable in the provided dataset.
|
|
392
|
+
"""
|
|
393
|
+
|
|
394
|
+
for var_name in ds.data_vars:
|
|
395
|
+
nan_check(ds[var_name].isel(time=0), mask)
|
|
396
|
+
|
|
396
397
|
def _add_global_metadata(self, ds=None):
|
|
397
398
|
|
|
398
399
|
if ds is None:
|
|
@@ -416,12 +417,12 @@ class SurfaceForcing:
|
|
|
416
417
|
|
|
417
418
|
return ds
|
|
418
419
|
|
|
419
|
-
def plot(self,
|
|
420
|
+
def plot(self, var_name, time=0) -> None:
|
|
420
421
|
"""Plot the specified surface forcing field for a given time slice.
|
|
421
422
|
|
|
422
423
|
Parameters
|
|
423
424
|
----------
|
|
424
|
-
|
|
425
|
+
var_name : str
|
|
425
426
|
The name of the surface forcing field to plot. Options include:
|
|
426
427
|
|
|
427
428
|
- "uwnd": 10 meter wind in x-direction.
|
|
@@ -450,7 +451,7 @@ class SurfaceForcing:
|
|
|
450
451
|
Raises
|
|
451
452
|
------
|
|
452
453
|
ValueError
|
|
453
|
-
If the specified
|
|
454
|
+
If the specified var_name is not found in dataset.
|
|
454
455
|
|
|
455
456
|
|
|
456
457
|
Examples
|
|
@@ -458,10 +459,16 @@ class SurfaceForcing:
|
|
|
458
459
|
>>> atm_forcing.plot("uwnd", time=0)
|
|
459
460
|
"""
|
|
460
461
|
|
|
461
|
-
if
|
|
462
|
-
raise ValueError(f"Variable '{
|
|
462
|
+
if var_name not in self.ds:
|
|
463
|
+
raise ValueError(f"Variable '{var_name}' is not found in dataset.")
|
|
464
|
+
|
|
465
|
+
field = self.ds[var_name].isel(time=time)
|
|
466
|
+
if self.use_dask:
|
|
467
|
+
from dask.diagnostics import ProgressBar
|
|
468
|
+
|
|
469
|
+
with ProgressBar():
|
|
470
|
+
field = field.load()
|
|
463
471
|
|
|
464
|
-
field = self.ds[varname].isel(time=time).load()
|
|
465
472
|
title = field.long_name
|
|
466
473
|
|
|
467
474
|
# assign lat / lon
|
|
@@ -476,14 +483,14 @@ class SurfaceForcing:
|
|
|
476
483
|
)
|
|
477
484
|
|
|
478
485
|
# choose colorbar
|
|
479
|
-
if
|
|
486
|
+
if var_name in ["uwnd", "vwnd"]:
|
|
480
487
|
vmax = max(field.max().values, -field.min().values)
|
|
481
488
|
vmin = -vmax
|
|
482
489
|
cmap = plt.colormaps.get_cmap("RdBu_r")
|
|
483
490
|
else:
|
|
484
491
|
vmax = field.max().values
|
|
485
492
|
vmin = field.min().values
|
|
486
|
-
if
|
|
493
|
+
if var_name in ["swrad", "lwrad", "Tair", "qair"]:
|
|
487
494
|
cmap = plt.colormaps.get_cmap("YlOrRd")
|
|
488
495
|
else:
|
|
489
496
|
cmap = plt.colormaps.get_cmap("YlGnBu")
|
|
@@ -501,24 +508,26 @@ class SurfaceForcing:
|
|
|
501
508
|
)
|
|
502
509
|
|
|
503
510
|
def save(
|
|
504
|
-
self,
|
|
511
|
+
self,
|
|
512
|
+
filepath: Union[str, Path],
|
|
513
|
+
np_eta: int = None,
|
|
514
|
+
np_xi: int = None,
|
|
515
|
+
group: bool = False,
|
|
505
516
|
) -> None:
|
|
506
|
-
"""Save the surface forcing fields to netCDF4 files.
|
|
507
|
-
|
|
508
|
-
This method saves the dataset by grouping it into subsets based on the data frequency. The subsets are then written
|
|
509
|
-
to one or more netCDF4 files. The filenames of the output files reflect the temporal coverage of the data.
|
|
510
|
-
|
|
511
|
-
There are two modes of saving the dataset:
|
|
517
|
+
"""Save the surface forcing fields to one or more netCDF4 files.
|
|
512
518
|
|
|
513
|
-
|
|
519
|
+
This method saves the dataset either as a single file or as multiple files depending on the partitioning and grouping options.
|
|
520
|
+
The dataset can be saved in two modes:
|
|
514
521
|
|
|
515
|
-
|
|
516
|
-
|
|
522
|
+
1. **Single File Mode (default)**:
|
|
523
|
+
- If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single netCDF4 file.
|
|
524
|
+
- The file is named based on the `filepath`, with `.nc` automatically appended.
|
|
517
525
|
|
|
518
|
-
|
|
526
|
+
2. **Partitioned Mode**:
|
|
527
|
+
- If either `np_eta` or `np_xi` is specified, the dataset is partitioned into spatial tiles along the `eta` and `xi` axes.
|
|
528
|
+
- Each tile is saved as a separate netCDF4 file, and filenames are modified with an index (e.g., `"filepath_YYYYMM.0.nc"`, `"filepath_YYYYMM.1.nc"`).
|
|
519
529
|
|
|
520
|
-
|
|
521
|
-
- Each spatial tile is saved as a separate netCDF4 file.
|
|
530
|
+
Additionally, if `group` is set to `True`, the dataset is first grouped into temporal subsets, resulting in multiple grouped files before partitioning and saving.
|
|
522
531
|
|
|
523
532
|
Parameters
|
|
524
533
|
----------
|
|
@@ -530,6 +539,8 @@ class SurfaceForcing:
|
|
|
530
539
|
The number of partitions along the `eta` direction. If `None`, no spatial partitioning is performed.
|
|
531
540
|
np_xi : int, optional
|
|
532
541
|
The number of partitions along the `xi` direction. If `None`, no spatial partitioning is performed.
|
|
542
|
+
group: bool, optional
|
|
543
|
+
If `True`, groups the dataset into multiple files based on temporal data frequency. Defaults to `False`.
|
|
533
544
|
|
|
534
545
|
Returns
|
|
535
546
|
-------
|
|
@@ -544,7 +555,18 @@ class SurfaceForcing:
|
|
|
544
555
|
if filepath.suffix == ".nc":
|
|
545
556
|
filepath = filepath.with_suffix("")
|
|
546
557
|
|
|
547
|
-
|
|
558
|
+
if self.use_dask:
|
|
559
|
+
from dask.diagnostics import ProgressBar
|
|
560
|
+
|
|
561
|
+
with ProgressBar():
|
|
562
|
+
self.ds.load()
|
|
563
|
+
|
|
564
|
+
if group:
|
|
565
|
+
dataset_list, output_filenames = group_dataset(self.ds, str(filepath))
|
|
566
|
+
else:
|
|
567
|
+
dataset_list = [self.ds]
|
|
568
|
+
output_filenames = [str(filepath)]
|
|
569
|
+
|
|
548
570
|
saved_filenames = save_datasets(
|
|
549
571
|
dataset_list, output_filenames, np_eta=np_eta, np_xi=np_xi
|
|
550
572
|
)
|
|
@@ -602,7 +624,7 @@ class SurfaceForcing:
|
|
|
602
624
|
# Write header
|
|
603
625
|
file.write(header)
|
|
604
626
|
# Write YAML data
|
|
605
|
-
yaml.dump(yaml_data, file, default_flow_style=False)
|
|
627
|
+
yaml.dump(yaml_data, file, default_flow_style=False, sort_keys=False)
|
|
606
628
|
|
|
607
629
|
@classmethod
|
|
608
630
|
def from_yaml(
|
roms_tools/setup/tides.py
CHANGED
|
@@ -20,8 +20,7 @@ from roms_tools.setup.utils import (
|
|
|
20
20
|
rotate_velocities,
|
|
21
21
|
get_vector_pairs,
|
|
22
22
|
)
|
|
23
|
-
from roms_tools.setup.
|
|
24
|
-
from roms_tools.setup.regrid import _lateral_regrid
|
|
23
|
+
from roms_tools.setup.regrid import LateralRegrid
|
|
25
24
|
import matplotlib.pyplot as plt
|
|
26
25
|
from pathlib import Path
|
|
27
26
|
|
|
@@ -77,71 +76,64 @@ class TidalForcing:
|
|
|
77
76
|
data = self._get_data()
|
|
78
77
|
data.check_number_constituents(self.ntides)
|
|
79
78
|
data.choose_subdomain(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
target_coords["lat"].max().values,
|
|
83
|
-
],
|
|
84
|
-
longitude_range=[
|
|
85
|
-
target_coords["lon"].min().values,
|
|
86
|
-
target_coords["lon"].max().values,
|
|
87
|
-
],
|
|
88
|
-
margin=2,
|
|
89
|
-
straddle=target_coords["straddle"],
|
|
79
|
+
target_coords,
|
|
80
|
+
buffer_points=20,
|
|
90
81
|
)
|
|
91
82
|
# select desired number of constituents
|
|
92
83
|
object.__setattr__(data, "ds", data.ds.isel(ntides=slice(None, self.ntides)))
|
|
93
84
|
self._correct_tides(data)
|
|
94
85
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
data_vars = {}
|
|
98
|
-
for var_name in data.var_names:
|
|
99
|
-
data_vars[var_name] = data.ds[data.var_names[var_name]]
|
|
86
|
+
data.apply_lateral_fill()
|
|
100
87
|
|
|
101
|
-
|
|
88
|
+
variable_info = self._set_variable_info()
|
|
89
|
+
var_names = variable_info.keys()
|
|
102
90
|
|
|
91
|
+
processed_fields = {}
|
|
103
92
|
# lateral regridding
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
lateral_regrid = LateralRegrid(target_coords, data.dim_names)
|
|
94
|
+
for var_name in var_names:
|
|
95
|
+
if var_name in data.var_names.keys():
|
|
96
|
+
processed_fields[var_name] = lateral_regrid.apply(
|
|
97
|
+
data.ds[data.var_names[var_name]]
|
|
98
|
+
)
|
|
108
99
|
|
|
109
100
|
# rotation of velocities and interpolation to u/v points
|
|
110
101
|
vector_pairs = get_vector_pairs(variable_info)
|
|
111
102
|
for pair in vector_pairs:
|
|
112
103
|
u_component = pair[0]
|
|
113
104
|
v_component = pair[1]
|
|
114
|
-
if u_component in
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
if u_component in processed_fields and v_component in processed_fields:
|
|
106
|
+
(
|
|
107
|
+
processed_fields[u_component],
|
|
108
|
+
processed_fields[v_component],
|
|
109
|
+
) = rotate_velocities(
|
|
110
|
+
processed_fields[u_component],
|
|
111
|
+
processed_fields[v_component],
|
|
118
112
|
target_coords["angle"],
|
|
119
113
|
interpolate=False,
|
|
120
114
|
)
|
|
121
115
|
|
|
122
116
|
# convert to barotropic velocity
|
|
123
|
-
for
|
|
124
|
-
|
|
117
|
+
for var_name in ["u_Re", "v_Re", "u_Im", "v_Im"]:
|
|
118
|
+
processed_fields[var_name] = processed_fields[var_name] / self.grid.ds.h
|
|
125
119
|
|
|
126
120
|
# interpolate from rho- to velocity points
|
|
127
121
|
for uname in ["u_Re", "u_Im"]:
|
|
128
|
-
|
|
122
|
+
processed_fields[uname] = interpolate_from_rho_to_u(processed_fields[uname])
|
|
129
123
|
for vname in ["v_Re", "v_Im"]:
|
|
130
|
-
|
|
124
|
+
processed_fields[vname] = interpolate_from_rho_to_v(processed_fields[vname])
|
|
131
125
|
|
|
132
126
|
d_meta = get_variable_metadata()
|
|
133
|
-
ds = self._write_into_dataset(
|
|
127
|
+
ds = self._write_into_dataset(processed_fields, d_meta)
|
|
134
128
|
ds["omega"] = data.ds["omega"]
|
|
135
129
|
|
|
136
130
|
ds = self._add_global_metadata(ds)
|
|
137
131
|
|
|
138
|
-
|
|
139
|
-
for var in ["ssh_Re", "u_Re", "v_Im"]:
|
|
140
|
-
nan_check(ds[var].isel(ntides=0), self.grid.ds.mask_rho)
|
|
132
|
+
self._validate(ds)
|
|
141
133
|
|
|
142
134
|
# substitute NaNs over land by a fill value to avoid blow-up of ROMS
|
|
143
|
-
for
|
|
144
|
-
ds[
|
|
135
|
+
for var_name in ds.data_vars:
|
|
136
|
+
ds[var_name] = substitute_nans_by_fillvalue(ds[var_name])
|
|
145
137
|
|
|
146
138
|
object.__setattr__(self, "ds", ds)
|
|
147
139
|
|
|
@@ -216,15 +208,15 @@ class TidalForcing:
|
|
|
216
208
|
|
|
217
209
|
return variable_info
|
|
218
210
|
|
|
219
|
-
def _write_into_dataset(self,
|
|
211
|
+
def _write_into_dataset(self, processed_fields, d_meta):
|
|
220
212
|
|
|
221
213
|
# save in new dataset
|
|
222
214
|
ds = xr.Dataset()
|
|
223
215
|
|
|
224
|
-
for
|
|
225
|
-
ds[
|
|
226
|
-
ds[
|
|
227
|
-
ds[
|
|
216
|
+
for var_name in processed_fields.keys():
|
|
217
|
+
ds[var_name] = processed_fields[var_name].astype(np.float32)
|
|
218
|
+
ds[var_name].attrs["long_name"] = d_meta[var_name]["long_name"]
|
|
219
|
+
ds[var_name].attrs["units"] = d_meta[var_name]["units"]
|
|
228
220
|
|
|
229
221
|
ds = ds.drop_vars(["lat_rho", "lon_rho"])
|
|
230
222
|
|
|
@@ -247,12 +239,35 @@ class TidalForcing:
|
|
|
247
239
|
|
|
248
240
|
return ds
|
|
249
241
|
|
|
250
|
-
def
|
|
242
|
+
def _validate(self, ds):
|
|
243
|
+
"""Validates the dataset by checking for NaN values at wet points, which would
|
|
244
|
+
indicate missing raw data coverage over the target domain.
|
|
245
|
+
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
ds : xarray.Dataset
|
|
249
|
+
The dataset to validate, containing tidal variables and a mask for wet points.
|
|
250
|
+
|
|
251
|
+
Raises
|
|
252
|
+
------
|
|
253
|
+
ValueError
|
|
254
|
+
If NaN values are found in any of the specified variables at wet points,
|
|
255
|
+
indicating incomplete data coverage.
|
|
256
|
+
|
|
257
|
+
Notes
|
|
258
|
+
-----
|
|
259
|
+
This check is applied to the first constituent (`ntides=0`) of each variable in the dataset.
|
|
260
|
+
The method utilizes `self.grid.ds.mask_rho` to determine the wet points in the domain.
|
|
261
|
+
"""
|
|
262
|
+
for var_name in ds.data_vars:
|
|
263
|
+
nan_check(ds[var_name].isel(ntides=0), self.grid.ds.mask_rho)
|
|
264
|
+
|
|
265
|
+
def plot(self, var_name, ntides=0) -> None:
|
|
251
266
|
"""Plot the specified tidal forcing variable for a given tidal constituent.
|
|
252
267
|
|
|
253
268
|
Parameters
|
|
254
269
|
----------
|
|
255
|
-
|
|
270
|
+
var_name : str
|
|
256
271
|
The tidal forcing variable to plot. Options include:
|
|
257
272
|
|
|
258
273
|
- "ssh_Re": Real part of tidal elevation.
|
|
@@ -285,7 +300,14 @@ class TidalForcing:
|
|
|
285
300
|
>>> tidal_forcing.plot("ssh_Re", nc=0)
|
|
286
301
|
"""
|
|
287
302
|
|
|
288
|
-
field = self.ds[
|
|
303
|
+
field = self.ds[var_name].isel(ntides=ntides)
|
|
304
|
+
|
|
305
|
+
if self.use_dask:
|
|
306
|
+
from dask.diagnostics import ProgressBar
|
|
307
|
+
|
|
308
|
+
with ProgressBar():
|
|
309
|
+
field = field.load()
|
|
310
|
+
|
|
289
311
|
if all(dim in field.dims for dim in ["eta_rho", "xi_rho"]):
|
|
290
312
|
field = field.where(self.grid.ds.mask_rho)
|
|
291
313
|
field = field.assign_coords(
|
|
@@ -306,7 +328,7 @@ class TidalForcing:
|
|
|
306
328
|
else:
|
|
307
329
|
ValueError("provided field does not have two horizontal dimension")
|
|
308
330
|
|
|
309
|
-
title = "%s, ntides = %i" % (field.long_name, self.ds[
|
|
331
|
+
title = "%s, ntides = %i" % (field.long_name, self.ds[var_name].ntides[ntides])
|
|
310
332
|
|
|
311
333
|
vmax = max(field.max(), -field.min())
|
|
312
334
|
vmin = -vmax
|
|
@@ -363,7 +385,13 @@ class TidalForcing:
|
|
|
363
385
|
if filepath.suffix == ".nc":
|
|
364
386
|
filepath = filepath.with_suffix("")
|
|
365
387
|
|
|
366
|
-
|
|
388
|
+
if self.use_dask:
|
|
389
|
+
from dask.diagnostics import ProgressBar
|
|
390
|
+
|
|
391
|
+
with ProgressBar():
|
|
392
|
+
self.ds.load()
|
|
393
|
+
|
|
394
|
+
dataset_list = [self.ds]
|
|
367
395
|
output_filenames = [str(filepath)]
|
|
368
396
|
|
|
369
397
|
saved_filenames = save_datasets(
|
|
@@ -404,8 +432,8 @@ class TidalForcing:
|
|
|
404
432
|
"TidalForcing": {
|
|
405
433
|
"source": self.source,
|
|
406
434
|
"ntides": self.ntides,
|
|
407
|
-
"model_reference_date": self.model_reference_date.isoformat(),
|
|
408
435
|
"allan_factor": self.allan_factor,
|
|
436
|
+
"model_reference_date": self.model_reference_date.isoformat(),
|
|
409
437
|
}
|
|
410
438
|
}
|
|
411
439
|
|
|
@@ -416,7 +444,7 @@ class TidalForcing:
|
|
|
416
444
|
# Write header
|
|
417
445
|
file.write(header)
|
|
418
446
|
# Write YAML data
|
|
419
|
-
yaml.dump(yaml_data, file, default_flow_style=False)
|
|
447
|
+
yaml.dump(yaml_data, file, default_flow_style=False, sort_keys=False)
|
|
420
448
|
|
|
421
449
|
@classmethod
|
|
422
450
|
def from_yaml(
|