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
@@ -5,7 +5,8 @@ from roms_tools import Grid, SurfaceForcing
5
5
  from roms_tools.download import download_test_data
6
6
  import textwrap
7
7
  from pathlib import Path
8
- from conftest import calculate_file_hash
8
+ import logging
9
+ from conftest import calculate_data_hash
9
10
 
10
11
 
11
12
  @pytest.fixture
@@ -163,7 +164,9 @@ def grid_that_lies_west_of_dateline_more_than_five_degrees_away():
163
164
  "grid_that_lies_west_of_dateline_more_than_five_degrees_away",
164
165
  ],
165
166
  )
166
- def test_successful_initialization_with_regional_data(grid_fixture, request, use_dask):
167
+ def test_successful_initialization_with_regional_data(
168
+ grid_fixture, request, caplog, use_dask
169
+ ):
167
170
  """Test the initialization of SurfaceForcing with regional ERA5 data.
168
171
 
169
172
  The test is performed twice:
@@ -178,16 +181,17 @@ def test_successful_initialization_with_regional_data(grid_fixture, request, use
178
181
 
179
182
  grid = request.getfixturevalue(grid_fixture)
180
183
 
181
- for use_coarse_grid in [False, True]:
182
- sfc_forcing = SurfaceForcing(
183
- grid=grid,
184
- use_coarse_grid=use_coarse_grid,
185
- start_time=start_time,
186
- end_time=end_time,
187
- source={"name": "ERA5", "path": fname},
188
- correct_radiation=True,
189
- use_dask=use_dask,
190
- )
184
+ for coarse_grid_mode in ["always", "never"]:
185
+ with caplog.at_level(logging.INFO):
186
+ sfc_forcing = SurfaceForcing(
187
+ grid=grid,
188
+ start_time=start_time,
189
+ end_time=end_time,
190
+ source={"name": "ERA5", "path": fname},
191
+ correct_radiation=True,
192
+ coarse_grid_mode=coarse_grid_mode,
193
+ use_dask=use_dask,
194
+ )
191
195
 
192
196
  assert sfc_forcing.ds is not None
193
197
  assert "uwnd" in sfc_forcing.ds
@@ -208,10 +212,15 @@ def test_successful_initialization_with_regional_data(grid_fixture, request, use
208
212
  }
209
213
  assert sfc_forcing.ds.coords["time"].attrs["units"] == "days"
210
214
 
211
- if use_coarse_grid:
215
+ if coarse_grid_mode == "always":
212
216
  assert sfc_forcing.use_coarse_grid
213
- else:
217
+ assert (
218
+ "Data will be interpolated onto grid coarsened by factor 2."
219
+ in caplog.text
220
+ )
221
+ elif coarse_grid_mode == "never":
214
222
  assert not sfc_forcing.use_coarse_grid
223
+ assert "Data will be interpolated onto fine grid." in caplog.text
215
224
 
216
225
  sfc_forcing.plot("uwnd", time=0)
217
226
  sfc_forcing.plot("vwnd", time=0)
@@ -239,12 +248,12 @@ def test_nan_detection_initialization_with_regional_data(
239
248
 
240
249
  grid = request.getfixturevalue(grid_fixture)
241
250
 
242
- for use_coarse_grid in [True, False]:
251
+ for coarse_grid_mode in ["always", "never"]:
243
252
  with pytest.raises(ValueError, match="NaN values found"):
244
253
 
245
254
  SurfaceForcing(
246
255
  grid=grid,
247
- use_coarse_grid=use_coarse_grid,
256
+ coarse_grid_mode=coarse_grid_mode,
248
257
  start_time=start_time,
249
258
  end_time=end_time,
250
259
  source={"name": "ERA5", "path": fname},
@@ -266,14 +275,14 @@ def test_no_longitude_intersection_initialization_with_regional_data(
266
275
 
267
276
  fname = Path(download_test_data("ERA5_regional_test_data.nc"))
268
277
 
269
- for use_coarse_grid in [True, False]:
278
+ for coarse_grid_mode in ["always", "never"]:
270
279
  with pytest.raises(
271
280
  ValueError, match="Selected longitude range does not intersect with dataset"
272
281
  ):
273
282
 
274
283
  SurfaceForcing(
275
284
  grid=grid_that_straddles_180_degree_meridian,
276
- use_coarse_grid=use_coarse_grid,
285
+ coarse_grid_mode=coarse_grid_mode,
277
286
  start_time=start_time,
278
287
  end_time=end_time,
279
288
  source={"name": "ERA5", "path": fname},
@@ -308,10 +317,10 @@ def test_successful_initialization_with_global_data(grid_fixture, request, use_d
308
317
 
309
318
  grid = request.getfixturevalue(grid_fixture)
310
319
 
311
- for use_coarse_grid in [True, False]:
320
+ for coarse_grid_mode in ["always", "never"]:
312
321
  sfc_forcing = SurfaceForcing(
313
322
  grid=grid,
314
- use_coarse_grid=use_coarse_grid,
323
+ coarse_grid_mode=coarse_grid_mode,
315
324
  start_time=start_time,
316
325
  end_time=end_time,
317
326
  source={"name": "ERA5", "path": fname},
@@ -336,12 +345,59 @@ def test_successful_initialization_with_global_data(grid_fixture, request, use_d
336
345
  assert sfc_forcing.ds.attrs["source"] == "ERA5"
337
346
  assert sfc_forcing.ds.coords["time"].attrs["units"] == "days"
338
347
 
339
- if use_coarse_grid:
348
+ if coarse_grid_mode == "always":
340
349
  assert sfc_forcing.use_coarse_grid
341
- else:
350
+ elif coarse_grid_mode == "never":
342
351
  assert not sfc_forcing.use_coarse_grid
343
352
 
344
353
 
354
+ def test_start_time_end_time_error(use_dask):
355
+ """Test error when start_time and end_time are not both provided or both None."""
356
+ # Case 1: Only start_time provided
357
+ with pytest.raises(
358
+ ValueError, match="Both `start_time` and `end_time` must be provided together"
359
+ ):
360
+ SurfaceForcing(
361
+ grid=None,
362
+ start_time=datetime(2022, 1, 1),
363
+ end_time=None, # end_time is None, should raise an error
364
+ source={"name": "ERA5", "path": "era5_data.nc"},
365
+ use_dask=use_dask,
366
+ )
367
+
368
+ # Case 2: Only end_time provided
369
+ with pytest.raises(
370
+ ValueError, match="Both `start_time` and `end_time` must be provided together"
371
+ ):
372
+ SurfaceForcing(
373
+ grid=None,
374
+ start_time=None, # start_time is None, should raise an error
375
+ end_time=datetime(2022, 1, 2),
376
+ source={"name": "ERA5", "path": "era5_data.nc"},
377
+ use_dask=use_dask,
378
+ )
379
+
380
+
381
+ def test_start_time_end_time_warning(grid_that_straddles_dateline, use_dask, caplog):
382
+ """Test that a warning is triggered when both start_time and end_time are None."""
383
+ fname = Path(download_test_data("ERA5_regional_test_data.nc"))
384
+
385
+ with caplog.at_level(logging.INFO):
386
+ SurfaceForcing(
387
+ grid=grid_that_straddles_dateline,
388
+ start_time=None,
389
+ end_time=None,
390
+ source={"name": "ERA5", "path": fname},
391
+ use_dask=use_dask,
392
+ )
393
+
394
+ # Verify the warning message in the log
395
+ assert (
396
+ "Both `start_time` and `end_time` are None. No time filtering will be applied to the source data."
397
+ in caplog.text
398
+ )
399
+
400
+
345
401
  def test_nans_filled_in(grid_that_straddles_dateline, use_dask):
346
402
  """Test that the surface forcing fields contain no NaNs.
347
403
 
@@ -356,10 +412,10 @@ def test_nans_filled_in(grid_that_straddles_dateline, use_dask):
356
412
  fname = Path(download_test_data("ERA5_regional_test_data.nc"))
357
413
  fname_bgc = Path(download_test_data("CESM_surface_global_test_data_climatology.nc"))
358
414
 
359
- for use_coarse_grid in [True, False]:
415
+ for coarse_grid_mode in ["always", "never"]:
360
416
  sfc_forcing = SurfaceForcing(
361
417
  grid=grid_that_straddles_dateline,
362
- use_coarse_grid=use_coarse_grid,
418
+ coarse_grid_mode=coarse_grid_mode,
363
419
  start_time=start_time,
364
420
  end_time=end_time,
365
421
  source={"name": "ERA5", "path": fname},
@@ -375,7 +431,7 @@ def test_nans_filled_in(grid_that_straddles_dateline, use_dask):
375
431
 
376
432
  sfc_forcing = SurfaceForcing(
377
433
  grid=grid_that_straddles_dateline,
378
- use_coarse_grid=use_coarse_grid,
434
+ coarse_grid_mode=coarse_grid_mode,
379
435
  start_time=start_time,
380
436
  end_time=end_time,
381
437
  source={"name": "CESM_REGRIDDED", "path": fname_bgc, "climatology": True},
@@ -479,6 +535,57 @@ def test_surface_forcing_pco2_replication(sfc_forcing_fixture, request):
479
535
  )
480
536
 
481
537
 
538
+ def test_determine_usage_coarse_grid():
539
+ # ERA5 data with 1/4 degree resolution spanning [-50E, 30E] and [40N, 80N]
540
+ fname = download_test_data("ERA5_regional_test_data.nc")
541
+
542
+ # at 50N, 1/4 degree of longitude is about 17.87 km; to automatically use the coarse grid, the ROMS grid needs to be of resolution < 17.87km / 2 = 8.9km
543
+ grid_10km = Grid(
544
+ nx=3, ny=3, size_x=30, size_y=30, center_lon=-10, center_lat=50, rot=0
545
+ )
546
+ surface_forcing = SurfaceForcing(
547
+ grid=grid_10km,
548
+ start_time=datetime(2020, 2, 1),
549
+ end_time=datetime(2020, 2, 2),
550
+ source={"name": "ERA5", "path": fname},
551
+ )
552
+ assert not surface_forcing.use_coarse_grid
553
+
554
+ grid_7km = Grid(
555
+ nx=3, ny=3, size_x=21, size_y=21, center_lon=-10, center_lat=50, rot=0
556
+ )
557
+ surface_forcing = SurfaceForcing(
558
+ grid=grid_7km,
559
+ start_time=datetime(2020, 2, 1),
560
+ end_time=datetime(2020, 2, 2),
561
+ source={"name": "ERA5", "path": fname},
562
+ )
563
+ assert surface_forcing.use_coarse_grid
564
+
565
+ # at 70N, 1/4 degree of longitude is about 9.5 km; to automatically use the coarse grid, the ROMS grid needs to be of resolution < 9.5km / 2 = 4.75km
566
+ grid_7km = Grid(
567
+ nx=3, ny=3, size_x=21, size_y=21, center_lon=-10, center_lat=70, rot=0
568
+ )
569
+ surface_forcing = SurfaceForcing(
570
+ grid=grid_7km,
571
+ start_time=datetime(2020, 2, 1),
572
+ end_time=datetime(2020, 2, 2),
573
+ source={"name": "ERA5", "path": fname},
574
+ )
575
+ assert not surface_forcing.use_coarse_grid
576
+
577
+ grid_4km = Grid(
578
+ nx=3, ny=3, size_x=12, size_y=12, center_lon=-10, center_lat=70, rot=0
579
+ )
580
+ surface_forcing = SurfaceForcing(
581
+ grid=grid_4km,
582
+ start_time=datetime(2020, 2, 1),
583
+ end_time=datetime(2020, 2, 2),
584
+ source={"name": "ERA5", "path": fname},
585
+ )
586
+ assert surface_forcing.use_coarse_grid
587
+
588
+
482
589
  @pytest.mark.parametrize(
483
590
  "sfc_forcing_fixture",
484
591
  [
@@ -499,15 +606,15 @@ def test_surface_forcing_save(sfc_forcing_fixture, request, tmp_path):
499
606
  str(tmp_path / file_str),
500
607
  ]: # test for Path object and str
501
608
 
502
- # Test saving without partitioning and grouping
503
- saved_filenames = sfc_forcing.save(filepath)
609
+ # Test saving without grouping
610
+ saved_filenames = sfc_forcing.save(filepath, group=False)
504
611
  filepath_str = str(Path(filepath).with_suffix(""))
505
612
  expected_filepath = Path(f"{filepath_str}.nc")
506
613
  assert saved_filenames == [expected_filepath]
507
614
  assert expected_filepath.exists()
508
615
  expected_filepath.unlink()
509
616
 
510
- # Test saving without partitioning but with grouping
617
+ # Test saving with grouping
511
618
  saved_filenames = sfc_forcing.save(filepath, group=True)
512
619
  filepath_str = str(Path(filepath).with_suffix(""))
513
620
  expected_filepath = Path(f"{filepath_str}_202002.nc")
@@ -515,17 +622,6 @@ def test_surface_forcing_save(sfc_forcing_fixture, request, tmp_path):
515
622
  assert expected_filepath.exists()
516
623
  expected_filepath.unlink()
517
624
 
518
- # Test saving with partitioning
519
- saved_filenames = sfc_forcing.save(filepath, np_eta=1, group=True)
520
-
521
- expected_filepath_list = [
522
- Path(filepath_str + f"_202002.{index}.nc") for index in range(1)
523
- ]
524
- assert saved_filenames == expected_filepath_list
525
- for expected_filepath in expected_filepath_list:
526
- assert expected_filepath.exists()
527
- expected_filepath.unlink()
528
-
529
625
 
530
626
  def test_surface_forcing_bgc_plot(bgc_surface_forcing):
531
627
  """Test plot method."""
@@ -543,15 +639,15 @@ def test_surface_forcing_bgc_save(bgc_surface_forcing, tmp_path):
543
639
  str(tmp_path / file_str),
544
640
  ]: # test for Path object and str
545
641
 
546
- # Test saving without partitioning and grouping
547
- saved_filenames = bgc_surface_forcing.save(filepath)
642
+ # Test saving without grouping
643
+ saved_filenames = bgc_surface_forcing.save(filepath, group=False)
548
644
  filepath_str = str(Path(filepath).with_suffix(""))
549
645
  expected_filepath = Path(f"{filepath_str}.nc")
550
646
  assert saved_filenames == [expected_filepath]
551
647
  assert expected_filepath.exists()
552
648
  expected_filepath.unlink()
553
649
 
554
- # Test saving without partitioning but with grouping
650
+ # Test saving with grouping
555
651
  saved_filenames = bgc_surface_forcing.save(filepath, group=True)
556
652
  filepath_str = str(Path(filepath).with_suffix(""))
557
653
  expected_filepath = Path(f"{filepath_str}_202002.nc")
@@ -559,17 +655,6 @@ def test_surface_forcing_bgc_save(bgc_surface_forcing, tmp_path):
559
655
  assert expected_filepath.exists()
560
656
  expected_filepath.unlink()
561
657
 
562
- # Test saving with partitioning
563
- saved_filenames = bgc_surface_forcing.save(filepath, np_xi=5, group=True)
564
-
565
- expected_filepath_list = [
566
- Path(filepath_str + f"_202002.{index}.nc") for index in range(5)
567
- ]
568
- assert saved_filenames == expected_filepath_list
569
- for expected_filepath in expected_filepath_list:
570
- assert expected_filepath.exists()
571
- expected_filepath.unlink()
572
-
573
658
 
574
659
  def test_surface_forcing_bgc_from_clim_save(
575
660
  bgc_surface_forcing_from_climatology, tmp_path
@@ -583,15 +668,17 @@ def test_surface_forcing_bgc_from_clim_save(
583
668
  str(tmp_path / file_str),
584
669
  ]: # test for Path object and str
585
670
 
586
- # Test saving without partitioning and grouping
587
- saved_filenames = bgc_surface_forcing_from_climatology.save(filepath)
671
+ # Test saving without grouping
672
+ saved_filenames = bgc_surface_forcing_from_climatology.save(
673
+ filepath, group=False
674
+ )
588
675
  filepath_str = str(Path(filepath).with_suffix(""))
589
676
  expected_filepath = Path(f"{filepath_str}.nc")
590
677
  assert saved_filenames == [expected_filepath]
591
678
  assert expected_filepath.exists()
592
679
  expected_filepath.unlink()
593
680
 
594
- # Test saving without partitioning but with grouping
681
+ # Test saving with grouping
595
682
  saved_filenames = bgc_surface_forcing_from_climatology.save(
596
683
  filepath, group=True
597
684
  )
@@ -601,19 +688,6 @@ def test_surface_forcing_bgc_from_clim_save(
601
688
  assert expected_filepath.exists()
602
689
  expected_filepath.unlink()
603
690
 
604
- # Test saving with partitioning and grouping
605
- saved_filenames = bgc_surface_forcing_from_climatology.save(
606
- filepath, np_eta=5, group=True
607
- )
608
-
609
- expected_filepath_list = [
610
- Path(filepath_str + f"_clim.{index}.nc") for index in range(5)
611
- ]
612
- assert saved_filenames == expected_filepath_list
613
- for expected_filepath in expected_filepath_list:
614
- assert expected_filepath.exists()
615
- expected_filepath.unlink()
616
-
617
691
 
618
692
  @pytest.mark.parametrize(
619
693
  "sfc_forcing_fixture",
@@ -675,8 +749,9 @@ def test_files_have_same_hash(sfc_forcing_fixture, request, tmp_path, use_dask):
675
749
  expected_filepath1 = f"{filepath_str1}_202002.nc"
676
750
  expected_filepath2 = f"{filepath_str2}_202002.nc"
677
751
 
678
- hash1 = calculate_file_hash(expected_filepath1)
679
- hash2 = calculate_file_hash(expected_filepath2)
752
+ # Only compare hash of datasets because metadata is non-deterministic with dask
753
+ hash1 = calculate_data_hash(expected_filepath1)
754
+ hash2 = calculate_data_hash(expected_filepath2)
680
755
 
681
756
  assert hash1 == hash2, f"Hashes do not match: {hash1} != {hash2}"
682
757
 
@@ -703,8 +778,9 @@ def test_files_have_same_hash_clim(
703
778
  expected_filepath1 = f"{filepath_str1}_clim.nc"
704
779
  expected_filepath2 = f"{filepath_str2}_clim.nc"
705
780
 
706
- hash1 = calculate_file_hash(expected_filepath1)
707
- hash2 = calculate_file_hash(expected_filepath2)
781
+ # Only compare hash of datasets because metadata is non-deterministic with dask
782
+ hash1 = calculate_data_hash(expected_filepath1)
783
+ hash2 = calculate_data_hash(expected_filepath2)
708
784
 
709
785
  assert hash1 == hash2, f"Hashes do not match: {hash1} != {hash2}"
710
786
 
@@ -4,7 +4,7 @@ import xarray as xr
4
4
  from roms_tools.download import download_test_data
5
5
  import textwrap
6
6
  from pathlib import Path
7
- from conftest import calculate_file_hash
7
+ from conftest import calculate_data_hash
8
8
 
9
9
 
10
10
  @pytest.fixture
@@ -185,7 +185,6 @@ def test_tidal_forcing_save(tidal_forcing, tmp_path):
185
185
  str(tmp_path / file_str),
186
186
  ]: # test for Path object and str
187
187
 
188
- # Test saving without partitioning
189
188
  saved_filenames = tidal_forcing.save(filepath)
190
189
  # Check if the .nc file was created
191
190
  filepath = Path(filepath).with_suffix(".nc")
@@ -194,18 +193,6 @@ def test_tidal_forcing_save(tidal_forcing, tmp_path):
194
193
  # Clean up the .nc file
195
194
  filepath.unlink()
196
195
 
197
- # Test saving with partitioning
198
- saved_filenames = tidal_forcing.save(filepath, np_eta=3, np_xi=3)
199
-
200
- filepath_str = str(filepath.with_suffix(""))
201
- expected_filepath_list = [
202
- Path(filepath_str + f".{index}.nc") for index in range(9)
203
- ]
204
- assert saved_filenames == expected_filepath_list
205
- for expected_filepath in expected_filepath_list:
206
- assert expected_filepath.exists()
207
- expected_filepath.unlink()
208
-
209
196
 
210
197
  def test_roundtrip_yaml(tidal_forcing, tmp_path, use_dask):
211
198
  """Test that creating a TidalForcing object, saving its parameters to yaml file, and
@@ -242,8 +229,9 @@ def test_files_have_same_hash(tidal_forcing, tmp_path, use_dask):
242
229
  tidal_forcing_from_file = TidalForcing.from_yaml(yaml_filepath, use_dask=use_dask)
243
230
  tidal_forcing_from_file.save(filepath2)
244
231
 
245
- hash1 = calculate_file_hash(filepath1)
246
- hash2 = calculate_file_hash(filepath2)
232
+ # Only compare hash of datasets because metadata is non-deterministic with dask
233
+ hash1 = calculate_data_hash(filepath1)
234
+ hash2 = calculate_data_hash(filepath2)
247
235
 
248
236
  assert hash1 == hash2, f"Hashes do not match: {hash1} != {hash2}"
249
237
 
@@ -15,6 +15,7 @@ def test_interpolate_from_climatology(use_dask):
15
15
 
16
16
  climatology = ERA5Correction(use_dask=use_dask)
17
17
  field = climatology.ds["ssr_corr"]
18
+ field["time"] = field["time"].dt.days
18
19
 
19
20
  interpolated_field = interpolate_from_climatology(field, "time", era5_times)
20
21
  assert len(interpolated_field.time) == len(era5_times)
@@ -70,7 +70,39 @@ def test_check_results(forcing_fixture, request):
70
70
 
71
71
  fname = _get_fname(forcing_fixture)
72
72
  expected_forcing_ds = xr.open_zarr(fname, decode_timedelta=False)
73
-
74
73
  forcing = request.getfixturevalue(forcing_fixture)
75
74
 
76
- xr.testing.assert_allclose(forcing.ds, expected_forcing_ds, rtol=1.0e-5)
75
+ xr.testing.assert_allclose(forcing.ds, expected_forcing_ds, rtol=1.0e-5, atol=1e-08)
76
+
77
+
78
+ @pytest.mark.parametrize(
79
+ "forcing_fixture",
80
+ [
81
+ "tidal_forcing",
82
+ "initial_conditions_with_bgc_from_climatology",
83
+ "surface_forcing",
84
+ "coarse_surface_forcing",
85
+ "corrected_surface_forcing",
86
+ "bgc_surface_forcing",
87
+ "bgc_surface_forcing_from_climatology",
88
+ "boundary_forcing",
89
+ "bgc_boundary_forcing_from_climatology",
90
+ ],
91
+ )
92
+ def test_dask_vs_no_dask(forcing_fixture, request, tmp_path, use_dask):
93
+ """Test comparing the forcing created with and without Dask on same platform."""
94
+
95
+ if not use_dask:
96
+ pytest.skip("Test only runs when --use_dask is specified")
97
+
98
+ # Get the forcing with Dask
99
+ forcing_with_dask = request.getfixturevalue(forcing_fixture)
100
+
101
+ filepath = tmp_path / "test.yaml"
102
+ forcing_with_dask.to_yaml(filepath)
103
+
104
+ # Get the forcing without Dask
105
+ forcing_without_dask = type(forcing_with_dask).from_yaml(filepath, use_dask=False)
106
+
107
+ # Compare the two datasets using assert_equal (only within the same platform)
108
+ xr.testing.assert_equal(forcing_with_dask.ds, forcing_without_dask.ds)
@@ -2,7 +2,7 @@ import pytest
2
2
  from pathlib import Path
3
3
  import xarray.testing as xrt
4
4
 
5
- from roms_tools.utils import partition, partition_netcdf
5
+ from roms_tools.tiling.partition import partition, partition_netcdf
6
6
  from roms_tools import Grid
7
7
 
8
8