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,17 +5,27 @@ from dataclasses import dataclass, field
5
5
  from typing import Dict, Union, List, Optional
6
6
  import matplotlib.pyplot as plt
7
7
  from pathlib import Path
8
+ import logging
8
9
  from datetime import datetime
9
10
  from roms_tools import Grid
10
11
  from roms_tools.regrid import LateralRegrid, VerticalRegrid
11
12
  from roms_tools.plot import _plot, _section_plot, _profile_plot, _line_plot
12
- from roms_tools.utils import transpose_dimensions
13
+ from roms_tools.utils import (
14
+ transpose_dimensions,
15
+ save_datasets,
16
+ get_dask_chunks,
17
+ interpolate_from_rho_to_u,
18
+ interpolate_from_rho_to_v,
19
+ )
20
+ from roms_tools.vertical_coordinate import (
21
+ compute_depth_coordinates,
22
+ compute_depth,
23
+ )
13
24
  from roms_tools.setup.datasets import GLORYSDataset, CESMBGCDataset
14
25
  from roms_tools.setup.utils import (
15
26
  nan_check,
16
27
  substitute_nans_by_fillvalue,
17
28
  get_variable_metadata,
18
- save_datasets,
19
29
  get_target_coords,
20
30
  rotate_velocities,
21
31
  compute_barotropic_velocity,
@@ -59,10 +69,17 @@ class InitialConditions:
59
69
  - A list of strings or Path objects containing multiple files.
60
70
  - "climatology" (bool): Indicates if the data is climatology data. Defaults to False.
61
71
 
72
+ adjust_depth_for_sea_surface_height : bool, optional
73
+ Whether to account for sea surface height variations when computing depth coordinates.
74
+ Defaults to `False`.
62
75
  model_reference_date : datetime, optional
63
76
  The reference date for the model. Defaults to January 1, 2000.
64
77
  use_dask: bool, optional
65
78
  Indicates whether to use dask for processing. If True, data is processed with dask; if False, data is processed eagerly. Defaults to False.
79
+ horizontal_chunk_size : int, optional
80
+ The chunk size used for horizontal partitioning for the vertical regridding when `use_dask = True`. Defaults to 50.
81
+ A larger number results in a bigger memory footprint but faster computations.
82
+ A smaller number results in a smaller memory footprint but slower computations.
66
83
  bypass_validation: bool, optional
67
84
  Indicates whether to skip validation checks in the processed data. When set to True,
68
85
  the validation process that ensures no NaN values exist at wet points
@@ -87,7 +104,9 @@ class InitialConditions:
87
104
  source: Dict[str, Union[str, Path, List[Union[str, Path]]]]
88
105
  bgc_source: Optional[Dict[str, Union[str, Path, List[Union[str, Path]]]]] = None
89
106
  model_reference_date: datetime = datetime(2000, 1, 1)
107
+ adjust_depth_for_sea_surface_height: bool = False
90
108
  use_dask: bool = False
109
+ horizontal_chunk_size: int = 50
91
110
  bypass_validation: bool = False
92
111
 
93
112
  ds: xr.Dataset = field(init=False, repr=False)
@@ -95,6 +114,8 @@ class InitialConditions:
95
114
  def __post_init__(self):
96
115
 
97
116
  self._input_checks()
117
+ # Dataset for depth coordinates
118
+ object.__setattr__(self, "ds_depth_coords", xr.Dataset())
98
119
 
99
120
  processed_fields = {}
100
121
  processed_fields = self._process_data(processed_fields, type="physics")
@@ -129,7 +150,8 @@ class InitialConditions:
129
150
  target_coords,
130
151
  buffer_points=20, # lateral fill needs good buffer from data margin
131
152
  )
132
-
153
+ # Enforce double precision to ensure reproducibility
154
+ data.convert_to_float64()
133
155
  data.extrapolate_deepest_to_bottom()
134
156
  data.apply_lateral_fill()
135
157
 
@@ -140,6 +162,7 @@ class InitialConditions:
140
162
 
141
163
  # lateral regridding
142
164
  lateral_regrid = LateralRegrid(target_coords, data.dim_names)
165
+
143
166
  for var_name in var_names:
144
167
  if var_name in data.var_names.keys():
145
168
  processed_fields[var_name] = lateral_regrid.apply(
@@ -148,60 +171,61 @@ class InitialConditions:
148
171
 
149
172
  # rotation of velocities and interpolation to u/v points
150
173
  if "u" in variable_info and "v" in variable_info:
151
- (processed_fields["u"], processed_fields["v"],) = rotate_velocities(
174
+ processed_fields["u"], processed_fields["v"] = rotate_velocities(
152
175
  processed_fields["u"],
153
176
  processed_fields["v"],
154
177
  target_coords["angle"],
155
178
  interpolate=True,
156
179
  )
157
180
 
158
- var_names_dict = {}
159
- for location in ["rho", "u", "v"]:
160
- var_names_dict[location] = [
181
+ var_names_dict = {
182
+ location: [
161
183
  name
162
184
  for name, info in variable_info.items()
163
185
  if info["location"] == location and info["is_3d"]
164
186
  ]
187
+ for location in ["rho", "u", "v"]
188
+ }
189
+
190
+ if type == "bgc":
191
+ # Ensure time coordinate matches that of physical variables
192
+ for var_name in variable_info.keys():
193
+ processed_fields[var_name] = processed_fields[var_name].assign_coords(
194
+ {"time": processed_fields["temp"]["time"]}
195
+ )
196
+
197
+ # Get depth coordinates
198
+ zeta = (
199
+ processed_fields["zeta"] if self.adjust_depth_for_sea_surface_height else 0
200
+ )
165
201
 
166
- # compute layer depth coordinates
167
- if len(var_names_dict["u"]) > 0 or len(var_names_dict["v"]) > 0:
168
- self._get_vertical_coordinates(
169
- type="layer",
170
- additional_locations=["u", "v"],
171
- )
172
- else:
173
- if len(var_names_dict["rho"]) > 0:
174
- self._get_vertical_coordinates(type="layer", additional_locations=[])
175
- # vertical regridding
202
+ for location in ["rho", "u", "v"]:
203
+ if len(var_names_dict[location]) > 0:
204
+ self._get_depth_coordinates(zeta, location, "layer")
205
+
206
+ # Vertical regridding
176
207
  for location in ["rho", "u", "v"]:
177
208
  if len(var_names_dict[location]) > 0:
178
209
  vertical_regrid = VerticalRegrid(
179
- self.grid.ds[f"layer_depth_{location}"],
210
+ self.ds_depth_coords[f"layer_depth_{location}"],
180
211
  data.ds[data.dim_names["depth"]],
181
212
  )
182
213
  for var_name in var_names_dict[location]:
183
214
  if var_name in processed_fields:
184
- processed_fields[var_name] = vertical_regrid.apply(
185
- processed_fields[var_name]
186
- )
187
-
188
- # compute barotropic velocities
215
+ field = processed_fields[var_name]
216
+ if self.use_dask:
217
+ field = field.chunk(
218
+ get_dask_chunks(location, self.horizontal_chunk_size)
219
+ )
220
+ processed_fields[var_name] = vertical_regrid.apply(field)
221
+
222
+ # Compute barotropic velocities
189
223
  if "u" in variable_info and "v" in variable_info:
190
- self._get_vertical_coordinates(
191
- type="interface",
192
- additional_locations=["u", "v"],
193
- )
194
224
  for location in ["u", "v"]:
225
+ self._get_depth_coordinates(zeta, location, "interface")
195
226
  processed_fields[f"{location}bar"] = compute_barotropic_velocity(
196
227
  processed_fields[location],
197
- self.grid.ds[f"interface_depth_{location}"],
198
- )
199
-
200
- if type == "bgc":
201
- # Ensure time coordinate matches that of physical variables
202
- for var_name in variable_info.keys():
203
- processed_fields[var_name] = processed_fields[var_name].assign_coords(
204
- {"time": processed_fields["temp"]["time"]}
228
+ self.ds_depth_coords[f"interface_depth_{location}"],
205
229
  )
206
230
 
207
231
  for var_name in processed_fields.keys():
@@ -212,6 +236,11 @@ class InitialConditions:
212
236
  return processed_fields
213
237
 
214
238
  def _input_checks(self):
239
+ # Check that ini_time is not None
240
+ if self.ini_time is None:
241
+ raise ValueError(
242
+ "`ini_time` must be a valid datetime object and cannot be None."
243
+ )
215
244
 
216
245
  if "name" not in self.source.keys():
217
246
  raise ValueError("`source` must include a 'name'.")
@@ -244,6 +273,12 @@ class InitialConditions:
244
273
  "climatology": self.bgc_source.get("climatology", False),
245
274
  },
246
275
  )
276
+ if self.adjust_depth_for_sea_surface_height:
277
+ logging.info("Sea surface height will be used to adjust depth coordinates.")
278
+ else:
279
+ logging.info(
280
+ "Sea surface height will NOT be used to adjust depth coordinates."
281
+ )
247
282
 
248
283
  def _get_data(self):
249
284
 
@@ -365,35 +400,61 @@ class InitialConditions:
365
400
 
366
401
  object.__setattr__(self, f"variable_info_{type}", variable_info)
367
402
 
368
- def _get_vertical_coordinates(self, type, additional_locations=["u", "v"]):
369
- """Retrieve layer and interface depth coordinates.
370
-
371
- This method computes and updates the layer and interface depth coordinates. It handles depth calculations for rho points and
372
- additional specified locations (u and v).
403
+ def _get_depth_coordinates(
404
+ self, zeta: xr.DataArray | float, location: str, depth_type: str = "layer"
405
+ ) -> None:
406
+ """Ensure depth coordinates are computed and stored for a given location and
407
+ depth type.
373
408
 
374
409
  Parameters
375
410
  ----------
376
- type : str
377
- The type of depth coordinate to retrieve. Valid options are:
378
- - "layer": Retrieves layer depth coordinates.
379
- - "interface": Retrieves interface depth coordinates.
380
-
381
- additional_locations : list of str, optional
382
- Specifies additional locations to compute depth coordinates for. Default is ["u", "v"].
383
- Valid options include:
384
- - "u": Computes depth coordinates for u points.
385
- - "v": Computes depth coordinates for v points.
386
-
387
- Updates
388
- -------
389
- self.grid.ds : xarray.Dataset
390
- The dataset is updated with the following vertical depth coordinates:
391
- - f"{type}_depth_rho": Depth coordinates at rho points.
392
- - f"{type}_depth_u": Depth coordinates at u points (if applicable).
393
- - f"{type}_depth_v": Depth coordinates at v points (if applicable).
411
+ zeta : xr.DataArray or float
412
+ Free-surface elevation (can be a scalar or a DataArray).
413
+ location : str
414
+ Grid location for depth computation ("rho", "u", or "v").
415
+ depth_type : str, optional
416
+ Type of depth coordinates to compute, by default "layer".
417
+
418
+ Notes
419
+ ------
420
+ Rather than calling compute_depth_coordinates from the vertical_coordinate.py module,
421
+ this method computes the depth coordinates from scratch because of optional chunking.
394
422
  """
423
+ key = f"{depth_type}_depth_{location}"
424
+
425
+ if key not in self.ds_depth_coords:
426
+ # Select the appropriate depth computation parameters
427
+ if depth_type == "layer":
428
+ Cs = self.grid.ds["Cs_r"]
429
+ sigma = self.grid.ds["sigma_r"]
430
+ elif depth_type == "interface":
431
+ Cs = self.grid.ds["Cs_w"]
432
+ sigma = self.grid.ds["sigma_w"]
433
+ else:
434
+ raise ValueError(
435
+ f"Invalid depth_type: {depth_type}. Choose 'layer' or 'interface'."
436
+ )
395
437
 
396
- self.grid.compute_depth_coordinates(type, additional_locations)
438
+ h = self.grid.ds["h"]
439
+
440
+ # Interpolate h and zeta to the specified location
441
+ if location == "u":
442
+ h = interpolate_from_rho_to_u(h)
443
+ if isinstance(zeta, xr.DataArray):
444
+ zeta = interpolate_from_rho_to_u(zeta)
445
+ elif location == "v":
446
+ h = interpolate_from_rho_to_v(h)
447
+ if isinstance(zeta, xr.DataArray):
448
+ zeta = interpolate_from_rho_to_v(zeta)
449
+
450
+ if self.use_dask:
451
+ h = h.chunk(get_dask_chunks(location, self.horizontal_chunk_size))
452
+ if self.adjust_depth_for_sea_surface_height:
453
+ zeta = zeta.chunk(
454
+ get_dask_chunks(location, self.horizontal_chunk_size)
455
+ )
456
+ depth = compute_depth(zeta, h, self.grid.ds.attrs["hc"], Cs, sigma)
457
+ self.ds_depth_coords[key] = depth
397
458
 
398
459
  def _write_into_dataset(self, processed_fields, d_meta):
399
460
 
@@ -407,7 +468,7 @@ class InitialConditions:
407
468
 
408
469
  # initialize vertical velocity to zero
409
470
  ds["w"] = xr.zeros_like(
410
- self.grid.ds["interface_depth_rho"].expand_dims(
471
+ (self.grid.ds["Cs_w"] * self.grid.ds["h"]).expand_dims(
411
472
  time=processed_fields["u"].time
412
473
  )
413
474
  ).astype(np.float32)
@@ -504,6 +565,9 @@ class InitialConditions:
504
565
  ds.attrs["roms_tools_version"] = roms_tools_version
505
566
  ds.attrs["ini_time"] = str(self.ini_time)
506
567
  ds.attrs["model_reference_date"] = str(self.model_reference_date)
568
+ ds.attrs["adjust_depth_for_sea_surface_height"] = str(
569
+ self.adjust_depth_for_sea_surface_height
570
+ )
507
571
  ds.attrs["source"] = self.source["name"]
508
572
  if self.bgc_source is not None:
509
573
  ds.attrs["bgc_source"] = self.bgc_source["name"]
@@ -637,7 +701,6 @@ class InitialConditions:
637
701
  loc = "rho"
638
702
  elif all(dim in field.dims for dim in ["eta_rho", "xi_u"]):
639
703
  loc = "u"
640
-
641
704
  elif all(dim in field.dims for dim in ["eta_v", "xi_rho"]):
642
705
  loc = "v"
643
706
  else:
@@ -656,47 +719,30 @@ class InitialConditions:
656
719
  if s is not None:
657
720
  layer_contours = False
658
721
  # Note that `layer_depth_{loc}` has already been computed during `__post_init__`.
659
- layer_depth = self.grid.ds[f"layer_depth_{loc}"]
660
- if layer_contours:
661
- if f"interface_depth_{loc}" not in self.grid.ds:
662
- if loc == "rho":
663
- self.get_vertical_coordinates(
664
- type="interface", additional_locations=[]
665
- )
666
- else:
667
- self.get_vertical_coordinates(
668
- type="interface", additional_locations=["u", "v"]
669
- )
670
- interface_depth = self.grid.ds[f"interface_depth_{loc}"]
671
- else:
672
- interface_depth = None
722
+ layer_depth = self.ds_depth_coords[f"layer_depth_{loc}"].squeeze()
673
723
 
674
724
  # Slice the field as desired
675
725
  def _slice_and_assign(
676
726
  field,
677
727
  mask,
678
728
  layer_depth,
679
- interface_depth,
680
729
  title,
681
730
  dim_name,
682
731
  dim_values,
683
732
  idx,
684
- layer_contours=False,
685
733
  ):
686
734
  if dim_name in field.dims:
687
735
  title = title + f", {dim_name} = {dim_values[idx].item()}"
688
736
  field = field.isel(**{dim_name: idx})
689
737
  mask = mask.isel(**{dim_name: idx})
690
738
  layer_depth = layer_depth.isel(**{dim_name: idx})
691
- if layer_contours:
692
- interface_depth = interface_depth.isel(**{dim_name: idx})
693
739
  if "s_rho" in field.dims:
694
740
  field = field.assign_coords({"layer_depth": layer_depth})
695
741
  else:
696
742
  raise ValueError(
697
743
  f"None of the expected dimensions ({dim_name}) found in field."
698
744
  )
699
- return field, mask, layer_depth, interface_depth, title
745
+ return field, mask, layer_depth, title
700
746
 
701
747
  title = field.long_name
702
748
  if s is not None:
@@ -708,29 +754,25 @@ class InitialConditions:
708
754
  depth_contours = False
709
755
 
710
756
  if eta is not None:
711
- field, mask, layer_depth, interface_depth, title = _slice_and_assign(
757
+ field, mask, layer_depth, title = _slice_and_assign(
712
758
  field,
713
759
  mask,
714
760
  layer_depth,
715
- interface_depth,
716
761
  title,
717
762
  "eta_rho" if "eta_rho" in field.dims else "eta_v",
718
763
  field.eta_rho if "eta_rho" in field.dims else field.eta_v,
719
764
  eta,
720
- layer_contours,
721
765
  )
722
766
 
723
767
  if xi is not None:
724
- field, mask, layer_depth, interface_depth, title = _slice_and_assign(
768
+ field, mask, layer_depth, title = _slice_and_assign(
725
769
  field,
726
770
  mask,
727
771
  layer_depth,
728
- interface_depth,
729
772
  title,
730
773
  "xi_rho" if "xi_rho" in field.dims else "xi_u",
731
774
  field.xi_rho if "xi_rho" in field.dims else field.xi_u,
732
775
  xi,
733
- layer_contours,
734
776
  )
735
777
 
736
778
  # Choose colorbar
@@ -757,19 +799,54 @@ class InitialConditions:
757
799
  c="g",
758
800
  )
759
801
  else:
760
- if not layer_contours:
761
- interface_depth = None
762
- else:
763
- # restrict number of layer_contours to 10 for the sake of plot clearity
764
- nr_layers = len(interface_depth["s_w"])
765
- selected_layers = np.linspace(
766
- 0, nr_layers - 1, min(nr_layers, 10), dtype=int
767
- )
768
- interface_depth = interface_depth.isel(s_w=selected_layers)
769
-
770
802
  if len(field.dims) == 2:
803
+ if layer_contours:
804
+ if loc == "rho":
805
+ # interface_depth_rho has not been computed yet
806
+ interface_depth = compute_depth_coordinates(
807
+ self.grid.ds,
808
+ self.ds.zeta,
809
+ depth_type="interface",
810
+ location=loc,
811
+ eta=eta,
812
+ xi=xi,
813
+ )
814
+ elif loc == "u":
815
+ index_kwargs = {}
816
+ if eta is not None:
817
+ index_kwargs["eta_rho"] = eta
818
+ if xi is not None:
819
+ index_kwargs["xi_u"] = xi
820
+
821
+ interface_depth = (
822
+ self.ds_depth_coords[f"interface_depth_{loc}"]
823
+ .isel(**index_kwargs)
824
+ .squeeze()
825
+ )
826
+ elif loc == "v":
827
+ index_kwargs = {}
828
+ if eta is not None:
829
+ index_kwargs["eta_v"] = eta
830
+ if xi is not None:
831
+ index_kwargs["xi_rho"] = xi
832
+
833
+ interface_depth = (
834
+ self.ds_depth_coords[f"interface_depth_{loc}"]
835
+ .isel(**index_kwargs)
836
+ .squeeze()
837
+ )
838
+
839
+ # restrict number of layer_contours to 10 for the sake of plot clearity
840
+ nr_layers = len(interface_depth["s_w"])
841
+ selected_layers = np.linspace(
842
+ 0, nr_layers - 1, min(nr_layers, 10), dtype=int
843
+ )
844
+ interface_depth = interface_depth.isel(s_w=selected_layers)
845
+ else:
846
+ interface_depth = None
847
+
771
848
  _section_plot(
772
- field.where(mask),
849
+ field,
773
850
  interface_depth=interface_depth,
774
851
  title=title,
775
852
  kwargs=kwargs,
@@ -781,36 +858,18 @@ class InitialConditions:
781
858
  else:
782
859
  _line_plot(field.where(mask), title=title, ax=ax)
783
860
 
784
- def save(
785
- self, filepath: Union[str, Path], np_eta: int = None, np_xi: int = None
786
- ) -> None:
787
- """Save the initial conditions information to a netCDF4 file.
788
-
789
- This method supports saving the dataset in two modes:
790
-
791
- 1. **Single File Mode (default)**:
792
-
793
- If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single netCDF4 file
794
- with the base filename specified by `filepath.nc`.
795
-
796
- 2. **Partitioned Mode**:
797
-
798
- - If either `np_eta` or `np_xi` is specified, the dataset is divided into spatial tiles along the eta-axis and xi-axis.
799
- - Each spatial tile is saved as a separate netCDF4 file.
861
+ def save(self, filepath: Union[str, Path]) -> None:
862
+ """Save the initial conditions information to one netCDF4 file.
800
863
 
801
864
  Parameters
802
865
  ----------
803
866
  filepath : Union[str, Path]
804
867
  The base path or filename where the dataset should be saved.
805
- np_eta : int, optional
806
- The number of partitions along the `eta` direction. If `None`, no spatial partitioning is performed.
807
- np_xi : int, optional
808
- The number of partitions along the `xi` direction. If `None`, no spatial partitioning is performed.
809
868
 
810
869
  Returns
811
870
  -------
812
- List[Path]
813
- A list of Path objects for the filenames that were saved.
871
+ Path
872
+ A `Path` object representing the location of the saved file.
814
873
  """
815
874
 
816
875
  # Ensure filepath is a Path object
@@ -820,17 +879,11 @@ class InitialConditions:
820
879
  if filepath.suffix == ".nc":
821
880
  filepath = filepath.with_suffix("")
822
881
 
823
- if self.use_dask:
824
- from dask.diagnostics import ProgressBar
825
-
826
- with ProgressBar():
827
- self.ds.load()
828
-
829
882
  dataset_list = [self.ds]
830
883
  output_filenames = [str(filepath)]
831
884
 
832
885
  saved_filenames = save_datasets(
833
- dataset_list, output_filenames, np_eta=np_eta, np_xi=np_xi
886
+ dataset_list, output_filenames, use_dask=self.use_dask
834
887
  )
835
888
 
836
889
  return saved_filenames
@@ -852,7 +905,6 @@ class InitialConditions:
852
905
  cls,
853
906
  filepath: Union[str, Path],
854
907
  use_dask: bool = False,
855
- bypass_validation: bool = False,
856
908
  ) -> "InitialConditions":
857
909
  """Create an instance of the InitialConditions class from a YAML file.
858
910
 
@@ -862,10 +914,6 @@ class InitialConditions:
862
914
  The path to the YAML file from which the parameters will be read.
863
915
  use_dask: bool, optional
864
916
  Indicates whether to use dask for processing. If True, data is processed with dask; if False, data is processed eagerly. Defaults to False.
865
- bypass_validation: bool, optional
866
- Indicates whether to skip validation checks in the processed data. When set to True,
867
- the validation process that ensures no NaN values exist at wet points
868
- in the processed dataset is bypassed. Defaults to False.
869
917
 
870
918
  Returns
871
919
  -------
@@ -880,5 +928,4 @@ class InitialConditions:
880
928
  grid=grid,
881
929
  **initial_conditions_params,
882
930
  use_dask=use_dask,
883
- bypass_validation=bypass_validation,
884
931
  )