roms-tools 2.3.0__py3-none-any.whl → 2.5.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 (303) hide show
  1. ci/environment.yml +1 -0
  2. roms_tools/__init__.py +2 -1
  3. roms_tools/analysis/roms_output.py +81 -98
  4. roms_tools/plot.py +4 -2
  5. roms_tools/setup/boundary_forcing.py +207 -208
  6. roms_tools/setup/datasets.py +149 -33
  7. roms_tools/setup/grid.py +35 -102
  8. roms_tools/setup/initial_conditions.py +179 -132
  9. roms_tools/setup/nesting.py +239 -86
  10. roms_tools/setup/river_forcing.py +266 -128
  11. roms_tools/setup/surface_forcing.py +137 -76
  12. roms_tools/setup/tides.py +10 -36
  13. roms_tools/setup/topography.py +25 -2
  14. roms_tools/setup/utils.py +52 -82
  15. roms_tools/tests/test_analysis/test_roms_output.py +233 -70
  16. roms_tools/tests/test_setup/test_boundary_forcing.py +283 -57
  17. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +3 -1
  18. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +3 -1
  19. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/0.0.0 +0 -0
  20. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/0.0.0 +0 -0
  21. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/0.0.0 +0 -0
  22. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0 +0 -0
  23. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/0.0.0 +0 -0
  24. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/0.0.0 +0 -0
  25. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/0.0.0 +0 -0
  26. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/0.0.0 +0 -0
  27. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/0.0.0 +0 -0
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/0.0.0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/0.0.0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/0.0.0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/0.0.0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/0.0.0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/0.0.0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/0.0.0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/0.0.0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/0.0.0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/0.0.0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/0.0.0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/0.0.0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/0.0.0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/0.0.0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/0.0.0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/0.0.0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/0.0.0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/0.0.0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/0.0.0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/0.0.0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/0.0.0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/0.0.0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/0.0.0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/0.0.0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/0.0.0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/0.0.0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/0.0.0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/0.0.0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/0.0.0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/0.0.0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/0.0.0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/0.0.0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/0.0.0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/0.0.0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/0.0.0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/0.0.0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/0.0.0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/0.0.0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/0.0.0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/0.0.0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/0.0.0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/0.0.0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/0.0.0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/0.0.0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/0.0.0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/0.0.0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/0.0.0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/0.0.0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/0.0.0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/0.0.0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/0.0.0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/0.0.0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/0.0.0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/0.0.0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/0.0.0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/0.0.0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/0.0.0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/0.0.0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/0.0.0 +0 -0
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/0.0.0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/0.0.0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/0.0.0 +0 -0
  111. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/0.0.0 +0 -0
  112. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/0.0.0 +0 -0
  113. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/0.0.0 +0 -0
  114. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/0.0.0 +0 -0
  115. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/0.0.0 +0 -0
  116. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/0.0.0 +0 -0
  117. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/0.0.0 +0 -0
  118. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/0.0.0 +0 -0
  119. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/0.0.0 +0 -0
  120. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/0.0.0 +0 -0
  121. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/0.0.0 +0 -0
  122. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/0.0.0 +0 -0
  123. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/0.0.0 +0 -0
  124. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/0.0.0 +0 -0
  125. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/0.0.0 +0 -0
  126. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/0.0.0 +0 -0
  127. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/0.0.0 +0 -0
  128. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/0.0.0 +0 -0
  129. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/0.0.0 +0 -0
  130. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/0.0.0 +0 -0
  131. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zattrs +2 -2
  132. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zmetadata +8 -7
  133. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/abs_time/.zattrs +1 -0
  134. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/dust/0.0.0 +0 -0
  135. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/dust_time/.zattrs +1 -1
  136. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/iron/0.0.0 +0 -0
  137. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/iron_time/.zattrs +1 -1
  138. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nhy/0.0.0 +0 -0
  139. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nhy_time/.zattrs +1 -1
  140. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nox/0.0.0 +0 -0
  141. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nox_time/.zattrs +1 -1
  142. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air/0.0.0 +0 -0
  143. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air_alt/0.0.0 +0 -0
  144. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_time/.zattrs +1 -1
  145. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +2 -2
  146. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +2 -2
  147. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust/0.0.0 +0 -0
  148. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron/0.0.0 +0 -0
  149. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy/0.0.0 +0 -0
  150. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox/0.0.0 +0 -0
  151. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air/0.0.0 +0 -0
  152. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/0.0.0 +0 -0
  153. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zattrs +5 -3
  154. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zmetadata +156 -121
  155. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/.zarray +2 -2
  156. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/.zattrs +2 -1
  157. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/abs_time/0 +0 -0
  158. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/bry_time/.zarray +2 -2
  159. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/bry_time/.zattrs +1 -1
  160. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/bry_time/0 +0 -0
  161. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/.zarray +4 -4
  162. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/0.0.0 +0 -0
  163. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/.zarray +4 -4
  164. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/0.0.0 +0 -0
  165. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/.zarray +4 -4
  166. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/0.0.0 +0 -0
  167. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/.zarray +4 -4
  168. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/0.0.0 +0 -0
  169. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/.zarray +4 -4
  170. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/0.0.0 +0 -0
  171. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/.zarray +4 -4
  172. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/0.0.0 +0 -0
  173. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/.zarray +4 -4
  174. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/0.0.0 +0 -0
  175. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/.zarray +4 -4
  176. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/0.0.0 +0 -0
  177. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/.zarray +4 -4
  178. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/0.0.0 +0 -0
  179. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/.zarray +4 -4
  180. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/0.0.0 +0 -0
  181. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/.zarray +4 -4
  182. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/0.0.0 +0 -0
  183. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/.zarray +4 -4
  184. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/0.0.0 +0 -0
  185. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/.zarray +4 -4
  186. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/0.0 +0 -0
  187. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/.zarray +4 -4
  188. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/0.0 +0 -0
  189. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/.zarray +4 -4
  190. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/0.0 +0 -0
  191. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/.zarray +4 -4
  192. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/0.0 +0 -0
  193. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/.zarray +4 -4
  194. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/0.0.0 +0 -0
  195. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/.zarray +4 -4
  196. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/0.0.0 +0 -0
  197. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/.zarray +4 -4
  198. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/0.0.0 +0 -0
  199. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/.zarray +4 -4
  200. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/0.0.0 +0 -0
  201. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/.zarray +4 -4
  202. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/0.0 +0 -0
  203. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/.zarray +4 -4
  204. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/0.0 +0 -0
  205. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/.zarray +4 -4
  206. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/0.0 +0 -0
  207. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/.zarray +4 -4
  208. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/0.0 +0 -0
  209. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/.zarray +4 -4
  210. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/.zattrs +8 -0
  211. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/0.0 +0 -0
  212. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/.zarray +4 -4
  213. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/.zattrs +8 -0
  214. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_north/0.0 +0 -0
  215. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/.zarray +4 -4
  216. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/.zattrs +8 -0
  217. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/0.0 +0 -0
  218. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/.zarray +4 -4
  219. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/.zattrs +8 -0
  220. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_west/0.0 +0 -0
  221. roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +1 -1
  222. roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +2 -2
  223. roms_tools/tests/test_setup/test_data/grid.zarr/angle/0.0 +0 -0
  224. roms_tools/tests/test_setup/test_data/grid.zarr/angle_coarse/0.0 +0 -0
  225. roms_tools/tests/test_setup/test_data/grid.zarr/f/0.0 +0 -0
  226. roms_tools/tests/test_setup/test_data/grid.zarr/h/.zattrs +1 -1
  227. roms_tools/tests/test_setup/test_data/grid.zarr/h/0.0 +0 -0
  228. roms_tools/tests/test_setup/test_data/grid.zarr/lat_coarse/0.0 +0 -0
  229. roms_tools/tests/test_setup/test_data/grid.zarr/lat_rho/0.0 +0 -0
  230. roms_tools/tests/test_setup/test_data/grid.zarr/lat_u/0.0 +0 -0
  231. roms_tools/tests/test_setup/test_data/grid.zarr/lat_v/0.0 +0 -0
  232. roms_tools/tests/test_setup/test_data/grid.zarr/pm/0.0 +0 -0
  233. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +4 -4
  234. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +4 -4
  235. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle/0.0 +0 -0
  236. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle_coarse/0.0 +0 -0
  237. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/f/0.0 +0 -0
  238. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/0.0 +0 -0
  239. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_coarse/0.0 +0 -0
  240. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_rho/0.0 +0 -0
  241. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_u/0.0 +0 -0
  242. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_v/0.0 +0 -0
  243. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_coarse/0.0 +0 -0
  244. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_rho/0.0 +0 -0
  245. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_u/0.0 +0 -0
  246. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_v/0.0 +0 -0
  247. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_coarse/0.0 +0 -0
  248. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_rho/0.0 +0 -0
  249. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_u/0.0 +0 -0
  250. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/mask_v/0.0 +0 -0
  251. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pm/0.0 +0 -0
  252. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pn/0.0 +0 -0
  253. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zattrs +2 -1
  254. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zmetadata +6 -4
  255. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Cs_r/.zattrs +1 -1
  256. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Cs_w/.zattrs +1 -1
  257. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/0.0.0.0 +0 -0
  258. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/0.0.0.0 +0 -0
  259. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/0.0.0.0 +0 -0
  260. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/abs_time/.zattrs +1 -0
  261. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/0.0.0.0 +0 -0
  262. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ocean_time/.zattrs +1 -1
  263. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/0.0.0.0 +0 -0
  264. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/0.0.0.0 +0 -0
  265. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/0.0.0.0 +0 -0
  266. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/0.0.0.0 +0 -0
  267. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/0.0.0.0 +0 -0
  268. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/0.0.0.0 +0 -0
  269. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/0.0.0 +0 -0
  270. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/0.0.0.0 +0 -0
  271. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/0.0.0 +0 -0
  272. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zeta/0.0.0 +0 -0
  273. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/.zmetadata +56 -0
  274. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/.zarray +20 -0
  275. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/.zattrs +6 -0
  276. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/nriver/0 +0 -0
  277. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/.zarray +22 -0
  278. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/.zattrs +8 -0
  279. roms_tools/tests/test_setup/test_data/river_forcing_no_climatology.zarr/river_location/0.0 +0 -0
  280. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/.zmetadata +56 -0
  281. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/.zarray +20 -0
  282. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/.zattrs +6 -0
  283. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/nriver/0 +0 -0
  284. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/.zarray +22 -0
  285. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/.zattrs +8 -0
  286. roms_tools/tests/test_setup/test_data/river_forcing_with_bgc.zarr/river_location/0.0 +0 -0
  287. roms_tools/tests/test_setup/test_grid.py +0 -13
  288. roms_tools/tests/test_setup/test_initial_conditions.py +220 -66
  289. roms_tools/tests/test_setup/test_nesting.py +139 -118
  290. roms_tools/tests/test_setup/test_river_forcing.py +583 -293
  291. roms_tools/tests/test_setup/test_surface_forcing.py +149 -73
  292. roms_tools/tests/test_setup/test_tides.py +4 -16
  293. roms_tools/tests/test_setup/test_utils.py +1 -0
  294. roms_tools/tests/test_setup/test_validation.py +34 -2
  295. roms_tools/tests/{test_utils.py → test_tiling/test_partition.py} +1 -1
  296. roms_tools/tiling/partition.py +338 -0
  297. roms_tools/utils.py +66 -333
  298. roms_tools/vertical_coordinate.py +54 -133
  299. {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/METADATA +1 -1
  300. {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/RECORD +303 -290
  301. {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/WHEEL +1 -1
  302. {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/LICENSE +0 -0
  303. {roms_tools-2.3.0.dist-info → roms_tools-2.5.0.dist-info}/top_level.txt +0 -0
roms_tools/setup/utils.py CHANGED
@@ -3,7 +3,6 @@ import numpy as np
3
3
  from typing import Union, Any, Dict, Type
4
4
  import pandas as pd
5
5
  import cftime
6
- from roms_tools.utils import partition
7
6
  from pathlib import Path
8
7
  from datetime import datetime
9
8
  from dataclasses import fields, asdict
@@ -131,23 +130,36 @@ def interpolate_from_climatology(
131
130
  time_dim_name: str,
132
131
  time: Union[xr.DataArray, pd.DatetimeIndex],
133
132
  ) -> Union[xr.DataArray, xr.Dataset]:
134
- """Interpolates the given field temporally based on the specified time points.
133
+ """Temporally interpolates a field based on specified time points.
135
134
 
136
- If `field` is an xarray.Dataset, this function applies the interpolation to all data variables in the dataset.
135
+ This function performs temporal interpolation on the input `field` to match the provided `time` values.
136
+ If the input `field` is an `xarray.Dataset`, the interpolation is applied to all its data variables individually.
137
137
 
138
138
  Parameters
139
139
  ----------
140
140
  field : xarray.DataArray or xarray.Dataset
141
- The field data to be interpolated. Can be a single DataArray or a Dataset.
141
+ The input field to be interpolated.
142
+ - If `field` is an `xarray.DataArray`, it should have a time dimension identified by `time_dim_name`.
143
+ - If `field` is an `xarray.Dataset`, all variables within the dataset are interpolated along the specified time dimension.
144
+ The time dimension is assumed to represent `day_of_year` for climatological purposes.
142
145
  time_dim_name : str
143
- The name of the dimension in `field` that represents time.
146
+ The name of the time dimension in the `field`. This dimension is used for interpolation.
144
147
  time : xarray.DataArray or pandas.DatetimeIndex
145
- The target time points for interpolation.
148
+ The target time points for interpolation. The time values should be compatible with the time format used in the `field`.
146
149
 
147
150
  Returns
148
151
  -------
149
152
  xarray.DataArray or xarray.Dataset
150
- The field values interpolated to the specified time points. The type matches the input type.
153
+ The interpolated field, with the same type as the input (`xarray.DataArray` or `xarray.Dataset`),
154
+ but aligned to the specified `time` values.
155
+
156
+ Notes
157
+ -----
158
+ - The interpolation assumes the time dimension in `field` corresponds to `day_of_year`.
159
+ If the input time values are in a datetime format, ensure they are converted to `day_of_year` before calling this function.
160
+ For example, you can preprocess the time as follows:
161
+
162
+ >>> field["time"] = field["time"].dt.dayofyear
151
163
  """
152
164
 
153
165
  def interpolate_single_field(data_array: xr.DataArray) -> xr.DataArray:
@@ -157,11 +169,11 @@ def interpolate_from_climatology(
157
169
  day_of_year = time.dt.dayofyear
158
170
  else:
159
171
  if np.size(time) == 1:
160
- day_of_year = time.timetuple().tm_yday
172
+ # Convert single datetime64 object to pandas.Timestamp
173
+ day_of_year = pd.Timestamp(time).dayofyear
161
174
  else:
162
- day_of_year = np.array([t.timetuple().tm_yday for t in time])
163
-
164
- data_array[time_dim_name] = data_array[time_dim_name].dt.days
175
+ # Convert each datetime64 object in the array to pandas.Timestamp
176
+ day_of_year = np.array([pd.Timestamp(t).dayofyear for t in time])
165
177
 
166
178
  # Concatenate across the beginning and end of the year
167
179
  time_concat = xr.concat(
@@ -201,6 +213,7 @@ def interpolate_from_climatology(
201
213
  for var, data_array in field.data_vars.items()
202
214
  }
203
215
  return xr.Dataset(interpolated_data_vars, attrs=field.attrs)
216
+
204
217
  else:
205
218
  raise TypeError("Input 'field' must be an xarray.DataArray or xarray.Dataset.")
206
219
 
@@ -568,59 +581,6 @@ def group_by_year(ds, filepath):
568
581
  return dataset_list, output_filenames
569
582
 
570
583
 
571
- def save_datasets(dataset_list, output_filenames, np_eta=None, np_xi=None):
572
- """Save the list of datasets to netCDF4 files, with optional spatial partitioning.
573
-
574
- Parameters
575
- ----------
576
- dataset_list : list
577
- List of datasets to be saved.
578
- output_filenames : list
579
- List of filenames for the output files.
580
- np_eta : int, optional
581
- The number of partitions along the `eta` direction. If `None`, no spatial partitioning is performed.
582
- np_xi : int, optional
583
- The number of partitions along the `xi` direction. If `None`, no spatial partitioning is performed.
584
-
585
- Returns
586
- -------
587
- List[Path]
588
- A list of Path objects for the filenames that were saved.
589
- """
590
-
591
- saved_filenames = []
592
-
593
- if np_eta is None and np_xi is None:
594
- # Save the dataset as a single file
595
- output_filenames = [f"{filename}.nc" for filename in output_filenames]
596
- xr.save_mfdataset(dataset_list, output_filenames)
597
-
598
- saved_filenames.extend(Path(f) for f in output_filenames)
599
-
600
- else:
601
- # Partition the dataset and save each partition as a separate file
602
- np_eta = np_eta or 1
603
- np_xi = np_xi or 1
604
-
605
- partitioned_datasets = []
606
- partitioned_filenames = []
607
- for dataset, base_filename in zip(dataset_list, output_filenames):
608
- partition_indices, partitions = partition(
609
- dataset, np_eta=np_eta, np_xi=np_xi
610
- )
611
- partition_filenames = [
612
- f"{base_filename}.{index}.nc" for index in partition_indices
613
- ]
614
- partitioned_datasets.extend(partitions)
615
- partitioned_filenames.extend(partition_filenames)
616
-
617
- xr.save_mfdataset(partitioned_datasets, partitioned_filenames)
618
-
619
- saved_filenames.extend(Path(f) for f in partitioned_filenames)
620
-
621
- return saved_filenames
622
-
623
-
624
584
  def get_target_coords(grid, use_coarse_grid=False):
625
585
  """Retrieves longitude and latitude coordinates from the grid, adjusting them based
626
586
  on longitude range.
@@ -652,8 +612,6 @@ def get_target_coords(grid, use_coarse_grid=False):
652
612
  mask = grid.ds.get("mask_coarse")
653
613
  if mask is not None:
654
614
  mask = mask.rename({"eta_coarse": "eta_rho", "xi_coarse": "xi_rho"})
655
- mask_u = interpolate_from_rho_to_u(mask, method="multiplicative")
656
- mask_v = interpolate_from_rho_to_v(mask, method="multiplicative")
657
615
 
658
616
  lat_psi = grid.ds.get("lat_psi_coarse")
659
617
  lon_psi = grid.ds.get("lon_psi_coarse")
@@ -663,8 +621,6 @@ def get_target_coords(grid, use_coarse_grid=False):
663
621
  lon = grid.ds.lon_rho
664
622
  angle = grid.ds.angle
665
623
  mask = grid.ds.get("mask_rho")
666
- mask_u = grid.ds.get("mask_u")
667
- mask_v = grid.ds.get("mask_v")
668
624
  lat_psi = grid.ds.get("lat_psi")
669
625
  lon_psi = grid.ds.get("lon_psi")
670
626
 
@@ -687,8 +643,6 @@ def get_target_coords(grid, use_coarse_grid=False):
687
643
  "lon_psi": lon_psi,
688
644
  "angle": angle,
689
645
  "mask": mask,
690
- "mask_u": mask_u,
691
- "mask_v": mask_v,
692
646
  "straddle": straddle,
693
647
  }
694
648
 
@@ -939,13 +893,9 @@ def _to_yaml(forcing_object, filepath: Union[str, Path]) -> None:
939
893
  if hasattr(forcing_object, "grid") and forcing_object.grid is not None:
940
894
  grid_data = asdict(forcing_object.grid)
941
895
  grid_yaml_data = {"Grid": _pop_grid_data(grid_data)}
942
- else:
943
- parent_grid_data = asdict(forcing_object.parent_grid)
944
- parent_grid_yaml_data = {"ParentGrid": _pop_grid_data(parent_grid_data)}
945
- child_grid_data = asdict(forcing_object.child_grid)
946
- child_grid_yaml_data = {"ChildGrid": _pop_grid_data(child_grid_data)}
947
-
948
- grid_yaml_data = {**parent_grid_yaml_data, **child_grid_yaml_data}
896
+ elif hasattr(forcing_object, "parent_grid"):
897
+ grid_data = asdict(forcing_object.parent_grid)
898
+ grid_yaml_data = {"ParentGrid": _pop_grid_data(grid_data)}
949
899
 
950
900
  # Step 2: Ensure Paths are Strings
951
901
  def ensure_paths_are_strings(obj, key):
@@ -979,11 +929,12 @@ def _to_yaml(forcing_object, filepath: Union[str, Path]) -> None:
979
929
  not in (
980
930
  "grid",
981
931
  "parent_grid",
982
- "child_grid",
983
932
  "ds",
984
933
  "use_dask",
985
- "bypass_validation",
986
934
  "climatology",
935
+ "verbose",
936
+ "straddle",
937
+ "indices",
987
938
  )
988
939
  ]
989
940
 
@@ -998,18 +949,37 @@ def _to_yaml(forcing_object, filepath: Union[str, Path]) -> None:
998
949
  # Add the field and its value to the forcing_data dictionary
999
950
  forcing_data[field_name] = value
1000
951
 
1001
- # Step 5: Combine Grid and Forcing Data into a single dictionary for the final YAML content
952
+ # Step 5: Serialize `indices` data (conditionally)
953
+ indices_data = getattr(forcing_object, "indices", None)
954
+ if indices_data is not None:
955
+ serialized_indices = {
956
+ "_convention": "eta_rho, xi_rho"
957
+ } # Add convention metadata
958
+
959
+ for key, value in indices_data.items():
960
+ serialized_indices[key] = [
961
+ f"{tup[0]}, {tup[1]}" for tup in value
962
+ ] # Comma-separated string
963
+
964
+ forcing_data["indices"] = serialized_indices
965
+
966
+ # Step 6: Combine Grid and Forcing Data into a single dictionary for the final YAML content
1002
967
  yaml_data = {
1003
968
  **grid_yaml_data, # Add the grid data to the final YAML structure
1004
969
  forcing_object.__class__.__name__: forcing_data, # Include the serialized forcing object data
1005
970
  }
1006
971
 
1007
- # Step 6: Write to YAML file
972
+ # Step 7: Write to YAML file
1008
973
  with filepath.open("w") as file:
1009
974
  # Write the header first
1010
975
  file.write(header)
1011
976
  # Write the serialized YAML data
1012
- yaml.dump(yaml_data, file, default_flow_style=False, sort_keys=False)
977
+ yaml.dump(
978
+ yaml_data,
979
+ file,
980
+ default_flow_style=False,
981
+ sort_keys=False,
982
+ )
1013
983
 
1014
984
 
1015
985
  def _pop_grid_data(grid_data):
@@ -18,7 +18,6 @@ def roms_output_from_restart_file(use_dask):
18
18
  return ROMSOutput(
19
19
  grid=grid,
20
20
  path=Path(download_test_data("eastpac25km_rst.19980106000000.nc")),
21
- type="restart",
22
21
  use_dask=use_dask,
23
22
  )
24
23
 
@@ -28,20 +27,6 @@ def test_load_model_output_file(roms_output_from_restart_file, use_dask):
28
27
  assert isinstance(roms_output_from_restart_file.ds, xr.Dataset)
29
28
 
30
29
 
31
- def test_load_model_output_directory(use_dask):
32
- fname_grid = Path(download_test_data("epac25km_grd.nc"))
33
- grid = Grid.from_file(fname_grid)
34
-
35
- # Download at least two files, so these will be found within the pooch directory
36
- _ = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
37
- _ = Path(download_test_data("eastpac25km_rst.19980126000000.nc"))
38
-
39
- # Directory
40
- directory = os.path.dirname(download_test_data("eastpac25km_rst.19980106000000.nc"))
41
- output = ROMSOutput(grid=grid, path=directory, type="restart", use_dask=use_dask)
42
- assert isinstance(output.ds, xr.Dataset)
43
-
44
-
45
30
  def test_load_model_output_file_list(use_dask):
46
31
  fname_grid = Path(download_test_data("epac25km_grd.nc"))
47
32
  grid = Grid.from_file(fname_grid)
@@ -49,24 +34,23 @@ def test_load_model_output_file_list(use_dask):
49
34
  # List of files
50
35
  file1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
51
36
  file2 = Path(download_test_data("eastpac25km_rst.19980126000000.nc"))
52
- output = ROMSOutput(
53
- grid=grid, path=[file1, file2], type="restart", use_dask=use_dask
54
- )
37
+ output = ROMSOutput(grid=grid, path=[file1, file2], use_dask=use_dask)
55
38
  assert isinstance(output.ds, xr.Dataset)
56
39
 
57
40
 
58
- def test_invalid_type(use_dask):
41
+ def test_load_model_output_with_wildcard(use_dask):
59
42
  fname_grid = Path(download_test_data("epac25km_grd.nc"))
60
43
  grid = Grid.from_file(fname_grid)
61
44
 
62
- # Invalid type
63
- with pytest.raises(ValueError, match="Invalid type 'invalid_type'"):
64
- ROMSOutput(
65
- grid=grid,
66
- path=Path(download_test_data("eastpac25km_rst.19980106000000.nc")),
67
- type="invalid_type",
68
- use_dask=use_dask,
69
- )
45
+ # Download at least two files, so these will be found within the pooch directory
46
+ Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
47
+ Path(download_test_data("eastpac25km_rst.19980126000000.nc"))
48
+ directory = Path(
49
+ os.path.dirname(download_test_data("eastpac25km_rst.19980106000000.nc"))
50
+ )
51
+
52
+ output = ROMSOutput(grid=grid, path=directory / "*rst*.nc", use_dask=use_dask)
53
+ assert isinstance(output.ds, xr.Dataset)
70
54
 
71
55
 
72
56
  def test_invalid_path(use_dask):
@@ -78,16 +62,6 @@ def test_invalid_path(use_dask):
78
62
  ROMSOutput(
79
63
  grid=grid,
80
64
  path=Path("/path/to/nonexistent/file.nc"),
81
- type="restart",
82
- use_dask=use_dask,
83
- )
84
-
85
- # Non-existent directory
86
- with pytest.raises(FileNotFoundError):
87
- ROMSOutput(
88
- grid=grid,
89
- path=Path("/path/to/nonexistent/directory"),
90
- type="restart",
91
65
  use_dask=use_dask,
92
66
  )
93
67
 
@@ -99,7 +73,6 @@ def test_set_correct_model_reference_date(use_dask):
99
73
  output = ROMSOutput(
100
74
  grid=grid,
101
75
  path=Path(download_test_data("eastpac25km_rst.19980106000000.nc")),
102
- type="restart",
103
76
  use_dask=use_dask,
104
77
  )
105
78
  assert output.model_reference_date == datetime(1995, 1, 1)
@@ -117,7 +90,6 @@ def test_model_reference_date_mismatch(use_dask):
117
90
  ROMSOutput(
118
91
  grid=grid,
119
92
  path=Path(download_test_data("eastpac25km_rst.19980106000000.nc")),
120
- type="restart",
121
93
  model_reference_date=model_ref_date,
122
94
  use_dask=use_dask,
123
95
  )
@@ -138,7 +110,7 @@ def test_model_reference_date_no_metadata(use_dask, tmp_path, caplog):
138
110
  expected_exception,
139
111
  match="Model reference date could not be inferred from the metadata",
140
112
  ):
141
- ROMSOutput(grid=grid, path=fname_mod, type="restart", use_dask=use_dask)
113
+ ROMSOutput(grid=grid, path=fname_mod, use_dask=use_dask)
142
114
 
143
115
  # Test case 2: When a model reference date is explicitly set, verify the warning
144
116
  with caplog.at_level(logging.WARNING):
@@ -146,7 +118,6 @@ def test_model_reference_date_no_metadata(use_dask, tmp_path, caplog):
146
118
  grid=grid,
147
119
  path=fname_mod,
148
120
  model_reference_date=datetime(1995, 1, 1),
149
- type="restart",
150
121
  use_dask=use_dask,
151
122
  )
152
123
 
@@ -175,20 +146,53 @@ def test_model_reference_date_no_metadata(use_dask, tmp_path, caplog):
175
146
  def test_compute_depth_coordinates(use_dask):
176
147
  fname_grid = Path(download_test_data("epac25km_grd.nc"))
177
148
  grid = Grid.from_file(fname_grid)
149
+ fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
150
+
151
+ for adjust_depth_for_sea_surface_height in [True, False]:
152
+ output = ROMSOutput(
153
+ grid=grid,
154
+ path=fname_restart1,
155
+ use_dask=use_dask,
156
+ adjust_depth_for_sea_surface_height=adjust_depth_for_sea_surface_height,
157
+ )
158
+
159
+ # Before calling get_vertical_coordinates, check if the dataset doesn't already have depth coordinates
160
+ assert "layer_depth_rho" not in output.ds_depth_coords.data_vars
161
+
162
+ # Call the method to get vertical coordinates
163
+ output._get_depth_coordinates(depth_type="layer")
164
+
165
+ # Check if the depth coordinates were added
166
+ assert "layer_depth_rho" in output.ds_depth_coords.data_vars
167
+
168
+
169
+ def test_missing_zeta_gets_raised(use_dask):
170
+ """Test that a ValueError is raised when `zeta` is missing from the dataset and
171
+ `adjust_depth_for_sea_surface_height` is enabled."""
172
+ # Load the grid
173
+ fname_grid = Path(download_test_data("epac25km_grd.nc"))
174
+ grid = Grid.from_file(fname_grid)
178
175
 
176
+ # Load the ROMS output
179
177
  fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
180
- output = ROMSOutput(
181
- grid=grid, path=fname_restart1, type="restart", use_dask=use_dask
178
+ roms_output = ROMSOutput(
179
+ grid=grid,
180
+ path=fname_restart1,
181
+ use_dask=use_dask,
182
+ adjust_depth_for_sea_surface_height=True,
182
183
  )
183
184
 
184
- # Before calling get_vertical_coordinates, check if the dataset doesn't already have depth coordinates
185
- assert "layer_depth_rho" not in output.ds.data_vars
186
-
187
- # Call the method to get vertical coordinates
188
- output.compute_depth_coordinates(depth_type="layer")
185
+ # Remove `zeta` from the dataset
186
+ object.__setattr__(
187
+ roms_output, "ds", roms_output.ds.drop_vars("zeta", errors="ignore")
188
+ )
189
189
 
190
- # Check if the depth coordinates were added
191
- assert "layer_depth_rho" in output.ds.data_vars
190
+ # Expect ValueError when calling `_get_depth_coordinates`
191
+ with pytest.raises(
192
+ ValueError,
193
+ match="`zeta` is required in provided ROMS output when `adjust_depth_for_sea_surface_height` is enabled.",
194
+ ):
195
+ roms_output._get_depth_coordinates()
192
196
 
193
197
 
194
198
  def test_check_vertical_coordinate_mismatch(use_dask):
@@ -196,9 +200,7 @@ def test_check_vertical_coordinate_mismatch(use_dask):
196
200
  grid = Grid.from_file(fname_grid)
197
201
 
198
202
  fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
199
- output = ROMSOutput(
200
- grid=grid, path=fname_restart1, type="restart", use_dask=use_dask
201
- )
203
+ output = ROMSOutput(grid=grid, path=fname_restart1, use_dask=use_dask)
202
204
 
203
205
  # create a mock dataset with inconsistent vertical coordinate parameters
204
206
  ds_mock = output.ds.copy()
@@ -226,9 +228,7 @@ def test_that_coordinates_are_added(use_dask):
226
228
  grid = Grid.from_file(fname_grid)
227
229
 
228
230
  fname_restart1 = Path(download_test_data("eastpac25km_rst.19980106000000.nc"))
229
- output = ROMSOutput(
230
- grid=grid, path=fname_restart1, type="restart", use_dask=use_dask
231
- )
231
+ output = ROMSOutput(grid=grid, path=fname_restart1, use_dask=use_dask)
232
232
 
233
233
  assert "abs_time" in output.ds.coords
234
234
  assert "lat_rho" in output.ds.coords
@@ -239,23 +239,186 @@ def test_plot(roms_output_from_restart_file, use_dask):
239
239
 
240
240
  kwargs = {}
241
241
  for var_name in ["temp", "u", "v"]:
242
- roms_output_from_restart_file.plot(var_name, time=0, s=-1, **kwargs)
243
- roms_output_from_restart_file.plot(var_name, time=0, eta=0, **kwargs)
244
- roms_output_from_restart_file.plot(var_name, time=0, xi=0, **kwargs)
245
- roms_output_from_restart_file.plot(var_name, time=0, eta=0, xi=0, **kwargs)
246
- roms_output_from_restart_file.plot(var_name, time=0, s=-1, eta=0, **kwargs)
242
+ for include_boundary in [False, True]:
243
+ roms_output_from_restart_file.plot(
244
+ var_name, time=0, s=-1, **kwargs, include_boundary=include_boundary
245
+ )
246
+ roms_output_from_restart_file.plot(
247
+ var_name, time=0, eta=0, **kwargs, include_boundary=include_boundary
248
+ )
249
+ roms_output_from_restart_file.plot(
250
+ var_name, time=0, eta=1, **kwargs, include_boundary=include_boundary
251
+ )
252
+ roms_output_from_restart_file.plot(
253
+ var_name, time=0, xi=0, **kwargs, include_boundary=include_boundary
254
+ )
255
+ roms_output_from_restart_file.plot(
256
+ var_name, time=0, xi=1, **kwargs, include_boundary=include_boundary
257
+ )
258
+ roms_output_from_restart_file.plot(
259
+ var_name,
260
+ time=0,
261
+ eta=0,
262
+ xi=0,
263
+ **kwargs,
264
+ include_boundary=include_boundary
265
+ )
266
+ roms_output_from_restart_file.plot(
267
+ var_name,
268
+ time=0,
269
+ eta=0,
270
+ xi=1,
271
+ **kwargs,
272
+ include_boundary=include_boundary
273
+ )
274
+ roms_output_from_restart_file.plot(
275
+ var_name,
276
+ time=0,
277
+ eta=1,
278
+ xi=0,
279
+ **kwargs,
280
+ include_boundary=include_boundary
281
+ )
282
+ roms_output_from_restart_file.plot(
283
+ var_name,
284
+ time=0,
285
+ eta=1,
286
+ xi=1,
287
+ **kwargs,
288
+ include_boundary=include_boundary
289
+ )
290
+ roms_output_from_restart_file.plot(
291
+ var_name,
292
+ time=0,
293
+ s=-1,
294
+ eta=0,
295
+ **kwargs,
296
+ include_boundary=include_boundary
297
+ )
298
+ roms_output_from_restart_file.plot(
299
+ var_name,
300
+ time=0,
301
+ s=-1,
302
+ eta=1,
303
+ **kwargs,
304
+ include_boundary=include_boundary
305
+ )
306
+ roms_output_from_restart_file.plot(
307
+ var_name,
308
+ time=0,
309
+ s=-1,
310
+ xi=0,
311
+ **kwargs,
312
+ include_boundary=include_boundary
313
+ )
314
+ roms_output_from_restart_file.plot(
315
+ var_name,
316
+ time=0,
317
+ s=-1,
318
+ xi=1,
319
+ **kwargs,
320
+ include_boundary=include_boundary
321
+ )
247
322
 
248
323
  kwargs = {"depth_contours": True, "layer_contours": True}
249
324
  for var_name in ["temp", "u", "v"]:
250
- roms_output_from_restart_file.plot(var_name, time=0, s=-1, **kwargs)
251
- roms_output_from_restart_file.plot(var_name, time=0, eta=0, **kwargs)
252
- roms_output_from_restart_file.plot(var_name, time=0, xi=0, **kwargs)
253
- roms_output_from_restart_file.plot(var_name, time=0, eta=0, xi=0, **kwargs)
254
- roms_output_from_restart_file.plot(var_name, time=0, s=-1, eta=0, **kwargs)
255
-
256
- roms_output_from_restart_file.plot("zeta", time=0, **kwargs)
257
- roms_output_from_restart_file.plot("zeta", time=0, eta=0, **kwargs)
258
- roms_output_from_restart_file.plot("zeta", time=0, xi=0, **kwargs)
325
+ for include_boundary in [False, True]:
326
+ roms_output_from_restart_file.plot(
327
+ var_name, time=0, s=-1, **kwargs, include_boundary=include_boundary
328
+ )
329
+ roms_output_from_restart_file.plot(
330
+ var_name, time=0, eta=0, **kwargs, include_boundary=include_boundary
331
+ )
332
+ roms_output_from_restart_file.plot(
333
+ var_name, time=0, eta=1, **kwargs, include_boundary=include_boundary
334
+ )
335
+ roms_output_from_restart_file.plot(
336
+ var_name, time=0, xi=0, **kwargs, include_boundary=include_boundary
337
+ )
338
+ roms_output_from_restart_file.plot(
339
+ var_name, time=0, xi=1, **kwargs, include_boundary=include_boundary
340
+ )
341
+ roms_output_from_restart_file.plot(
342
+ var_name,
343
+ time=0,
344
+ eta=0,
345
+ xi=0,
346
+ **kwargs,
347
+ include_boundary=include_boundary
348
+ )
349
+ roms_output_from_restart_file.plot(
350
+ var_name,
351
+ time=0,
352
+ eta=0,
353
+ xi=1,
354
+ **kwargs,
355
+ include_boundary=include_boundary
356
+ )
357
+ roms_output_from_restart_file.plot(
358
+ var_name,
359
+ time=0,
360
+ eta=1,
361
+ xi=0,
362
+ **kwargs,
363
+ include_boundary=include_boundary
364
+ )
365
+ roms_output_from_restart_file.plot(
366
+ var_name,
367
+ time=0,
368
+ eta=1,
369
+ xi=1,
370
+ **kwargs,
371
+ include_boundary=include_boundary
372
+ )
373
+ roms_output_from_restart_file.plot(
374
+ var_name,
375
+ time=0,
376
+ s=-1,
377
+ eta=0,
378
+ **kwargs,
379
+ include_boundary=include_boundary
380
+ )
381
+ roms_output_from_restart_file.plot(
382
+ var_name,
383
+ time=0,
384
+ s=-1,
385
+ eta=1,
386
+ **kwargs,
387
+ include_boundary=include_boundary
388
+ )
389
+ roms_output_from_restart_file.plot(
390
+ var_name,
391
+ time=0,
392
+ s=-1,
393
+ xi=0,
394
+ **kwargs,
395
+ include_boundary=include_boundary
396
+ )
397
+ roms_output_from_restart_file.plot(
398
+ var_name,
399
+ time=0,
400
+ s=-1,
401
+ xi=1,
402
+ **kwargs,
403
+ include_boundary=include_boundary
404
+ )
405
+
406
+ for include_boundary in [False, True]:
407
+ roms_output_from_restart_file.plot(
408
+ "zeta", time=0, **kwargs, include_boundary=include_boundary
409
+ )
410
+ roms_output_from_restart_file.plot(
411
+ "zeta", time=0, eta=0, **kwargs, include_boundary=include_boundary
412
+ )
413
+ roms_output_from_restart_file.plot(
414
+ "zeta", time=0, eta=1, **kwargs, include_boundary=include_boundary
415
+ )
416
+ roms_output_from_restart_file.plot(
417
+ "zeta", time=0, xi=0, **kwargs, include_boundary=include_boundary
418
+ )
419
+ roms_output_from_restart_file.plot(
420
+ "zeta", time=0, xi=1, **kwargs, include_boundary=include_boundary
421
+ )
259
422
 
260
423
 
261
424
  def test_plot_errors(roms_output_from_restart_file, use_dask):