roms-tools 1.6.2__py3-none-any.whl → 2.0.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 (283) hide show
  1. ci/environment.yml +1 -1
  2. roms_tools/__init__.py +1 -0
  3. roms_tools/_version.py +1 -1
  4. roms_tools/setup/boundary_forcing.py +266 -256
  5. roms_tools/setup/datasets.py +986 -231
  6. roms_tools/setup/download.py +41 -15
  7. roms_tools/setup/grid.py +561 -512
  8. roms_tools/setup/initial_conditions.py +162 -106
  9. roms_tools/setup/mask.py +69 -0
  10. roms_tools/setup/plot.py +81 -23
  11. roms_tools/setup/regrid.py +4 -2
  12. roms_tools/setup/river_forcing.py +589 -0
  13. roms_tools/setup/surface_forcing.py +21 -130
  14. roms_tools/setup/tides.py +15 -79
  15. roms_tools/setup/topography.py +92 -128
  16. roms_tools/setup/utils.py +307 -25
  17. roms_tools/setup/vertical_coordinate.py +5 -16
  18. roms_tools/tests/test_setup/test_boundary_forcing.py +10 -7
  19. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +1 -1
  20. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +157 -130
  21. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/.zattrs +1 -1
  22. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/.zattrs +1 -1
  23. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/.zattrs +1 -1
  24. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/.zattrs +1 -1
  25. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/.zattrs +1 -1
  26. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/.zattrs +1 -1
  27. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/.zattrs +1 -1
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/.zattrs +1 -1
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/.zattrs +1 -1
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/.zattrs +1 -1
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/.zattrs +1 -1
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/.zattrs +1 -1
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/.zattrs +1 -1
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/.zattrs +1 -1
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/.zattrs +1 -1
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/.zattrs +1 -1
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/.zattrs +1 -1
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/.zattrs +1 -1
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/.zattrs +1 -1
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/.zattrs +1 -1
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/.zattrs +1 -1
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/.zattrs +1 -1
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/.zattrs +1 -1
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/.zattrs +1 -1
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/.zattrs +1 -1
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/.zattrs +1 -1
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/.zattrs +1 -1
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/.zattrs +1 -1
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/.zattrs +1 -1
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/.zattrs +1 -1
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/.zattrs +1 -1
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/.zattrs +1 -1
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/.zattrs +1 -1
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/.zattrs +1 -1
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/.zattrs +1 -1
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/.zattrs +1 -1
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/.zattrs +1 -1
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/.zattrs +1 -1
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/.zattrs +1 -1
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/.zattrs +1 -1
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/.zattrs +1 -1
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/.zattrs +1 -1
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/.zattrs +1 -1
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/.zattrs +1 -1
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/.zattrs +1 -1
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/.zattrs +1 -1
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/.zattrs +1 -1
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/.zattrs +1 -1
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/.zattrs +1 -1
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/.zattrs +1 -1
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/.zattrs +1 -1
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/.zattrs +1 -1
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/.zattrs +1 -1
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/.zattrs +1 -1
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/.zattrs +1 -1
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/.zattrs +1 -1
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/.zattrs +1 -1
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/.zattrs +1 -1
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/.zattrs +1 -1
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/.zattrs +1 -1
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/.zattrs +1 -1
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/.zattrs +1 -1
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/.zattrs +1 -1
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/.zattrs +1 -1
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/.zattrs +1 -1
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/.zattrs +1 -1
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/.zattrs +1 -1
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/.zattrs +1 -1
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/abs_time/.zattrs +1 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/bry_time/.zattrs +1 -1
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/.zattrs +1 -1
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/.zattrs +1 -1
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/.zattrs +1 -1
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/.zattrs +1 -1
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/.zattrs +1 -1
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/.zattrs +1 -1
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/.zattrs +1 -1
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/.zattrs +1 -1
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/.zattrs +1 -1
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/.zattrs +1 -1
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/.zattrs +1 -1
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/.zattrs +1 -1
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/.zattrs +1 -1
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/.zattrs +1 -1
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/.zattrs +1 -1
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/.zattrs +1 -1
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/.zattrs +1 -1
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/.zattrs +1 -1
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/.zattrs +1 -1
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/.zattrs +1 -1
  111. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/.zattrs +1 -1
  112. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/.zattrs +1 -1
  113. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/.zattrs +1 -1
  114. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/.zattrs +1 -1
  115. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/.zattrs +1 -1
  116. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/.zattrs +1 -1
  117. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/.zattrs +1 -1
  118. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/.zattrs +1 -1
  119. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/.zattrs +1 -1
  120. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/.zattrs +1 -1
  121. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/.zattrs +1 -1
  122. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/.zattrs +1 -1
  123. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/.zattrs +1 -1
  124. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/.zattrs +1 -1
  125. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/.zattrs +1 -1
  126. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/.zattrs +1 -1
  127. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/month/.zarray +20 -0
  128. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/month/.zattrs +6 -0
  129. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/month/0 +0 -0
  130. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/.zattrs +1 -1
  131. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/.zattrs +1 -1
  132. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/.zattrs +1 -1
  133. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/.zattrs +1 -1
  134. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/.zattrs +1 -1
  135. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/.zattrs +1 -1
  136. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/.zattrs +1 -1
  137. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/.zattrs +1 -1
  138. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/.zattrs +1 -1
  139. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/.zattrs +1 -1
  140. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/.zattrs +1 -1
  141. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/.zattrs +1 -1
  142. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/.zattrs +1 -1
  143. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/.zattrs +1 -1
  144. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/.zattrs +1 -1
  145. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/.zattrs +1 -1
  146. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/.zattrs +1 -1
  147. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/.zattrs +1 -1
  148. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/.zattrs +1 -1
  149. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/.zattrs +1 -1
  150. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/.zattrs +1 -1
  151. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/.zattrs +1 -1
  152. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/.zattrs +1 -1
  153. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/.zattrs +1 -1
  154. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +1 -1
  155. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +39 -12
  156. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/abs_time/.zattrs +1 -0
  157. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust/.zattrs +1 -1
  158. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust_time/.zattrs +1 -1
  159. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron/.zattrs +1 -1
  160. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron_time/.zattrs +1 -1
  161. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/month/.zarray +20 -0
  162. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/month/.zattrs +6 -0
  163. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/month/0 +0 -0
  164. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy/.zattrs +1 -1
  165. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy_time/.zattrs +1 -1
  166. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox/.zattrs +1 -1
  167. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox_time/.zattrs +1 -1
  168. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air/.zattrs +1 -1
  169. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/.zattrs +1 -1
  170. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_time/.zattrs +1 -1
  171. roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +0 -1
  172. roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +56 -201
  173. roms_tools/tests/test_setup/test_data/grid.zarr/Cs_r/.zattrs +1 -1
  174. roms_tools/tests/test_setup/test_data/grid.zarr/Cs_w/.zattrs +1 -1
  175. roms_tools/tests/test_setup/test_data/grid.zarr/{interface_depth_rho → sigma_r}/.zarray +2 -6
  176. roms_tools/tests/test_setup/test_data/grid.zarr/sigma_r/.zattrs +7 -0
  177. roms_tools/tests/test_setup/test_data/grid.zarr/sigma_r/0 +0 -0
  178. roms_tools/tests/test_setup/test_data/grid.zarr/{interface_depth_u → sigma_w}/.zarray +2 -6
  179. roms_tools/tests/test_setup/test_data/grid.zarr/sigma_w/.zattrs +7 -0
  180. roms_tools/tests/test_setup/test_data/grid.zarr/sigma_w/0 +0 -0
  181. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +1 -2
  182. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +58 -203
  183. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/Cs_r/.zattrs +1 -1
  184. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/Cs_w/.zattrs +1 -1
  185. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/.zattrs +1 -1
  186. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/0.0 +0 -0
  187. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_coarse/0.0 +0 -0
  188. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_rho/0.0 +0 -0
  189. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_u/0.0 +0 -0
  190. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_v/0.0 +0 -0
  191. roms_tools/tests/test_setup/test_data/{grid.zarr/interface_depth_v → grid_that_straddles_dateline.zarr/sigma_r}/.zarray +2 -6
  192. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_r/.zattrs +7 -0
  193. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_r/0 +0 -0
  194. roms_tools/tests/test_setup/test_data/{grid.zarr/layer_depth_rho → grid_that_straddles_dateline.zarr/sigma_w}/.zarray +2 -6
  195. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_w/.zattrs +7 -0
  196. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/sigma_w/0 +0 -0
  197. roms_tools/tests/test_setup/test_data/river_forcing.zarr/.zattrs +3 -0
  198. roms_tools/tests/test_setup/test_data/river_forcing.zarr/.zgroup +3 -0
  199. roms_tools/tests/test_setup/test_data/river_forcing.zarr/.zmetadata +214 -0
  200. roms_tools/tests/test_setup/test_data/river_forcing.zarr/abs_time/.zarray +20 -0
  201. roms_tools/tests/test_setup/test_data/river_forcing.zarr/abs_time/.zattrs +8 -0
  202. roms_tools/tests/test_setup/test_data/river_forcing.zarr/abs_time/0 +0 -0
  203. roms_tools/tests/test_setup/test_data/river_forcing.zarr/month/.zarray +20 -0
  204. roms_tools/tests/test_setup/test_data/river_forcing.zarr/month/.zattrs +6 -0
  205. roms_tools/tests/test_setup/test_data/river_forcing.zarr/month/0 +0 -0
  206. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_name/.zarray +24 -0
  207. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_name/.zattrs +6 -0
  208. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_name/0 +0 -0
  209. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_time/.zarray +20 -0
  210. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_time/.zattrs +8 -0
  211. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_time/0 +0 -0
  212. roms_tools/tests/test_setup/test_data/{grid.zarr/layer_depth_v → river_forcing.zarr/river_tracer}/.zarray +4 -4
  213. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_tracer/.zattrs +10 -0
  214. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_tracer/0.0.0 +0 -0
  215. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_volume/.zarray +22 -0
  216. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_volume/.zattrs +9 -0
  217. roms_tools/tests/test_setup/test_data/river_forcing.zarr/river_volume/0.0 +0 -0
  218. roms_tools/tests/test_setup/test_data/{grid.zarr/layer_depth_u → river_forcing.zarr/tracer_name}/.zarray +2 -6
  219. roms_tools/tests/test_setup/test_data/river_forcing.zarr/tracer_name/.zattrs +6 -0
  220. roms_tools/tests/test_setup/test_data/river_forcing.zarr/tracer_name/0 +0 -0
  221. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zattrs +1 -0
  222. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zgroup +3 -0
  223. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zmetadata +185 -0
  224. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/abs_time/.zarray +20 -0
  225. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/abs_time/.zattrs +8 -0
  226. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/abs_time/0 +0 -0
  227. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_name/.zarray +24 -0
  228. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_name/.zattrs +6 -0
  229. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_name/0 +0 -0
  230. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_time/.zarray +20 -0
  231. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_time/.zattrs +7 -0
  232. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_time/0 +0 -0
  233. roms_tools/tests/test_setup/test_data/{grid_that_straddles_dateline.zarr/interface_depth_v → river_forcing_no_climatology.zarr/river_tracer}/.zarray +4 -4
  234. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_tracer/.zattrs +10 -0
  235. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_tracer/0.0.0 +0 -0
  236. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_volume/.zarray +22 -0
  237. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_volume/.zattrs +9 -0
  238. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_volume/0.0 +0 -0
  239. roms_tools/tests/test_setup/test_data/{grid_that_straddles_dateline.zarr/interface_depth_u → river_forcing_no_climatology.zarr/tracer_name}/.zarray +2 -6
  240. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/tracer_name/.zattrs +6 -0
  241. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/tracer_name/0 +0 -0
  242. roms_tools/tests/test_setup/test_grid.py +110 -12
  243. roms_tools/tests/test_setup/test_initial_conditions.py +2 -3
  244. roms_tools/tests/test_setup/test_river_forcing.py +367 -0
  245. roms_tools/tests/test_setup/test_surface_forcing.py +2 -24
  246. roms_tools/tests/test_setup/test_tides.py +2 -3
  247. roms_tools/tests/test_setup/test_topography.py +106 -1
  248. roms_tools/tests/test_setup/test_validation.py +4 -0
  249. roms_tools/utils.py +12 -10
  250. {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/LICENSE +1 -1
  251. {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/METADATA +6 -5
  252. {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/RECORD +254 -225
  253. {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/WHEEL +1 -1
  254. roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_rho/.zattrs +0 -9
  255. roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_rho/0.0.0 +0 -0
  256. roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_u/.zattrs +0 -9
  257. roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_u/0.0.0 +0 -0
  258. roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_v/.zattrs +0 -9
  259. roms_tools/tests/test_setup/test_data/grid.zarr/interface_depth_v/0.0.0 +0 -0
  260. roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_rho/.zattrs +0 -9
  261. roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_rho/0.0.0 +0 -0
  262. roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_u/.zattrs +0 -9
  263. roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_u/0.0.0 +0 -0
  264. roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_v/.zattrs +0 -9
  265. roms_tools/tests/test_setup/test_data/grid.zarr/layer_depth_v/0.0.0 +0 -0
  266. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_rho/.zarray +0 -24
  267. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_rho/.zattrs +0 -9
  268. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_rho/0.0.0 +0 -0
  269. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_u/.zattrs +0 -9
  270. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_u/0.0.0 +0 -0
  271. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_v/.zattrs +0 -9
  272. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/interface_depth_v/0.0.0 +0 -0
  273. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_rho/.zarray +0 -24
  274. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_rho/.zattrs +0 -9
  275. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_rho/0.0.0 +0 -0
  276. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_u/.zarray +0 -24
  277. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_u/.zattrs +0 -9
  278. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_u/0.0.0 +0 -0
  279. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_v/.zarray +0 -24
  280. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_v/.zattrs +0 -9
  281. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/layer_depth_v/0.0.0 +0 -0
  282. roms_tools/tests/test_setup/test_vertical_coordinate.py +0 -91
  283. {roms_tools-1.6.2.dist-info → roms_tools-2.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,367 @@
1
+ from roms_tools import RiverForcing, Grid
2
+ import xarray as xr
3
+ import numpy as np
4
+ from datetime import datetime
5
+ import textwrap
6
+ from pathlib import Path
7
+ import pytest
8
+ from conftest import calculate_file_hash
9
+ from roms_tools.setup.download import download_river_data
10
+
11
+
12
+ @pytest.fixture
13
+ def river_forcing_climatology():
14
+ """Fixture for creating a RiverForcing object from the global Dai river dataset."""
15
+ grid = Grid(
16
+ nx=18, ny=18, size_x=800, size_y=800, center_lon=-18, center_lat=65, rot=20, N=3
17
+ )
18
+
19
+ start_time = datetime(1998, 1, 1)
20
+ end_time = datetime(1998, 3, 1)
21
+
22
+ return RiverForcing(
23
+ grid=grid,
24
+ start_time=start_time,
25
+ end_time=end_time,
26
+ convert_to_climatology="always",
27
+ )
28
+
29
+
30
+ @pytest.fixture
31
+ def river_forcing_for_grid_that_straddles_dateline():
32
+ """Fixture for creating a RiverForcing object from the global Dai river dataset for
33
+ a grid that straddles the dateline."""
34
+
35
+ grid = Grid(
36
+ nx=18,
37
+ ny=18,
38
+ size_x=1500,
39
+ size_y=1500,
40
+ center_lon=-0,
41
+ center_lat=65,
42
+ rot=20,
43
+ N=3,
44
+ )
45
+ start_time = datetime(1998, 1, 1)
46
+ end_time = datetime(1998, 3, 1)
47
+
48
+ return RiverForcing(
49
+ grid=grid,
50
+ start_time=start_time,
51
+ end_time=end_time,
52
+ )
53
+
54
+
55
+ def compare_dictionaries(dict1, dict2):
56
+ assert dict1.keys() == dict2.keys()
57
+
58
+ for key in dict1.keys():
59
+ assert np.array_equal(dict1[key], dict2[key])
60
+
61
+
62
+ @pytest.mark.parametrize(
63
+ "river_forcing_fixture",
64
+ ["river_forcing", "river_forcing_for_grid_that_straddles_dateline"],
65
+ )
66
+ def test_successful_initialization_with_climatological_dai_data(
67
+ river_forcing_fixture, request
68
+ ):
69
+
70
+ river_forcing = request.getfixturevalue(river_forcing_fixture)
71
+
72
+ assert isinstance(river_forcing.ds, xr.Dataset)
73
+ assert len(river_forcing.ds.nriver) > 0
74
+ assert len(river_forcing.original_indices["name"]) > 0
75
+ assert "river_volume" in river_forcing.ds
76
+ assert "river_tracer" in river_forcing.ds
77
+ assert river_forcing.climatology
78
+ assert "river_time" in river_forcing.ds
79
+ assert hasattr(
80
+ river_forcing.ds.river_time,
81
+ "cycle_length",
82
+ )
83
+ assert hasattr(river_forcing.ds, "climatology")
84
+
85
+
86
+ def test_successful_initialization_with_monthly_dai_data(river_forcing_no_climatology):
87
+
88
+ assert isinstance(river_forcing_no_climatology.ds, xr.Dataset)
89
+ assert "river_volume" in river_forcing_no_climatology.ds
90
+ assert "river_tracer" in river_forcing_no_climatology.ds
91
+ assert "river_time" in river_forcing_no_climatology.ds
92
+ assert not river_forcing_no_climatology.climatology
93
+ assert not hasattr(
94
+ river_forcing_no_climatology.ds.river_time,
95
+ "cycle_length",
96
+ )
97
+ assert not hasattr(river_forcing_no_climatology.ds, "climatology")
98
+
99
+
100
+ def test_reproducibility(river_forcing, river_forcing_climatology):
101
+
102
+ xr.testing.assert_allclose(river_forcing.ds, river_forcing_climatology.ds)
103
+
104
+ compare_dictionaries(
105
+ river_forcing.original_indices, river_forcing_climatology.original_indices
106
+ )
107
+ compare_dictionaries(
108
+ river_forcing.updated_indices, river_forcing_climatology.updated_indices
109
+ )
110
+
111
+
112
+ def test_reproducibility_indices(river_forcing, river_forcing_no_climatology):
113
+
114
+ compare_dictionaries(
115
+ river_forcing.original_indices, river_forcing_no_climatology.original_indices
116
+ )
117
+ compare_dictionaries(
118
+ river_forcing.updated_indices, river_forcing_no_climatology.updated_indices
119
+ )
120
+
121
+
122
+ @pytest.mark.parametrize(
123
+ "river_forcing_fixture",
124
+ ["river_forcing_climatology", "river_forcing_no_climatology"],
125
+ )
126
+ def test_constant_tracers(river_forcing_fixture, request):
127
+ river_forcing = request.getfixturevalue(river_forcing_fixture)
128
+
129
+ np.testing.assert_allclose(
130
+ river_forcing.ds.river_tracer.isel(ntracers=0).values, 17.0, atol=0
131
+ )
132
+ np.testing.assert_allclose(
133
+ river_forcing.ds.river_tracer.isel(ntracers=1).values, 1.0, atol=0
134
+ )
135
+
136
+
137
+ @pytest.mark.parametrize(
138
+ "river_forcing_fixture",
139
+ ["river_forcing_climatology", "river_forcing_no_climatology"],
140
+ )
141
+ def test_river_locations_are_along_coast(river_forcing_fixture, request):
142
+ river_forcing = request.getfixturevalue(river_forcing_fixture)
143
+
144
+ mask = river_forcing.grid.ds.mask_rho
145
+ faces = (
146
+ mask.shift(eta_rho=1)
147
+ + mask.shift(eta_rho=-1)
148
+ + mask.shift(xi_rho=1)
149
+ + mask.shift(xi_rho=-1)
150
+ )
151
+ coast = (1 - mask) * (faces > 0)
152
+
153
+ indices = river_forcing.updated_indices
154
+ for i in range(len(indices["station"])):
155
+ eta_rho = indices["eta_rho"][i]
156
+ xi_rho = indices["xi_rho"][i]
157
+ assert coast[eta_rho, xi_rho]
158
+ assert river_forcing.grid.ds["river_flux"][eta_rho, xi_rho] > 0
159
+
160
+
161
+ def test_missing_source_name():
162
+
163
+ grid = Grid(
164
+ nx=2,
165
+ ny=2,
166
+ size_x=500,
167
+ size_y=1000,
168
+ center_lon=0,
169
+ center_lat=55,
170
+ rot=10,
171
+ N=3, # number of vertical levels
172
+ )
173
+
174
+ with pytest.raises(ValueError, match="`source` must include a 'name'."):
175
+ RiverForcing(
176
+ grid=grid,
177
+ start_time=datetime(1998, 1, 1),
178
+ end_time=datetime(1998, 3, 1),
179
+ source={"path": "river_data.nc"},
180
+ )
181
+
182
+
183
+ def test_no_rivers_found():
184
+
185
+ # Create a grid over open ocean
186
+ grid = Grid(
187
+ nx=2, ny=2, size_x=50, size_y=50, center_lon=0, center_lat=55, rot=10, N=3
188
+ )
189
+ with pytest.raises(
190
+ ValueError,
191
+ match="No relevant rivers found.",
192
+ ):
193
+
194
+ RiverForcing(
195
+ grid=grid,
196
+ start_time=datetime(1998, 1, 1),
197
+ end_time=datetime(1998, 3, 1),
198
+ )
199
+
200
+
201
+ def test_reproducibility_same_grid(river_forcing):
202
+
203
+ the_same_river_forcing = RiverForcing(
204
+ grid=river_forcing.grid,
205
+ start_time=datetime(1998, 1, 1),
206
+ end_time=datetime(1998, 3, 1),
207
+ )
208
+
209
+ assert river_forcing == the_same_river_forcing
210
+
211
+
212
+ def test_update_river_flux_variable_without_conflicts(river_forcing, tmp_path):
213
+
214
+ fname = download_river_data("dai_trenberth_may2019.nc")
215
+ ds = xr.open_dataset(fname, decode_times=False)
216
+ # only keep the 300 biggest rivers, which will lower the total relevant river number
217
+ ds = ds.isel(station=slice(None, 300))
218
+ filepath = tmp_path / "test.nc"
219
+ ds.to_netcdf(filepath)
220
+
221
+ another_river_forcing = RiverForcing(
222
+ grid=river_forcing.grid,
223
+ start_time=datetime(1998, 1, 1),
224
+ end_time=datetime(1998, 3, 1),
225
+ source={"name": "DAI", "path": filepath},
226
+ )
227
+
228
+ assert isinstance(another_river_forcing.ds, xr.Dataset)
229
+
230
+
231
+ def test_river_forcing_plot(river_forcing):
232
+ """Test plot method."""
233
+
234
+ river_forcing.plot_locations()
235
+ river_forcing.plot("river_volume")
236
+ river_forcing.plot("river_temperature")
237
+ river_forcing.plot("river_salinity")
238
+
239
+
240
+ def test_river_forcing_save(river_forcing, tmp_path):
241
+ """Test save method."""
242
+
243
+ for file_str, grid_file_str in zip(
244
+ ["test_rivers", "test_rivers.nc"], ["test_grid", "test_grid.nc"]
245
+ ):
246
+ # Create a temporary filepath using the tmp_path fixture
247
+ for filepath, grid_filepath in zip(
248
+ [tmp_path / file_str, str(tmp_path / file_str)],
249
+ [tmp_path / grid_file_str, str(tmp_path / grid_file_str)],
250
+ ): # test for Path object and str
251
+
252
+ # Test saving without partitioning
253
+ saved_filenames = river_forcing.save(filepath, grid_filepath)
254
+ # Check if the .nc file was created
255
+ filepath = Path(filepath).with_suffix(".nc")
256
+ grid_filepath = Path(grid_filepath).with_suffix(".nc")
257
+ assert saved_filenames == [filepath, grid_filepath]
258
+ assert filepath.exists()
259
+ assert grid_filepath.exists()
260
+ # Clean up the .nc file
261
+ filepath.unlink()
262
+ grid_filepath.unlink()
263
+
264
+ # Test saving with partitioning
265
+ saved_filenames = river_forcing.save(
266
+ filepath, grid_filepath, np_eta=3, np_xi=3
267
+ )
268
+
269
+ filepath_str = str(filepath.with_suffix(""))
270
+ grid_filepath_str = str(grid_filepath.with_suffix(""))
271
+ expected_filepath_list = [
272
+ Path(filepath_str + f".{index}.nc") for index in range(9)
273
+ ] + [Path(grid_filepath_str + f".{index}.nc") for index in range(9)]
274
+ assert saved_filenames == expected_filepath_list
275
+ for expected_filepath in expected_filepath_list:
276
+ assert expected_filepath.exists()
277
+ expected_filepath.unlink()
278
+
279
+
280
+ def test_roundtrip_yaml(river_forcing, tmp_path):
281
+ """Test that creating an RiverForcing object, saving its parameters to yaml file,
282
+ and re-opening yaml file creates the same object."""
283
+
284
+ # Create a temporary filepath using the tmp_path fixture
285
+ file_str = "test_yaml"
286
+ for filepath in [
287
+ tmp_path / file_str,
288
+ str(tmp_path / file_str),
289
+ ]: # test for Path object and str
290
+
291
+ river_forcing.to_yaml(filepath)
292
+
293
+ river_forcing_from_file = RiverForcing.from_yaml(filepath)
294
+
295
+ assert river_forcing == river_forcing_from_file
296
+
297
+ filepath = Path(filepath)
298
+ filepath.unlink()
299
+
300
+
301
+ def test_files_have_same_hash(river_forcing, tmp_path):
302
+
303
+ yaml_filepath = tmp_path / "test_yaml.yaml"
304
+ filepath1 = tmp_path / "test1.nc"
305
+ filepath2 = tmp_path / "test2.nc"
306
+ grid_filepath1 = tmp_path / "grid_test1.nc"
307
+ grid_filepath2 = tmp_path / "grid_test2.nc"
308
+
309
+ river_forcing.to_yaml(yaml_filepath)
310
+ river_forcing.save(filepath1, grid_filepath1)
311
+ rf_from_file = RiverForcing.from_yaml(yaml_filepath)
312
+ rf_from_file.save(filepath2, grid_filepath2)
313
+
314
+ hash1 = calculate_file_hash(filepath1)
315
+ hash2 = calculate_file_hash(filepath2)
316
+
317
+ assert hash1 == hash2, f"Hashes do not match: {hash1} != {hash2}"
318
+
319
+ yaml_filepath.unlink()
320
+ filepath1.unlink()
321
+ filepath2.unlink()
322
+ grid_filepath1.unlink()
323
+ grid_filepath2.unlink()
324
+
325
+
326
+ def test_from_yaml_missing_river_forcing(tmp_path):
327
+ yaml_content = textwrap.dedent(
328
+ """\
329
+ ---
330
+ roms_tools_version: 0.0.0
331
+ ---
332
+ Grid:
333
+ nx: 100
334
+ ny: 100
335
+ size_x: 1800
336
+ size_y: 2400
337
+ center_lon: -10
338
+ center_lat: 61
339
+ rot: -20
340
+ topography_source:
341
+ name: ETOPO5
342
+ hmin: 5.0
343
+ """
344
+ )
345
+
346
+ # Create a temporary filepath using the tmp_path fixture
347
+ file_str = "test_yaml"
348
+ for yaml_filepath in [
349
+ tmp_path / file_str,
350
+ str(tmp_path / file_str),
351
+ ]: # test for Path object and str
352
+
353
+ # Write YAML content to file
354
+ if isinstance(yaml_filepath, Path):
355
+ yaml_filepath.write_text(yaml_content)
356
+ else:
357
+ with open(yaml_filepath, "w") as f:
358
+ f.write(yaml_content)
359
+
360
+ with pytest.raises(
361
+ ValueError,
362
+ match="No RiverForcing configuration found in the YAML file.",
363
+ ):
364
+ RiverForcing.from_yaml(yaml_filepath)
365
+
366
+ yaml_filepath = Path(yaml_filepath)
367
+ yaml_filepath.unlink()
@@ -153,27 +153,6 @@ def grid_that_lies_west_of_dateline_more_than_five_degrees_away():
153
153
  return grid
154
154
 
155
155
 
156
- @pytest.fixture
157
- def grid_that_straddles_180_degree_meridian():
158
- """Fixture for creating a domain that straddles 180 degree meridian.
159
-
160
- This is a good test grid for the global ERA5 data, which comes on an [-180, 180]
161
- longitude grid.
162
- """
163
-
164
- grid = Grid(
165
- nx=5,
166
- ny=5,
167
- size_x=1800,
168
- size_y=2400,
169
- center_lon=180,
170
- center_lat=61,
171
- rot=20,
172
- )
173
-
174
- return grid
175
-
176
-
177
156
  @pytest.mark.parametrize(
178
157
  "grid_fixture",
179
158
  [
@@ -747,10 +726,9 @@ def test_from_yaml_missing_surface_forcing(tmp_path, use_dask):
747
726
  center_lon: -10
748
727
  center_lat: 61
749
728
  rot: -20
750
- topography_source: ETOPO5
751
- smooth_factor: 8
729
+ topography_source:
730
+ name: ETOPO5
752
731
  hmin: 5.0
753
- rmax: 0.2
754
732
  """
755
733
  )
756
734
 
@@ -266,10 +266,9 @@ def test_from_yaml_missing_tidal_forcing(tmp_path, use_dask):
266
266
  center_lon: -10
267
267
  center_lat: 61
268
268
  rot: -20
269
- topography_source: ETOPO5
270
- smooth_factor: 8
269
+ topography_source:
270
+ name: ETOPO5
271
271
  hmin: 5.0
272
- rmax: 0.2
273
272
  """
274
273
  )
275
274
 
@@ -1,5 +1,7 @@
1
+ import pytest
1
2
  from roms_tools import Grid
2
3
  from roms_tools.setup.topography import _compute_rfactor
4
+ from roms_tools.setup.download import download_test_data
3
5
  import numpy as np
4
6
  import numpy.testing as npt
5
7
  from scipy.ndimage import label
@@ -52,7 +54,13 @@ def test_hmin_criterion():
52
54
  assert grid.hmin == 5.0
53
55
  assert np.less_equal(grid.hmin, grid.ds.h.min())
54
56
 
55
- grid.update_topography_and_mask(hmin=10.0)
57
+ grid.update_topography(hmin=10.0)
58
+
59
+ assert grid.hmin == 10.0
60
+ assert np.less_equal(grid.hmin, grid.ds.h.min())
61
+
62
+ # this should not do anything
63
+ grid.update_topography()
56
64
 
57
65
  assert grid.hmin == 10.0
58
66
  assert np.less_equal(grid.hmin, grid.ds.h.min())
@@ -94,3 +102,100 @@ def test_mask_topography_boundary():
94
102
  np.testing.assert_array_equal(
95
103
  grid.ds.mask_rho.isel(xi_rho=-1).data, grid.ds.mask_rho.isel(xi_rho=-2).data
96
104
  )
105
+
106
+
107
+ @pytest.fixture()
108
+ def grid_that_straddles_dateline_with_shifted_global_etopo_data():
109
+
110
+ grid = Grid(
111
+ nx=5,
112
+ ny=5,
113
+ size_x=1000,
114
+ size_y=1000,
115
+ center_lon=0,
116
+ center_lat=0,
117
+ rot=20,
118
+ topography_source={
119
+ "name": "ETOPO5",
120
+ "path": download_test_data("etopo5_coarsened_and_shifted.nc"),
121
+ },
122
+ )
123
+
124
+ return grid
125
+
126
+
127
+ @pytest.fixture()
128
+ def grid_that_straddles_dateline_with_global_srtm15_data():
129
+
130
+ grid = Grid(
131
+ nx=5,
132
+ ny=5,
133
+ size_x=1000,
134
+ size_y=1000,
135
+ center_lon=0,
136
+ center_lat=0,
137
+ rot=20,
138
+ topography_source={
139
+ "name": "SRTM15",
140
+ "path": download_test_data("srtm15_coarsened.nc"),
141
+ },
142
+ )
143
+
144
+ return grid
145
+
146
+
147
+ @pytest.fixture()
148
+ def grid_that_straddles_180_degree_meridian_with_shifted_global_etopo_data():
149
+
150
+ grid = Grid(
151
+ nx=5,
152
+ ny=5,
153
+ size_x=1000,
154
+ size_y=1000,
155
+ center_lon=180,
156
+ center_lat=0,
157
+ rot=20,
158
+ topography_source={
159
+ "name": "ETOPO5",
160
+ "path": download_test_data("etopo5_coarsened_and_shifted.nc"),
161
+ },
162
+ )
163
+
164
+ return grid
165
+
166
+
167
+ @pytest.fixture()
168
+ def grid_that_straddles_180_degree_meridian_with_global_srtm15_data():
169
+
170
+ grid = Grid(
171
+ nx=5,
172
+ ny=5,
173
+ size_x=1000,
174
+ size_y=1000,
175
+ center_lon=180,
176
+ center_lat=0,
177
+ rot=20,
178
+ topography_source={
179
+ "name": "SRTM15",
180
+ "path": download_test_data("srtm15_coarsened.nc"),
181
+ },
182
+ )
183
+
184
+ return grid
185
+
186
+
187
+ @pytest.mark.parametrize(
188
+ "grid_fixture",
189
+ [
190
+ "grid_that_straddles_dateline",
191
+ "grid_that_straddles_180_degree_meridian",
192
+ "grid_that_straddles_dateline_with_shifted_global_etopo_data",
193
+ "grid_that_straddles_180_degree_meridian_with_shifted_global_etopo_data",
194
+ "grid_that_straddles_dateline_with_global_srtm15_data",
195
+ "grid_that_straddles_180_degree_meridian_with_global_srtm15_data",
196
+ ],
197
+ )
198
+ def test_successful_initialization(grid_fixture, request):
199
+
200
+ grid = request.getfixturevalue(grid_fixture)
201
+ assert grid is not None
@@ -23,6 +23,8 @@ def _get_fname(name):
23
23
  "bgc_surface_forcing_from_climatology",
24
24
  "boundary_forcing",
25
25
  "bgc_boundary_forcing_from_climatology",
26
+ "river_forcing",
27
+ "river_forcing_no_climatology",
26
28
  ],
27
29
  )
28
30
  # this test will not be run by default
@@ -60,6 +62,8 @@ def test_save_results(forcing_fixture, request):
60
62
  "bgc_surface_forcing_from_climatology",
61
63
  "boundary_forcing",
62
64
  "bgc_boundary_forcing_from_climatology",
65
+ "river_forcing",
66
+ "river_forcing_no_climatology",
63
67
  ],
64
68
  )
65
69
  def test_check_results(forcing_fixture, request):
roms_tools/utils.py CHANGED
@@ -176,11 +176,12 @@ def partition(
176
176
  ]
177
177
 
178
178
  if np_eta > 1:
179
- partitioned_sizes["eta_rho"] = (
180
- [eta_rho_domain_size + n_eta_ghost_cells]
181
- + [eta_rho_domain_size] * (np_eta - 2)
182
- + [eta_rho_domain_size + n_eta_ghost_cells]
183
- )
179
+ if "eta_rho" in dims_to_partition:
180
+ partitioned_sizes["eta_rho"] = (
181
+ [eta_rho_domain_size + n_eta_ghost_cells]
182
+ + [eta_rho_domain_size] * (np_eta - 2)
183
+ + [eta_rho_domain_size + n_eta_ghost_cells]
184
+ )
184
185
  if "eta_psi" in dims_to_partition:
185
186
  partitioned_sizes["eta_psi"] = (
186
187
  [n_eta_ghost_cells + eta_psi_domain_size]
@@ -195,11 +196,12 @@ def partition(
195
196
  )
196
197
 
197
198
  if np_xi > 1:
198
- partitioned_sizes["xi_rho"] = (
199
- [xi_rho_domain_size + n_xi_ghost_cells]
200
- + [xi_rho_domain_size] * (np_xi - 2)
201
- + [xi_rho_domain_size + n_xi_ghost_cells]
202
- )
199
+ if "xi_rho" in dims_to_partition:
200
+ partitioned_sizes["xi_rho"] = (
201
+ [xi_rho_domain_size + n_xi_ghost_cells]
202
+ + [xi_rho_domain_size] * (np_xi - 2)
203
+ + [xi_rho_domain_size + n_xi_ghost_cells]
204
+ )
203
205
  if "xi_psi" in dims_to_partition:
204
206
  partitioned_sizes["xi_psi"] = (
205
207
  [n_xi_ghost_cells + xi_psi_domain_size]
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2024 [C-Worthy]
189
+ Copyright 2024 [C]-Worthy LLC.
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: roms-tools
3
- Version: 1.6.2
3
+ Version: 2.0.0
4
4
  Summary: Tools for running and analysing UCLA-ROMS simulations
5
5
  Author-email: Nora Loose <nora.loose@gmail.com>, Thomas Nicholas <tom@cworthy.org>
6
6
  License: Apache-2
@@ -26,13 +26,14 @@ Requires-Dist: matplotlib
26
26
  Requires-Dist: cartopy
27
27
  Requires-Dist: packaging
28
28
  Requires-Dist: scipy
29
- Requires-Dist: gcm-filters
29
+ Requires-Dist: gcm_filters
30
30
  Requires-Dist: netcdf4
31
31
  Requires-Dist: PyYAML
32
32
  Requires-Dist: pyamg
33
33
  Requires-Dist: bottleneck
34
+ Requires-Dist: regionmask
34
35
  Provides-Extra: dask
35
- Requires-Dist: dask; extra == "dask"
36
+ Requires-Dist: dask[diagnostics]; extra == "dask"
36
37
 
37
38
  # ROMS-Tools
38
39
  [![Conda version](https://img.shields.io/conda/vn/conda-forge/roms-tools.svg)](https://anaconda.org/conda-forge/roms-tools)
@@ -47,7 +48,7 @@ Requires-Dist: dask; extra == "dask"
47
48
 
48
49
  A suite of python tools for setting up a [ROMS](https://github.com/CESR-lab/ucla-roms) simulation.
49
50
 
50
- <mark>**DISCLAIMER**: This project is **ALPHA** and will be **EXPERIMENTAL** at least throughout Fall 2024. We do not recommend to use this software before this ALPHA development and test phase is completed.</mark>
51
+ <mark>**DISCLAIMER**: This project is **ALPHA** and will be **EXPERIMENTAL** at least throughout 2024. We do not recommend to use this software before this ALPHA development and test phase is completed.</mark>
51
52
 
52
53
  ## Installation
53
54
 
@@ -98,7 +99,7 @@ If you want to use `ROMS-Tools` together with dask (which we recommend), you can
98
99
  install `ROMS-Tools` along with the additional dependency via:
99
100
 
100
101
  ```bash
101
- pip install -e .[dask]
102
+ pip install -e ".[dask]"
102
103
  ```
103
104
 
104
105