roms-tools 3.1.2__py3-none-any.whl → 3.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- roms_tools/__init__.py +3 -0
- roms_tools/analysis/cdr_analysis.py +203 -0
- roms_tools/analysis/cdr_ensemble.py +198 -0
- roms_tools/analysis/roms_output.py +80 -46
- roms_tools/data/grids/GLORYS_global_grid.nc +0 -0
- roms_tools/download.py +4 -0
- roms_tools/plot.py +113 -51
- roms_tools/setup/boundary_forcing.py +45 -20
- roms_tools/setup/cdr_forcing.py +122 -8
- roms_tools/setup/cdr_release.py +161 -8
- roms_tools/setup/grid.py +150 -141
- roms_tools/setup/initial_conditions.py +113 -48
- roms_tools/setup/{datasets.py → lat_lon_datasets.py} +443 -938
- roms_tools/setup/mask.py +63 -7
- roms_tools/setup/nesting.py +314 -117
- roms_tools/setup/river_datasets.py +527 -0
- roms_tools/setup/river_forcing.py +46 -20
- roms_tools/setup/surface_forcing.py +7 -9
- roms_tools/setup/tides.py +2 -3
- roms_tools/setup/topography.py +8 -10
- roms_tools/setup/utils.py +396 -23
- roms_tools/tests/test_analysis/test_cdr_analysis.py +144 -0
- roms_tools/tests/test_analysis/test_cdr_ensemble.py +202 -0
- roms_tools/tests/test_analysis/test_roms_output.py +61 -3
- roms_tools/tests/test_setup/test_boundary_forcing.py +54 -52
- roms_tools/tests/test_setup/test_cdr_forcing.py +54 -0
- roms_tools/tests/test_setup/test_cdr_release.py +118 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zarr.json +406 -406
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zarr.json +182 -182
- roms_tools/tests/test_setup/test_data/grid.zarr/h/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/zarr.json +191 -191
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/c/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/zarr.json +210 -210
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zarr.json +182 -182
- roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/zarr.json +187 -187
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/c/0/0/0 +0 -0
- roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/zarr.json +66 -66
- roms_tools/tests/test_setup/test_grid.py +236 -115
- roms_tools/tests/test_setup/test_initial_conditions.py +94 -41
- roms_tools/tests/test_setup/{test_datasets.py → test_lat_lon_datasets.py} +409 -100
- roms_tools/tests/test_setup/test_nesting.py +119 -31
- roms_tools/tests/test_setup/test_river_datasets.py +48 -0
- roms_tools/tests/test_setup/test_surface_forcing.py +2 -1
- roms_tools/tests/test_setup/test_utils.py +92 -2
- roms_tools/tests/test_setup/utils.py +71 -0
- roms_tools/tests/test_tiling/test_join.py +241 -0
- roms_tools/tests/test_utils.py +139 -17
- roms_tools/tiling/join.py +189 -0
- roms_tools/utils.py +131 -99
- {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/METADATA +12 -2
- {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/RECORD +221 -211
- {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/WHEEL +0 -0
- {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/licenses/LICENSE +0 -0
- {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/top_level.txt +0 -0
|
@@ -121,6 +121,33 @@ def grid_that_straddles_180_degree_meridian_with_global_srtm15_data():
|
|
|
121
121
|
return grid
|
|
122
122
|
|
|
123
123
|
|
|
124
|
+
@pytest.fixture()
|
|
125
|
+
def grid_with_gshhs_coastlines():
|
|
126
|
+
iceland_fjord_kwargs = {
|
|
127
|
+
"nx": 80,
|
|
128
|
+
"ny": 40,
|
|
129
|
+
"size_x": 40,
|
|
130
|
+
"size_y": 20,
|
|
131
|
+
"center_lon": -21.76,
|
|
132
|
+
"center_lat": 64.325,
|
|
133
|
+
"rot": 0,
|
|
134
|
+
"N": 3,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Make sure all 4 L1 files are downloaded
|
|
138
|
+
_ = download_test_data("GSHHS_l_L1.dbf")
|
|
139
|
+
_ = download_test_data("GSHHS_l_L1.prj")
|
|
140
|
+
_ = download_test_data("GSHHS_l_L1.shx")
|
|
141
|
+
shapefile = download_test_data("GSHHS_l_L1.shp")
|
|
142
|
+
|
|
143
|
+
grid = Grid(
|
|
144
|
+
**iceland_fjord_kwargs,
|
|
145
|
+
mask_shapefile=shapefile,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
return grid
|
|
149
|
+
|
|
150
|
+
|
|
124
151
|
def test_grid_creation(grid):
|
|
125
152
|
assert grid.nx == 1
|
|
126
153
|
assert grid.ny == 1
|
|
@@ -175,11 +202,33 @@ def test_coords_relation(grid_fixture, request):
|
|
|
175
202
|
"grid_that_straddles_180_degree_meridian_with_shifted_global_etopo_data",
|
|
176
203
|
"grid_that_straddles_dateline_with_global_srtm15_data",
|
|
177
204
|
"grid_that_straddles_180_degree_meridian_with_global_srtm15_data",
|
|
205
|
+
"grid_with_gshhs_coastlines",
|
|
178
206
|
],
|
|
179
207
|
)
|
|
180
208
|
def test_successful_initialization_with_topography(grid_fixture, request):
|
|
181
209
|
grid = request.getfixturevalue(grid_fixture)
|
|
182
|
-
|
|
210
|
+
|
|
211
|
+
expected_attrs = [
|
|
212
|
+
"nx",
|
|
213
|
+
"ny",
|
|
214
|
+
"size_x",
|
|
215
|
+
"size_y",
|
|
216
|
+
"center_lon",
|
|
217
|
+
"center_lat",
|
|
218
|
+
"rot",
|
|
219
|
+
"N",
|
|
220
|
+
"theta_s",
|
|
221
|
+
"theta_b",
|
|
222
|
+
"hc",
|
|
223
|
+
"topography_source",
|
|
224
|
+
"hmin",
|
|
225
|
+
"mask_shapefile",
|
|
226
|
+
"verbose",
|
|
227
|
+
"straddle",
|
|
228
|
+
]
|
|
229
|
+
|
|
230
|
+
for attr in expected_attrs:
|
|
231
|
+
assert hasattr(grid, attr), f"Missing attribute: {attr}"
|
|
183
232
|
|
|
184
233
|
|
|
185
234
|
def test_plot(grid_that_straddles_180_degree_meridian):
|
|
@@ -187,6 +236,20 @@ def test_plot(grid_that_straddles_180_degree_meridian):
|
|
|
187
236
|
grid_that_straddles_180_degree_meridian.plot(with_dim_names=True)
|
|
188
237
|
|
|
189
238
|
|
|
239
|
+
def test_plot_wide_grid():
|
|
240
|
+
# This grid should be handled via different cartopy projection
|
|
241
|
+
grid = Grid(
|
|
242
|
+
nx=10,
|
|
243
|
+
ny=10,
|
|
244
|
+
size_x=15000,
|
|
245
|
+
size_y=15000,
|
|
246
|
+
center_lon=-161,
|
|
247
|
+
center_lat=14.4,
|
|
248
|
+
rot=-3,
|
|
249
|
+
)
|
|
250
|
+
grid.plot()
|
|
251
|
+
|
|
252
|
+
|
|
190
253
|
@pytest.mark.skipif(xesmf is None, reason="xesmf required")
|
|
191
254
|
def test_plot_along_lat_lon(grid_that_straddles_180_degree_meridian):
|
|
192
255
|
grid_that_straddles_180_degree_meridian.plot(lat=61)
|
|
@@ -280,6 +343,7 @@ def test_grid_straddle_crosses_meridian():
|
|
|
280
343
|
"grid",
|
|
281
344
|
"grid_that_straddles_dateline_with_shifted_global_etopo_data",
|
|
282
345
|
"grid_that_straddles_dateline_with_global_srtm15_data",
|
|
346
|
+
"grid_with_gshhs_coastlines",
|
|
283
347
|
],
|
|
284
348
|
)
|
|
285
349
|
def test_roundtrip_netcdf(grid_fixture, tmp_path, request):
|
|
@@ -301,8 +365,8 @@ def test_roundtrip_netcdf(grid_fixture, tmp_path, request):
|
|
|
301
365
|
# Load the grid from the file
|
|
302
366
|
grid_from_file = Grid.from_file(filepath.with_suffix(".nc"))
|
|
303
367
|
|
|
304
|
-
# Assert that the initial grid and the loaded grid are equivalent (including the 'ds' attribute)
|
|
305
368
|
assert grid == grid_from_file
|
|
369
|
+
xr.testing.assert_equal(grid.ds, grid_from_file.ds)
|
|
306
370
|
|
|
307
371
|
# Clean up the .nc file
|
|
308
372
|
(filepath.with_suffix(".nc")).unlink()
|
|
@@ -314,6 +378,7 @@ def test_roundtrip_netcdf(grid_fixture, tmp_path, request):
|
|
|
314
378
|
"grid",
|
|
315
379
|
"grid_that_straddles_dateline_with_shifted_global_etopo_data",
|
|
316
380
|
"grid_that_straddles_dateline_with_global_srtm15_data",
|
|
381
|
+
"grid_with_gshhs_coastlines",
|
|
317
382
|
],
|
|
318
383
|
)
|
|
319
384
|
def test_roundtrip_yaml(grid_fixture, tmp_path, request):
|
|
@@ -332,8 +397,8 @@ def test_roundtrip_yaml(grid_fixture, tmp_path, request):
|
|
|
332
397
|
|
|
333
398
|
grid_from_file = Grid.from_yaml(filepath)
|
|
334
399
|
|
|
335
|
-
# Assert that the initial grid and the loaded grid are equivalent (including the 'ds' attribute)
|
|
336
400
|
assert grid == grid_from_file
|
|
401
|
+
xr.testing.assert_equal(grid.ds, grid_from_file.ds)
|
|
337
402
|
|
|
338
403
|
filepath = Path(filepath)
|
|
339
404
|
filepath.unlink()
|
|
@@ -345,6 +410,7 @@ def test_roundtrip_yaml(grid_fixture, tmp_path, request):
|
|
|
345
410
|
"grid",
|
|
346
411
|
"grid_that_straddles_dateline_with_shifted_global_etopo_data",
|
|
347
412
|
"grid_that_straddles_dateline_with_global_srtm15_data",
|
|
413
|
+
"grid_with_gshhs_coastlines",
|
|
348
414
|
],
|
|
349
415
|
)
|
|
350
416
|
def test_roundtrip_from_file_yaml(grid_fixture, tmp_path, request):
|
|
@@ -359,30 +425,33 @@ def test_roundtrip_from_file_yaml(grid_fixture, tmp_path, request):
|
|
|
359
425
|
filepath_yaml = Path(tmp_path / "test.yaml")
|
|
360
426
|
grid_from_file.to_yaml(filepath_yaml)
|
|
361
427
|
|
|
428
|
+
grid_from_yaml = Grid.from_yaml(filepath_yaml)
|
|
429
|
+
|
|
430
|
+
assert grid_from_yaml == grid
|
|
431
|
+
xr.testing.assert_equal(grid.ds, grid_from_yaml.ds)
|
|
432
|
+
|
|
362
433
|
filepath.unlink()
|
|
363
434
|
filepath_yaml.unlink()
|
|
364
435
|
|
|
365
436
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
hmin=5.0,
|
|
378
|
-
)
|
|
437
|
+
@pytest.mark.parametrize(
|
|
438
|
+
"grid_fixture",
|
|
439
|
+
[
|
|
440
|
+
"grid",
|
|
441
|
+
"grid_that_straddles_dateline_with_shifted_global_etopo_data",
|
|
442
|
+
"grid_that_straddles_dateline_with_global_srtm15_data",
|
|
443
|
+
"grid_with_gshhs_coastlines",
|
|
444
|
+
],
|
|
445
|
+
)
|
|
446
|
+
def test_files_have_same_hash(grid_fixture, tmp_path, request):
|
|
447
|
+
grid = request.getfixturevalue(grid_fixture)
|
|
379
448
|
|
|
380
449
|
yaml_filepath = tmp_path / "test_yaml"
|
|
381
450
|
filepath1 = tmp_path / "test1.nc"
|
|
382
451
|
filepath2 = tmp_path / "test2.nc"
|
|
383
452
|
|
|
384
|
-
|
|
385
|
-
|
|
453
|
+
grid.to_yaml(yaml_filepath)
|
|
454
|
+
grid.save(filepath1)
|
|
386
455
|
|
|
387
456
|
grid_from_file = Grid.from_yaml(yaml_filepath)
|
|
388
457
|
grid_from_file.save(filepath2)
|
|
@@ -505,6 +574,9 @@ def test_from_yaml_version_mismatch(tmp_path, caplog):
|
|
|
505
574
|
yaml_filepath.unlink()
|
|
506
575
|
|
|
507
576
|
|
|
577
|
+
# Vertical coordinate tests
|
|
578
|
+
|
|
579
|
+
|
|
508
580
|
def test_invalid_theta_s_value():
|
|
509
581
|
"""Test the validation of the theta_s value."""
|
|
510
582
|
with pytest.raises(ValueError):
|
|
@@ -608,6 +680,152 @@ def test_plot_vertical_coordinate():
|
|
|
608
680
|
grid.plot_vertical_coordinate(eta=-1, xi=0, s=-1)
|
|
609
681
|
|
|
610
682
|
|
|
683
|
+
# Topography tests
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def test_enclosed_regions():
|
|
687
|
+
"""Test that there are only two connected regions, one dry and one wet."""
|
|
688
|
+
grid = Grid(
|
|
689
|
+
nx=100,
|
|
690
|
+
ny=100,
|
|
691
|
+
size_x=1800,
|
|
692
|
+
size_y=2400,
|
|
693
|
+
center_lon=30,
|
|
694
|
+
center_lat=61,
|
|
695
|
+
rot=20,
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
reg, nreg = label(grid.ds.mask_rho)
|
|
699
|
+
npt.assert_equal(nreg, 2)
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
def test_rmax_criterion():
|
|
703
|
+
grid = Grid(
|
|
704
|
+
nx=100,
|
|
705
|
+
ny=100,
|
|
706
|
+
size_x=1800,
|
|
707
|
+
size_y=2400,
|
|
708
|
+
center_lon=30,
|
|
709
|
+
center_lat=61,
|
|
710
|
+
rot=20,
|
|
711
|
+
)
|
|
712
|
+
r_eta, r_xi = _compute_rfactor(grid.ds.h)
|
|
713
|
+
rmax0 = np.max([r_eta.max(), r_xi.max()])
|
|
714
|
+
npt.assert_array_less(rmax0, 0.2)
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
def test_hmin_criterion_and_update_topography():
|
|
718
|
+
grid = Grid(
|
|
719
|
+
nx=100,
|
|
720
|
+
ny=100,
|
|
721
|
+
size_x=1800,
|
|
722
|
+
size_y=2400,
|
|
723
|
+
center_lon=30,
|
|
724
|
+
center_lat=61,
|
|
725
|
+
rot=20,
|
|
726
|
+
hmin=5.0,
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
assert grid.hmin == 5.0
|
|
730
|
+
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
731
|
+
|
|
732
|
+
grid.update_topography(hmin=10.0)
|
|
733
|
+
|
|
734
|
+
assert grid.hmin == 10.0
|
|
735
|
+
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
736
|
+
|
|
737
|
+
# this should not do anything
|
|
738
|
+
grid.update_topography()
|
|
739
|
+
|
|
740
|
+
assert grid.hmin == 10.0
|
|
741
|
+
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
# Mask tests
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
def test_update_mask():
|
|
748
|
+
iceland_fjord_kwargs = {
|
|
749
|
+
"nx": 80,
|
|
750
|
+
"ny": 40,
|
|
751
|
+
"size_x": 40,
|
|
752
|
+
"size_y": 20,
|
|
753
|
+
"center_lon": -21.76,
|
|
754
|
+
"center_lat": 64.325,
|
|
755
|
+
"rot": 0,
|
|
756
|
+
"N": 3,
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
# Make sure all 4 L1 files are downloaded
|
|
760
|
+
_ = download_test_data("GSHHS_l_L1.dbf")
|
|
761
|
+
_ = download_test_data("GSHHS_l_L1.prj")
|
|
762
|
+
_ = download_test_data("GSHHS_l_L1.shx")
|
|
763
|
+
shapefile = download_test_data("GSHHS_l_L1.shp")
|
|
764
|
+
|
|
765
|
+
grid = Grid(
|
|
766
|
+
**iceland_fjord_kwargs,
|
|
767
|
+
mask_shapefile=shapefile,
|
|
768
|
+
)
|
|
769
|
+
|
|
770
|
+
assert grid.mask_shapefile == shapefile
|
|
771
|
+
|
|
772
|
+
# Save original mask
|
|
773
|
+
mask_orig = grid.ds.mask_rho.copy()
|
|
774
|
+
|
|
775
|
+
# Update mask (switches to Natural Earth)
|
|
776
|
+
grid.update_mask()
|
|
777
|
+
|
|
778
|
+
assert grid.mask_shapefile is None
|
|
779
|
+
|
|
780
|
+
# New mask after update
|
|
781
|
+
mask_new = grid.ds.mask_rho.copy()
|
|
782
|
+
|
|
783
|
+
assert abs(mask_new - mask_orig).max() == 1, (
|
|
784
|
+
"Mask should change after update_mask()"
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
# Boundary tests
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
def test_mask_topography_boundary():
|
|
792
|
+
"""Test that the mask and topography along the grid boundaries (north, south, east,
|
|
793
|
+
west) are identical to the adjacent inland cells.
|
|
794
|
+
"""
|
|
795
|
+
# Create a grid with some land along the northern boundary
|
|
796
|
+
grid = Grid(
|
|
797
|
+
nx=10, ny=10, size_x=1000, size_y=1000, center_lon=-20, center_lat=60, rot=0
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
# Toopography
|
|
801
|
+
np.testing.assert_array_equal(
|
|
802
|
+
grid.ds.h.isel(eta_rho=0).data, grid.ds.h.isel(eta_rho=1).data
|
|
803
|
+
)
|
|
804
|
+
np.testing.assert_array_equal(
|
|
805
|
+
grid.ds.h.isel(eta_rho=-1).data, grid.ds.h.isel(eta_rho=-2).data
|
|
806
|
+
)
|
|
807
|
+
np.testing.assert_array_equal(
|
|
808
|
+
grid.ds.h.isel(xi_rho=0).data, grid.ds.h.isel(xi_rho=1).data
|
|
809
|
+
)
|
|
810
|
+
np.testing.assert_array_equal(
|
|
811
|
+
grid.ds.h.isel(xi_rho=-1).data, grid.ds.h.isel(xi_rho=-2).data
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
# Mask
|
|
815
|
+
np.testing.assert_array_equal(
|
|
816
|
+
grid.ds.mask_rho.isel(eta_rho=0).data, grid.ds.mask_rho.isel(eta_rho=1).data
|
|
817
|
+
)
|
|
818
|
+
np.testing.assert_array_equal(
|
|
819
|
+
grid.ds.mask_rho.isel(eta_rho=-1).data, grid.ds.mask_rho.isel(eta_rho=-2).data
|
|
820
|
+
)
|
|
821
|
+
np.testing.assert_array_equal(
|
|
822
|
+
grid.ds.mask_rho.isel(xi_rho=0).data, grid.ds.mask_rho.isel(xi_rho=1).data
|
|
823
|
+
)
|
|
824
|
+
np.testing.assert_array_equal(
|
|
825
|
+
grid.ds.mask_rho.isel(xi_rho=-1).data, grid.ds.mask_rho.isel(xi_rho=-2).data
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
|
|
611
829
|
# More Grid.from_file() tests
|
|
612
830
|
|
|
613
831
|
|
|
@@ -723,100 +941,3 @@ def test_from_file_partial_parameters_raises_error(grid, tmp_path):
|
|
|
723
941
|
|
|
724
942
|
with pytest.raises(ValueError, match="must provide all of"):
|
|
725
943
|
Grid.from_file(path, theta_s=5.0)
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
# Topography tests
|
|
729
|
-
def test_enclosed_regions():
|
|
730
|
-
"""Test that there are only two connected regions, one dry and one wet."""
|
|
731
|
-
grid = Grid(
|
|
732
|
-
nx=100,
|
|
733
|
-
ny=100,
|
|
734
|
-
size_x=1800,
|
|
735
|
-
size_y=2400,
|
|
736
|
-
center_lon=30,
|
|
737
|
-
center_lat=61,
|
|
738
|
-
rot=20,
|
|
739
|
-
)
|
|
740
|
-
|
|
741
|
-
reg, nreg = label(grid.ds.mask_rho)
|
|
742
|
-
npt.assert_equal(nreg, 2)
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
def test_rmax_criterion():
|
|
746
|
-
grid = Grid(
|
|
747
|
-
nx=100,
|
|
748
|
-
ny=100,
|
|
749
|
-
size_x=1800,
|
|
750
|
-
size_y=2400,
|
|
751
|
-
center_lon=30,
|
|
752
|
-
center_lat=61,
|
|
753
|
-
rot=20,
|
|
754
|
-
)
|
|
755
|
-
r_eta, r_xi = _compute_rfactor(grid.ds.h)
|
|
756
|
-
rmax0 = np.max([r_eta.max(), r_xi.max()])
|
|
757
|
-
npt.assert_array_less(rmax0, 0.2)
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
def test_hmin_criterion():
|
|
761
|
-
grid = Grid(
|
|
762
|
-
nx=100,
|
|
763
|
-
ny=100,
|
|
764
|
-
size_x=1800,
|
|
765
|
-
size_y=2400,
|
|
766
|
-
center_lon=30,
|
|
767
|
-
center_lat=61,
|
|
768
|
-
rot=20,
|
|
769
|
-
hmin=5.0,
|
|
770
|
-
)
|
|
771
|
-
|
|
772
|
-
assert grid.hmin == 5.0
|
|
773
|
-
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
774
|
-
|
|
775
|
-
grid.update_topography(hmin=10.0)
|
|
776
|
-
|
|
777
|
-
assert grid.hmin == 10.0
|
|
778
|
-
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
779
|
-
|
|
780
|
-
# this should not do anything
|
|
781
|
-
grid.update_topography()
|
|
782
|
-
|
|
783
|
-
assert grid.hmin == 10.0
|
|
784
|
-
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
def test_mask_topography_boundary():
|
|
788
|
-
"""Test that the mask and topography along the grid boundaries (north, south, east,
|
|
789
|
-
west) are identical to the adjacent inland cells.
|
|
790
|
-
"""
|
|
791
|
-
# Create a grid with some land along the northern boundary
|
|
792
|
-
grid = Grid(
|
|
793
|
-
nx=10, ny=10, size_x=1000, size_y=1000, center_lon=-20, center_lat=60, rot=0
|
|
794
|
-
)
|
|
795
|
-
|
|
796
|
-
# Toopography
|
|
797
|
-
np.testing.assert_array_equal(
|
|
798
|
-
grid.ds.h.isel(eta_rho=0).data, grid.ds.h.isel(eta_rho=1).data
|
|
799
|
-
)
|
|
800
|
-
np.testing.assert_array_equal(
|
|
801
|
-
grid.ds.h.isel(eta_rho=-1).data, grid.ds.h.isel(eta_rho=-2).data
|
|
802
|
-
)
|
|
803
|
-
np.testing.assert_array_equal(
|
|
804
|
-
grid.ds.h.isel(xi_rho=0).data, grid.ds.h.isel(xi_rho=1).data
|
|
805
|
-
)
|
|
806
|
-
np.testing.assert_array_equal(
|
|
807
|
-
grid.ds.h.isel(xi_rho=-1).data, grid.ds.h.isel(xi_rho=-2).data
|
|
808
|
-
)
|
|
809
|
-
|
|
810
|
-
# Mask
|
|
811
|
-
np.testing.assert_array_equal(
|
|
812
|
-
grid.ds.mask_rho.isel(eta_rho=0).data, grid.ds.mask_rho.isel(eta_rho=1).data
|
|
813
|
-
)
|
|
814
|
-
np.testing.assert_array_equal(
|
|
815
|
-
grid.ds.mask_rho.isel(eta_rho=-1).data, grid.ds.mask_rho.isel(eta_rho=-2).data
|
|
816
|
-
)
|
|
817
|
-
np.testing.assert_array_equal(
|
|
818
|
-
grid.ds.mask_rho.isel(xi_rho=0).data, grid.ds.mask_rho.isel(xi_rho=1).data
|
|
819
|
-
)
|
|
820
|
-
np.testing.assert_array_equal(
|
|
821
|
-
grid.ds.mask_rho.isel(xi_rho=-1).data, grid.ds.mask_rho.isel(xi_rho=-2).data
|
|
822
|
-
)
|
|
@@ -11,7 +11,35 @@ import xarray as xr
|
|
|
11
11
|
from conftest import calculate_data_hash
|
|
12
12
|
from roms_tools import Grid, InitialConditions
|
|
13
13
|
from roms_tools.download import download_test_data
|
|
14
|
-
from roms_tools.setup.
|
|
14
|
+
from roms_tools.setup.lat_lon_datasets import (
|
|
15
|
+
CESMBGCDataset,
|
|
16
|
+
UnifiedBGCDataset,
|
|
17
|
+
)
|
|
18
|
+
from roms_tools.tests.test_setup.utils import download_regional_and_bigger
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
import copernicusmarine # type: ignore
|
|
22
|
+
except ImportError:
|
|
23
|
+
copernicusmarine = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.fixture
|
|
27
|
+
def example_grid():
|
|
28
|
+
grid = Grid(
|
|
29
|
+
nx=2,
|
|
30
|
+
ny=2,
|
|
31
|
+
size_x=500,
|
|
32
|
+
size_y=1000,
|
|
33
|
+
center_lon=0,
|
|
34
|
+
center_lat=55,
|
|
35
|
+
rot=10,
|
|
36
|
+
N=3, # number of vertical levels
|
|
37
|
+
theta_s=5.0, # surface control parameter
|
|
38
|
+
theta_b=2.0, # bottom control parameter
|
|
39
|
+
hc=250.0, # critical depth
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return grid
|
|
15
43
|
|
|
16
44
|
|
|
17
45
|
@pytest.mark.parametrize(
|
|
@@ -25,7 +53,9 @@ from roms_tools.setup.datasets import CESMBGCDataset, UnifiedBGCDataset
|
|
|
25
53
|
"initial_conditions_with_unified_bgc_from_climatology",
|
|
26
54
|
],
|
|
27
55
|
)
|
|
28
|
-
def
|
|
56
|
+
def test_initial_conditions_creation_with_nondefault_glorys_dataset(
|
|
57
|
+
ic_fixture, request
|
|
58
|
+
):
|
|
29
59
|
"""Test the creation of the InitialConditions object."""
|
|
30
60
|
ic = request.getfixturevalue(ic_fixture)
|
|
31
61
|
|
|
@@ -37,12 +67,65 @@ def test_initial_conditions_creation(ic_fixture, request):
|
|
|
37
67
|
}
|
|
38
68
|
assert hasattr(ic.ds, "adjust_depth_for_sea_surface_height")
|
|
39
69
|
assert isinstance(ic.ds, xr.Dataset)
|
|
40
|
-
assert "temp" in ic.ds
|
|
41
|
-
assert "salt" in ic.ds
|
|
42
|
-
assert "u" in ic.ds
|
|
43
|
-
assert "v" in ic.ds
|
|
44
|
-
assert "zeta" in ic.ds
|
|
45
70
|
assert ic.ds.coords["ocean_time"].attrs["units"] == "seconds"
|
|
71
|
+
expected_vars = {"temp", "salt", "u", "v", "zeta", "ubar", "vbar"}
|
|
72
|
+
assert set(ic.ds.data_vars).issuperset(expected_vars)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@pytest.mark.stream
|
|
76
|
+
@pytest.mark.use_copernicus
|
|
77
|
+
@pytest.mark.use_dask
|
|
78
|
+
def test_initial_conditions_creation_with_default_glorys_dataset(example_grid: Grid):
|
|
79
|
+
"""Verify the default GLORYS dataset is loaded when a path is not provided."""
|
|
80
|
+
ic = InitialConditions(
|
|
81
|
+
grid=example_grid,
|
|
82
|
+
ini_time=datetime(2021, 6, 29),
|
|
83
|
+
source={"name": "GLORYS"},
|
|
84
|
+
use_dask=True,
|
|
85
|
+
bypass_validation=True,
|
|
86
|
+
)
|
|
87
|
+
expected_vars = {"temp", "salt", "u", "v", "zeta", "ubar", "vbar"}
|
|
88
|
+
assert set(ic.ds.data_vars).issuperset(expected_vars)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@pytest.mark.use_copernicus
|
|
92
|
+
@pytest.mark.skipif(copernicusmarine is None, reason="copernicusmarine required")
|
|
93
|
+
@pytest.mark.parametrize(
|
|
94
|
+
"grid_fixture",
|
|
95
|
+
[
|
|
96
|
+
"tiny_grid_that_straddles_dateline",
|
|
97
|
+
"tiny_grid_that_straddles_180_degree_meridian",
|
|
98
|
+
"tiny_rotated_grid",
|
|
99
|
+
],
|
|
100
|
+
)
|
|
101
|
+
def test_invariance_to_get_glorys_bounds(tmp_path, grid_fixture, use_dask, request):
|
|
102
|
+
ini_time = datetime(2012, 1, 1)
|
|
103
|
+
grid = request.getfixturevalue(grid_fixture)
|
|
104
|
+
regional_file, bigger_regional_file = download_regional_and_bigger(
|
|
105
|
+
tmp_path, grid, ini_time
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
ic_from_regional = InitialConditions(
|
|
109
|
+
grid=grid,
|
|
110
|
+
source={"name": "GLORYS", "path": str(regional_file)},
|
|
111
|
+
ini_time=ini_time,
|
|
112
|
+
use_dask=use_dask,
|
|
113
|
+
)
|
|
114
|
+
ic_from_bigger_regional = InitialConditions(
|
|
115
|
+
grid=grid,
|
|
116
|
+
source={"name": "GLORYS", "path": str(bigger_regional_file)},
|
|
117
|
+
ini_time=ini_time,
|
|
118
|
+
use_dask=use_dask,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Use assert_allclose instead of equals: necessary for grids that straddle the 180° meridian.
|
|
122
|
+
# Copernicus returns data on [-180, 180] by default, but if you request a range
|
|
123
|
+
# like [170, 190], it remaps longitudes. That remapping introduces tiny floating
|
|
124
|
+
# point differences in the longitude coordinate, which will then propagate into further differences once you do regridding.
|
|
125
|
+
# Need to adjust the tolerances for these grids that straddle the 180° meridian.
|
|
126
|
+
xr.testing.assert_allclose(
|
|
127
|
+
ic_from_bigger_regional.ds, ic_from_regional.ds, rtol=1e-4, atol=1e-5
|
|
128
|
+
)
|
|
46
129
|
|
|
47
130
|
|
|
48
131
|
def test_initial_conditions_creation_with_duplicates(use_dask: bool) -> None:
|
|
@@ -67,6 +150,7 @@ def test_initial_conditions_creation_with_duplicates(use_dask: bool) -> None:
|
|
|
67
150
|
grid=grid,
|
|
68
151
|
ini_time=datetime(2012, 1, 1),
|
|
69
152
|
source={"path": [fname1, fname2], "name": "GLORYS"},
|
|
153
|
+
allow_flex_time=True,
|
|
70
154
|
use_dask=use_dask,
|
|
71
155
|
)
|
|
72
156
|
|
|
@@ -74,6 +158,7 @@ def test_initial_conditions_creation_with_duplicates(use_dask: bool) -> None:
|
|
|
74
158
|
grid=grid,
|
|
75
159
|
ini_time=datetime(2012, 1, 1),
|
|
76
160
|
source={"path": [fname1, fname1, fname2], "name": "GLORYS"},
|
|
161
|
+
allow_flex_time=True,
|
|
77
162
|
use_dask=use_dask,
|
|
78
163
|
)
|
|
79
164
|
|
|
@@ -134,28 +219,9 @@ def test_initial_condition_creation_with_bgc(ic_fixture, request):
|
|
|
134
219
|
assert var in ic.ds
|
|
135
220
|
|
|
136
221
|
|
|
137
|
-
@pytest.fixture
|
|
138
|
-
def example_grid():
|
|
139
|
-
grid = Grid(
|
|
140
|
-
nx=2,
|
|
141
|
-
ny=2,
|
|
142
|
-
size_x=500,
|
|
143
|
-
size_y=1000,
|
|
144
|
-
center_lon=0,
|
|
145
|
-
center_lat=55,
|
|
146
|
-
rot=10,
|
|
147
|
-
N=3, # number of vertical levels
|
|
148
|
-
theta_s=5.0, # surface control parameter
|
|
149
|
-
theta_b=2.0, # bottom control parameter
|
|
150
|
-
hc=250.0, # critical depth
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
return grid
|
|
154
|
-
|
|
155
|
-
|
|
156
222
|
# Test initialization with missing 'name' in source
|
|
157
223
|
def test_initial_conditions_missing_physics_name(example_grid, use_dask):
|
|
158
|
-
with pytest.raises(ValueError, match="`source` must include a 'name'
|
|
224
|
+
with pytest.raises(ValueError, match="`source` must include a 'name'"):
|
|
159
225
|
InitialConditions(
|
|
160
226
|
grid=example_grid,
|
|
161
227
|
ini_time=datetime(2021, 6, 29),
|
|
@@ -164,23 +230,10 @@ def test_initial_conditions_missing_physics_name(example_grid, use_dask):
|
|
|
164
230
|
)
|
|
165
231
|
|
|
166
232
|
|
|
167
|
-
# Test initialization with missing 'path' in source
|
|
168
|
-
def test_initial_conditions_missing_physics_path(example_grid, use_dask):
|
|
169
|
-
with pytest.raises(ValueError, match="`source` must include a 'path'."):
|
|
170
|
-
InitialConditions(
|
|
171
|
-
grid=example_grid,
|
|
172
|
-
ini_time=datetime(2021, 6, 29),
|
|
173
|
-
source={"name": "GLORYS"},
|
|
174
|
-
use_dask=use_dask,
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
|
|
178
233
|
# Test initialization with missing 'name' in bgc_source
|
|
179
234
|
def test_initial_conditions_missing_bgc_name(example_grid, use_dask):
|
|
180
235
|
fname = Path(download_test_data("GLORYS_coarse_test_data.nc"))
|
|
181
|
-
with pytest.raises(
|
|
182
|
-
ValueError, match="`bgc_source` must include a 'name' if it is provided."
|
|
183
|
-
):
|
|
236
|
+
with pytest.raises(ValueError, match="`bgc_source` must include a 'name'"):
|
|
184
237
|
InitialConditions(
|
|
185
238
|
grid=example_grid,
|
|
186
239
|
ini_time=datetime(2021, 6, 29),
|