roms-tools 2.4.0__py3-none-any.whl → 2.6.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.
- ci/environment-with-xesmf.yml +16 -0
- roms_tools/__init__.py +1 -1
- roms_tools/analysis/roms_output.py +339 -234
- roms_tools/analysis/utils.py +137 -0
- roms_tools/plot.py +353 -214
- roms_tools/regrid.py +154 -9
- roms_tools/setup/boundary_forcing.py +51 -37
- roms_tools/setup/datasets.py +129 -74
- roms_tools/setup/grid.py +32 -33
- roms_tools/setup/initial_conditions.py +30 -37
- roms_tools/setup/nesting.py +238 -64
- roms_tools/setup/river_forcing.py +256 -86
- roms_tools/setup/surface_forcing.py +40 -28
- roms_tools/setup/tides.py +10 -13
- roms_tools/setup/topography.py +27 -4
- roms_tools/setup/utils.py +28 -12
- roms_tools/tests/test_analysis/test_roms_output.py +299 -80
- roms_tools/tests/test_regrid.py +85 -2
- roms_tools/tests/test_setup/test_boundary_forcing.py +63 -0
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +3 -1
- roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +3 -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_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_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_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_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 +2 -2
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zmetadata +8 -7
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/abs_time/.zattrs +1 -0
- 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/dust_time/.zattrs +1 -1
- 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/iron_time/.zattrs +1 -1
- 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/nhy_time/.zattrs +1 -1
- 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/nox_time/.zattrs +1 -1
- 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.zarr/pco2_time/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +2 -2
- 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/grid.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +2 -2
- roms_tools/tests/test_setup/test_data/grid.zarr/angle/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/angle_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/f/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/h/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid.zarr/h/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_rho/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/pm/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +1 -1
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/f/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_rho/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_coarse/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_rho/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/grid_that_straddles_dateline.zarr/pm/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pn/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/salt/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/river_forcing_no_climatology.zarr/.zmetadata +27 -1
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/.zattrs +1 -1
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/.zmetadata +27 -1
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/.zarray +20 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/.zattrs +6 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/0 +0 -0
- roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/.zattrs +1 -1
- roms_tools/tests/test_setup/test_initial_conditions.py +16 -0
- roms_tools/tests/test_setup/test_nesting.py +141 -104
- roms_tools/tests/test_setup/test_river_forcing.py +580 -266
- roms_tools/tests/test_setup/test_surface_forcing.py +47 -0
- roms_tools/tests/test_setup/test_validation.py +34 -2
- roms_tools/utils.py +11 -7
- roms_tools/vertical_coordinate.py +1 -0
- {roms_tools-2.4.0.dist-info → roms_tools-2.6.0.dist-info}/METADATA +22 -11
- {roms_tools-2.4.0.dist-info → roms_tools-2.6.0.dist-info}/RECORD +214 -206
- {roms_tools-2.4.0.dist-info → roms_tools-2.6.0.dist-info}/WHEEL +1 -1
- {roms_tools-2.4.0.dist-info → roms_tools-2.6.0.dist-info/licenses}/LICENSE +0 -0
- {roms_tools-2.4.0.dist-info → roms_tools-2.6.0.dist-info}/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@ import xarray as xr
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import logging
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from roms_tools import Grid,
|
|
6
|
+
from roms_tools import Grid, ChildGrid
|
|
7
7
|
from roms_tools.setup.utils import get_boundary_coords
|
|
8
8
|
from conftest import calculate_file_hash
|
|
9
9
|
from roms_tools.setup.nesting import (
|
|
@@ -15,14 +15,14 @@ from roms_tools.setup.nesting import (
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@pytest.fixture()
|
|
18
|
-
def
|
|
18
|
+
def big_grid():
|
|
19
19
|
return Grid(
|
|
20
20
|
nx=5, ny=7, center_lon=-23, center_lat=61, rot=20, size_x=1800, size_y=2400
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@pytest.fixture()
|
|
25
|
-
def
|
|
25
|
+
def small_grid():
|
|
26
26
|
return Grid(
|
|
27
27
|
nx=10, ny=10, center_lon=-23, center_lat=61, rot=-20, size_x=500, size_y=500
|
|
28
28
|
)
|
|
@@ -36,30 +36,44 @@ def baby_grid():
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
@pytest.fixture()
|
|
39
|
-
def
|
|
39
|
+
def big_grid_that_straddles():
|
|
40
40
|
return Grid(
|
|
41
41
|
nx=5, ny=7, center_lon=10, center_lat=61, rot=20, size_x=1800, size_y=2400
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
@pytest.fixture()
|
|
46
|
-
def
|
|
46
|
+
def small_grid_that_straddles():
|
|
47
47
|
return Grid(
|
|
48
48
|
nx=10, ny=10, center_lon=10, center_lat=61, rot=-20, size_x=500, size_y=500
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@pytest.fixture()
|
|
53
|
-
def
|
|
54
|
-
return
|
|
53
|
+
def child_grid(big_grid):
|
|
54
|
+
return ChildGrid(
|
|
55
|
+
parent_grid=big_grid,
|
|
56
|
+
nx=10,
|
|
57
|
+
ny=10,
|
|
58
|
+
center_lon=-23,
|
|
59
|
+
center_lat=61,
|
|
60
|
+
rot=-20,
|
|
61
|
+
size_x=500,
|
|
62
|
+
size_y=500,
|
|
63
|
+
)
|
|
55
64
|
|
|
56
65
|
|
|
57
66
|
@pytest.fixture()
|
|
58
|
-
def
|
|
59
|
-
return
|
|
60
|
-
parent_grid=
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
def child_grid_that_straddles(big_grid_that_straddles):
|
|
68
|
+
return ChildGrid(
|
|
69
|
+
parent_grid=big_grid_that_straddles,
|
|
70
|
+
nx=10,
|
|
71
|
+
ny=10,
|
|
72
|
+
center_lon=10,
|
|
73
|
+
center_lat=61,
|
|
74
|
+
rot=-20,
|
|
75
|
+
size_x=500,
|
|
76
|
+
size_y=500,
|
|
63
77
|
)
|
|
64
78
|
|
|
65
79
|
|
|
@@ -67,8 +81,8 @@ class TestInterpolateIndices:
|
|
|
67
81
|
@pytest.mark.parametrize(
|
|
68
82
|
"grid",
|
|
69
83
|
[
|
|
70
|
-
"
|
|
71
|
-
"
|
|
84
|
+
"big_grid",
|
|
85
|
+
"big_grid_that_straddles",
|
|
72
86
|
],
|
|
73
87
|
)
|
|
74
88
|
def test_correct_indices_of_same_grid(self, grid, caplog, request):
|
|
@@ -114,34 +128,34 @@ class TestInterpolateIndices:
|
|
|
114
128
|
np.testing.assert_allclose(i_xi.values, expected_i_xi)
|
|
115
129
|
|
|
116
130
|
@pytest.mark.parametrize(
|
|
117
|
-
"
|
|
131
|
+
"big_grid_fixture, small_grid_fixture",
|
|
118
132
|
[
|
|
119
|
-
("
|
|
120
|
-
("
|
|
133
|
+
("big_grid", "small_grid"),
|
|
134
|
+
("big_grid_that_straddles", "small_grid_that_straddles"),
|
|
121
135
|
],
|
|
122
136
|
)
|
|
123
137
|
def test_indices_are_within_range_of_parent_grid(
|
|
124
|
-
self,
|
|
138
|
+
self, big_grid_fixture, small_grid_fixture, request
|
|
125
139
|
):
|
|
126
140
|
"""Ensure interpolated indices fall within the parent grid's bounds."""
|
|
127
141
|
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
big_grid = request.getfixturevalue(big_grid_fixture)
|
|
143
|
+
small_grid = request.getfixturevalue(small_grid_fixture)
|
|
130
144
|
|
|
131
145
|
bdry_coords_dict = get_boundary_coords()
|
|
132
146
|
for location in ["rho", "u", "v"]:
|
|
133
147
|
for direction in ["south", "east", "north", "west"]:
|
|
134
148
|
bdry_coords = bdry_coords_dict[location][direction]
|
|
135
|
-
lon =
|
|
136
|
-
lat =
|
|
137
|
-
mask =
|
|
149
|
+
lon = small_grid.ds[f"lon_{location}"].isel(**bdry_coords)
|
|
150
|
+
lat = small_grid.ds[f"lat_{location}"].isel(**bdry_coords)
|
|
151
|
+
mask = small_grid.ds[f"mask_{location}"].isel(**bdry_coords)
|
|
138
152
|
|
|
139
|
-
i_eta, i_xi = interpolate_indices(
|
|
153
|
+
i_eta, i_xi = interpolate_indices(big_grid.ds, lon, lat, mask)
|
|
140
154
|
|
|
141
155
|
expected_i_eta_min = -0.5
|
|
142
|
-
expected_i_eta_max =
|
|
156
|
+
expected_i_eta_max = big_grid.ds.eta_rho[-1] - 0.5
|
|
143
157
|
expected_i_xi_min = -0.5
|
|
144
|
-
expected_i_xi_max =
|
|
158
|
+
expected_i_xi_max = big_grid.ds.xi_rho[-1] - 0.5
|
|
145
159
|
|
|
146
160
|
assert (i_eta >= expected_i_eta_min).all()
|
|
147
161
|
assert (i_eta <= expected_i_eta_max).all()
|
|
@@ -150,36 +164,34 @@ class TestInterpolateIndices:
|
|
|
150
164
|
|
|
151
165
|
|
|
152
166
|
class TestMapChildBoundaries:
|
|
153
|
-
def test_update_indices_does_nothing_if_no_parent_land(self,
|
|
167
|
+
def test_update_indices_does_nothing_if_no_parent_land(self, small_grid, baby_grid):
|
|
154
168
|
"""Verify no change in indices when parent grid has no land at boundaries."""
|
|
155
169
|
|
|
156
170
|
ds_without_updated_indices = map_child_boundaries_onto_parent_grid_indices(
|
|
157
|
-
|
|
171
|
+
small_grid.ds, baby_grid.ds, update_land_indices=False
|
|
158
172
|
)
|
|
159
173
|
ds_with_updated_indices = map_child_boundaries_onto_parent_grid_indices(
|
|
160
|
-
|
|
174
|
+
small_grid.ds, baby_grid.ds, update_land_indices=True
|
|
161
175
|
)
|
|
162
176
|
|
|
163
177
|
xr.testing.assert_allclose(ds_without_updated_indices, ds_with_updated_indices)
|
|
164
178
|
|
|
165
179
|
@pytest.mark.parametrize(
|
|
166
|
-
"
|
|
180
|
+
"big_grid_fixture, small_grid_fixture",
|
|
167
181
|
[
|
|
168
|
-
("
|
|
169
|
-
("
|
|
182
|
+
("big_grid", "small_grid"),
|
|
183
|
+
("big_grid_that_straddles", "small_grid_that_straddles"),
|
|
170
184
|
],
|
|
171
185
|
)
|
|
172
186
|
def test_updated_indices_map_to_wet_points(
|
|
173
|
-
self,
|
|
187
|
+
self, big_grid_fixture, small_grid_fixture, request
|
|
174
188
|
):
|
|
175
189
|
"""Check updated indices map to wet points on the parent grid."""
|
|
176
190
|
|
|
177
|
-
|
|
178
|
-
|
|
191
|
+
big_grid = request.getfixturevalue(big_grid_fixture)
|
|
192
|
+
small_grid = request.getfixturevalue(small_grid_fixture)
|
|
179
193
|
|
|
180
|
-
ds = map_child_boundaries_onto_parent_grid_indices(
|
|
181
|
-
parent_grid.ds, child_grid.ds
|
|
182
|
-
)
|
|
194
|
+
ds = map_child_boundaries_onto_parent_grid_indices(big_grid.ds, small_grid.ds)
|
|
183
195
|
for direction in ["south", "east", "north", "west"]:
|
|
184
196
|
for location in ["rho", "u", "v"]:
|
|
185
197
|
if location == "rho":
|
|
@@ -191,7 +203,7 @@ class TestMapChildBoundaries:
|
|
|
191
203
|
for i in range(len(i_xi)):
|
|
192
204
|
i_eta_lower = int(np.floor(i_eta[i]))
|
|
193
205
|
i_xi_lower = int(np.floor(i_xi[i]))
|
|
194
|
-
mask =
|
|
206
|
+
mask = big_grid.ds.mask_rho.isel(
|
|
195
207
|
eta_rho=slice(i_eta_lower, i_eta_lower + 2),
|
|
196
208
|
xi_rho=slice(i_xi_lower, i_xi_lower + 2),
|
|
197
209
|
)
|
|
@@ -199,24 +211,24 @@ class TestMapChildBoundaries:
|
|
|
199
211
|
# TODO: check also u and v locations
|
|
200
212
|
|
|
201
213
|
@pytest.mark.parametrize(
|
|
202
|
-
"
|
|
214
|
+
"big_grid_fixture, small_grid_fixture",
|
|
203
215
|
[
|
|
204
|
-
("
|
|
205
|
-
("
|
|
216
|
+
("big_grid", "small_grid"),
|
|
217
|
+
("big_grid_that_straddles", "small_grid_that_straddles"),
|
|
206
218
|
],
|
|
207
219
|
)
|
|
208
220
|
def test_indices_are_monotonically_increasing(
|
|
209
|
-
self,
|
|
221
|
+
self, big_grid_fixture, small_grid_fixture, request
|
|
210
222
|
):
|
|
211
223
|
"""Test that child boundary indices are monotonically increasing or decreasing
|
|
212
224
|
in both the xi and eta directions, for all boundaries and locations."""
|
|
213
225
|
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
big_grid = request.getfixturevalue(big_grid_fixture)
|
|
227
|
+
small_grid = request.getfixturevalue(small_grid_fixture)
|
|
216
228
|
|
|
217
229
|
for update_land_indices in [False, True]:
|
|
218
230
|
ds = map_child_boundaries_onto_parent_grid_indices(
|
|
219
|
-
|
|
231
|
+
big_grid.ds, small_grid.ds, update_land_indices=update_land_indices
|
|
220
232
|
)
|
|
221
233
|
|
|
222
234
|
for direction in ["south", "east", "north", "west"]:
|
|
@@ -240,7 +252,7 @@ class TestBoundaryDistance:
|
|
|
240
252
|
@pytest.mark.parametrize(
|
|
241
253
|
"grid_fixture",
|
|
242
254
|
[
|
|
243
|
-
"
|
|
255
|
+
"small_grid",
|
|
244
256
|
"baby_grid",
|
|
245
257
|
],
|
|
246
258
|
)
|
|
@@ -266,10 +278,10 @@ class TestBoundaryDistance:
|
|
|
266
278
|
== 1
|
|
267
279
|
)
|
|
268
280
|
|
|
269
|
-
def test_boundary_distance_for_grid_with_land_along_boundary(self,
|
|
281
|
+
def test_boundary_distance_for_grid_with_land_along_boundary(self, big_grid):
|
|
270
282
|
"""Test that there are 1s along the boundary of alpha if the grid has land along
|
|
271
283
|
the boundary."""
|
|
272
|
-
alpha = compute_boundary_distance(
|
|
284
|
+
alpha = compute_boundary_distance(big_grid.ds.mask_rho)
|
|
273
285
|
assert (alpha.isel(eta_rho=0) == 1).any()
|
|
274
286
|
assert (alpha.isel(eta_rho=-1) == 1).any()
|
|
275
287
|
assert (alpha.isel(xi_rho=0) == 1).any()
|
|
@@ -278,21 +290,21 @@ class TestBoundaryDistance:
|
|
|
278
290
|
|
|
279
291
|
class TestModifyChid:
|
|
280
292
|
def test_mask_is_not_modified_if_no_parent_land_along_boundaries(
|
|
281
|
-
self,
|
|
293
|
+
self, small_grid, baby_grid
|
|
282
294
|
):
|
|
283
295
|
"""Confirm child mask remains unchanged if no parent land is at boundaries."""
|
|
284
296
|
|
|
285
297
|
mask_original = baby_grid.ds.mask_rho.copy()
|
|
286
298
|
modified_baby_grid_ds = modify_child_topography_and_mask(
|
|
287
|
-
|
|
299
|
+
small_grid.ds, baby_grid.ds
|
|
288
300
|
)
|
|
289
301
|
xr.testing.assert_allclose(modified_baby_grid_ds.mask_rho, mask_original)
|
|
290
302
|
|
|
291
303
|
@pytest.mark.parametrize(
|
|
292
304
|
"grid_fixture",
|
|
293
305
|
[
|
|
294
|
-
"
|
|
295
|
-
"
|
|
306
|
+
"big_grid",
|
|
307
|
+
"small_grid",
|
|
296
308
|
"baby_grid",
|
|
297
309
|
],
|
|
298
310
|
)
|
|
@@ -308,16 +320,16 @@ class TestModifyChid:
|
|
|
308
320
|
xr.testing.assert_allclose(modified_grid_ds.h, h_original)
|
|
309
321
|
xr.testing.assert_allclose(modified_grid_ds.mask_rho, mask_original)
|
|
310
322
|
|
|
311
|
-
def test_modification_only_along_boundaries(self,
|
|
323
|
+
def test_modification_only_along_boundaries(self, big_grid, small_grid):
|
|
312
324
|
"""Test that modifications to the child grid's topography and mask occur only
|
|
313
325
|
along the boundaries, leaving the interior unchanged."""
|
|
314
326
|
|
|
315
327
|
# Make copies of original data for comparison
|
|
316
|
-
h_original =
|
|
317
|
-
mask_original =
|
|
328
|
+
h_original = small_grid.ds.h.copy()
|
|
329
|
+
mask_original = small_grid.ds.mask_rho.copy()
|
|
318
330
|
|
|
319
331
|
# Apply the modification function
|
|
320
|
-
modified_ds = modify_child_topography_and_mask(
|
|
332
|
+
modified_ds = modify_child_topography_and_mask(big_grid.ds, small_grid.ds)
|
|
321
333
|
|
|
322
334
|
# Calculate the center indices for the grid
|
|
323
335
|
eta_center = h_original.sizes["eta_rho"] // 2
|
|
@@ -339,23 +351,24 @@ class TestModifyChid:
|
|
|
339
351
|
|
|
340
352
|
class TestNesting:
|
|
341
353
|
@pytest.mark.parametrize(
|
|
342
|
-
"
|
|
343
|
-
["
|
|
354
|
+
"child_grid_fixture",
|
|
355
|
+
["child_grid", "child_grid_that_straddles"],
|
|
344
356
|
)
|
|
345
|
-
def test_successful_initialization(self,
|
|
346
|
-
|
|
357
|
+
def test_successful_initialization(self, child_grid_fixture, request):
|
|
358
|
+
child_grid = request.getfixturevalue(child_grid_fixture)
|
|
347
359
|
|
|
348
|
-
assert
|
|
360
|
+
assert child_grid.boundaries == {
|
|
349
361
|
"south": True,
|
|
350
362
|
"east": True,
|
|
351
363
|
"north": True,
|
|
352
364
|
"west": True,
|
|
353
365
|
}
|
|
354
|
-
assert
|
|
355
|
-
assert
|
|
356
|
-
assert isinstance(
|
|
366
|
+
assert child_grid.metadata["prefix"] == "child"
|
|
367
|
+
assert child_grid.metadata["period"] == 3600.0
|
|
368
|
+
assert isinstance(child_grid.ds, xr.Dataset)
|
|
369
|
+
assert isinstance(child_grid.ds_nesting, xr.Dataset)
|
|
357
370
|
|
|
358
|
-
ds =
|
|
371
|
+
ds = child_grid.ds_nesting
|
|
359
372
|
for direction in ["south", "east", "north", "west"]:
|
|
360
373
|
for location in ["r", "u", "v"]:
|
|
361
374
|
assert f"child_{direction}_{location}" in ds.data_vars
|
|
@@ -379,58 +392,76 @@ class TestNesting:
|
|
|
379
392
|
)
|
|
380
393
|
|
|
381
394
|
@pytest.mark.parametrize(
|
|
382
|
-
"
|
|
395
|
+
"big_grid_fixture, small_grid_fixture",
|
|
383
396
|
[
|
|
384
|
-
("
|
|
385
|
-
("
|
|
397
|
+
("big_grid", "small_grid_that_straddles"),
|
|
398
|
+
("big_grid_that_straddles", "small_grid"),
|
|
386
399
|
],
|
|
387
400
|
)
|
|
388
401
|
def test_error_if_child_grid_beyond_parent_grid(
|
|
389
|
-
self,
|
|
402
|
+
self, big_grid_fixture, small_grid_fixture, request
|
|
390
403
|
):
|
|
391
|
-
|
|
392
|
-
|
|
404
|
+
big_grid = request.getfixturevalue(big_grid_fixture)
|
|
405
|
+
small_grid = request.getfixturevalue(small_grid_fixture)
|
|
406
|
+
|
|
407
|
+
import dataclasses
|
|
408
|
+
|
|
409
|
+
params = dataclasses.asdict(small_grid)
|
|
410
|
+
del params["ds"], params["straddle"]
|
|
393
411
|
|
|
394
412
|
with pytest.raises(ValueError, match="Some points are outside the grid."):
|
|
395
|
-
|
|
413
|
+
ChildGrid(parent_grid=big_grid, **params)
|
|
396
414
|
|
|
397
415
|
@pytest.mark.parametrize(
|
|
398
|
-
"
|
|
399
|
-
["
|
|
416
|
+
"child_grid_fixture",
|
|
417
|
+
["child_grid", "child_grid_that_straddles"],
|
|
400
418
|
)
|
|
401
|
-
def test_plot(self,
|
|
419
|
+
def test_plot(self, child_grid_fixture, request):
|
|
402
420
|
"""Test plot method."""
|
|
403
|
-
|
|
421
|
+
child_grid = request.getfixturevalue(child_grid_fixture)
|
|
404
422
|
|
|
405
|
-
|
|
406
|
-
|
|
423
|
+
child_grid.plot()
|
|
424
|
+
child_grid.plot_nesting()
|
|
425
|
+
child_grid.plot_nesting(with_dim_names=True)
|
|
407
426
|
|
|
408
|
-
def test_save(self,
|
|
409
|
-
"""Test save
|
|
427
|
+
def test_save(self, child_grid, tmp_path):
|
|
428
|
+
"""Test save methods."""
|
|
410
429
|
|
|
411
|
-
for file_str
|
|
412
|
-
["test_nesting", "test_nesting.nc"], ["test_grid", "test_grid.nc"]
|
|
413
|
-
):
|
|
430
|
+
for file_str in ["test_grid", "test_grid.nc"]:
|
|
414
431
|
# Create a temporary filepath using the tmp_path fixture
|
|
415
|
-
for filepath,
|
|
416
|
-
[tmp_path / file_str, str(tmp_path / file_str)],
|
|
417
|
-
[tmp_path / grid_file_str, str(tmp_path / grid_file_str)],
|
|
418
|
-
): # test for Path object and str
|
|
432
|
+
for filepath in [tmp_path / file_str, str(tmp_path / file_str)]:
|
|
419
433
|
|
|
420
|
-
saved_filenames =
|
|
434
|
+
saved_filenames = child_grid.save(filepath)
|
|
421
435
|
# Check if the .nc file was created
|
|
422
436
|
filepath = Path(filepath).with_suffix(".nc")
|
|
423
|
-
|
|
424
|
-
assert saved_filenames == [filepath, grid_filepath]
|
|
437
|
+
assert saved_filenames == [filepath]
|
|
425
438
|
assert filepath.exists()
|
|
426
|
-
assert grid_filepath.exists()
|
|
427
439
|
# Clean up the .nc file
|
|
428
440
|
filepath.unlink()
|
|
429
|
-
grid_filepath.unlink()
|
|
430
441
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
442
|
+
for file_str in ["test_nesting", "test_nesting.nc"]:
|
|
443
|
+
# Create a temporary filepath using the tmp_path fixture
|
|
444
|
+
for filepath in [tmp_path / file_str, str(tmp_path / file_str)]:
|
|
445
|
+
|
|
446
|
+
saved_filenames = child_grid.save_nesting(filepath)
|
|
447
|
+
# Check if the .nc file was created
|
|
448
|
+
filepath = Path(filepath).with_suffix(".nc")
|
|
449
|
+
assert saved_filenames == [filepath]
|
|
450
|
+
assert filepath.exists()
|
|
451
|
+
# Clean up the .nc file
|
|
452
|
+
filepath.unlink()
|
|
453
|
+
|
|
454
|
+
def test_disabled_from_file_method(self):
|
|
455
|
+
"""Test that parent from_file method is indeed disabled."""
|
|
456
|
+
with pytest.raises(
|
|
457
|
+
NotImplementedError,
|
|
458
|
+
match="The 'from_file' method is disabled in this subclass.",
|
|
459
|
+
):
|
|
460
|
+
ChildGrid.from_file(filepath="some_file.nc")
|
|
461
|
+
|
|
462
|
+
def test_roundtrip_yaml(self, child_grid, tmp_path):
|
|
463
|
+
"""Test that creating a ChildGrid object, saving its parameters to yaml file,
|
|
464
|
+
and re-opening yaml file creates the same object."""
|
|
434
465
|
|
|
435
466
|
# Create a temporary filepath using the tmp_path fixture
|
|
436
467
|
file_str = "test_yaml"
|
|
@@ -439,16 +470,16 @@ class TestNesting:
|
|
|
439
470
|
str(tmp_path / file_str),
|
|
440
471
|
]: # test for Path object and str
|
|
441
472
|
|
|
442
|
-
|
|
473
|
+
child_grid.to_yaml(filepath)
|
|
443
474
|
|
|
444
|
-
|
|
475
|
+
child_grid_from_file = ChildGrid.from_yaml(filepath)
|
|
445
476
|
|
|
446
|
-
assert
|
|
477
|
+
assert child_grid == child_grid_from_file
|
|
447
478
|
|
|
448
479
|
filepath = Path(filepath)
|
|
449
480
|
filepath.unlink()
|
|
450
481
|
|
|
451
|
-
def test_files_have_same_hash(self,
|
|
482
|
+
def test_files_have_same_hash(self, child_grid, tmp_path):
|
|
452
483
|
|
|
453
484
|
yaml_filepath = tmp_path / "test_yaml.yaml"
|
|
454
485
|
filepath1 = tmp_path / "test1.nc"
|
|
@@ -456,14 +487,20 @@ class TestNesting:
|
|
|
456
487
|
grid_filepath1 = tmp_path / "grid_test1.nc"
|
|
457
488
|
grid_filepath2 = tmp_path / "grid_test2.nc"
|
|
458
489
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
490
|
+
child_grid.to_yaml(yaml_filepath)
|
|
491
|
+
child_grid.save(grid_filepath1)
|
|
492
|
+
child_grid.save_nesting(filepath1)
|
|
493
|
+
|
|
494
|
+
child_grid_from_file = ChildGrid.from_yaml(yaml_filepath)
|
|
495
|
+
child_grid_from_file.save(grid_filepath2)
|
|
496
|
+
child_grid_from_file.save_nesting(filepath2)
|
|
463
497
|
|
|
464
498
|
hash1 = calculate_file_hash(filepath1)
|
|
465
499
|
hash2 = calculate_file_hash(filepath2)
|
|
500
|
+
assert hash1 == hash2, f"Hashes do not match: {hash1} != {hash2}"
|
|
466
501
|
|
|
502
|
+
hash1 = calculate_file_hash(grid_filepath1)
|
|
503
|
+
hash2 = calculate_file_hash(grid_filepath2)
|
|
467
504
|
assert hash1 == hash2, f"Hashes do not match: {hash1} != {hash2}"
|
|
468
505
|
|
|
469
506
|
yaml_filepath.unlink()
|