roms-tools 3.1.2__py3-none-any.whl → 3.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. roms_tools/__init__.py +3 -0
  2. roms_tools/analysis/cdr_analysis.py +203 -0
  3. roms_tools/analysis/cdr_ensemble.py +198 -0
  4. roms_tools/analysis/roms_output.py +80 -46
  5. roms_tools/data/grids/GLORYS_global_grid.nc +0 -0
  6. roms_tools/download.py +4 -0
  7. roms_tools/plot.py +113 -51
  8. roms_tools/setup/boundary_forcing.py +45 -20
  9. roms_tools/setup/cdr_forcing.py +122 -8
  10. roms_tools/setup/cdr_release.py +161 -8
  11. roms_tools/setup/grid.py +150 -141
  12. roms_tools/setup/initial_conditions.py +113 -48
  13. roms_tools/setup/{datasets.py → lat_lon_datasets.py} +443 -938
  14. roms_tools/setup/mask.py +63 -7
  15. roms_tools/setup/nesting.py +314 -117
  16. roms_tools/setup/river_datasets.py +527 -0
  17. roms_tools/setup/river_forcing.py +46 -20
  18. roms_tools/setup/surface_forcing.py +7 -9
  19. roms_tools/setup/tides.py +2 -3
  20. roms_tools/setup/topography.py +8 -10
  21. roms_tools/setup/utils.py +396 -23
  22. roms_tools/tests/test_analysis/test_cdr_analysis.py +144 -0
  23. roms_tools/tests/test_analysis/test_cdr_ensemble.py +202 -0
  24. roms_tools/tests/test_analysis/test_roms_output.py +61 -3
  25. roms_tools/tests/test_setup/test_boundary_forcing.py +54 -52
  26. roms_tools/tests/test_setup/test_cdr_forcing.py +54 -0
  27. roms_tools/tests/test_setup/test_cdr_release.py +118 -1
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/c/0/0/0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/c/0/0/0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/c/0/0/0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/c/0/0/0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/c/0/0/0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/c/0/0/0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/c/0/0/0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/c/0/0/0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/c/0/0/0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/c/0/0/0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/c/0/0/0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/c/0/0/0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/c/0/0/0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/c/0/0/0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/c/0/0/0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/c/0/0/0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/c/0/0/0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/c/0/0/0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/c/0/0/0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/c/0/0/0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/c/0/0/0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/c/0/0/0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/c/0/0/0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/c/0/0/0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/c/0/0/0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/c/0/0/0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/c/0/0/0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/c/0/0/0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/c/0/0/0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/c/0/0/0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/c/0/0/0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/c/0/0/0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/c/0/0/0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/c/0/0/0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/c/0/0/0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/c/0/0/0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/c/0/0/0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/c/0/0/0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/c/0/0/0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/c/0/0/0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/c/0/0/0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/c/0/0/0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/c/0/0/0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/c/0/0/0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/c/0/0/0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/c/0/0/0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/c/0/0/0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/c/0/0/0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/c/0/0/0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/c/0/0/0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/c/0/0/0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/c/0/0/0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/c/0/0/0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/c/0/0/0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/c/0/0/0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/c/0/0/0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/c/0/0/0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/c/0/0/0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/c/0/0/0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/c/0/0/0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/c/0/0/0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/c/0/0/0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/c/0/0/0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/c/0/0/0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/c/0/0/0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/c/0/0/0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/c/0/0/0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/c/0/0/0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/c/0/0/0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/c/0/0/0 +0 -0
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/c/0/0/0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/c/0/0/0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/c/0/0/0 +0 -0
  111. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
  112. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/c/0/0/0 +0 -0
  113. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/c/0/0/0 +0 -0
  114. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/c/0/0/0 +0 -0
  115. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/c/0/0/0 +0 -0
  116. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/c/0/0/0 +0 -0
  117. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/c/0/0/0 +0 -0
  118. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/c/0/0/0 +0 -0
  119. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/c/0/0/0 +0 -0
  120. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/c/0/0/0 +0 -0
  121. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zarr.json +406 -406
  122. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/c/0/0/0 +0 -0
  123. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/c/0/0/0 +0 -0
  124. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/c/0/0/0 +0 -0
  125. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/c/0/0/0 +0 -0
  126. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/c/0/0/0 +0 -0
  127. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/c/0/0/0 +0 -0
  128. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/c/0/0/0 +0 -0
  129. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/c/0/0/0 +0 -0
  130. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/c/0/0/0 +0 -0
  131. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/c/0/0/0 +0 -0
  132. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/c/0/0/0 +0 -0
  133. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/c/0/0/0 +0 -0
  134. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/c/0/0/0 +0 -0
  135. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/c/0/0/0 +0 -0
  136. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/c/0/0/0 +0 -0
  137. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/c/0/0 +0 -0
  138. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/c/0/0 +0 -0
  139. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/c/0/0 +0 -0
  140. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/c/0/0 +0 -0
  141. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/c/0/0/0 +0 -0
  142. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/c/0/0/0 +0 -0
  143. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/c/0/0/0 +0 -0
  144. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/c/0/0/0 +0 -0
  145. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/c/0/0 +0 -0
  146. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/c/0/0 +0 -0
  147. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/c/0/0 +0 -0
  148. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/c/0/0 +0 -0
  149. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zarr.json +182 -182
  150. roms_tools/tests/test_setup/test_data/grid.zarr/h/c/0/0 +0 -0
  151. roms_tools/tests/test_setup/test_data/grid.zarr/zarr.json +191 -191
  152. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/c/0/0 +0 -0
  153. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/zarr.json +210 -210
  154. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/c/0/0/0/0 +0 -0
  155. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/c/0/0/0/0 +0 -0
  156. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/c/0/0/0/0 +0 -0
  157. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/c/0/0/0/0 +0 -0
  158. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/c/0/0/0/0 +0 -0
  159. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/c/0/0/0/0 +0 -0
  160. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/c/0/0/0/0 +0 -0
  161. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/c/0/0/0/0 +0 -0
  162. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/c/0/0/0/0 +0 -0
  163. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/c/0/0/0/0 +0 -0
  164. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/c/0/0/0/0 +0 -0
  165. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/c/0/0/0/0 +0 -0
  166. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/c/0/0/0/0 +0 -0
  167. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/c/0/0/0/0 +0 -0
  168. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/c/0/0/0/0 +0 -0
  169. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/c/0/0/0/0 +0 -0
  170. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/c/0/0/0/0 +0 -0
  171. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/c/0/0/0/0 +0 -0
  172. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/c/0/0/0/0 +0 -0
  173. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/c/0/0/0/0 +0 -0
  174. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/c/0/0/0/0 +0 -0
  175. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/c/0/0/0/0 +0 -0
  176. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/c/0/0/0/0 +0 -0
  177. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/c/0/0/0/0 +0 -0
  178. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/c/0/0/0/0 +0 -0
  179. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/c/0/0/0/0 +0 -0
  180. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  181. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/c/0/0/0/0 +0 -0
  182. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/c/0/0/0/0 +0 -0
  183. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/c/0/0/0/0 +0 -0
  184. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/c/0/0/0/0 +0 -0
  185. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/c/0/0/0/0 +0 -0
  186. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  187. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  188. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  189. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  190. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  191. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zarr.json +182 -182
  192. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/c/0/0/0/0 +0 -0
  193. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  194. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  195. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  196. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  197. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  198. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  199. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/zarr.json +187 -187
  200. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/c/0/0/0 +0 -0
  201. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/c/0/0/0 +0 -0
  202. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/c/0/0/0 +0 -0
  203. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/c/0/0/0 +0 -0
  204. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/zarr.json +66 -66
  205. roms_tools/tests/test_setup/test_grid.py +236 -115
  206. roms_tools/tests/test_setup/test_initial_conditions.py +94 -41
  207. roms_tools/tests/test_setup/{test_datasets.py → test_lat_lon_datasets.py} +409 -100
  208. roms_tools/tests/test_setup/test_nesting.py +119 -31
  209. roms_tools/tests/test_setup/test_river_datasets.py +48 -0
  210. roms_tools/tests/test_setup/test_surface_forcing.py +2 -1
  211. roms_tools/tests/test_setup/test_utils.py +92 -2
  212. roms_tools/tests/test_setup/utils.py +71 -0
  213. roms_tools/tests/test_tiling/test_join.py +241 -0
  214. roms_tools/tests/test_utils.py +139 -17
  215. roms_tools/tiling/join.py +189 -0
  216. roms_tools/utils.py +131 -99
  217. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/METADATA +12 -2
  218. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/RECORD +221 -211
  219. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/WHEEL +0 -0
  220. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/licenses/LICENSE +0 -0
  221. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/top_level.txt +0 -0
@@ -3,6 +3,7 @@ from collections import defaultdict
3
3
  from dataclasses import dataclass, field
4
4
  from datetime import datetime
5
5
  from pathlib import Path
6
+ from typing import TypeAlias
6
7
 
7
8
  import matplotlib.pyplot as plt
8
9
  import numpy as np
@@ -16,11 +17,12 @@ from roms_tools.plot import (
16
17
  plot_2d_horizontal_field,
17
18
  plot_location,
18
19
  )
19
- from roms_tools.setup.datasets import (
20
+ from roms_tools.setup.river_datasets import (
20
21
  DaiRiverDataset,
21
22
  get_indices_of_nearest_grid_cell_for_rivers,
22
23
  )
23
24
  from roms_tools.setup.utils import (
25
+ RawDataSource,
24
26
  add_time_info_to_ds,
25
27
  add_tracer_metadata_to_ds,
26
28
  from_yaml,
@@ -38,6 +40,8 @@ from roms_tools.utils import save_datasets
38
40
  INCLUDE_ALL_RIVER_NAMES = "all"
39
41
  MAX_RIVERS_TO_PLOT = 20 # must be <= MAX_DISTINCT_COLORS
40
42
 
43
+ TRiverIndex: TypeAlias = dict[tuple[int, int], list[str]]
44
+
41
45
 
42
46
  @dataclass(kw_only=True)
43
47
  class RiverForcing:
@@ -51,7 +55,7 @@ class RiverForcing:
51
55
  Start time of the desired river forcing data.
52
56
  end_time : datetime
53
57
  End time of the desired river forcing data.
54
- source : Dict[str, Union[str, Path, List[Union[str, Path]]], bool], optional
58
+ source : RawDataSource, optional
55
59
  Dictionary specifying the source of the river forcing data. Keys include:
56
60
 
57
61
  - "name" (str): Name of the data source (e.g., "DAI").
@@ -75,7 +79,7 @@ class RiverForcing:
75
79
  Whether to include BGC tracers. Defaults to `False`.
76
80
  model_reference_date : datetime, optional
77
81
  Reference date for the ROMS simulation. Default is January 1, 2000.
78
- indices : dict[str, list[tuple]], optional
82
+ indices : dict[str, list[tuple[int, int]]], optional
79
83
  A dictionary specifying the river indices for each river to be included in the river forcing. This parameter is optional. If not provided,
80
84
  the river indices will be automatically determined based on the grid and the source dataset. If provided, it allows for explicit specification
81
85
  of river locations. The dictionary structure consists of river names as keys, and each value is a list of tuples. Each tuple represents
@@ -101,7 +105,7 @@ class RiverForcing:
101
105
  """Start time of the desired river forcing data."""
102
106
  end_time: datetime
103
107
  """End time of the desired river forcing data."""
104
- source: dict[str, str | Path | list[str | Path]] = None
108
+ source: RawDataSource | None = None
105
109
  """Dictionary specifying the source of the river forcing data."""
106
110
  convert_to_climatology: str = "if_any_missing"
107
111
  """Determines when to compute climatology for river forcing."""
@@ -110,7 +114,7 @@ class RiverForcing:
110
114
  model_reference_date: datetime = datetime(2000, 1, 1)
111
115
  """Reference date for the ROMS simulation."""
112
116
 
113
- indices: dict[str, dict[str, int | list[int]]] | None = None
117
+ indices: dict[str, list[tuple[int, int]]] | None = None
114
118
  """A dictionary of river indices.
115
119
 
116
120
  If not provided during initialization, it will be automatically determined based on
@@ -462,7 +466,7 @@ class RiverForcing:
462
466
 
463
467
  return ds_updated
464
468
 
465
- def _get_overlapping_rivers(self) -> dict[tuple[int, int], list[str]]:
469
+ def _get_overlapping_rivers(self) -> TRiverIndex:
466
470
  """Identify grid cells shared by multiple rivers.
467
471
 
468
472
  Scans through the river indices and finds all grid cell indices
@@ -474,7 +478,10 @@ class RiverForcing:
474
478
  A dictionary mapping grid cell indices (eta_rho, xi_rho) to a list
475
479
  of river names that overlap at that grid cell.
476
480
  """
477
- index_to_rivers = defaultdict(list)
481
+ if self.indices is None:
482
+ return {}
483
+
484
+ index_to_rivers: TRiverIndex = defaultdict(list)
478
485
 
479
486
  # Collect all index pairs used by multiple rivers
480
487
  for river_name, index_list in self.indices.items():
@@ -520,6 +527,9 @@ class RiverForcing:
520
527
  The volume-weighted tracer concentration at the overlapping grid cell,
521
528
  as a new 1-entry DataArray with updated coordinates.
522
529
  """
530
+ if self.indices is None:
531
+ self.indices = {}
532
+
523
533
  new_name = f"overlap_{i}"
524
534
  self.indices[new_name] = [idx_pair]
525
535
 
@@ -578,7 +588,7 @@ class RiverForcing:
578
588
  return combined_river_volume, combined_river_tracer
579
589
 
580
590
  def _reduce_river_volumes(
581
- self, ds: xr.Dataset, overlapping_rivers: dict[tuple[int, int], list[str]]
591
+ self, ds: xr.Dataset, overlapping_rivers: TRiverIndex
582
592
  ) -> xr.Dataset:
583
593
  """Reduce river volumes for rivers contributing to overlapping grid cells.
584
594
 
@@ -595,8 +605,14 @@ class RiverForcing:
595
605
  ds : xr.Dataset
596
606
  Updated dataset with reduced river volumes.
597
607
  """
608
+ if self.indices is None:
609
+ raise ValueError(
610
+ "`self.indices` must be set before calling _reduce_river_volumes"
611
+ )
612
+
598
613
  # Count number of overlaps for each river
599
- river_overlap_count = defaultdict(int)
614
+ river_overlap_count: dict[str, int] = defaultdict(int)
615
+
600
616
  for rivers in overlapping_rivers.values():
601
617
  for name in rivers:
602
618
  river_overlap_count[name] += 1
@@ -671,13 +687,15 @@ class RiverForcing:
671
687
  Warning
672
688
  If NaN values are found in any of the dataset variables, a warning message is logged.
673
689
  """
674
- for var_name in ds.data_vars:
675
- da = ds[var_name]
676
- if da.isnull().any().values:
690
+ var_name = "river_volume"
691
+ da = ds[var_name]
692
+ if da.isnull().any().values:
693
+ logging.warning(
694
+ f"NaNs detected in '{var_name}' and set to zero. This may indicate missing river data and affect model accuracy. "
695
+ )
696
+ if not self.climatology:
677
697
  logging.warning(
678
- f"NaN values detected in the '{var_name}' field. These values are being set to zero. "
679
- "This may indicate missing river data, which could affect model accuracy. Consider setting "
680
- "`convert_to_climatology = 'if_any_missing'` to automatically fill missing values with climatological data."
698
+ "Consider `convert_to_climatology='if_any_missing'` to fill missing values with climatological data."
681
699
  )
682
700
 
683
701
  def plot_locations(self, river_names: list[str] | str = INCLUDE_ALL_RIVER_NAMES):
@@ -691,7 +709,8 @@ class RiverForcing:
691
709
  Defaults to "all".
692
710
 
693
711
  """
694
- valid_river_names = list(self.indices.keys())
712
+ valid_river_names = list(self.indices or [])
713
+
695
714
  river_names = _validate_river_names(river_names, valid_river_names)
696
715
  if len(valid_river_names) > MAX_DISTINCT_COLORS:
697
716
  colors = assign_category_colors(river_names)
@@ -806,7 +825,8 @@ class RiverForcing:
806
825
  Defaults to "all".
807
826
 
808
827
  """
809
- valid_river_names = list(self.indices.keys())
828
+ valid_river_names = list(self.indices or [])
829
+
810
830
  river_names = _validate_river_names(river_names, valid_river_names)
811
831
  if len(valid_river_names) > MAX_DISTINCT_COLORS:
812
832
  colors = assign_category_colors(river_names)
@@ -900,11 +920,17 @@ class RiverForcing:
900
920
  """
901
921
  forcing_dict = to_dict(self, exclude=["climatology"])
902
922
 
903
- # Convert indices format
904
- indices_data = forcing_dict["RiverForcing"]["indices"]
905
- serialized_indices = {"_convention": "eta_rho, xi_rho"}
923
+ indices_data = forcing_dict.get("RiverForcing", {}).get("indices")
924
+ if not indices_data:
925
+ # If no indices, just write the dict as is
926
+ write_to_yaml(forcing_dict, filepath)
927
+ return
928
+
929
+ # Convert tuple indices to string format for YAML
930
+ serialized_indices: dict[str, str | list[str]] = {}
906
931
  for key, value in indices_data.items():
907
932
  serialized_indices[key] = [f"{tup[0]}, {tup[1]}" for tup in value]
933
+ serialized_indices["_convention"] = "eta_rho, xi_rho"
908
934
 
909
935
  # Remove keys starting with "overlap_"
910
936
  filtered_indices = {
@@ -10,15 +10,16 @@ import xarray as xr
10
10
  from roms_tools import Grid
11
11
  from roms_tools.plot import plot
12
12
  from roms_tools.regrid import LateralRegridToROMS
13
- from roms_tools.setup.datasets import (
13
+ from roms_tools.setup.lat_lon_datasets import (
14
14
  CESMBGCSurfaceForcingDataset,
15
- Dataset,
16
15
  ERA5ARCODataset,
17
16
  ERA5Correction,
18
17
  ERA5Dataset,
18
+ LatLonDataset,
19
19
  UnifiedBGCSurfaceDataset,
20
20
  )
21
21
  from roms_tools.setup.utils import (
22
+ RawDataSource,
22
23
  add_time_info_to_ds,
23
24
  compute_missing_surface_bgc_variables,
24
25
  from_yaml,
@@ -56,7 +57,7 @@ class SurfaceForcing:
56
57
  The end time of the desired surface forcing data. This time is used to filter the dataset
57
58
  to include only records on or before this time, with a single record at or after this time.
58
59
  If no time filtering is desired, set it to None. Default is None.
59
- source : Dict[str, Union[str, Path, List[Union[str, Path]]], bool]
60
+ source : RawDataSource
60
61
  Dictionary specifying the source of the surface forcing data. Keys include:
61
62
 
62
63
  - "name" (str): Name of the data source. Currently supported: "ERA5"
@@ -116,7 +117,7 @@ class SurfaceForcing:
116
117
  """The start time of the desired surface forcing data."""
117
118
  end_time: datetime | None = None
118
119
  """The end time of the desired surface forcing data."""
119
- source: dict[str, str | Path | list[str | Path]]
120
+ source: RawDataSource
120
121
  """Dictionary specifying the source of the surface forcing data."""
121
122
  type: str = "physics"
122
123
  """Specifies the type of forcing data ("physics", "bgc")."""
@@ -169,7 +170,6 @@ class SurfaceForcing:
169
170
 
170
171
  data.choose_subdomain(
171
172
  target_coords,
172
- buffer_points=20, # lateral fill needs some buffer from data margin
173
173
  )
174
174
  # Enforce double precision to ensure reproducibility
175
175
  data.convert_to_float64()
@@ -420,7 +420,7 @@ class SurfaceForcing:
420
420
  self.variable_info = variable_info
421
421
 
422
422
  def _apply_radiation_correction(
423
- self, radiation: xr.DataArray, data: Dataset
423
+ self, radiation: xr.DataArray, data: LatLonDataset
424
424
  ) -> xr.DataArray:
425
425
  """Apply a climatological correction to shortwave radiation.
426
426
 
@@ -447,9 +447,7 @@ class SurfaceForcing:
447
447
  "lat": data.ds[data.dim_names["latitude"]],
448
448
  "lon": data.ds[data.dim_names["longitude"]],
449
449
  }
450
- correction_data.choose_subdomain(
451
- coords_correction, straddle=self.target_coords["straddle"]
452
- )
450
+ correction_data.match_subdomain(coords_correction)
453
451
  correction_data.ds["mask"] = data.ds["mask"] # use mask from ERA5 data
454
452
  correction_data.ds["time"] = correction_data.ds["time"].dt.days
455
453
 
roms_tools/setup/tides.py CHANGED
@@ -9,7 +9,7 @@ import xarray as xr
9
9
  from roms_tools import Grid
10
10
  from roms_tools.plot import plot
11
11
  from roms_tools.regrid import LateralRegridToROMS
12
- from roms_tools.setup.datasets import TPXOManager
12
+ from roms_tools.setup.lat_lon_datasets import TPXOManager
13
13
  from roms_tools.setup.utils import (
14
14
  from_yaml,
15
15
  get_target_coords,
@@ -80,7 +80,7 @@ class TidalForcing:
80
80
 
81
81
  grid: Grid
82
82
  """Object representing the grid information."""
83
- source: dict[str, str | Path | list[str | Path]]
83
+ source: dict[str, str | Path | dict[str, str | Path]]
84
84
  """Dictionary specifying the source of the tidal data."""
85
85
  ntides: int = 10
86
86
  """Number of constituents to consider."""
@@ -105,7 +105,6 @@ class TidalForcing:
105
105
  if key != "omega":
106
106
  data.choose_subdomain(
107
107
  target_coords,
108
- buffer_points=20,
109
108
  )
110
109
  # Enforce double precision to ensure reproducibility
111
110
  data.convert_to_float64()
@@ -8,16 +8,16 @@ import numpy as np
8
8
  import xarray as xr
9
9
 
10
10
  from roms_tools.regrid import LateralRegridToROMS
11
- from roms_tools.setup.datasets import ETOPO5Dataset, SRTM15Dataset
11
+ from roms_tools.setup.lat_lon_datasets import ETOPO5Dataset, SRTM15Dataset
12
12
  from roms_tools.setup.utils import handle_boundaries
13
13
 
14
14
 
15
- def _add_topography(
15
+ def add_topography(
16
16
  ds,
17
17
  target_coords,
18
18
  topography_source,
19
19
  hmin,
20
- smooth_factor=6.0,
20
+ smooth_factor=5.0,
21
21
  rmax=0.2,
22
22
  verbose=False,
23
23
  ) -> xr.Dataset:
@@ -77,10 +77,8 @@ def _add_topography(
77
77
  # smooth topography locally to satisfy r < rmax
78
78
  if verbose:
79
79
  start_time = time.time()
80
- # inserting hraw * mask_rho into this function eliminates any inconsistencies between
81
- # the land according to the topography and the land according to the mask; land points
82
- # will always be set to hmin
83
- ds["h"] = _smooth_topography_locally(hraw * ds["mask_rho"], hmin, rmax)
80
+
81
+ ds["h"] = _smooth_topography_locally(hraw, hmin, rmax)
84
82
  ds["h"].attrs = {
85
83
  "long_name": "Bathymetry at rho-points",
86
84
  "units": "meter",
@@ -241,7 +239,7 @@ def _smooth_topography_locally(h, hmin=5, rmax=0.2):
241
239
  rmax_log = 0.0
242
240
 
243
241
  # Apply hmin threshold
244
- h = _clip_depth(h, hmin)
242
+ h = clip_depth(h, hmin)
245
243
 
246
244
  # Perform logarithmic transformation of the height field
247
245
  h_log = np.log(h / hmin)
@@ -324,7 +322,7 @@ def _smooth_topography_locally(h, hmin=5, rmax=0.2):
324
322
  h = hmin * np.exp(h_log)
325
323
 
326
324
  # Apply hmin threshold again
327
- h = _clip_depth(h, hmin)
325
+ h = clip_depth(h, hmin)
328
326
 
329
327
  # Compute maximum slope parameter r
330
328
  r_eta, r_xi = _compute_rfactor(h)
@@ -335,7 +333,7 @@ def _smooth_topography_locally(h, hmin=5, rmax=0.2):
335
333
  return h
336
334
 
337
335
 
338
- def _clip_depth(h: xr.DataArray, hmin: float) -> xr.DataArray:
336
+ def clip_depth(h: xr.DataArray, hmin: float) -> xr.DataArray:
339
337
  """Ensures that depth values do not fall below a minimum threshold.
340
338
 
341
339
  This function replaces all depth values in `h` that are less than `hmin` with `hmin`,