roms-tools 3.2.0__py3-none-any.whl → 3.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 (318) hide show
  1. roms_tools/__init__.py +1 -1
  2. roms_tools/analysis/cdr_ensemble.py +10 -13
  3. roms_tools/analysis/roms_output.py +5 -304
  4. roms_tools/{download.py → datasets/download.py} +1 -0
  5. roms_tools/{setup/datasets.py → datasets/lat_lon_datasets.py} +85 -854
  6. roms_tools/datasets/river_datasets.py +532 -0
  7. roms_tools/datasets/roms_dataset.py +767 -0
  8. roms_tools/datasets/utils.py +475 -0
  9. roms_tools/{setup/fill.py → fill.py} +110 -13
  10. roms_tools/plot.py +42 -34
  11. roms_tools/setup/boundary_forcing.py +52 -44
  12. roms_tools/setup/cdr_release.py +2 -4
  13. roms_tools/setup/grid.py +42 -17
  14. roms_tools/setup/initial_conditions.py +23 -23
  15. roms_tools/setup/nesting.py +270 -94
  16. roms_tools/setup/river_forcing.py +5 -5
  17. roms_tools/setup/surface_forcing.py +17 -12
  18. roms_tools/setup/tides.py +1 -1
  19. roms_tools/setup/topography.py +13 -7
  20. roms_tools/setup/utils.py +103 -294
  21. roms_tools/tests/test_analysis/test_cdr_ensemble.py +4 -6
  22. roms_tools/tests/test_analysis/test_roms_output.py +1 -220
  23. roms_tools/tests/{test_setup/test_datasets.py → test_datasets/test_lat_lon_datasets.py} +25 -64
  24. roms_tools/tests/test_datasets/test_river_datasets.py +48 -0
  25. roms_tools/tests/test_datasets/test_roms_dataset.py +539 -0
  26. roms_tools/tests/test_datasets/test_utils.py +527 -0
  27. roms_tools/tests/{test_setup/test_fill.py → test_fill.py} +72 -9
  28. roms_tools/tests/test_setup/test_boundary_forcing.py +57 -138
  29. roms_tools/tests/test_setup/test_cdr_release.py +4 -5
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/c/0/0/0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/c/0/0/0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/c/0/0/0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/c/0/0/0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/c/0/0/0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/c/0/0/0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/c/0/0/0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/c/0/0/0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/c/0/0/0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/c/0/0/0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/c/0/0/0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/c/0/0/0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/c/0/0/0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/c/0/0/0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/c/0/0/0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/c/0/0/0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/c/0/0/0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/c/0/0/0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/c/0/0/0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/c/0/0/0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/c/0/0/0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/c/0/0/0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/c/0/0/0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/c/0/0/0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/c/0/0/0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/c/0/0/0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/c/0/0/0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/c/0/0/0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/c/0/0/0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/c/0/0/0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/c/0/0/0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/c/0/0/0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/c/0/0/0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/c/0/0/0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/c/0/0/0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/c/0/0/0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/c/0/0/0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/c/0/0/0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/c/0/0/0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/c/0/0/0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/c/0/0/0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/c/0/0/0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/c/0/0/0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/c/0/0/0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/c/0/0/0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/c/0/0/0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/c/0/0/0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/c/0/0/0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/c/0/0/0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/c/0/0/0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/c/0/0/0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/c/0/0/0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/c/0/0/0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/c/0/0/0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/c/0/0/0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/c/0/0/0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/c/0/0/0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/c/0/0/0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/c/0/0/0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/c/0/0/0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/c/0/0/0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/c/0/0/0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zarr.json +289 -2017
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/c/0/0/0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/c/0/0/0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/zarr.json +294 -2022
  96. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/c/0/0/0 +0 -0
  97. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/c/0/0/0 +0 -0
  98. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/c/0/0/0 +0 -0
  99. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/c/0/0/0 +0 -0
  100. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/c/0/0/0 +0 -0
  101. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/c/0/0/0 +0 -0
  102. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/c/0/0/0 +0 -0
  103. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/c/0/0/0 +0 -0
  104. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/c/0/0/0 +0 -0
  105. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/c/0/0/0 +0 -0
  106. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/c/0/0/0 +0 -0
  107. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/c/0/0/0 +0 -0
  108. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/c/0/0 +0 -0
  109. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/c/0/0 +0 -0
  110. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/c/0/0 +0 -0
  111. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/c/0/0 +0 -0
  112. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/c/0/0/0 +0 -0
  113. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/c/0/0/0 +0 -0
  114. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/c/0/0/0 +0 -0
  115. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/c/0/0/0 +0 -0
  116. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/c/0/0 +0 -0
  117. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/c/0/0 +0 -0
  118. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/c/0/0 +0 -0
  119. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/c/0/0 +0 -0
  120. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zarr.json +182 -182
  121. roms_tools/tests/test_setup/test_data/grid.zarr/h/c/0/0 +0 -0
  122. roms_tools/tests/test_setup/test_data/grid.zarr/zarr.json +191 -191
  123. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/c/0/0 +0 -0
  124. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/zarr.json +210 -210
  125. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/c/0/0/0/0 +0 -0
  126. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/c/0/0/0/0 +0 -0
  127. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/c/0/0/0/0 +0 -0
  128. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/c/0/0/0/0 +0 -0
  129. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/c/0/0/0/0 +0 -0
  130. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/c/0/0/0/0 +0 -0
  131. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/c/0/0/0/0 +0 -0
  132. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/c/0/0/0/0 +0 -0
  133. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/c/0/0/0/0 +0 -0
  134. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/c/0/0/0/0 +0 -0
  135. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/c/0/0/0/0 +0 -0
  136. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/c/0/0/0/0 +0 -0
  137. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/c/0/0/0/0 +0 -0
  138. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/c/0/0/0/0 +0 -0
  139. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/c/0/0/0/0 +0 -0
  140. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/c/0/0/0/0 +0 -0
  141. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/c/0/0/0/0 +0 -0
  142. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/c/0/0/0/0 +0 -0
  143. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/c/0/0/0/0 +0 -0
  144. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/c/0/0/0/0 +0 -0
  145. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/c/0/0/0/0 +0 -0
  146. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/c/0/0/0/0 +0 -0
  147. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/c/0/0/0/0 +0 -0
  148. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/c/0/0/0/0 +0 -0
  149. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/c/0/0/0/0 +0 -0
  150. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/c/0/0/0/0 +0 -0
  151. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  152. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/c/0/0/0/0 +0 -0
  153. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/c/0/0/0/0 +0 -0
  154. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/c/0/0/0/0 +0 -0
  155. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/c/0/0/0/0 +0 -0
  156. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/c/0/0/0/0 +0 -0
  157. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  158. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  159. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  160. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  161. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  162. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zarr.json +182 -182
  163. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/c/0/0/0/0 +0 -0
  164. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  165. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  166. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  167. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  168. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  169. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  170. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/zarr.json +187 -187
  171. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/c/0/0/0 +0 -0
  172. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/c/0/0/0 +0 -0
  173. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/c/0/0/0 +0 -0
  174. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/c/0/0/0 +0 -0
  175. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/zarr.json +66 -66
  176. roms_tools/tests/test_setup/test_grid.py +56 -1
  177. roms_tools/tests/test_setup/test_initial_conditions.py +3 -94
  178. roms_tools/tests/test_setup/test_nesting.py +119 -30
  179. roms_tools/tests/test_setup/test_surface_forcing.py +2 -2
  180. roms_tools/tests/test_setup/test_tides.py +1 -1
  181. roms_tools/tests/test_setup/test_utils.py +100 -15
  182. roms_tools/tests/test_tiling/test_partition.py +63 -15
  183. roms_tools/tests/test_utils.py +78 -0
  184. roms_tools/tiling/partition.py +81 -211
  185. roms_tools/utils.py +193 -0
  186. {roms_tools-3.2.0.dist-info → roms_tools-3.4.0.dist-info}/METADATA +1 -1
  187. {roms_tools-3.2.0.dist-info → roms_tools-3.4.0.dist-info}/RECORD +190 -312
  188. {roms_tools-3.2.0.dist-info → roms_tools-3.4.0.dist-info}/WHEEL +1 -1
  189. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
  190. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/zarr.json +0 -54
  191. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/c/0/0/0 +0 -0
  192. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/zarr.json +0 -54
  193. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
  194. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/zarr.json +0 -54
  195. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/c/0/0/0 +0 -0
  196. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/zarr.json +0 -54
  197. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/c/0/0/0 +0 -0
  198. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/zarr.json +0 -54
  199. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
  200. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/zarr.json +0 -54
  201. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/c/0/0/0 +0 -0
  202. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/zarr.json +0 -54
  203. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/c/0/0/0 +0 -0
  204. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/zarr.json +0 -54
  205. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/c/0/0/0 +0 -0
  206. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/zarr.json +0 -54
  207. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
  208. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/zarr.json +0 -54
  209. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/c/0/0/0 +0 -0
  210. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/zarr.json +0 -54
  211. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/c/0/0/0 +0 -0
  212. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/zarr.json +0 -54
  213. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/c/0/0/0 +0 -0
  214. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/zarr.json +0 -54
  215. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/c/0/0/0 +0 -0
  216. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/zarr.json +0 -54
  217. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/c/0/0/0 +0 -0
  218. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/zarr.json +0 -54
  219. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/c/0/0/0 +0 -0
  220. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/zarr.json +0 -54
  221. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
  222. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/zarr.json +0 -54
  223. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/c/0/0/0 +0 -0
  224. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/zarr.json +0 -54
  225. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
  226. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/zarr.json +0 -54
  227. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
  228. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/zarr.json +0 -54
  229. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/c/0/0/0 +0 -0
  230. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/zarr.json +0 -54
  231. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
  232. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/zarr.json +0 -54
  233. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/c/0/0/0 +0 -0
  234. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/zarr.json +0 -54
  235. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
  236. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/zarr.json +0 -54
  237. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
  238. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/zarr.json +0 -54
  239. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/c/0/0/0 +0 -0
  240. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/zarr.json +0 -54
  241. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/c/0/0/0 +0 -0
  242. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/zarr.json +0 -54
  243. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
  244. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/zarr.json +0 -54
  245. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/c/0/0/0 +0 -0
  246. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/zarr.json +0 -54
  247. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/c/0/0/0 +0 -0
  248. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/zarr.json +0 -54
  249. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/c/0/0/0 +0 -0
  250. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/zarr.json +0 -54
  251. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/c/0/0/0 +0 -0
  252. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/zarr.json +0 -54
  253. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
  254. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_ALT_CO2_west/zarr.json +0 -54
  255. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_west/c/0/0/0 +0 -0
  256. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/ALK_west/zarr.json +0 -54
  257. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_ALT_CO2_west/c/0/0/0 +0 -0
  258. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_ALT_CO2_west/zarr.json +0 -54
  259. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_west/c/0/0/0 +0 -0
  260. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DIC_west/zarr.json +0 -54
  261. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOC_west/c/0/0/0 +0 -0
  262. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOC_west/zarr.json +0 -54
  263. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
  264. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOCr_west/zarr.json +0 -54
  265. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DON_west/c/0/0/0 +0 -0
  266. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DON_west/zarr.json +0 -54
  267. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DONr_west/c/0/0/0 +0 -0
  268. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DONr_west/zarr.json +0 -54
  269. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOP_west/c/0/0/0 +0 -0
  270. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOP_west/zarr.json +0 -54
  271. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
  272. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/DOPr_west/zarr.json +0 -54
  273. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Fe_west/c/0/0/0 +0 -0
  274. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Fe_west/zarr.json +0 -54
  275. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Lig_west/c/0/0/0 +0 -0
  276. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/Lig_west/zarr.json +0 -54
  277. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NH4_west/c/0/0/0 +0 -0
  278. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NH4_west/zarr.json +0 -54
  279. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NO3_west/c/0/0/0 +0 -0
  280. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/NO3_west/zarr.json +0 -54
  281. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/O2_west/c/0/0/0 +0 -0
  282. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/O2_west/zarr.json +0 -54
  283. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/PO4_west/c/0/0/0 +0 -0
  284. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/PO4_west/zarr.json +0 -54
  285. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
  286. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/SiO3_west/zarr.json +0 -54
  287. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatC_west/c/0/0/0 +0 -0
  288. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatC_west/zarr.json +0 -54
  289. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
  290. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatChl_west/zarr.json +0 -54
  291. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
  292. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatFe_west/zarr.json +0 -54
  293. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatP_west/c/0/0/0 +0 -0
  294. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatP_west/zarr.json +0 -54
  295. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
  296. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diatSi_west/zarr.json +0 -54
  297. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazC_west/c/0/0/0 +0 -0
  298. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazC_west/zarr.json +0 -54
  299. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
  300. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazChl_west/zarr.json +0 -54
  301. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
  302. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazFe_west/zarr.json +0 -54
  303. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazP_west/c/0/0/0 +0 -0
  304. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/diazP_west/zarr.json +0 -54
  305. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spC_west/c/0/0/0 +0 -0
  306. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spC_west/zarr.json +0 -54
  307. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
  308. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spCaCO3_west/zarr.json +0 -54
  309. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spChl_west/c/0/0/0 +0 -0
  310. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spChl_west/zarr.json +0 -54
  311. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spFe_west/c/0/0/0 +0 -0
  312. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spFe_west/zarr.json +0 -54
  313. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spP_west/c/0/0/0 +0 -0
  314. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/spP_west/zarr.json +0 -54
  315. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/zooC_west/c/0/0/0 +0 -0
  316. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_unified_climatology.zarr/zooC_west/zarr.json +0 -54
  317. {roms_tools-3.2.0.dist-info → roms_tools-3.4.0.dist-info}/licenses/LICENSE +0 -0
  318. {roms_tools-3.2.0.dist-info → roms_tools-3.4.0.dist-info}/top_level.txt +0 -0
@@ -7,8 +7,12 @@ import gcm_filters
7
7
  import numpy as np
8
8
  import xarray as xr
9
9
 
10
+ from roms_tools.datasets.lat_lon_datasets import (
11
+ EMODDataset,
12
+ ETOPO5Dataset,
13
+ SRTM15Dataset,
14
+ )
10
15
  from roms_tools.regrid import LateralRegridToROMS
11
- from roms_tools.setup.datasets import ETOPO5Dataset, SRTM15Dataset
12
16
  from roms_tools.setup.utils import handle_boundaries
13
17
 
14
18
 
@@ -17,7 +21,7 @@ def add_topography(
17
21
  target_coords,
18
22
  topography_source,
19
23
  hmin,
20
- smooth_factor=6.0,
24
+ smooth_factor=5.0,
21
25
  rmax=0.2,
22
26
  verbose=False,
23
27
  ) -> xr.Dataset:
@@ -77,10 +81,8 @@ def add_topography(
77
81
  # smooth topography locally to satisfy r < rmax
78
82
  if verbose:
79
83
  start_time = time.time()
80
- # inserting hraw * mask_rho into this function eliminates any inconsistencies between
81
- # the land according to the topography and the land according to the mask; land points
82
- # will always be set to hmin
83
- ds["h"] = _smooth_topography_locally(hraw * ds["mask_rho"], hmin, rmax)
84
+
85
+ ds["h"] = _smooth_topography_locally(hraw, hmin, rmax)
84
86
  ds["h"].attrs = {
85
87
  "long_name": "Bathymetry at rho-points",
86
88
  "units": "meter",
@@ -117,9 +119,12 @@ def _get_topography_data(source):
117
119
  elif source["name"] == "SRTM15":
118
120
  kwargs["filename"] = source["path"]
119
121
  data = SRTM15Dataset(**kwargs)
122
+ elif source["name"] == "EMOD":
123
+ kwargs["filename"] = source["path"]
124
+ data = EMODDataset(**kwargs)
120
125
  else:
121
126
  raise ValueError(
122
- 'Only "ETOPO5" and "SRTM15" are valid options for topography_source["name"].'
127
+ 'Only "ETOPO5", "SRTM15" and "EMOD" are valid options for topography_source["name"].'
123
128
  )
124
129
 
125
130
  return data
@@ -149,6 +154,7 @@ def _make_raw_topography(
149
154
  data.choose_subdomain(target_coords, buffer_points=3, verbose=verbose)
150
155
  # Enforce double precision to ensure reproducibility
151
156
  data.convert_to_float64()
157
+ data.apply_lateral_fill()
152
158
 
153
159
  if verbose:
154
160
  start_time = time.time()
roms_tools/setup/utils.py CHANGED
@@ -7,9 +7,8 @@ from dataclasses import asdict, fields, is_dataclass
7
7
  from datetime import datetime
8
8
  from enum import StrEnum
9
9
  from pathlib import Path
10
- from typing import Any, Literal
10
+ from typing import Any, Literal, TypeAlias
11
11
 
12
- import cftime
13
12
  import numba as nb
14
13
  import numpy as np
15
14
  import pandas as pd
@@ -31,6 +30,8 @@ yaml.SafeDumper.add_multi_representer(
31
30
  HEADER_SZ = 96
32
31
  HEADER_CHAR = "="
33
32
 
33
+ RawDataSource: TypeAlias = dict[str, str | Path | list[str | Path] | bool]
34
+
34
35
 
35
36
  def log_the_separator() -> None:
36
37
  """Log a separator line using HEADER_CHAR repeated HEADER_SZ times."""
@@ -126,32 +127,6 @@ def substitute_nans_by_fillvalue(field, fill_value=0.0) -> xr.DataArray:
126
127
  return field.fillna(fill_value)
127
128
 
128
129
 
129
- def one_dim_fill(da: xr.DataArray, dim: str, direction="forward") -> xr.DataArray:
130
- """Fill NaN values in a DataArray along a specified dimension.
131
-
132
- Parameters
133
- ----------
134
- da : xr.DataArray
135
- The input DataArray with NaN values to be filled, which must include the specified dimension.
136
- dim : str
137
- The name of the dimension along which to fill NaN values (e.g., 'depth' or 'time').
138
- direction : str, optional
139
- The filling direction; either "forward" to propagate non-NaN values downward or "backward" to propagate them upward.
140
- Defaults to "forward".
141
-
142
- Returns
143
- -------
144
- xr.DataArray
145
- A new DataArray with NaN values filled in the specified direction, leaving the original data unchanged.
146
- """
147
- if dim in da.dims:
148
- if direction == "forward":
149
- return da.ffill(dim=dim)
150
- elif direction == "backward":
151
- return da.bfill(dim=dim)
152
- return da
153
-
154
-
155
130
  def assign_dates_to_climatology(ds: xr.Dataset, time_dim: str) -> xr.Dataset:
156
131
  """Assigns climatology dates to the dataset's time dimension.
157
132
 
@@ -180,240 +155,6 @@ def assign_dates_to_climatology(ds: xr.Dataset, time_dim: str) -> xr.Dataset:
180
155
  return ds
181
156
 
182
157
 
183
- def interpolate_cyclic_time(
184
- data_array: xr.DataArray,
185
- time_dim_name: str,
186
- day_of_year: int | float | np.ndarray | xr.DataArray | Sequence[int | float],
187
- ) -> xr.DataArray:
188
- """Interpolates a DataArray cyclically across the start and end of the year.
189
-
190
- This function extends the data cyclically by appending the last time step
191
- (shifted back by one year) at the beginning and the first time step
192
- (shifted forward by one year) at the end. It then performs linear interpolation
193
- to match the specified `day_of_year` values.
194
-
195
- Parameters
196
- ----------
197
- data_array : xr.DataArray
198
- The input data array containing a time-like dimension.
199
- time_dim_name : str
200
- The name of the time dimension in the dataset.
201
- day_of_year : Union[int, float, np.ndarray, xr.DataArray, Sequence[Union[int, float]]]
202
- The target day(s) of the year for interpolation. This can be:
203
- - A single integer or float representing the day of the year.
204
- - A NumPy array or xarray DataArray containing multiple days.
205
- - A list or tuple of integers or floats for multiple target days.
206
-
207
- Returns
208
- -------
209
- xr.DataArray
210
- The interpolated DataArray, ensuring cyclic continuity across year boundaries.
211
-
212
- Notes
213
- -----
214
- - This function is useful for interpolating climatological data, where the time axis
215
- represents a repeating annual cycle.
216
- - The `day_of_year` values should be within the range [1, 365] or [1, 366] for leap years.
217
- """
218
- # Concatenate across the beginning and end of the year
219
- time_concat = xr.concat(
220
- [
221
- data_array[time_dim_name][-1] - 365.25, # Shift last time backward
222
- data_array[time_dim_name],
223
- data_array[time_dim_name][0] + 365.25, # Shift first time forward
224
- ],
225
- dim=time_dim_name,
226
- )
227
-
228
- data_array_concat = xr.concat(
229
- [
230
- data_array.isel(
231
- **{time_dim_name: -1}
232
- ), # Append last value at the beginning
233
- data_array,
234
- data_array.isel(**{time_dim_name: 0}), # Append first value at the end
235
- ],
236
- dim=time_dim_name,
237
- )
238
- data_array_concat[time_dim_name] = time_concat
239
-
240
- # Interpolate to specified times
241
- data_array_interpolated = data_array_concat.interp(
242
- **{time_dim_name: day_of_year}, method="linear"
243
- )
244
-
245
- return data_array_interpolated
246
-
247
-
248
- def interpolate_from_climatology(
249
- field: xr.DataArray | xr.Dataset,
250
- time_dim_name: str,
251
- time: xr.DataArray | pd.DatetimeIndex,
252
- ) -> xr.DataArray | xr.Dataset:
253
- """Interpolates a climatological field to specified time points.
254
-
255
- This function interpolates the input `field` based on `day_of_year` values
256
- extracted from the provided `time` points. If `field` is an `xarray.Dataset`,
257
- interpolation is applied to all its data variables individually.
258
-
259
- Parameters
260
- ----------
261
- field : xarray.DataArray or xarray.Dataset
262
- The input field to be interpolated.
263
- - If `field` is an `xarray.DataArray`, it must have a time dimension identified by `time_dim_name`.
264
- - If `field` is an `xarray.Dataset`, all variables within the dataset are interpolated along `time_dim_name`.
265
- The time dimension is assumed to represent `day_of_year` for climatological purposes.
266
- time_dim_name : str
267
- The name of the time dimension in `field`. This dimension is used for interpolation.
268
- time : xarray.DataArray or pandas.DatetimeIndex
269
- The target time points for interpolation. These are internally converted to `day_of_year`
270
- before performing interpolation.
271
-
272
- Returns
273
- -------
274
- xarray.DataArray or xarray.Dataset
275
- The interpolated field, maintaining the same type (`xarray.DataArray` or `xarray.Dataset`)
276
- but aligned to the specified `time` values.
277
-
278
- Notes
279
- -----
280
- - This function assumes that `field` represents a climatological dataset, where time is expressed as `day_of_year` (1-365).
281
- - The `time` input is automatically converted to `day_of_year`, so manual conversion is not required before calling this function.
282
- """
283
-
284
- def interpolate_single_field(data_array: xr.DataArray) -> xr.DataArray:
285
- if isinstance(time, xr.DataArray):
286
- # Extract day of year from xarray.DataArray
287
- day_of_year = time.dt.dayofyear
288
- else:
289
- if np.size(time) == 1:
290
- # Convert single datetime64 object to pandas.Timestamp
291
- date = pd.Timestamp(time)
292
- day_of_year = (
293
- date.dayofyear
294
- + (date.hour / 24)
295
- + (date.minute / 1440)
296
- + (date.second / 86400)
297
- )
298
- else:
299
- # Convert each datetime64 object in the array to pandas.Timestamp and compute fractional day of year
300
- day_of_year = np.array(
301
- [
302
- pd.Timestamp(t).dayofyear
303
- + (pd.Timestamp(t).hour / 24)
304
- + (pd.Timestamp(t).minute / 1440)
305
- + (pd.Timestamp(t).second / 86400)
306
- for t in time
307
- ]
308
- )
309
-
310
- data_array_interpolated = interpolate_cyclic_time(
311
- data_array, time_dim_name, day_of_year
312
- )
313
-
314
- if np.size(time) == 1:
315
- data_array_interpolated = data_array_interpolated.expand_dims(
316
- {time_dim_name: 1}
317
- )
318
- return data_array_interpolated
319
-
320
- if isinstance(field, xr.DataArray):
321
- return interpolate_single_field(field)
322
- elif isinstance(field, xr.Dataset):
323
- interpolated_data_vars = {
324
- var: interpolate_single_field(data_array)
325
- for var, data_array in field.data_vars.items()
326
- }
327
- return xr.Dataset(interpolated_data_vars, attrs=field.attrs)
328
-
329
- else:
330
- raise TypeError("Input 'field' must be an xarray.DataArray or xarray.Dataset.")
331
-
332
-
333
- def get_time_type(data_array: xr.DataArray) -> str:
334
- """Determines the type of time values in the xarray DataArray.
335
-
336
- Parameters
337
- ----------
338
- data_array : xr.DataArray
339
- The xarray DataArray to be checked for time data types.
340
-
341
- Returns
342
- -------
343
- str
344
- A string indicating the type of the time data: 'cftime', 'datetime', or 'int'.
345
-
346
- Raises
347
- ------
348
- TypeError
349
- If the values in the DataArray are not of type numpy.ndarray or list.
350
- """
351
- # List of cftime datetime types
352
- cftime_types = (
353
- cftime.DatetimeNoLeap,
354
- cftime.DatetimeJulian,
355
- cftime.DatetimeGregorian,
356
- cftime.Datetime360Day,
357
- cftime.DatetimeProlepticGregorian,
358
- )
359
-
360
- # Check if any of the coordinate values are of cftime, datetime, or integer type
361
- if isinstance(data_array.values, np.ndarray | list):
362
- # Check if the data type is numpy datetime64, indicating standard datetime objects
363
- if data_array.values.dtype == "datetime64[ns]":
364
- return "datetime"
365
-
366
- # Check if any values in the array are instances of cftime types
367
- if any(isinstance(value, cftime_types) for value in data_array.values):
368
- return "cftime"
369
-
370
- # Check if all values are of integer type (e.g., for indices or time steps)
371
- if np.issubdtype(data_array.values.dtype, np.integer):
372
- return "int"
373
-
374
- # If none of the above conditions are met, raise a ValueError
375
- raise ValueError("Unsupported data type for time values in input dataset.")
376
-
377
- # Handle unexpected types
378
- raise TypeError("DataArray values must be of type numpy.ndarray or list.")
379
-
380
-
381
- def convert_cftime_to_datetime(data_array: np.ndarray) -> np.ndarray:
382
- """Converts cftime datetime objects to numpy datetime64 objects in a numpy ndarray.
383
-
384
- Parameters
385
- ----------
386
- data_array : np.ndarray
387
- The numpy ndarray containing cftime datetime objects to be converted.
388
-
389
- Returns
390
- -------
391
- np.ndarray
392
- The ndarray with cftime datetimes converted to numpy datetime64 objects.
393
-
394
- Notes
395
- -----
396
- This function is intended to be used with numpy ndarrays. If you need to convert
397
- cftime datetime objects in an xarray.DataArray, please use the appropriate function
398
- to handle xarray.DataArray conversions.
399
- """
400
- # List of cftime datetime types
401
- cftime_types = (
402
- cftime.DatetimeNoLeap,
403
- cftime.DatetimeJulian,
404
- cftime.DatetimeGregorian,
405
- )
406
-
407
- # Define a conversion function for cftime to numpy datetime64
408
- def convert_datetime(dt):
409
- if isinstance(dt, cftime_types):
410
- # Convert to ISO format and then to nanosecond precision
411
- return np.datetime64(dt.isoformat(), "ns")
412
- return np.datetime64(dt, "ns")
413
-
414
- return np.vectorize(convert_datetime)(data_array)
415
-
416
-
417
158
  def get_variable_metadata():
418
159
  """Retrieves metadata for commonly used variables in the dataset.
419
160
 
@@ -1859,38 +1600,6 @@ def get_boundary_coords():
1859
1600
  return bdry_coords
1860
1601
 
1861
1602
 
1862
- def wrap_longitudes(grid_ds, straddle):
1863
- """Adjusts longitude values in a dataset to handle dateline crossing.
1864
-
1865
- Parameters
1866
- ----------
1867
- grid_ds : xr.Dataset
1868
- The dataset containing longitude variables to adjust.
1869
- straddle : bool
1870
- If True, adjusts longitudes to the range [-180, 180] for datasets
1871
- that straddle the dateline. If False, adjusts longitudes to the
1872
- range [0, 360].
1873
-
1874
- Returns
1875
- -------
1876
- xr.Dataset
1877
- The dataset with adjusted longitude values.
1878
- """
1879
- for lon_dim in ["lon_rho", "lon_u", "lon_v"]:
1880
- if straddle:
1881
- grid_ds[lon_dim] = xr.where(
1882
- grid_ds[lon_dim] > 180,
1883
- grid_ds[lon_dim] - 360,
1884
- grid_ds[lon_dim],
1885
- )
1886
- else:
1887
- grid_ds[lon_dim] = xr.where(
1888
- grid_ds[lon_dim] < 0, grid_ds[lon_dim] + 360, grid_ds[lon_dim]
1889
- )
1890
-
1891
- return grid_ds
1892
-
1893
-
1894
1603
  def to_float(val):
1895
1604
  """Convert a value or list of values to float.
1896
1605
 
@@ -1963,3 +1672,103 @@ def validate_names(
1963
1672
  names = names[:max_to_plot]
1964
1673
 
1965
1674
  return names
1675
+
1676
+
1677
+ def check_and_set_boundaries(
1678
+ boundaries: dict[str, bool] | None,
1679
+ mask: xr.DataArray,
1680
+ ) -> dict[str, bool]:
1681
+ """
1682
+ Validate and finalize the `boundaries` dictionary.
1683
+
1684
+ Parameters
1685
+ ----------
1686
+ boundaries : dict[str, bool] or None
1687
+ User-supplied dictionary controlling which boundaries are active.
1688
+ Keys may include any subset of {"south", "east", "north", "west"}.
1689
+ Missing keys will be filled from mask-based defaults.
1690
+ If None, all boundaries are inferred from the land mask.
1691
+
1692
+ mask : xr.DataArray
1693
+ 2D land/sea mask on rho-points. Used to determine which boundaries
1694
+ contain at least one ocean point.
1695
+
1696
+ Returns
1697
+ -------
1698
+ dict[str, bool]
1699
+ Completed and validated boundary configuration.
1700
+ """
1701
+ valid_keys = {"south", "east", "north", "west"}
1702
+
1703
+ # --------------------------------------------
1704
+ # Case 1: boundaries not provided → infer them
1705
+ # --------------------------------------------
1706
+ if boundaries is None:
1707
+ inferred = _infer_valid_boundaries_from_mask(mask)
1708
+ logging.info(f"No `boundaries` provided. Using mask-based defaults: {inferred}")
1709
+ return inferred
1710
+
1711
+ # --------------------------------------------
1712
+ # Case 2: boundaries provided → validate
1713
+ # --------------------------------------------
1714
+ if not isinstance(boundaries, dict):
1715
+ raise TypeError(
1716
+ "`boundaries` must be a dict mapping boundary names to booleans."
1717
+ )
1718
+
1719
+ # Unknown keys?
1720
+ unknown_keys = set(boundaries) - valid_keys
1721
+ if unknown_keys:
1722
+ raise ValueError(
1723
+ f"`boundaries` contains invalid keys: {unknown_keys}. "
1724
+ "Allowed keys are: 'south', 'east', 'north', 'west'."
1725
+ )
1726
+
1727
+ # Type-check provided values
1728
+ for key, val in boundaries.items():
1729
+ if not isinstance(val, bool):
1730
+ raise TypeError(f"Boundary '{key}' must be a boolean.")
1731
+
1732
+ # Fill missing boundaries using defaults
1733
+ inferred_defaults = _infer_valid_boundaries_from_mask(mask)
1734
+ completed = boundaries.copy()
1735
+
1736
+ for key in valid_keys:
1737
+ if key not in completed:
1738
+ completed[key] = inferred_defaults[key]
1739
+ logging.info(
1740
+ f"`boundaries[{key!r}]` not provided — defaulting to "
1741
+ f"{inferred_defaults[key]}"
1742
+ )
1743
+
1744
+ logging.info(f"Using boundary configuration: {completed}")
1745
+ return completed
1746
+
1747
+
1748
+ def _infer_valid_boundaries_from_mask(mask: xr.DataArray) -> dict[str, bool]:
1749
+ """
1750
+ Determine which grid boundaries contain at least one ocean point.
1751
+
1752
+ Any boundary consisting entirely of land is considered inactive.
1753
+
1754
+ Parameters
1755
+ ----------
1756
+ mask : xr.DataArray
1757
+ 2D mask array on rho-points where 1 = ocean, 0 = land.
1758
+
1759
+ Returns
1760
+ -------
1761
+ dict[str, bool]
1762
+ Boolean availability for {south, east, north, west}.
1763
+ """
1764
+ bdry_coords = get_boundary_coords()
1765
+ boundaries = {}
1766
+
1767
+ for direction in ["south", "east", "north", "west"]:
1768
+ coords = bdry_coords["rho"][direction]
1769
+ bdry_mask = mask.isel(**coords)
1770
+
1771
+ # Boundary is valid if ANY ocean point exists
1772
+ boundaries[direction] = bool(bdry_mask.values.any())
1773
+
1774
+ return boundaries
@@ -86,18 +86,16 @@ def test_extract_efficiency(create_member_ds: xr.Dataset) -> None:
86
86
  assert eff_rel.time.attrs.get("long_name") == "time since release start"
87
87
 
88
88
 
89
- def test_extract_efficiency_missing_abs_time() -> None:
90
- """Test that _extract_efficiency raises an error if 'abs_time' is missing."""
89
+ def test_extract_efficiency_missing_time() -> None:
90
+ """Test that _extract_efficiency raises an error if 'time' is missing."""
91
91
  times = np.array(["2000-01-01", "2000-01-02"], dtype="datetime64[ns]")
92
92
  ds = xr.Dataset(
93
93
  {"cdr_efficiency": ("time", [0.1, 0.2])},
94
- coords={"time": times}, # Note: no 'abs_time' coordinate
94
+ coords={"abs_time": times}, # Note: no 'time' coordinate
95
95
  )
96
96
 
97
97
  ens = Ensemble.__new__(Ensemble)
98
- with pytest.raises(
99
- ValueError, match="Dataset must contain an 'abs_time' coordinate."
100
- ):
98
+ with pytest.raises(ValueError, match="Dataset must contain a 'time' coordinate."):
101
99
  ens._extract_efficiency(ds)
102
100
 
103
101