roms-tools 1.3.0__py3-none-any.whl → 1.4.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 (308) hide show
  1. roms_tools/_version.py +1 -1
  2. roms_tools/setup/boundary_forcing.py +1 -1
  3. roms_tools/setup/datasets.py +278 -105
  4. roms_tools/setup/download.py +5 -0
  5. roms_tools/setup/fill.py +266 -331
  6. roms_tools/setup/initial_conditions.py +10 -11
  7. roms_tools/setup/mixins.py +29 -21
  8. roms_tools/setup/surface_forcing.py +3 -5
  9. roms_tools/setup/tides.py +44 -46
  10. roms_tools/setup/utils.py +41 -23
  11. roms_tools/tests/test_setup/test_boundary_forcing.py +1 -1
  12. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +1 -1
  13. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +1 -1
  14. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/0.0.0 +0 -0
  15. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/0.0.0 +0 -0
  16. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/0.0.0 +0 -0
  17. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0 +0 -0
  18. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/0.0.0 +0 -0
  19. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/0.0.0 +0 -0
  20. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/0.0.0 +0 -0
  21. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/0.0.0 +0 -0
  22. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/0.0.0 +0 -0
  23. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0 +0 -0
  24. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0 +0 -0
  25. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0 +0 -0
  26. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0 +0 -0
  27. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0 +0 -0
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/0.0.0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/0.0.0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/0.0.0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/0.0.0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/0.0.0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/0.0.0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/0.0.0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/0.0.0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/0.0.0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/0.0.0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/0.0.0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/0.0.0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/0.0.0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/0.0.0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/0.0.0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/0.0.0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/0.0.0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/0.0.0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/0.0.0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/0.0.0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/0.0.0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/0.0.0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/0.0.0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/0.0.0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/0.0.0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/0.0.0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/0.0.0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/0.0.0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/0.0.0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/0.0.0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/0.0.0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/0.0.0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/0.0.0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/0.0.0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/0.0.0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/0.0.0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/0.0.0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/0.0.0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/0.0.0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/0.0.0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/0.0.0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/0.0.0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/0.0.0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/0.0.0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/0.0.0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/0.0.0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/0.0.0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/0.0.0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/0.0.0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/0.0.0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/0.0.0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/0.0.0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/0.0.0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/0.0.0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/0.0.0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/0.0.0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/0.0.0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/0.0.0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/0.0.0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/0.0.0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/0.0.0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/0.0.0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/0.0.0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/0.0.0 +0 -0
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/0.0.0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/0.0.0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zattrs +1 -1
  111. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zmetadata +1 -1
  112. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/dust/0.0.0 +0 -0
  113. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/iron/0.0.0 +0 -0
  114. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nhy/0.0.0 +0 -0
  115. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/nox/0.0.0 +0 -0
  116. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air/0.0.0 +0 -0
  117. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air_alt/0.0.0 +0 -0
  118. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +1 -1
  119. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +1 -1
  120. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/dust/0.0.0 +0 -0
  121. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/iron/0.0.0 +0 -0
  122. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nhy/0.0.0 +0 -0
  123. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/nox/0.0.0 +0 -0
  124. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air/0.0.0 +0 -0
  125. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/0.0.0 +0 -0
  126. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zattrs +1 -1
  127. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zmetadata +1 -1
  128. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/0.0.0 +0 -0
  129. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/0.0.0 +0 -0
  130. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/0.0.0 +0 -0
  131. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/0.0.0 +0 -0
  132. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/0.0.0 +0 -0
  133. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/0.0.0 +0 -0
  134. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/0.0.0 +0 -0
  135. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/0.0.0 +0 -0
  136. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/0.0.0 +0 -0
  137. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/0.0 +0 -0
  138. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/0.0 +0 -0
  139. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/0.0 +0 -0
  140. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/0.0.0 +0 -0
  141. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/0.0.0 +0 -0
  142. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/0.0.0 +0 -0
  143. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/0.0.0 +0 -0
  144. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/0.0 +0 -0
  145. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/0.0 +0 -0
  146. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/0.0 +0 -0
  147. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/0.0 +0 -0
  148. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/0.0 +0 -0
  149. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/0.0 +0 -0
  150. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/.zattrs +1 -1
  151. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/.zmetadata +8 -8
  152. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/Tair/.zarray +1 -1
  153. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/Tair/0.0.0 +0 -0
  154. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/lwrad/.zarray +1 -1
  155. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/lwrad/0.0.0 +0 -0
  156. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/qair/.zarray +1 -1
  157. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/qair/0.0.0 +0 -0
  158. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/rain/.zarray +1 -1
  159. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/rain/0.0.0 +0 -0
  160. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/swrad/.zarray +1 -1
  161. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/swrad/0.0.0 +0 -0
  162. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/uwnd/.zarray +1 -1
  163. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/uwnd/0.0.0 +0 -0
  164. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/vwnd/.zarray +1 -1
  165. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/vwnd/0.0.0 +0 -0
  166. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/.zattrs +1 -1
  167. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/.zmetadata +8 -8
  168. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/Tair/.zarray +1 -1
  169. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/Tair/0.0.0 +0 -0
  170. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/lwrad/.zarray +1 -1
  171. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/lwrad/0.0.0 +0 -0
  172. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/qair/.zarray +1 -1
  173. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/qair/0.0.0 +0 -0
  174. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/rain/.zarray +1 -1
  175. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/rain/0.0.0 +0 -0
  176. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/swrad/.zarray +1 -1
  177. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/swrad/0.0.0 +0 -0
  178. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/uwnd/.zarray +1 -1
  179. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/uwnd/0.0.0 +0 -0
  180. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/vwnd/.zarray +1 -1
  181. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/vwnd/0.0.0 +0 -0
  182. roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +1 -1
  183. roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +1 -1
  184. roms_tools/tests/test_setup/test_data/grid.zarr/angle/0.0 +0 -0
  185. roms_tools/tests/test_setup/test_data/grid.zarr/angle_coarse/0.0 +0 -0
  186. roms_tools/tests/test_setup/test_data/grid.zarr/f/0.0 +0 -0
  187. roms_tools/tests/test_setup/test_data/grid.zarr/h/0.0 +0 -0
  188. roms_tools/tests/test_setup/test_data/grid.zarr/lat_coarse/0.0 +0 -0
  189. roms_tools/tests/test_setup/test_data/grid.zarr/lat_rho/0.0 +0 -0
  190. roms_tools/tests/test_setup/test_data/grid.zarr/lat_u/0.0 +0 -0
  191. roms_tools/tests/test_setup/test_data/grid.zarr/lat_v/0.0 +0 -0
  192. roms_tools/tests/test_setup/test_data/grid.zarr/pm/0.0 +0 -0
  193. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +1 -1
  194. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +1 -1
  195. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle/0.0 +0 -0
  196. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle_coarse/0.0 +0 -0
  197. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/f/0.0 +0 -0
  198. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/0.0 +0 -0
  199. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_coarse/0.0 +0 -0
  200. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_rho/0.0 +0 -0
  201. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_u/0.0 +0 -0
  202. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_v/0.0 +0 -0
  203. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_coarse/0.0 +0 -0
  204. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_rho/0.0 +0 -0
  205. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_u/0.0 +0 -0
  206. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_v/0.0 +0 -0
  207. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pm/0.0 +0 -0
  208. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pn/0.0 +0 -0
  209. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zattrs +1 -1
  210. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zmetadata +1 -1
  211. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/0.0.0.0 +0 -0
  212. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/0.0.0.0 +0 -0
  213. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/0.0.0.0 +0 -0
  214. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/0.0.0.0 +0 -0
  215. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/0.0.0.0 +0 -0
  216. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/0.0.0.0 +0 -0
  217. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/0.0.0.0 +0 -0
  218. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/0.0.0.0 +0 -0
  219. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/0.0.0.0 +0 -0
  220. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/0.0.0.0 +0 -0
  221. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/0.0.0.0 +0 -0
  222. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/0.0.0.0 +0 -0
  223. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/0.0.0.0 +0 -0
  224. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/0.0.0.0 +0 -0
  225. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/0.0.0.0 +0 -0
  226. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/0.0.0.0 +0 -0
  227. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/0.0.0.0 +0 -0
  228. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/0.0.0.0 +0 -0
  229. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/0.0.0.0 +0 -0
  230. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/0.0.0.0 +0 -0
  231. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/0.0.0.0 +0 -0
  232. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/0.0.0.0 +0 -0
  233. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/0.0.0.0 +0 -0
  234. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/0.0.0.0 +0 -0
  235. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/0.0.0.0 +0 -0
  236. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/0.0.0.0 +0 -0
  237. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/0.0.0.0 +0 -0
  238. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/0.0.0.0 +0 -0
  239. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/0.0.0.0 +0 -0
  240. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/0.0.0.0 +0 -0
  241. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/0.0.0.0 +0 -0
  242. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/0.0.0.0 +0 -0
  243. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/0.0.0.0 +0 -0
  244. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/0.0.0.0 +0 -0
  245. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/0.0.0 +0 -0
  246. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/0.0.0.0 +0 -0
  247. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/0.0.0 +0 -0
  248. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zeta/0.0.0 +0 -0
  249. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/0.0.0.0 +0 -0
  250. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/.zattrs +1 -1
  251. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/.zmetadata +8 -8
  252. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/Tair/.zarray +1 -1
  253. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/Tair/0.0.0 +0 -0
  254. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/lwrad/.zarray +1 -1
  255. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/lwrad/0.0.0 +0 -0
  256. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/qair/.zarray +1 -1
  257. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/qair/0.0.0 +0 -0
  258. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/rain/.zarray +1 -1
  259. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/rain/0.0.0 +0 -0
  260. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/swrad/.zarray +1 -1
  261. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/swrad/0.0.0 +0 -0
  262. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/uwnd/.zarray +1 -1
  263. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/uwnd/0.0.0 +0 -0
  264. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/vwnd/.zarray +1 -1
  265. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/vwnd/0.0.0 +0 -0
  266. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/.zattrs +1 -1
  267. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/.zmetadata +2 -4
  268. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/omega/.zattrs +1 -3
  269. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/pot_Im/0.0.0 +0 -0
  270. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/pot_Re/0.0.0 +0 -0
  271. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/ssh_Im/0.0.0 +0 -0
  272. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/ssh_Re/0.0.0 +0 -0
  273. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/0.0.0 +0 -0
  274. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/0.0.0 +0 -0
  275. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/0.0.0 +0 -0
  276. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/0.0.0 +0 -0
  277. roms_tools/tests/test_setup/test_datasets.py +280 -211
  278. roms_tools/tests/test_setup/test_fill.py +177 -0
  279. roms_tools/tests/test_setup/test_initial_conditions.py +5 -3
  280. roms_tools/tests/test_setup/test_surface_forcing.py +2 -2
  281. roms_tools/tests/test_setup/test_tides.py +5 -2
  282. roms_tools/tests/test_setup/test_validation.py +1 -1
  283. {roms_tools-1.3.0.dist-info → roms_tools-1.4.0.dist-info}/METADATA +11 -3
  284. {roms_tools-1.3.0.dist-info → roms_tools-1.4.0.dist-info}/RECORD +287 -307
  285. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/Tair/1.0.0 +0 -0
  286. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/lwrad/1.0.0 +0 -0
  287. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/qair/1.0.0 +0 -0
  288. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/rain/1.0.0 +0 -0
  289. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/swrad/1.0.0 +0 -0
  290. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/uwnd/1.0.0 +0 -0
  291. roms_tools/tests/test_setup/test_data/coarse_surface_forcing.zarr/vwnd/1.0.0 +0 -0
  292. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/Tair/1.0.0 +0 -0
  293. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/lwrad/1.0.0 +0 -0
  294. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/qair/1.0.0 +0 -0
  295. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/rain/1.0.0 +0 -0
  296. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/swrad/1.0.0 +0 -0
  297. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/uwnd/1.0.0 +0 -0
  298. roms_tools/tests/test_setup/test_data/corrected_surface_forcing.zarr/vwnd/1.0.0 +0 -0
  299. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/Tair/1.0.0 +0 -0
  300. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/lwrad/1.0.0 +0 -0
  301. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/qair/1.0.0 +0 -0
  302. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/rain/1.0.0 +0 -0
  303. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/swrad/1.0.0 +0 -0
  304. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/uwnd/1.0.0 +0 -0
  305. roms_tools/tests/test_setup/test_data/surface_forcing.zarr/vwnd/1.0.0 +0 -0
  306. {roms_tools-1.3.0.dist-info → roms_tools-1.4.0.dist-info}/LICENSE +0 -0
  307. {roms_tools-1.3.0.dist-info → roms_tools-1.4.0.dist-info}/WHEEL +0 -0
  308. {roms_tools-1.3.0.dist-info → roms_tools-1.4.0.dist-info}/top_level.txt +0 -0
@@ -30,6 +30,7 @@ class InitialConditions(ROMSToolsMixins):
30
30
  Object representing the grid information used for the model.
31
31
  ini_time : datetime
32
32
  The date and time at which the initial conditions are set.
33
+ If no exact match is found, the closest time entry to `ini_time` within the time range [ini_time, ini_time + 24 hours] is selected.
33
34
  source : Dict[str, Union[str, Path, List[Union[str, Path]]], bool]
34
35
  Dictionary specifying the source of the physical initial condition data:
35
36
  - "name" (str): Name of the data source (e.g., "GLORYS").
@@ -41,7 +42,7 @@ class InitialConditions(ROMSToolsMixins):
41
42
  - "name" (str): Name of the BGC data source (e.g., "CESM_REGRIDDED").
42
43
  - "path" (Union[str, Path, List[Union[str, Path]]]): The path to the raw data file(s). Can be a single string (with or without wildcards),
43
44
  a single Path object, or a list of strings or Path objects containing multiple files.
44
- - "climatology" (bool): Indicates if the BGC data is climatology data. Defaults to True.
45
+ - "climatology" (bool): Indicates if the BGC data is climatology data. Defaults to False.
45
46
  model_reference_date : datetime, optional
46
47
  The reference date for the model. Defaults to January 1, 2000.
47
48
  use_dask: bool, optional
@@ -61,7 +62,7 @@ class InitialConditions(ROMSToolsMixins):
61
62
  ... bgc_source={
62
63
  ... "name": "CESM_REGRIDDED",
63
64
  ... "path": "bgc_data.nc",
64
- ... "climatology": True,
65
+ ... "climatology": False,
65
66
  ... },
66
67
  ... )
67
68
  """
@@ -106,12 +107,11 @@ class InitialConditions(ROMSToolsMixins):
106
107
  vars_3d = bgc_data.var_names.keys()
107
108
  bgc_data_vars = super().regrid_data(bgc_data, vars_2d, vars_3d, lon, lat)
108
109
 
109
- # Ensure time coordinate matches if climatology is applied in one case but not the other
110
- if not self.source["climatology"] and self.bgc_source["climatology"]:
111
- for var in bgc_data_vars.keys():
112
- bgc_data_vars[var] = bgc_data_vars[var].assign_coords(
113
- {"time": data_vars["temp"]["time"]}
114
- )
110
+ # Ensure time coordinate matches that of physical variables
111
+ for var in bgc_data_vars.keys():
112
+ bgc_data_vars[var] = bgc_data_vars[var].assign_coords(
113
+ {"time": data_vars["temp"]["time"]}
114
+ )
115
115
 
116
116
  # Combine data variables from physical and biogeochemical sources
117
117
  data_vars.update(bgc_data_vars)
@@ -155,13 +155,13 @@ class InitialConditions(ROMSToolsMixins):
155
155
  raise ValueError(
156
156
  "`bgc_source` must include a 'path' if it is provided."
157
157
  )
158
- # set self.bgc_source["climatology"] to True if not provided
158
+ # set self.bgc_source["climatology"] to False if not provided
159
159
  object.__setattr__(
160
160
  self,
161
161
  "bgc_source",
162
162
  {
163
163
  **self.bgc_source,
164
- "climatology": self.bgc_source.get("climatology", True),
164
+ "climatology": self.bgc_source.get("climatology", False),
165
165
  },
166
166
  )
167
167
 
@@ -188,7 +188,6 @@ class InitialConditions(ROMSToolsMixins):
188
188
  climatology=self.bgc_source["climatology"],
189
189
  use_dask=self.use_dask,
190
190
  )
191
- data.post_process()
192
191
  else:
193
192
  raise ValueError(
194
193
  'Only "CESM_REGRIDDED" is a valid option for bgc_source["name"].'
@@ -1,6 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
  from roms_tools.setup.grid import Grid
3
- from roms_tools.setup.fill import fill_and_interpolate
3
+ from roms_tools.setup.fill import LateralFill
4
4
  from roms_tools.setup.utils import (
5
5
  extrapolate_deepest_to_bottom,
6
6
  interpolate_from_rho_to_u,
@@ -106,18 +106,25 @@ class ROMSToolsMixins:
106
106
  # interpolate onto desired grid
107
107
  data_vars = {}
108
108
 
109
+ # Set up solver that does lateral fill
110
+ lateral_fill = LateralFill(
111
+ data.ds["mask"],
112
+ [data.dim_names["latitude"], data.dim_names["longitude"]],
113
+ )
114
+
109
115
  # 2d interpolation
110
- fill_dims = [data.dim_names["latitude"], data.dim_names["longitude"]]
111
116
  coords = {data.dim_names["latitude"]: lat, data.dim_names["longitude"]: lon}
112
117
  for var in vars_2d:
113
- mask = xr.where(data.ds[data.var_names[var]].isel(time=0).isnull(), 0, 1)
114
-
115
- data_vars[var] = fill_and_interpolate(
116
- data.ds[data.var_names[var]].astype(np.float64),
117
- mask,
118
- fill_dims=fill_dims,
119
- coords=coords,
120
- method="linear",
118
+ # Propagate ocean values into land via lateral fill
119
+ data.ds[data.var_names[var]] = lateral_fill.apply(
120
+ data.ds[data.var_names[var]].astype(np.float64)
121
+ )
122
+
123
+ # Regrid
124
+ data_vars[var] = (
125
+ data.ds[data.var_names[var]]
126
+ .interp(coords, method="linear")
127
+ .drop_vars(list(coords.keys()))
121
128
  )
122
129
 
123
130
  if vars_3d:
@@ -127,25 +134,26 @@ class ROMSToolsMixins:
127
134
  data.dim_names["latitude"]: lat,
128
135
  data.dim_names["longitude"]: lon,
129
136
  }
130
- # extrapolate deepest value all the way to bottom ("flooding")
137
+ # extrapolate deepest value all the way to bottom
131
138
  for var in vars_3d:
132
139
  data.ds[data.var_names[var]] = extrapolate_deepest_to_bottom(
133
140
  data.ds[data.var_names[var]], data.dim_names["depth"]
134
141
  )
135
- mask = xr.where(data.ds[data.var_names[var]].isel(time=0).isnull(), 0, 1)
142
+ # Propagate ocean values into land via lateral fill
143
+ data.ds[data.var_names[var]] = lateral_fill.apply(
144
+ data.ds[data.var_names[var]].astype(np.float64)
145
+ )
136
146
 
137
- # setting fillvalue_interp to None means that we allow extrapolation in the
147
+ # Regrid
148
+ # setting the fill value to None means that we allow extrapolation in the
138
149
  # interpolation step to avoid NaNs at the surface if the lowest depth in original
139
150
  # data is greater than zero
140
-
141
- data_vars[var] = fill_and_interpolate(
142
- data.ds[data.var_names[var]].astype(np.float64),
143
- mask,
144
- fill_dims=fill_dims,
145
- coords=coords,
146
- method="linear",
147
- fillvalue_interp=None,
151
+ data_vars[var] = (
152
+ data.ds[data.var_names[var]]
153
+ .interp(coords, method="linear", kwargs={"fill_value": None})
154
+ .drop_vars(list(coords.keys()))
148
155
  )
156
+
149
157
  if data.dim_names["time"] != "time":
150
158
  data_vars[var] = data_vars[var].rename({data.dim_names["time"]: "time"})
151
159
 
@@ -127,13 +127,12 @@ class SurfaceForcing(ROMSToolsMixins):
127
127
  correction_data.choose_subdomain(coords_correction, straddle=straddle)
128
128
  # apply mask from ERA5 data
129
129
  if "mask" in data.var_names.keys():
130
- mask = xr.where(
131
- data.ds[data.var_names["mask"]].isel(time=0).isnull(), 0, 1
132
- )
130
+ mask = data.ds["mask"]
133
131
  for var in correction_data.ds.data_vars:
134
132
  correction_data.ds[var] = xr.where(
135
133
  mask == 1, correction_data.ds[var], np.nan
136
134
  )
135
+ correction_data.ds["mask"] = mask
137
136
  vars_2d = ["swr_corr"]
138
137
  vars_3d = []
139
138
  # spatial interpolation
@@ -203,7 +202,6 @@ class SurfaceForcing(ROMSToolsMixins):
203
202
  if self.type == "physics":
204
203
  if self.source["name"] == "ERA5":
205
204
  data = ERA5Dataset(**data_dict)
206
- data.post_process()
207
205
  else:
208
206
  raise ValueError(
209
207
  'Only "ERA5" is a valid option for source["name"] when type is "physics".'
@@ -213,7 +211,6 @@ class SurfaceForcing(ROMSToolsMixins):
213
211
  if self.source["name"] == "CESM_REGRIDDED":
214
212
 
215
213
  data = CESMBGCSurfaceForcingDataset(**data_dict)
216
- data.post_process()
217
214
  else:
218
215
  raise ValueError(
219
216
  'Only "CESM_REGRIDDED" is a valid option for source["name"] when type is "bgc".'
@@ -301,6 +298,7 @@ class SurfaceForcing(ROMSToolsMixins):
301
298
  ds[time_coord].attrs["units"] = "days"
302
299
  if data.climatology:
303
300
  ds[time_coord].attrs["cycle_length"] = 365.25
301
+ ds.encoding["unlimited_dims"] = "time"
304
302
 
305
303
  if self.type == "bgc":
306
304
  ds = ds.drop_vars(["time"])
roms_tools/setup/tides.py CHANGED
@@ -8,7 +8,6 @@ from typing import Dict, Union, List
8
8
  from dataclasses import dataclass, field, asdict
9
9
  from roms_tools.setup.grid import Grid
10
10
  from roms_tools.setup.plot import _plot
11
- from roms_tools.setup.fill import fill_and_interpolate
12
11
  from roms_tools.setup.datasets import TPXODataset
13
12
  from roms_tools.setup.utils import (
14
13
  nan_check,
@@ -82,17 +81,12 @@ class TidalForcing(ROMSToolsMixins):
82
81
  straddle=straddle,
83
82
  )
84
83
 
85
- tides = self._get_corrected_tides(data)
86
-
87
84
  # select desired number of constituents
88
- for k in tides.keys():
89
- tides[k] = tides[k].isel(ntides=slice(None, self.ntides))
85
+ object.__setattr__(data, "ds", data.ds.isel(ntides=slice(None, self.ntides)))
90
86
 
91
- # interpolate onto desired grid
92
- coords = {"latitude": lat, "longitude": lon}
93
- mask = xr.where(data.ds.depth > 0, 1, 0)
87
+ self._correct_tides(data)
94
88
 
95
- varnames = [
89
+ vars_2d = [
96
90
  "ssh_Re",
97
91
  "ssh_Im",
98
92
  "pot_Re",
@@ -102,16 +96,9 @@ class TidalForcing(ROMSToolsMixins):
102
96
  "v_Re",
103
97
  "v_Im",
104
98
  ]
105
- data_vars = {}
106
-
107
- for var in varnames:
108
- data_vars[var] = fill_and_interpolate(
109
- tides[var],
110
- mask,
111
- list(coords.keys()),
112
- coords,
113
- method="linear",
114
- )
99
+ vars_3d = []
100
+
101
+ data_vars = super().regrid_data(data, vars_2d, vars_3d, lon, lat)
115
102
 
116
103
  data_vars = super().process_velocities(
117
104
  data_vars, angle, "u_Re", "v_Re", interpolate=False
@@ -132,7 +119,7 @@ class TidalForcing(ROMSToolsMixins):
132
119
 
133
120
  d_meta = get_variable_metadata()
134
121
  ds = self._write_into_dataset(data_vars, d_meta)
135
- ds["omega"] = tides["omega"]
122
+ ds["omega"] = data.ds["omega"]
136
123
 
137
124
  ds = self._add_global_metadata(ds)
138
125
 
@@ -412,13 +399,28 @@ class TidalForcing(ROMSToolsMixins):
412
399
  # Create and return an instance of TidalForcing
413
400
  return cls(grid=grid, **tidal_forcing_params, use_dask=use_dask)
414
401
 
415
- def _get_corrected_tides(self, data):
402
+ def _correct_tides(self, data):
403
+ """
404
+ Apply tidal corrections to the dataset.
405
+ This method corrects the dataset for equilibrium tides, self-attraction and loading (SAL) effects, and
406
+ adjusts phases and amplitudes of tidal elevations and transports using Egbert's correction.
407
+ Parameters
408
+ ----------
409
+ data : Dataset
410
+ The dataset containing tidal data, including variables for sea surface height (ssh), zonal and meridional
411
+ currents (u, v), and self-attraction and loading corrections (sal).
412
+ Returns
413
+ -------
414
+ None
415
+ The dataset is modified in-place with corrected real and imaginary components for ssh, u, v, and the
416
+ potential field ('pot_Re', 'pot_Im').
417
+ """
416
418
 
417
419
  # Get equilibrium tides
418
420
  tpc = compute_equilibrium_tide(
419
421
  data.ds[data.dim_names["longitude"]], data.ds[data.dim_names["latitude"]]
420
422
  )
421
- tpc = tpc.isel(**{data.dim_names["ntides"]: data.ds[data.dim_names["ntides"]]})
423
+ tpc = tpc.isel(ntides=data.ds["ntides"])
422
424
  # Correct for SAL
423
425
  tsc = self.allan_factor * (
424
426
  data.ds[data.var_names["sal_Re"]] + 1j * data.ds[data.var_names["sal_Im"]]
@@ -432,9 +434,9 @@ class TidalForcing(ROMSToolsMixins):
432
434
 
433
435
  # Apply correction for phases and amplitudes
434
436
  pf, pu, aa = egbert_correction(self.model_reference_date)
435
- pf = pf.isel(**{data.dim_names["ntides"]: data.ds[data.dim_names["ntides"]]})
436
- pu = pu.isel(**{data.dim_names["ntides"]: data.ds[data.dim_names["ntides"]]})
437
- aa = aa.isel(**{data.dim_names["ntides"]: data.ds[data.dim_names["ntides"]]})
437
+ pf = pf.isel(ntides=data.ds["ntides"])
438
+ pu = pu.isel(ntides=data.ds["ntides"])
439
+ aa = aa.isel(ntides=data.ds["ntides"])
438
440
 
439
441
  dt = (self.model_reference_date - data.reference_date).days * 3600 * 24
440
442
 
@@ -443,22 +445,18 @@ class TidalForcing(ROMSToolsMixins):
443
445
  tvc = pf * tvc * np.exp(1j * (data.ds["omega"] * dt + pu + aa))
444
446
  tpc = pf * tpc * np.exp(1j * (data.ds["omega"] * dt + pu + aa))
445
447
 
446
- tides = {
447
- "ssh_Re": thc.real,
448
- "ssh_Im": thc.imag,
449
- "u_Re": tuc.real,
450
- "u_Im": tuc.imag,
451
- "v_Re": tvc.real,
452
- "v_Im": tvc.imag,
453
- "pot_Re": tpc.real,
454
- "pot_Im": tpc.imag,
455
- "omega": data.ds["omega"],
456
- }
457
-
458
- for k in tides.keys():
459
- tides[k] = tides[k].rename({data.dim_names["ntides"]: "ntides"})
448
+ data.ds[data.var_names["ssh_Re"]] = thc.real
449
+ data.ds[data.var_names["ssh_Im"]] = thc.imag
450
+ data.ds[data.var_names["u_Re"]] = tuc.real
451
+ data.ds[data.var_names["u_Im"]] = tuc.imag
452
+ data.ds[data.var_names["v_Re"]] = tvc.real
453
+ data.ds[data.var_names["v_Im"]] = tvc.imag
454
+ data.ds["pot_Re"] = tpc.real
455
+ data.ds["pot_Im"] = tpc.imag
460
456
 
461
- return tides
457
+ # Update var_names dictionary
458
+ var_names = {**data.var_names, "pot_Re": "pot_Re", "pot_Im": "pot_Im"}
459
+ object.__setattr__(data, "var_names", var_names)
462
460
 
463
461
 
464
462
  def modified_julian_days(year, month, day, hour=0):
@@ -611,7 +609,7 @@ def egbert_correction(date):
611
609
  pf[12] = pftmp**2 # Ms4
612
610
  pf[13] = pftmp # 2n2
613
611
  pf[14] = 1.0 # S1
614
- pf = xr.DataArray(pf, dims="nc")
612
+ pf = xr.DataArray(pf, dims="ntides")
615
613
 
616
614
  putmp = (
617
615
  np.arctan(
@@ -647,7 +645,7 @@ def egbert_correction(date):
647
645
  pu[12] = putmp # Ms4
648
646
  pu[13] = putmp # 2n2
649
647
  pu[14] = 0.0 # S1
650
- pu = xr.DataArray(pu, dims="nc")
648
+ pu = xr.DataArray(pu, dims="ntides")
651
649
  # convert from degrees to radians
652
650
  pu = pu * rad
653
651
 
@@ -671,7 +669,7 @@ def egbert_correction(date):
671
669
  0.0, # S1
672
670
  ]
673
671
  ),
674
- dims="nc",
672
+ dims="ntides",
675
673
  )
676
674
 
677
675
  return pf, pu, aa
@@ -725,7 +723,7 @@ def compute_equilibrium_tide(lon, lat):
725
723
  0.000764, # S1
726
724
  ]
727
725
  ),
728
- dims="nc",
726
+ dims="ntides",
729
727
  )
730
728
  B = xr.DataArray(
731
729
  data=np.array(
@@ -747,12 +745,12 @@ def compute_equilibrium_tide(lon, lat):
747
745
  0.693, # S1
748
746
  ]
749
747
  ),
750
- dims="nc",
748
+ dims="ntides",
751
749
  )
752
750
 
753
751
  # types: 2 = semidiurnal, 1 = diurnal, 0 = long-term
754
752
  ityp = xr.DataArray(
755
- data=np.array([2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 2, 1]), dims="nc"
753
+ data=np.array([2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 2, 1]), dims="ntides"
756
754
  )
757
755
 
758
756
  d2r = np.pi / 180
roms_tools/setup/utils.py CHANGED
@@ -165,27 +165,31 @@ def interpolate_from_rho_to_v(field, method="additive"):
165
165
 
166
166
  def extrapolate_deepest_to_bottom(field: xr.DataArray, dim: str) -> xr.DataArray:
167
167
  """
168
- Extrapolate the deepest non-NaN values to the bottom along a specified dimension.
168
+ Extrapolates the deepest non-NaN values to the bottom along the specified dimension using forward fill.
169
+
170
+ This function assumes that the specified dimension is ordered from top to bottom (e.g., a vertical dimension like 'depth').
171
+ It fills `NaN` values below the deepest valid (non-NaN) entry along the given dimension by carrying forward the last valid value.
169
172
 
170
173
  Parameters
171
174
  ----------
172
175
  field : xr.DataArray
173
- The input data array containing NaN values that need to be filled. This array
174
- should have at least one dimension named by `dim`.
176
+ The input `xarray.DataArray` containing potential `NaN` values to be filled.
177
+ This array must have at least one dimension corresponding to `dim`, typically
178
+ a vertical axis such as 'depth' or 'height'.
175
179
  dim : str
176
- The name of the dimension along which to perform the interpolation and extrapolation.
177
- Typically, this would be a vertical dimension such as 'depth' or 's_rho'.
180
+ The name of the dimension along which to perform the forward fill operation.
181
+ The function assumes that this dimension is ordered from top to bottom, with
182
+ larger index values representing deeper or lower levels.
178
183
 
179
184
  Returns
180
185
  -------
181
- field_interpolated : xr.DataArray
182
- A new data array with NaN values along the specified dimension filled by nearest
183
- neighbor interpolation and extrapolation to the bottom. The original data array is not modified.
186
+ xr.DataArray
187
+ A new `xarray.DataArray` with the `NaN` values along the specified dimension
188
+ filled by forward filling the deepest valid values down to the bottom.
189
+ The original input data remains unmodified.
184
190
 
185
191
  """
186
- field_interpolated = field.interpolate_na(
187
- dim=dim, method="nearest", fill_value="extrapolate"
188
- )
192
+ field_interpolated = field.ffill(dim=dim)
189
193
 
190
194
  return field_interpolated
191
195
 
@@ -300,19 +304,19 @@ def interpolate_from_climatology(
300
304
  raise TypeError("Input 'field' must be an xarray.DataArray or xarray.Dataset.")
301
305
 
302
306
 
303
- def is_cftime_datetime(data_array: xr.DataArray) -> bool:
307
+ def get_time_type(data_array: xr.DataArray) -> str:
304
308
  """
305
- Checks if the xarray DataArray contains cftime datetime objects.
309
+ Determines the type of time values in the xarray DataArray.
306
310
 
307
311
  Parameters
308
312
  ----------
309
313
  data_array : xr.DataArray
310
- The xarray DataArray to be checked for cftime datetime objects.
314
+ The xarray DataArray to be checked for time data types.
311
315
 
312
316
  Returns
313
317
  -------
314
- bool
315
- True if the DataArray contains cftime datetime objects, False otherwise.
318
+ str
319
+ A string indicating the type of the time data: 'cftime', 'datetime', or 'int'.
316
320
 
317
321
  Raises
318
322
  ------
@@ -324,16 +328,26 @@ def is_cftime_datetime(data_array: xr.DataArray) -> bool:
324
328
  cftime.DatetimeNoLeap,
325
329
  cftime.DatetimeJulian,
326
330
  cftime.DatetimeGregorian,
331
+ cftime.Datetime360Day,
332
+ cftime.DatetimeProlepticGregorian,
327
333
  )
328
334
 
329
- # Check if any of the coordinate values are of cftime type
335
+ # Check if any of the coordinate values are of cftime, datetime, or integer type
330
336
  if isinstance(data_array.values, (np.ndarray, list)):
331
- # Check the dtype of the array; numpy datetime64 indicates it's not cftime
337
+ # Check if the data type is numpy datetime64, indicating standard datetime objects
332
338
  if data_array.values.dtype == "datetime64[ns]":
333
- return False
339
+ return "datetime"
334
340
 
335
- # Check if any of the values in the array are instances of cftime types
336
- return any(isinstance(value, cftime_types) for value in data_array.values)
341
+ # Check if any values in the array are instances of cftime types
342
+ if any(isinstance(value, cftime_types) for value in data_array.values):
343
+ return "cftime"
344
+
345
+ # Check if all values are of integer type (e.g., for indices or time steps)
346
+ if np.issubdtype(data_array.values.dtype, np.integer):
347
+ return "int"
348
+
349
+ # If none of the above conditions are met, raise a ValueError
350
+ raise ValueError("Unsupported data type for time values in input dataset.")
337
351
 
338
352
  # Handle unexpected types
339
353
  raise TypeError("DataArray values must be of type numpy.ndarray or list.")
@@ -599,8 +613,12 @@ def group_dataset(ds, filepath):
599
613
  if len(ds["abs_time"]) > 2:
600
614
  # Determine the frequency of the data
601
615
  abs_time_freq = pd.infer_freq(ds["abs_time"].to_index())
602
-
603
- if abs_time_freq in ["D", "H", "T", "S"]: # Daily or higher frequency
616
+ if abs_time_freq.lower() in [
617
+ "d",
618
+ "h",
619
+ "t",
620
+ "s",
621
+ ]: # Daily or higher frequency
604
622
  dataset_list, output_filenames = group_by_month(ds, filepath)
605
623
  else:
606
624
  dataset_list, output_filenames = group_by_year(ds, filepath)
@@ -199,7 +199,7 @@ def test_roundtrip_yaml(bdry_forcing_fixture, request, tmp_path, use_dask):
199
199
 
200
200
  def test_files_have_same_hash(boundary_forcing, tmp_path, use_dask):
201
201
 
202
- yaml_filepath = tmp_path / "test_yaml"
202
+ yaml_filepath = tmp_path / "test_yaml_.yaml"
203
203
  filepath1 = tmp_path / "test1.nc"
204
204
  filepath2 = tmp_path / "test2.nc"
205
205
 
@@ -3,7 +3,7 @@
3
3
  "end_time": "2021-06-30 00:00:00",
4
4
  "hc": 250.0,
5
5
  "model_reference_date": "2000-01-01 00:00:00",
6
- "roms_tools_version": "0.1.dev98",
6
+ "roms_tools_version": "0.1.dev152+dirty",
7
7
  "source": "CESM_REGRIDDED",
8
8
  "start_time": "2021-06-29 00:00:00",
9
9
  "theta_b": 2.0,
@@ -5,7 +5,7 @@
5
5
  "end_time": "2021-06-30 00:00:00",
6
6
  "hc": 250.0,
7
7
  "model_reference_date": "2000-01-01 00:00:00",
8
- "roms_tools_version": "0.1.dev98",
8
+ "roms_tools_version": "0.1.dev152+dirty",
9
9
  "source": "CESM_REGRIDDED",
10
10
  "start_time": "2021-06-29 00:00:00",
11
11
  "theta_b": 2.0,