roms-tools 1.4.1__py3-none-any.whl → 1.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 (252) hide show
  1. roms_tools/_version.py +1 -1
  2. roms_tools/setup/boundary_forcing.py +350 -166
  3. roms_tools/setup/datasets.py +57 -74
  4. roms_tools/setup/download.py +3 -6
  5. roms_tools/setup/fill.py +46 -18
  6. roms_tools/setup/grid.py +74 -113
  7. roms_tools/setup/initial_conditions.py +209 -76
  8. roms_tools/setup/regrid.py +198 -0
  9. roms_tools/setup/surface_forcing.py +167 -80
  10. roms_tools/setup/tides.py +135 -67
  11. roms_tools/setup/topography.py +9 -17
  12. roms_tools/setup/utils.py +251 -77
  13. roms_tools/setup/vertical_coordinate.py +4 -6
  14. roms_tools/tests/test_setup/test_boundary_forcing.py +6 -13
  15. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zattrs +1 -1
  16. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/.zmetadata +1 -1
  17. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/0.0.0 +0 -0
  18. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/0.0.0 +0 -0
  19. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/0.0.0 +0 -0
  20. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/0.0.0 +0 -0
  21. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0 +0 -0
  22. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/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_north/0.0.0 +0 -0
  27. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/0.0.0 +0 -0
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/0.0.0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/0.0.0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/0.0.0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/0.0.0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/0.0.0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/0.0.0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/0.0.0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/0.0.0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/0.0.0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/0.0.0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/0.0.0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/0.0.0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/0.0.0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/0.0.0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/0.0.0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/0.0.0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/0.0.0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/0.0.0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/0.0.0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/0.0.0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/0.0.0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/0.0.0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/0.0.0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/0.0.0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/0.0.0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/0.0.0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/0.0.0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/0.0.0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/0.0.0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/0.0.0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/0.0.0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/0.0.0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/0.0.0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/0.0.0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/0.0.0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/0.0.0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/0.0.0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/0.0.0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/0.0.0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/0.0.0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/0.0.0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/0.0.0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/0.0.0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/0.0.0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/0.0.0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/0.0.0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/0.0.0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/0.0.0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/0.0.0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/0.0.0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/0.0.0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/0.0.0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/0.0.0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/0.0.0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/0.0.0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/0.0.0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/0.0.0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/0.0.0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/0.0.0 +0 -0
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/0.0.0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/0.0.0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/0.0.0 +0 -0
  111. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/0.0.0 +0 -0
  112. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/0.0.0 +0 -0
  113. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/0.0.0 +0 -0
  114. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/0.0.0 +0 -0
  115. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/0.0.0 +0 -0
  116. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/0.0.0 +0 -0
  117. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/0.0.0 +0 -0
  118. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/0.0.0 +0 -0
  119. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/0.0.0 +0 -0
  120. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/0.0.0 +0 -0
  121. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/0.0.0 +0 -0
  122. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/0.0.0 +0 -0
  123. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/0.0.0 +0 -0
  124. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/0.0.0 +0 -0
  125. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/0.0.0 +0 -0
  126. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/0.0.0 +0 -0
  127. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/0.0.0 +0 -0
  128. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/0.0.0 +0 -0
  129. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/0.0.0 +0 -0
  130. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/0.0.0 +0 -0
  131. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/0.0.0 +0 -0
  132. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/0.0.0 +0 -0
  133. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/0.0.0 +0 -0
  134. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/0.0.0 +0 -0
  135. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/0.0.0 +0 -0
  136. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/0.0.0 +0 -0
  137. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/0.0.0 +0 -0
  138. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/0.0.0 +0 -0
  139. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/0.0.0 +0 -0
  140. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/0.0.0 +0 -0
  141. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/0.0.0 +0 -0
  142. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/0.0.0 +0 -0
  143. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/0.0.0 +0 -0
  144. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/0.0.0 +0 -0
  145. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zattrs +1 -1
  146. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/.zmetadata +1 -1
  147. roms_tools/tests/test_setup/test_data/bgc_surface_forcing.zarr/pco2_air_alt/0.0.0 +0 -0
  148. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zattrs +1 -1
  149. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/.zmetadata +1 -1
  150. roms_tools/tests/test_setup/test_data/bgc_surface_forcing_from_climatology.zarr/pco2_air_alt/0.0.0 +0 -0
  151. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zattrs +1 -1
  152. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/.zmetadata +1 -1
  153. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/0.0.0 +0 -0
  154. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/0.0.0 +0 -0
  155. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/0.0.0 +0 -0
  156. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/0.0.0 +0 -0
  157. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/0.0.0 +0 -0
  158. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/0.0.0 +0 -0
  159. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/0.0.0 +0 -0
  160. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/0.0.0 +0 -0
  161. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/0.0.0 +0 -0
  162. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/0.0.0 +0 -0
  163. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/0.0.0 +0 -0
  164. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/0.0.0 +0 -0
  165. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/0.0 +0 -0
  166. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/0.0 +0 -0
  167. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/0.0 +0 -0
  168. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/0.0 +0 -0
  169. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/0.0.0 +0 -0
  170. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/0.0.0 +0 -0
  171. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/0.0.0 +0 -0
  172. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/0.0.0 +0 -0
  173. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/0.0 +0 -0
  174. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/0.0 +0 -0
  175. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/0.0 +0 -0
  176. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/0.0 +0 -0
  177. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_east/0.0 +0 -0
  178. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zeta_south/0.0 +0 -0
  179. roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +2 -2
  180. roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +2 -62
  181. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +2 -2
  182. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +2 -62
  183. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zattrs +1 -1
  184. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/.zmetadata +1 -1
  185. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/0.0.0.0 +0 -0
  186. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/0.0.0.0 +0 -0
  187. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/0.0.0.0 +0 -0
  188. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/0.0.0.0 +0 -0
  189. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/0.0.0.0 +0 -0
  190. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/0.0.0.0 +0 -0
  191. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/0.0.0.0 +0 -0
  192. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/0.0.0.0 +0 -0
  193. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/0.0.0.0 +0 -0
  194. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/0.0.0.0 +0 -0
  195. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/0.0.0.0 +0 -0
  196. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/0.0.0.0 +0 -0
  197. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/0.0.0.0 +0 -0
  198. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/0.0.0.0 +0 -0
  199. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/0.0.0.0 +0 -0
  200. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/0.0.0.0 +0 -0
  201. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/0.0.0.0 +0 -0
  202. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/0.0.0.0 +0 -0
  203. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/0.0.0.0 +0 -0
  204. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/0.0.0.0 +0 -0
  205. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/0.0.0.0 +0 -0
  206. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/0.0.0.0 +0 -0
  207. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/0.0.0.0 +0 -0
  208. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/0.0.0.0 +0 -0
  209. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/0.0.0.0 +0 -0
  210. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/0.0.0.0 +0 -0
  211. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/0.0.0.0 +0 -0
  212. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/0.0.0.0 +0 -0
  213. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/0.0.0.0 +0 -0
  214. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/0.0.0.0 +0 -0
  215. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/0.0.0.0 +0 -0
  216. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/0.0.0.0 +0 -0
  217. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/0.0.0.0 +0 -0
  218. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/0.0.0.0 +0 -0
  219. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/0.0.0 +0 -0
  220. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/0.0.0.0 +0 -0
  221. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/0.0.0 +0 -0
  222. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zeta/0.0.0 +0 -0
  223. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/0.0.0.0 +0 -0
  224. roms_tools/tests/test_setup/test_datasets.py +8 -18
  225. roms_tools/tests/test_setup/test_fill.py +43 -14
  226. roms_tools/tests/test_setup/test_grid.py +9 -9
  227. roms_tools/tests/test_setup/test_initial_conditions.py +4 -7
  228. roms_tools/tests/test_setup/test_regrid.py +59 -0
  229. roms_tools/tests/test_setup/test_surface_forcing.py +74 -56
  230. roms_tools/tests/test_setup/test_tides.py +6 -10
  231. roms_tools/tests/test_setup/test_topography.py +2 -4
  232. roms_tools/tests/test_setup/test_vertical_coordinate.py +2 -6
  233. roms_tools/tests/test_utils.py +30 -30
  234. roms_tools/utils.py +6 -7
  235. {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/METADATA +2 -2
  236. {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/RECORD +239 -250
  237. roms_tools/setup/mixins.py +0 -231
  238. roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zarray +0 -22
  239. roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zattrs +0 -8
  240. roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/0.0 +0 -0
  241. roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zarray +0 -22
  242. roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zattrs +0 -8
  243. roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/0.0 +0 -0
  244. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zarray +0 -22
  245. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zattrs +0 -8
  246. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/0.0 +0 -0
  247. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zarray +0 -22
  248. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zattrs +0 -8
  249. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/0.0 +0 -0
  250. {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/LICENSE +0 -0
  251. {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/WHEEL +0 -0
  252. {roms_tools-1.4.1.dist-info → roms_tools-1.5.0.dist-info}/top_level.txt +0 -0
@@ -18,8 +18,7 @@ from roms_tools.setup.download import download_correction_data
18
18
 
19
19
  @dataclass(frozen=True, kw_only=True)
20
20
  class Dataset:
21
- """
22
- Represents forcing data on original grid.
21
+ """Represents forcing data on original grid.
23
22
 
24
23
  Parameters
25
24
  ----------
@@ -131,8 +130,7 @@ class Dataset:
131
130
  self.post_process()
132
131
 
133
132
  def load_data(self) -> xr.Dataset:
134
- """
135
- Load dataset from the specified file.
133
+ """Load dataset from the specified file.
136
134
 
137
135
  Returns
138
136
  -------
@@ -246,8 +244,7 @@ class Dataset:
246
244
  return ds
247
245
 
248
246
  def clean_up(self, ds: xr.Dataset) -> xr.Dataset:
249
- """
250
- Dummy method to be overridden by child classes to clean up the dataset.
247
+ """Dummy method to be overridden by child classes to clean up the dataset.
251
248
 
252
249
  This method is intended as a placeholder and should be implemented in subclasses
253
250
  to provide specific functionality.
@@ -265,8 +262,7 @@ class Dataset:
265
262
  return ds
266
263
 
267
264
  def check_dataset(self, ds: xr.Dataset) -> None:
268
- """
269
- Check if the dataset contains the specified variables and dimensions.
265
+ """Check if the dataset contains the specified variables and dimensions.
270
266
 
271
267
  Parameters
272
268
  ----------
@@ -293,8 +289,8 @@ class Dataset:
293
289
  )
294
290
 
295
291
  def select_relevant_fields(self, ds) -> xr.Dataset:
296
- """
297
- Selects and returns a subset of the dataset containing only the variables specified in `self.var_names`.
292
+ """Selects and returns a subset of the dataset containing only the variables
293
+ specified in `self.var_names`.
298
294
 
299
295
  Parameters
300
296
  ----------
@@ -305,7 +301,6 @@ class Dataset:
305
301
  -------
306
302
  xr.Dataset
307
303
  A dataset containing only the variables specified in `self.var_names`.
308
-
309
304
  """
310
305
 
311
306
  for var in ds.data_vars:
@@ -315,8 +310,8 @@ class Dataset:
315
310
  return ds
316
311
 
317
312
  def add_time_info(self, ds: xr.Dataset) -> xr.Dataset:
318
- """
319
- Dummy method to be overridden by child classes to add time information to the dataset.
313
+ """Dummy method to be overridden by child classes to add time information to the
314
+ dataset.
320
315
 
321
316
  This method is intended as a placeholder and should be implemented in subclasses
322
317
  to provide specific functionality for adding time-related information to the dataset.
@@ -334,8 +329,7 @@ class Dataset:
334
329
  return ds
335
330
 
336
331
  def select_relevant_times(self, ds) -> xr.Dataset:
337
- """
338
- Select a subset of the dataset based on the specified time range.
332
+ """Select a subset of the dataset based on the specified time range.
339
333
 
340
334
  This method filters the dataset to include all records between `start_time` and `end_time`.
341
335
  Additionally, it ensures that one record at or before `start_time` and one record at or
@@ -467,8 +461,7 @@ class Dataset:
467
461
  def ensure_dimension_is_ascending(
468
462
  self, ds: xr.Dataset, dim="latitude"
469
463
  ) -> xr.Dataset:
470
- """
471
- Ensure that the specified dimension in the dataset is in ascending order.
464
+ """Ensure that the specified dimension in the dataset is in ascending order.
472
465
 
473
466
  If the values along the specified dimension are in descending order, this function reverses the order of the dimension to make it ascending.
474
467
 
@@ -486,7 +479,6 @@ class Dataset:
486
479
  A new `xarray.Dataset` with the specified dimension in ascending order.
487
480
  If the dimension was already in ascending order, the original dataset is returned unchanged.
488
481
  If the dimension was in descending order, the dataset is returned with the dimension reversed.
489
-
490
482
  """
491
483
  # Make sure that latitude is ascending
492
484
  diff = np.diff(ds[self.dim_names[dim]])
@@ -496,8 +488,7 @@ class Dataset:
496
488
  return ds
497
489
 
498
490
  def check_if_global(self, ds) -> bool:
499
- """
500
- Checks if the dataset covers the entire globe in the longitude dimension.
491
+ """Checks if the dataset covers the entire globe in the longitude dimension.
501
492
 
502
493
  This function calculates the mean difference between consecutive longitude values.
503
494
  It then checks if the difference between the first and last longitude values (plus 360 degrees)
@@ -508,7 +499,6 @@ class Dataset:
508
499
  -------
509
500
  bool
510
501
  True if the dataset covers the entire globe in the longitude dimension, False otherwise.
511
-
512
502
  """
513
503
  dlon_mean = (
514
504
  ds[self.dim_names["longitude"]].diff(dim=self.dim_names["longitude"]).mean()
@@ -569,8 +559,8 @@ class Dataset:
569
559
  return ds_concatenated
570
560
 
571
561
  def post_process(self):
572
- """
573
- Placeholder method to be overridden by subclasses for dataset post-processing.
562
+ """Placeholder method to be overridden by subclasses for dataset post-
563
+ processing.
574
564
 
575
565
  Returns
576
566
  -------
@@ -582,10 +572,9 @@ class Dataset:
582
572
  def choose_subdomain(
583
573
  self, latitude_range, longitude_range, margin, straddle, return_subdomain=False
584
574
  ):
585
- """
586
- Selects a subdomain from the xarray Dataset based on specified latitude and longitude ranges,
587
- extending the selection by a specified margin. Handles longitude conversions to accommodate different
588
- longitude ranges.
575
+ """Selects a subdomain from the xarray Dataset based on specified latitude and
576
+ longitude ranges, extending the selection by a specified margin. Handles
577
+ longitude conversions to accommodate different longitude ranges.
589
578
 
590
579
  Parameters
591
580
  ----------
@@ -679,8 +668,7 @@ class Dataset:
679
668
 
680
669
  @dataclass(frozen=True, kw_only=True)
681
670
  class TPXODataset(Dataset):
682
- """
683
- Represents tidal data on the original grid from the TPXO dataset.
671
+ """Represents tidal data on the original grid from the TPXO dataset.
684
672
 
685
673
  Parameters
686
674
  ----------
@@ -732,8 +720,8 @@ class TPXODataset(Dataset):
732
720
  reference_date: datetime = datetime(1992, 1, 1)
733
721
 
734
722
  def clean_up(self, ds: xr.Dataset) -> xr.Dataset:
735
- """
736
- Clean up and standardize the dimensions and coordinates of the dataset for further processing.
723
+ """Clean up and standardize the dimensions and coordinates of the dataset for
724
+ further processing.
737
725
 
738
726
  This method performs the following operations:
739
727
  - Assigns new coordinate variables for 'omega', 'longitude', and 'latitude' based on existing dataset variables.
@@ -782,8 +770,7 @@ class TPXODataset(Dataset):
782
770
  return ds
783
771
 
784
772
  def check_number_constituents(self, ntides: int):
785
- """
786
- Checks if the number of constituents in the dataset is at least `ntides`.
773
+ """Checks if the number of constituents in the dataset is at least `ntides`.
787
774
 
788
775
  Parameters
789
776
  ----------
@@ -801,8 +788,8 @@ class TPXODataset(Dataset):
801
788
  )
802
789
 
803
790
  def post_process(self):
804
- """
805
- Apply a depth-based mask to the dataset, ensuring only positive depths are retained.
791
+ """Apply a depth-based mask to the dataset, ensuring only positive depths are
792
+ retained.
806
793
 
807
794
  This method checks if the 'depth' variable is present in the dataset. If found, a mask is created where
808
795
  depths greater than 0 are considered valid (mask value of 1). This mask is applied to all data variables
@@ -818,16 +805,17 @@ class TPXODataset(Dataset):
818
805
  if "depth" in self.var_names.keys():
819
806
  mask = xr.where(self.ds["depth"] > 0, 1, 0)
820
807
 
821
- for var in self.ds.data_vars:
822
- self.ds[var] = xr.where(mask == 1, self.ds[var], np.nan)
823
-
824
808
  self.ds["mask"] = mask
825
809
 
810
+ # Remove "depth" from var_names
811
+ updated_var_names = {**self.var_names} # Create a copy of the dictionary
812
+ updated_var_names.pop("depth", None) # Remove "depth" if it exists
813
+ object.__setattr__(self, "var_names", updated_var_names)
814
+
826
815
 
827
816
  @dataclass(frozen=True, kw_only=True)
828
817
  class GLORYSDataset(Dataset):
829
- """
830
- Represents GLORYS data on original grid.
818
+ """Represents GLORYS data on original grid.
831
819
 
832
820
  Parameters
833
821
  ----------
@@ -873,8 +861,8 @@ class GLORYSDataset(Dataset):
873
861
  climatology: Optional[bool] = False
874
862
 
875
863
  def post_process(self):
876
- """
877
- Apply a mask to the dataset based on the 'zeta' variable, with 0 where 'zeta' is NaN.
864
+ """Apply a mask to the dataset based on the 'zeta' variable, with 0 where 'zeta'
865
+ is NaN.
878
866
 
879
867
  This method creates a mask based on the
880
868
  first time step (time=0) of 'zeta'. The mask has 1 for valid data and 0 where 'zeta' is NaN. This mask is applied
@@ -885,7 +873,6 @@ class GLORYSDataset(Dataset):
885
873
  -------
886
874
  None
887
875
  The dataset is modified in-place by applying the mask to each variable.
888
-
889
876
  """
890
877
 
891
878
  mask = xr.where(
@@ -893,17 +880,21 @@ class GLORYSDataset(Dataset):
893
880
  0,
894
881
  1,
895
882
  )
896
-
897
- for var in self.ds.data_vars:
898
- self.ds[var] = xr.where(mask == 1, self.ds[var], np.nan)
883
+ mask_vel = xr.where(
884
+ self.ds[self.var_names["u"]]
885
+ .isel({self.dim_names["time"]: 0, self.dim_names["depth"]: 0})
886
+ .isnull(),
887
+ 0,
888
+ 1,
889
+ )
899
890
 
900
891
  self.ds["mask"] = mask
892
+ self.ds["mask_vel"] = mask_vel
901
893
 
902
894
 
903
895
  @dataclass(frozen=True, kw_only=True)
904
896
  class CESMDataset(Dataset):
905
- """
906
- Represents CESM data on original grid.
897
+ """Represents CESM data on original grid.
907
898
 
908
899
  Parameters
909
900
  ----------
@@ -929,8 +920,7 @@ class CESMDataset(Dataset):
929
920
 
930
921
  # overwrite clean_up method from parent class
931
922
  def clean_up(self, ds: xr.Dataset) -> xr.Dataset:
932
- """
933
- Ensure the dataset's time dimension is correctly defined and standardized.
923
+ """Ensure the dataset's time dimension is correctly defined and standardized.
934
924
 
935
925
  This method verifies that the time dimension exists in the dataset and assigns it appropriately. If the "time" dimension is missing, the method attempts to assign an existing "time" or "month" dimension. If neither exists, it expands the dataset to include a "time" dimension with a size of one.
936
926
 
@@ -938,7 +928,6 @@ class CESMDataset(Dataset):
938
928
  -------
939
929
  ds : xr.Dataset
940
930
  The xarray Dataset with the correct time dimension assigned or added.
941
-
942
931
  """
943
932
 
944
933
  if "time" not in self.dim_names:
@@ -954,8 +943,8 @@ class CESMDataset(Dataset):
954
943
  return ds
955
944
 
956
945
  def add_time_info(self, ds: xr.Dataset) -> xr.Dataset:
957
- """
958
- Adds time information to the dataset based on the climatology flag and dimension names.
946
+ """Adds time information to the dataset based on the climatology flag and
947
+ dimension names.
959
948
 
960
949
  This method processes the dataset to include time information according to the climatology
961
950
  setting. If the dataset represents climatology data and the time dimension is labeled as
@@ -991,8 +980,7 @@ class CESMDataset(Dataset):
991
980
 
992
981
  @dataclass(frozen=True, kw_only=True)
993
982
  class CESMBGCDataset(CESMDataset):
994
- """
995
- Represents CESM BGC data on original grid.
983
+ """Represents CESM BGC data on original grid.
996
984
 
997
985
  Parameters
998
986
  ----------
@@ -1107,16 +1095,12 @@ class CESMBGCDataset(CESMDataset):
1107
1095
  1,
1108
1096
  )
1109
1097
 
1110
- for var in self.ds.data_vars:
1111
- self.ds[var] = xr.where(mask == 1, self.ds[var], np.nan)
1112
-
1113
1098
  self.ds["mask"] = mask
1114
1099
 
1115
1100
 
1116
1101
  @dataclass(frozen=True, kw_only=True)
1117
1102
  class CESMBGCSurfaceForcingDataset(CESMDataset):
1118
- """
1119
- Represents CESM BGC surface forcing data on original grid.
1103
+ """Represents CESM BGC surface forcing data on original grid.
1120
1104
 
1121
1105
  Parameters
1122
1106
  ----------
@@ -1161,8 +1145,7 @@ class CESMBGCSurfaceForcingDataset(CESMDataset):
1161
1145
  climatology: Optional[bool] = False
1162
1146
 
1163
1147
  def post_process(self):
1164
- """
1165
- Perform post-processing on the dataset to remove specific variables.
1148
+ """Perform post-processing on the dataset to remove specific variables.
1166
1149
 
1167
1150
  This method checks if the variable "z_t" exists in the dataset. If it does,
1168
1151
  the variable is removed from the dataset. The modified dataset is then
@@ -1181,16 +1164,12 @@ class CESMBGCSurfaceForcingDataset(CESMDataset):
1181
1164
  1,
1182
1165
  )
1183
1166
 
1184
- for var in self.ds.data_vars:
1185
- self.ds[var] = xr.where(mask == 1, self.ds[var], np.nan)
1186
-
1187
1167
  self.ds["mask"] = mask
1188
1168
 
1189
1169
 
1190
1170
  @dataclass(frozen=True, kw_only=True)
1191
1171
  class ERA5Dataset(Dataset):
1192
- """
1193
- Represents ERA5 data on original grid.
1172
+ """Represents ERA5 data on original grid.
1194
1173
 
1195
1174
  Parameters
1196
1175
  ----------
@@ -1288,21 +1267,25 @@ class ERA5Dataset(Dataset):
1288
1267
 
1289
1268
  # Update var_names dictionary
1290
1269
  var_names = {**self.var_names, "qair": "qair"}
1270
+ var_names.pop("d2m")
1291
1271
  object.__setattr__(self, "var_names", var_names)
1292
1272
 
1293
1273
  if "mask" in self.var_names.keys():
1294
1274
  mask = xr.where(self.ds[self.var_names["mask"]].isel(time=0).isnull(), 0, 1)
1295
1275
 
1296
- for var in self.ds.data_vars:
1297
- self.ds[var] = xr.where(mask == 1, self.ds[var], np.nan)
1298
-
1299
1276
  self.ds["mask"] = mask
1300
1277
 
1278
+ # Remove mask from var_names dictionary
1279
+ var_names = self.var_names
1280
+ var_names.pop("mask")
1281
+ object.__setattr__(self, "var_names", var_names)
1282
+
1301
1283
 
1302
1284
  @dataclass(frozen=True, kw_only=True)
1303
1285
  class ERA5Correction(Dataset):
1304
- """
1305
- Global dataset to correct ERA5 radiation. The dataset contains multiplicative correction factors for the ERA5 shortwave radiation, obtained by comparing the COREv2 climatology to the ERA5 climatology.
1286
+ """Global dataset to correct ERA5 radiation. The dataset contains multiplicative
1287
+ correction factors for the ERA5 shortwave radiation, obtained by comparing the
1288
+ COREv2 climatology to the ERA5 climatology.
1306
1289
 
1307
1290
  Parameters
1308
1291
  ----------
@@ -1352,8 +1335,8 @@ class ERA5Correction(Dataset):
1352
1335
  super().__post_init__()
1353
1336
 
1354
1337
  def choose_subdomain(self, coords, straddle: bool):
1355
- """
1356
- Converts longitude values in the dataset if necessary and selects a subdomain based on the specified coordinates.
1338
+ """Converts longitude values in the dataset if necessary and selects a subdomain
1339
+ based on the specified coordinates.
1357
1340
 
1358
1341
  This method converts longitude values between different ranges if required and then extracts a subset of the
1359
1342
  dataset according to the given coordinates. It updates the dataset in place to reflect the selected subdomain.
@@ -53,8 +53,7 @@ pup_test_data = pooch.create(
53
53
 
54
54
 
55
55
  def fetch_topo(topography_source: str) -> xr.Dataset:
56
- """
57
- Load the global topography data as an xarray Dataset.
56
+ """Load the global topography data as an xarray Dataset.
58
57
 
59
58
  Parameters
60
59
  ----------
@@ -79,8 +78,7 @@ def fetch_topo(topography_source: str) -> xr.Dataset:
79
78
 
80
79
 
81
80
  def download_correction_data(filename: str) -> str:
82
- """
83
- Download the correction data file.
81
+ """Download the correction data file.
84
82
 
85
83
  Parameters
86
84
  ----------
@@ -100,8 +98,7 @@ def download_correction_data(filename: str) -> str:
100
98
 
101
99
 
102
100
  def download_test_data(filename: str) -> str:
103
- """
104
- Download the test data file.
101
+ """Download the test data file.
105
102
 
106
103
  Parameters
107
104
  ----------
roms_tools/setup/fill.py CHANGED
@@ -6,9 +6,8 @@ from scipy import sparse
6
6
 
7
7
  class LateralFill:
8
8
  def __init__(self, mask, dims, tol=1.0e-4):
9
- """
10
- Initializes the LateralFill class, which fills NaN values in a DataArray
11
- by iteratively solving a Poisson equation using a lateral diffusion approach.
9
+ """Initializes the LateralFill class, which fills NaN values in a DataArray by
10
+ iteratively solving a Poisson equation using a lateral diffusion approach.
12
11
 
13
12
  Parameters
14
13
  ----------
@@ -16,7 +15,7 @@ class LateralFill:
16
15
  A 2D boolean mask indicating valid points (True) and land points (False).
17
16
  Boundary points are automatically set to land (True).
18
17
  dims : list of str
19
- Dimensions along which to perform the lateral fill. Defaults to ["latitude", "longitude"].
18
+ Dimensions along which to perform the lateral fill.
20
19
  tol : float, optional
21
20
  Tolerance for the iterative solver, determining convergence. Default is 1.0e-4.
22
21
 
@@ -51,8 +50,7 @@ class LateralFill:
51
50
  self.tol = tol
52
51
 
53
52
  def apply(self, var):
54
- """
55
- Fills NaN values in an xarray DataArray using iterative lateral diffusion.
53
+ """Fills NaN values in an xarray DataArray using iterative lateral diffusion.
56
54
 
57
55
  Parameters
58
56
  ----------
@@ -65,10 +63,9 @@ class LateralFill:
65
63
  var_filled : xarray.DataArray
66
64
  A DataArray with NaN values filled by iterative smoothing, while preserving
67
65
  non-NaN values.
68
-
69
66
  """
70
67
  # Apply fill to anomaly field
71
- mean = var.mean(dim=self.dims, skipna=True)
68
+ mean = var.where(self.mask).mean(dim=self.dims, skipna=True)
72
69
  var = var - mean
73
70
 
74
71
  # Setup the right-hand side (RHS): ocean points take their original values, land points are set to 0
@@ -96,11 +93,9 @@ class LateralFill:
96
93
 
97
94
 
98
95
  def _lateral_fill_np_array(x0, b, ml, tol=1.0e-4):
99
- """
100
- Fills all NaN values in a 2D NumPy array using an iterative solver,
101
- while preserving the existing non-NaN values.
102
- The filling process uses an AMG solver to efficiently perform smoothing
103
- based on the Laplace operator.
96
+ """Fills all NaN values in a 2D NumPy array using an iterative solver, while
97
+ preserving the existing non-NaN values. The filling process uses an AMG solver to
98
+ efficiently perform smoothing based on the Laplace operator.
104
99
 
105
100
  Parameters
106
101
  ----------
@@ -136,8 +131,7 @@ def _lateral_fill_np_array(x0, b, ml, tol=1.0e-4):
136
131
 
137
132
 
138
133
  def laplacian(grid, mask, dtype=float, format=None):
139
- """
140
- Return a sparse matrix for solving a 2-dimensional Poisson problem.
134
+ """Return a sparse matrix for solving a 2-dimensional Poisson problem.
141
135
 
142
136
  This function generates a finite difference approximation of the Laplacian operator
143
137
  on a 2-dimensional grid with unit grid spacing and Dirichlet boundary conditions.
@@ -164,7 +158,6 @@ def laplacian(grid, mask, dtype=float, format=None):
164
158
  sparse matrix
165
159
  A sparse matrix representing the finite difference Laplacian operator for
166
160
  the given grid.
167
-
168
161
  """
169
162
  grid = tuple(grid)
170
163
 
@@ -180,8 +173,7 @@ def laplacian(grid, mask, dtype=float, format=None):
180
173
 
181
174
 
182
175
  def stencil_grid_mod(S, grid, msk, dtype=None, format=None):
183
- """
184
- Construct a sparse matrix from a local matrix stencil.
176
+ """Construct a sparse matrix from a local matrix stencil.
185
177
 
186
178
  This function generates a sparse matrix that represents an operator
187
179
  by applying the given stencil `S` at each vertex of a regular grid with
@@ -309,3 +301,39 @@ def stencil_grid_mod(S, grid, msk, dtype=None, format=None):
309
301
  data[4, i + diags[4]] = 0
310
302
 
311
303
  return sparse.dia_matrix((data, diags), shape=(N_v, N_v)).asformat(format)
304
+
305
+
306
+ def _lateral_fill(data_vars, data):
307
+ """Wrapper function to apply lateral fill to variables using the dataset's mask and
308
+ grid dimensions.
309
+
310
+ Parameters
311
+ ----------
312
+ data_vars : dict of str : xarray.DataArray
313
+ Dictionary of variables to be filled.
314
+ data : Dataset
315
+ Dataset containing the mask and grid dimensions.
316
+
317
+ Returns
318
+ -------
319
+ dict of str : xarray.DataArray
320
+ Dictionary of filled variables.
321
+ """
322
+ lateral_fill = LateralFill(
323
+ data.ds["mask"],
324
+ [data.dim_names["latitude"], data.dim_names["longitude"]],
325
+ )
326
+
327
+ if "mask_vel" in data.ds.data_vars:
328
+ lateral_fill_vel = LateralFill(
329
+ data.ds["mask_vel"],
330
+ [data.dim_names["latitude"], data.dim_names["longitude"]],
331
+ )
332
+
333
+ for var in data.var_names:
334
+ if var in ["u", "v"]:
335
+ data_vars[var] = lateral_fill_vel.apply(data_vars[var])
336
+ else:
337
+ data_vars[var] = lateral_fill.apply(data_vars[var])
338
+
339
+ return data_vars