roms-tools 3.2.0__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.
Files changed (202) hide show
  1. roms_tools/__init__.py +1 -1
  2. roms_tools/plot.py +38 -30
  3. roms_tools/setup/boundary_forcing.py +2 -2
  4. roms_tools/setup/grid.py +13 -5
  5. roms_tools/setup/initial_conditions.py +5 -5
  6. roms_tools/setup/{datasets.py → lat_lon_datasets.py} +23 -804
  7. roms_tools/setup/nesting.py +262 -90
  8. roms_tools/setup/river_datasets.py +527 -0
  9. roms_tools/setup/river_forcing.py +2 -2
  10. roms_tools/setup/surface_forcing.py +4 -4
  11. roms_tools/setup/tides.py +1 -1
  12. roms_tools/setup/topography.py +4 -6
  13. roms_tools/setup/utils.py +263 -2
  14. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/c/0/0/0 +0 -0
  15. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/c/0/0/0 +0 -0
  16. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
  17. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/c/0/0/0 +0 -0
  18. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/c/0/0/0 +0 -0
  19. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/c/0/0/0 +0 -0
  20. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/c/0/0/0 +0 -0
  21. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/c/0/0/0 +0 -0
  22. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
  23. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/c/0/0/0 +0 -0
  24. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/c/0/0/0 +0 -0
  25. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/c/0/0/0 +0 -0
  26. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/c/0/0/0 +0 -0
  27. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/c/0/0/0 +0 -0
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/c/0/0/0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/c/0/0/0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/c/0/0/0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/c/0/0/0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/c/0/0/0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/c/0/0/0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/c/0/0/0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/c/0/0/0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/c/0/0/0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/c/0/0/0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/c/0/0/0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/c/0/0/0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/c/0/0/0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/c/0/0/0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/c/0/0/0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/c/0/0/0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/c/0/0/0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/c/0/0/0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/c/0/0/0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/c/0/0/0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/c/0/0/0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/c/0/0/0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/c/0/0/0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/c/0/0/0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/c/0/0/0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/c/0/0/0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/c/0/0/0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/c/0/0/0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/c/0/0/0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/c/0/0/0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/c/0/0/0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/c/0/0/0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/c/0/0/0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/c/0/0/0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/c/0/0/0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/c/0/0/0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/c/0/0/0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/c/0/0/0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/c/0/0/0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/c/0/0/0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/c/0/0/0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/c/0/0/0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/c/0/0/0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/c/0/0/0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/c/0/0/0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/c/0/0/0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/c/0/0/0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/c/0/0/0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/c/0/0/0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/c/0/0/0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/c/0/0/0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/c/0/0/0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/c/0/0/0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/c/0/0/0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/c/0/0/0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/c/0/0/0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/c/0/0/0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/c/0/0/0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/c/0/0/0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/c/0/0/0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/c/0/0/0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/c/0/0/0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/c/0/0/0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/c/0/0/0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/c/0/0/0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/c/0/0/0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/c/0/0/0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/c/0/0/0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/c/0/0/0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/c/0/0/0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zarr.json +406 -406
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/c/0/0/0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/c/0/0/0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/c/0/0/0 +0 -0
  111. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/c/0/0/0 +0 -0
  112. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/c/0/0/0 +0 -0
  113. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/c/0/0/0 +0 -0
  114. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/c/0/0/0 +0 -0
  115. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/c/0/0/0 +0 -0
  116. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/c/0/0/0 +0 -0
  117. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/c/0/0/0 +0 -0
  118. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/c/0/0/0 +0 -0
  119. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/c/0/0/0 +0 -0
  120. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/c/0/0/0 +0 -0
  121. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/c/0/0/0 +0 -0
  122. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/c/0/0/0 +0 -0
  123. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/c/0/0 +0 -0
  124. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/c/0/0 +0 -0
  125. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/c/0/0 +0 -0
  126. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/c/0/0 +0 -0
  127. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/c/0/0/0 +0 -0
  128. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/c/0/0/0 +0 -0
  129. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/c/0/0/0 +0 -0
  130. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/c/0/0/0 +0 -0
  131. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/c/0/0 +0 -0
  132. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/c/0/0 +0 -0
  133. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/c/0/0 +0 -0
  134. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/c/0/0 +0 -0
  135. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zarr.json +182 -182
  136. roms_tools/tests/test_setup/test_data/grid.zarr/h/c/0/0 +0 -0
  137. roms_tools/tests/test_setup/test_data/grid.zarr/zarr.json +191 -191
  138. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/c/0/0 +0 -0
  139. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/zarr.json +210 -210
  140. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/c/0/0/0/0 +0 -0
  141. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/c/0/0/0/0 +0 -0
  142. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/c/0/0/0/0 +0 -0
  143. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/c/0/0/0/0 +0 -0
  144. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/c/0/0/0/0 +0 -0
  145. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/c/0/0/0/0 +0 -0
  146. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/c/0/0/0/0 +0 -0
  147. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/c/0/0/0/0 +0 -0
  148. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/c/0/0/0/0 +0 -0
  149. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/c/0/0/0/0 +0 -0
  150. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/c/0/0/0/0 +0 -0
  151. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/c/0/0/0/0 +0 -0
  152. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/c/0/0/0/0 +0 -0
  153. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/c/0/0/0/0 +0 -0
  154. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/c/0/0/0/0 +0 -0
  155. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/c/0/0/0/0 +0 -0
  156. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/c/0/0/0/0 +0 -0
  157. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/c/0/0/0/0 +0 -0
  158. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/c/0/0/0/0 +0 -0
  159. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/c/0/0/0/0 +0 -0
  160. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/c/0/0/0/0 +0 -0
  161. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/c/0/0/0/0 +0 -0
  162. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/c/0/0/0/0 +0 -0
  163. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/c/0/0/0/0 +0 -0
  164. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/c/0/0/0/0 +0 -0
  165. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/c/0/0/0/0 +0 -0
  166. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  167. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/c/0/0/0/0 +0 -0
  168. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/c/0/0/0/0 +0 -0
  169. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/c/0/0/0/0 +0 -0
  170. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/c/0/0/0/0 +0 -0
  171. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/c/0/0/0/0 +0 -0
  172. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  173. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  174. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  175. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  176. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  177. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zarr.json +182 -182
  178. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/c/0/0/0/0 +0 -0
  179. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  180. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  181. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  182. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  183. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  184. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  185. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/zarr.json +187 -187
  186. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/c/0/0/0 +0 -0
  187. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/c/0/0/0 +0 -0
  188. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/c/0/0/0 +0 -0
  189. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/c/0/0/0 +0 -0
  190. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/zarr.json +66 -66
  191. roms_tools/tests/test_setup/test_grid.py +14 -0
  192. roms_tools/tests/test_setup/test_initial_conditions.py +1 -1
  193. roms_tools/tests/test_setup/{test_datasets.py → test_lat_lon_datasets.py} +22 -61
  194. roms_tools/tests/test_setup/test_nesting.py +119 -31
  195. roms_tools/tests/test_setup/test_river_datasets.py +48 -0
  196. roms_tools/tests/test_setup/test_surface_forcing.py +1 -1
  197. roms_tools/tests/test_setup/test_utils.py +1 -1
  198. {roms_tools-3.2.0.dist-info → roms_tools-3.3.0.dist-info}/METADATA +1 -1
  199. {roms_tools-3.2.0.dist-info → roms_tools-3.3.0.dist-info}/RECORD +202 -200
  200. {roms_tools-3.2.0.dist-info → roms_tools-3.3.0.dist-info}/WHEEL +0 -0
  201. {roms_tools-3.2.0.dist-info → roms_tools-3.3.0.dist-info}/licenses/LICENSE +0 -0
  202. {roms_tools-3.2.0.dist-info → roms_tools-3.3.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ from collections.abc import Callable
2
3
  from dataclasses import dataclass, field
3
4
  from pathlib import Path
4
5
  from typing import Any
@@ -80,11 +81,6 @@ class ChildGrid(Grid):
80
81
  """An xarray Dataset containing boundary mappings, where child grid boundaries are
81
82
  mapped onto parent grid indices."""
82
83
 
83
- def __post_init__(self):
84
- super().__post_init__()
85
- self._map_child_boundaries_onto_parent_grid_indices(verbose=self.verbose)
86
- self._modify_child_topography_and_mask(verbose=self.verbose)
87
-
88
84
  def _map_child_boundaries_onto_parent_grid_indices(self, verbose: bool = False):
89
85
  """Maps child grid boundary points onto absolute indices of the parent grid."""
90
86
  with Timed(
@@ -105,66 +101,124 @@ class ChildGrid(Grid):
105
101
 
106
102
  self.ds_nesting = ds_nesting
107
103
 
108
- def _modify_child_topography_and_mask(self, verbose: bool = False):
109
- """Adjust the topography and mask of the child grid to align with the parent grid.
110
-
111
- Uses a weighted sum based on boundary distance and clips depth values to a
112
- minimum.
113
- """
114
- with Timed("=== Modifying child topography and mask ===", verbose=verbose):
115
- # Prepare parent and child grid datasets by adjusting longitudes for dateline crossing
104
+ def _apply_child_modification(
105
+ self,
106
+ modifier: Callable,
107
+ modifier_name: str,
108
+ verbose: bool = False,
109
+ ):
110
+ """Shared logic for modifying child mask/topography."""
111
+ with Timed(f"=== Modifying the child {modifier_name} ===", verbose=verbose):
112
+ # Prepare datasets (fix dateline)
116
113
  parent_grid_ds, child_grid_ds = self._prepare_grid_datasets()
117
- child_grid_ds = modify_child_topography_and_mask(
118
- parent_grid_ds, child_grid_ds, self.boundaries, self.hmin
119
- )
120
114
 
121
- # Finalize grid datasets by adjusting longitudes back to [0, 360] range
122
- parent_grid_ds, child_grid_ds = self._finalize_grid_datasets(
115
+ # Apply modification function
116
+ child_grid_ds = modifier(parent_grid_ds, child_grid_ds)
117
+
118
+ # Restore longitudes to 0-360
119
+ _, child_grid_ds = self._finalize_grid_datasets(
123
120
  parent_grid_ds, child_grid_ds
124
121
  )
125
122
 
126
123
  self.ds = child_grid_ds
127
124
 
125
+ def _modify_child_mask(self, verbose: bool = False) -> None:
126
+ """Adjust child grid mask to align with the parent grid."""
127
+ self._apply_child_modification(
128
+ modifier=lambda p, c: modify_child_mask(p, c, self.boundaries),
129
+ modifier_name="mask",
130
+ verbose=verbose,
131
+ )
132
+
133
+ def _modify_child_topography(self, hmin: float, verbose: bool = False) -> None:
134
+ """Adjust child grid topography to align with the parent grid."""
135
+ self._apply_child_modification(
136
+ modifier=lambda p, c: modify_child_topography(p, c, self.boundaries, hmin),
137
+ modifier_name="topography",
138
+ verbose=verbose,
139
+ )
140
+
141
+ def update_mask(
142
+ self, mask_shapefile: str | Path | None = None, verbose: bool = False
143
+ ) -> None:
144
+ """
145
+ Update the child grid mask and ensure consistency with the parent grid.
146
+
147
+ This method performs the following steps:
148
+
149
+ 1. Derives the child mask from the provided ``mask_shapefile`` (or from the
150
+ default Natural Earth 10m coastline if ``None``).
151
+ 2. Updates the mapping of child boundaries to parent-grid indices.
152
+ This mapping depends on the updated mask, since masked (land) points may
153
+ extend outside the parent grid.
154
+ 3. Adjusts the child mask to ensure consistency with the parent mask.
155
+
156
+ Parameters
157
+ ----------
158
+ mask_shapefile : str or Path, optional
159
+ Path to a coastal shapefile used to derive the land mask. If ``None``,
160
+ a default coastline dataset is used.
161
+ verbose : bool, default False
162
+ If True, prints timing and progress information.
163
+
164
+ Returns
165
+ -------
166
+ None
167
+ Updates the internal datasets (``self.ds`` and ``self.ds_nesting``) in place,
168
+ modifying the mask and ensuring consistent parent-child boundary mapping.
169
+ """
170
+ super().update_mask(mask_shapefile=mask_shapefile, verbose=verbose)
171
+ self._map_child_boundaries_onto_parent_grid_indices(verbose=verbose)
172
+ self._modify_child_mask(verbose=verbose)
173
+
128
174
  def update_topography(
129
- self, topography_source=None, hmin=None, verbose=False
175
+ self,
176
+ topography_source: dict | None = None,
177
+ hmin: float | None = None,
178
+ verbose: bool = False,
130
179
  ) -> None:
131
- """Update the child grid topography via the following steps.
180
+ """
181
+ Update the child grid topography and ensure consistency with the parent grid.
182
+
183
+ This method performs the following operations:
132
184
 
133
- - Regrids the topography based on the specified source.
134
- - Applies global and local smoothing.
135
- - Adjusts the child grid topography and mask to match the parent grid.
136
- - Ensures the minimum depth constraint (`hmin`) is enforced.
137
- - Updates the internal dataset (`self.ds`) with the processed topography.
185
+ 1. Regrids the topography from the specified source.
186
+ 2. Applies domain-wide and local smoothing.
187
+ 3. Enforces the minimum depth constraint ``hmin``.
188
+ 4. Adjusts the child grid topography to maintain consistency with the
189
+ parent grid.
190
+ 5. Updates the internal dataset (``self.ds``) with the processed bathymetry.
138
191
 
139
192
  Parameters
140
193
  ----------
141
194
  topography_source : dict, optional
142
- A dictionary specifying the source of the topography data. Expected keys:
143
- - `"name"` (str): Name of the topography dataset (e.g., `"SRTM15"`).
144
- - `"path"` (str or Path): File path to the topography dataset.
195
+ Dictionary describing the topography data source. Expected keys:
145
196
 
146
- If not provided, the existing topography source remains unchanged.
197
+ - ``"name"`` (str): Name of the source dataset (e.g., ``"SRTM15"``).
198
+ - ``"path"`` (str or Path): Path to the dataset file.
199
+
200
+ If ``None``, the previously configured topography source is used.
147
201
 
148
202
  hmin : float, optional
149
- The minimum allowable ocean depth (in meters). If not provided, the existing
150
- value remains unchanged.
203
+ Minimum allowable ocean depth (meters). If ``None``, the existing value
204
+ is retained.
151
205
 
152
- verbose : bool, optional
153
- If `True`, prints detailed information about each processing step, including
154
- timing and modifications. Defaults to `False`.
206
+ verbose : bool, default False
207
+ If ``True``, prints progress messages and timing information.
155
208
 
156
209
  Returns
157
210
  -------
158
211
  None
159
- This method updates the internal dataset (`self.ds`) in place, modifying the
160
- topography variable. It does not return a value.
212
+ Updates ``self.ds`` in place by modifying the topography field. Nothing
213
+ is returned.
161
214
  """
215
+ hmin = hmin or self.hmin
162
216
  super().update_topography(
163
- topography_source=topography_source, hmin=hmin, verbose=verbose
217
+ topography_source=topography_source,
218
+ hmin=hmin,
219
+ verbose=verbose,
164
220
  )
165
-
166
- # Modify child topography and mask to match the parent grid
167
- self._modify_child_topography_and_mask(verbose=verbose)
221
+ self._modify_child_topography(hmin=hmin, verbose=verbose)
168
222
 
169
223
  def plot_nesting(self, with_dim_names=False) -> None:
170
224
  """Plot the parent and child grids in a single figure.
@@ -268,9 +322,12 @@ class ChildGrid(Grid):
268
322
  - The modified child grid dataset.
269
323
  """
270
324
  parent_grid_ds = wrap_longitudes(
271
- self.parent_grid.ds, straddle=self.parent_grid.straddle
325
+ self.parent_grid.ds.copy(), straddle=self.parent_grid.straddle
326
+ )
327
+ child_grid_ds = wrap_longitudes(
328
+ self.ds.copy(), straddle=self.parent_grid.straddle
272
329
  )
273
- child_grid_ds = wrap_longitudes(self.ds, straddle=self.parent_grid.straddle)
330
+
274
331
  return parent_grid_ds, child_grid_ds
275
332
 
276
333
  def _finalize_grid_datasets(
@@ -318,12 +375,12 @@ class ChildGrid(Grid):
318
375
 
319
376
 
320
377
  def map_child_boundaries_onto_parent_grid_indices(
321
- parent_grid_ds,
322
- child_grid_ds,
323
- boundaries={"south": True, "east": True, "north": True, "west": True},
324
- prefix="child",
325
- period=3600.0,
326
- update_land_indices=True,
378
+ parent_grid_ds: xr.Dataset,
379
+ child_grid_ds: xr.Dataset,
380
+ boundaries: dict = {"south": True, "east": True, "north": True, "west": True},
381
+ prefix: str = "child",
382
+ period: float = 3600.0,
383
+ update_land_indices: bool = True,
327
384
  ):
328
385
  """Maps child grid boundary points onto absolute indices of the parent grid.
329
386
 
@@ -369,6 +426,7 @@ def map_child_boundaries_onto_parent_grid_indices(
369
426
  bdry_coords_dict = get_boundary_coords()
370
427
 
371
428
  # add angles at u- and v-points
429
+
372
430
  child_grid_ds["angle_u"] = interpolate_from_rho_to_u(child_grid_ds["angle"])
373
431
  child_grid_ds["angle_v"] = interpolate_from_rho_to_v(child_grid_ds["angle"])
374
432
 
@@ -399,10 +457,10 @@ def map_child_boundaries_onto_parent_grid_indices(
399
457
  mask_child = child_grid_ds[names["mask"]].isel(**bdry_coords[direction])
400
458
 
401
459
  i_eta, i_xi = interpolate_indices(
402
- parent_grid_ds, lon_child, lat_child, mask_child
460
+ parent_grid_ds, lon_child, lat_child, mask_child, direction
403
461
  )
404
462
 
405
- if update_land_indices:
463
+ if update_land_indices and mask_child.sum() > 0:
406
464
  i_eta, i_xi = update_indices_if_on_parent_land(
407
465
  i_eta, i_xi, grid_location, parent_grid_ds
408
466
  )
@@ -445,8 +503,22 @@ def map_child_boundaries_onto_parent_grid_indices(
445
503
  return ds
446
504
 
447
505
 
448
- def interpolate_indices(parent_grid_ds, lon, lat, mask):
449
- """Interpolate the parent indices to the child grid.
506
+ def interpolate_indices(
507
+ parent_grid_ds: xr.Dataset,
508
+ lon: xr.DataArray,
509
+ lat: xr.DataArray,
510
+ mask: xr.DataArray,
511
+ direction: str,
512
+ ) -> tuple[xr.DataArray, xr.DataArray]:
513
+ """Interpolate the parent indices to the child grid boundary.
514
+
515
+ Uses the parent grid ``lon_rho``/``lat_rho`` coordinates to compute
516
+ fractional i/j indices at child-boundary longitude/latitude points using
517
+ linear interpolation. The function verifies that all ocean child points
518
+ (based on ``mask``) lie within the parent grid and warns if child
519
+ boundary points fall near the parent-grid edges. Land child points that fall
520
+ outside the parent grid (i.e., interpolation returns NaN) are filled with
521
+ ``-1e5``.
450
522
 
451
523
  Parameters
452
524
  ----------
@@ -458,6 +530,9 @@ def interpolate_indices(parent_grid_ds, lon, lat, mask):
458
530
  Latitudes of the child grid where interpolation is desired.
459
531
  mask: xarray.DataArray
460
532
  Mask for the child longitudes and latitudes under consideration.
533
+ direction : str
534
+ Boundary identifier (``"south"``, ``"north"``, ``"east"``, ``"west"``).
535
+ Used for generating informative warnings or errors.
461
536
  Returns
462
537
  -------
463
538
  i : xarray.DataArray
@@ -492,27 +567,67 @@ def interpolate_indices(parent_grid_ds, lon, lat, mask):
492
567
  i = xr.DataArray(i, dims=lon.dims)
493
568
  j = xr.DataArray(j, dims=lon.dims)
494
569
 
495
- # Check for NaN values
496
- if np.sum(np.isnan(i)) > 0 or np.sum(np.isnan(j)) > 0:
570
+ # Check whether ocean child points fall outside the parent grid
571
+ if (
572
+ i.where(mask, other=0.0).isnull().any()
573
+ or j.where(mask, other=0.0).isnull().any()
574
+ ):
497
575
  raise ValueError(
498
- "Some points are outside the grid. Please choose either a bigger parent grid or a smaller child grid."
576
+ f"Some wet points on the {direction}ern boundary of the child grid lie "
577
+ "outside the parent grid. Please use a larger parent grid or a smaller child grid."
499
578
  )
500
579
 
501
- # Check whether indices are close to border of parent grid
580
+ # Try to fix NaNs if there only a few per boundary. Fix with out-of-bounds points is not valid.
502
581
  nxp, nyp = lon_parent.shape
503
- if np.min(i) < 0 or np.max(i) > nxp - 2:
504
- logging.warning(
505
- "Some boundary points of the child grid are very close to the boundary of the parent grid."
582
+ nan_idx = (
583
+ i.isnull() | j.isnull() | (i > nxp - 2) | (i < 0) | (j > nyp - 2) | (j < 0)
584
+ )
585
+
586
+ idx = xr.DataArray(np.arange(i.size), dims=i.dims)
587
+
588
+ # Interpolate indices for points that are invalid (NaN or out-of-bounds)
589
+ if nan_idx.any() and not nan_idx.all():
590
+ idx_tmp = idx.where(~nan_idx, drop=True) # valid poins
591
+ i_tmp = i.where(~nan_idx, drop=True) # valid points
592
+ j_tmp = j.where(~nan_idx, drop=True) # valid points
593
+
594
+ interp_i = interp1d(
595
+ idx_tmp.values, i_tmp.values, kind="nearest", fill_value="extrapolate"
596
+ )
597
+ interp_j = interp1d(
598
+ idx_tmp.values, j_tmp.values, kind="nearest", fill_value="extrapolate"
599
+ )
600
+
601
+ i[nan_idx.values] = interp_i(idx[nan_idx].values)
602
+ j[nan_idx.values] = interp_j(idx[nan_idx].values)
603
+
604
+ # This should only occur in rare edge cases
605
+ if i.isnull().any() or j.isnull().any():
606
+ raise ValueError(
607
+ f"Mapping failed: the {direction}ern boundary of the child grid could not be "
608
+ "mapped onto parent-grid indices. Please adjust the parent/child grid configuration."
506
609
  )
507
- if np.min(j) < 0 or np.max(j) > nyp - 2:
610
+
611
+ # Warn if child boundary points are near the edges of the parent grid
612
+ if (
613
+ i.where(mask).min() < 0
614
+ or i.where(mask).max() > nxp - 2
615
+ or j.where(mask).min() < 0
616
+ or j.where(mask).max() > nyp - 2
617
+ ):
508
618
  logging.warning(
509
- "Some boundary points of the child grid are very close to the boundary of the parent grid."
619
+ f"Some wet points on the {direction}ern boundary of the child grid lie very close to the edges of the parent grid."
510
620
  )
511
621
 
512
622
  return i, j
513
623
 
514
624
 
515
- def update_indices_if_on_parent_land(i_eta, i_xi, grid_location, parent_grid_ds):
625
+ def update_indices_if_on_parent_land(
626
+ i_eta: xr.DataArray,
627
+ i_xi: xr.DataArray,
628
+ grid_location: str,
629
+ parent_grid_ds: xr.Dataset,
630
+ ) -> tuple[xr.DataArray, xr.DataArray]:
516
631
  """Finds points that are in the parent land mask but not land masked in the child
517
632
  and replaces parent indices with nearest neighbor wet points.
518
633
 
@@ -606,13 +721,88 @@ def update_indices_if_on_parent_land(i_eta, i_xi, grid_location, parent_grid_ds)
606
721
  return i_eta, i_xi
607
722
 
608
723
 
609
- def modify_child_topography_and_mask(
724
+ def _interpolate_parent(
725
+ parent_da: xr.DataArray, child_da: xr.DataArray
726
+ ) -> xr.DataArray:
727
+ """
728
+ Interpolate data from a parent grid onto a child grid using linear interpolation.
729
+
730
+ Parameters
731
+ ----------
732
+ parent_da : xr.DataArray
733
+ The data array on the parent grid. Must have coordinates `lon_rho` and `lat_rho`.
734
+ child_da : xr.DataArray
735
+ The target child grid data array. Must have coordinates `lon_rho` and `lat_rho`.
736
+
737
+ Returns
738
+ -------
739
+ xr.DataArray
740
+ The interpolated data on the child grid, with dimensions ("eta_rho", "xi_rho").
741
+ """
742
+ points = np.column_stack(
743
+ (parent_da.lon_rho.values.ravel(), parent_da.lat_rho.values.ravel())
744
+ )
745
+ xi = (child_da.lon_rho.values, child_da.lat_rho.values)
746
+ values = parent_da.values.ravel()
747
+
748
+ parent_interpolated = griddata(points, values, xi, method="linear")
749
+ return xr.DataArray(parent_interpolated, dims=("eta_rho", "xi_rho"))
750
+
751
+
752
+ def modify_child_mask(
753
+ parent_grid_ds: xr.Dataset,
754
+ child_grid_ds: xr.Dataset,
755
+ boundaries: dict = {"south": True, "east": True, "north": True, "west": True},
756
+ ):
757
+ """Adjust the child gridmask to align with the parent grid.
758
+
759
+ The mask of the child grid is adjusted using a weighted sum based on the boundary distance.
760
+
761
+ Parameters
762
+ ----------
763
+ parent_grid_ds : xarray.Dataset
764
+ The parent grid dataset containing `mask_rho` (land-sea mask).
765
+
766
+ child_grid_ds : xarray.Dataset
767
+ The child grid dataset whose `mask_rho` will be modified.
768
+
769
+ boundaries : dict, optional
770
+ A dictionary specifying which boundaries should be modified. Expected keys:
771
+ - `"south"` (bool): Whether to adjust the southern boundary.
772
+ - `"east"` (bool): Whether to adjust the eastern boundary.
773
+ - `"north"` (bool): Whether to adjust the northern boundary.
774
+ - `"west"` (bool): Whether to adjust the western boundary.
775
+ Defaults to modifying all boundaries.
776
+
777
+ Returns
778
+ -------
779
+ xarray.Dataset
780
+ The updated child grid dataset with modified mask (`mask_rho`).
781
+ """
782
+ # regrid parent mask onto child grid
783
+ mask_parent_interpolated = _interpolate_parent(
784
+ parent_grid_ds["mask_rho"], child_grid_ds["mask_rho"]
785
+ )
786
+
787
+ # compute weight based on distance
788
+ alpha = compute_boundary_distance(child_grid_ds["mask_rho"], boundaries)
789
+
790
+ # update child mask to be weighted sum between original child and interpolated parent
791
+ child_mask = (
792
+ alpha * child_grid_ds["mask_rho"] + (1 - alpha) * mask_parent_interpolated
793
+ )
794
+ child_grid_ds["mask_rho"] = xr.where(child_mask >= 0.5, 1, 0)
795
+
796
+ return child_grid_ds
797
+
798
+
799
+ def modify_child_topography(
610
800
  parent_grid_ds,
611
801
  child_grid_ds,
612
802
  boundaries={"south": True, "east": True, "north": True, "west": True},
613
803
  hmin=5.0,
614
804
  ):
615
- """Adjust the child grid topography and mask to align with the parent grid.
805
+ """Adjust the child grid topography to align with the parent grid.
616
806
 
617
807
  The topography of the child grid is adjusted using a weighted sum based on the boundary distance,
618
808
  and the depth values are clipped to enforce a minimum depth constraint.
@@ -620,10 +810,10 @@ def modify_child_topography_and_mask(
620
810
  Parameters
621
811
  ----------
622
812
  parent_grid_ds : xarray.Dataset
623
- The parent grid dataset containing `h` (topography) and `mask_rho` (land-sea mask).
813
+ The parent grid dataset containing `h` (topography).
624
814
 
625
815
  child_grid_ds : xarray.Dataset
626
- The child grid dataset whose `h` and `mask_rho` will be modified.
816
+ The child grid dataset whose `h` will be modified.
627
817
 
628
818
  boundaries : dict, optional
629
819
  A dictionary specifying which boundaries should be modified. Expected keys:
@@ -641,40 +831,22 @@ def modify_child_topography_and_mask(
641
831
  Returns
642
832
  -------
643
833
  xarray.Dataset
644
- The updated child grid dataset with modified topography (`h`) and mask (`mask_rho`).
834
+ The updated child grid dataset with modified topography (`h`).
645
835
  """
646
- # regrid parent topography and mask onto child grid
647
- points = np.column_stack(
648
- (parent_grid_ds.lon_rho.values.ravel(), parent_grid_ds.lat_rho.values.ravel())
649
- )
650
- xi = (child_grid_ds.lon_rho.values, child_grid_ds.lat_rho.values)
651
-
652
- values = parent_grid_ds["h"].values.ravel()
653
- h_parent_interpolated = griddata(points, values, xi, method="linear")
654
- h_parent_interpolated = xr.DataArray(
655
- h_parent_interpolated, dims=("eta_rho", "xi_rho")
656
- )
657
-
658
- values = parent_grid_ds["mask_rho"].values.ravel()
659
- mask_parent_interpolated = griddata(points, values, xi, method="linear")
660
- mask_parent_interpolated = xr.DataArray(
661
- mask_parent_interpolated, dims=("eta_rho", "xi_rho")
662
- )
836
+ # regrid parent mask onto child grid
837
+ h_parent_interpolated = _interpolate_parent(parent_grid_ds["h"], child_grid_ds["h"])
663
838
 
664
839
  # compute weight based on distance
665
840
  alpha = compute_boundary_distance(child_grid_ds["mask_rho"], boundaries)
666
- # update child topography and mask to be weighted sum between original child and interpolated parent
841
+
842
+ # update child topography to be weighted sum between original child and interpolated parent
667
843
  child_grid_ds["h"] = (
668
844
  alpha * child_grid_ds["h"] + (1 - alpha) * h_parent_interpolated
669
845
  )
846
+
670
847
  # Clip depth on modified child topography
671
848
  child_grid_ds["h"] = clip_depth(child_grid_ds["h"], hmin)
672
849
 
673
- child_mask = (
674
- alpha * child_grid_ds["mask_rho"] + (1 - alpha) * mask_parent_interpolated
675
- )
676
- child_grid_ds["mask_rho"] = xr.where(child_mask >= 0.5, 1, 0)
677
-
678
850
  return child_grid_ds
679
851
 
680
852