roms-tools 3.1.2__py3-none-any.whl → 3.3.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 (221) hide show
  1. roms_tools/__init__.py +3 -0
  2. roms_tools/analysis/cdr_analysis.py +203 -0
  3. roms_tools/analysis/cdr_ensemble.py +198 -0
  4. roms_tools/analysis/roms_output.py +80 -46
  5. roms_tools/data/grids/GLORYS_global_grid.nc +0 -0
  6. roms_tools/download.py +4 -0
  7. roms_tools/plot.py +113 -51
  8. roms_tools/setup/boundary_forcing.py +45 -20
  9. roms_tools/setup/cdr_forcing.py +122 -8
  10. roms_tools/setup/cdr_release.py +161 -8
  11. roms_tools/setup/grid.py +150 -141
  12. roms_tools/setup/initial_conditions.py +113 -48
  13. roms_tools/setup/{datasets.py → lat_lon_datasets.py} +443 -938
  14. roms_tools/setup/mask.py +63 -7
  15. roms_tools/setup/nesting.py +314 -117
  16. roms_tools/setup/river_datasets.py +527 -0
  17. roms_tools/setup/river_forcing.py +46 -20
  18. roms_tools/setup/surface_forcing.py +7 -9
  19. roms_tools/setup/tides.py +2 -3
  20. roms_tools/setup/topography.py +8 -10
  21. roms_tools/setup/utils.py +396 -23
  22. roms_tools/tests/test_analysis/test_cdr_analysis.py +144 -0
  23. roms_tools/tests/test_analysis/test_cdr_ensemble.py +202 -0
  24. roms_tools/tests/test_analysis/test_roms_output.py +61 -3
  25. roms_tools/tests/test_setup/test_boundary_forcing.py +54 -52
  26. roms_tools/tests/test_setup/test_cdr_forcing.py +54 -0
  27. roms_tools/tests/test_setup/test_cdr_release.py +118 -1
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/c/0/0/0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/c/0/0/0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/c/0/0/0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/c/0/0/0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/c/0/0/0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/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_ALT_CO2_west/c/0/0/0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/c/0/0/0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/c/0/0/0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/c/0/0/0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/c/0/0/0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/c/0/0/0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/c/0/0/0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/c/0/0/0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/c/0/0/0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/c/0/0/0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/c/0/0/0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/c/0/0/0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/c/0/0/0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/c/0/0/0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/c/0/0/0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/c/0/0/0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/c/0/0/0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/c/0/0/0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/c/0/0/0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/c/0/0/0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/c/0/0/0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/c/0/0/0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/c/0/0/0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/c/0/0/0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/c/0/0/0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/c/0/0/0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/c/0/0/0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/c/0/0/0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/c/0/0/0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/c/0/0/0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/c/0/0/0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/c/0/0/0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/c/0/0/0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/c/0/0/0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/c/0/0/0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/c/0/0/0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/c/0/0/0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/c/0/0/0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/c/0/0/0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/c/0/0/0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/c/0/0/0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/c/0/0/0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/c/0/0/0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/c/0/0/0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/c/0/0/0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/c/0/0/0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/c/0/0/0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/c/0/0/0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/c/0/0/0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/c/0/0/0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/c/0/0/0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/c/0/0/0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/c/0/0/0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/c/0/0/0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/c/0/0/0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/c/0/0/0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/c/0/0/0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/c/0/0/0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/c/0/0/0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/c/0/0/0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/c/0/0/0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/c/0/0/0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/c/0/0/0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/c/0/0/0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/c/0/0/0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/c/0/0/0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/c/0/0/0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/c/0/0/0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/c/0/0/0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/c/0/0/0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/c/0/0/0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/c/0/0/0 +0 -0
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/c/0/0/0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/c/0/0/0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/c/0/0/0 +0 -0
  111. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/c/0/0/0 +0 -0
  112. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/c/0/0/0 +0 -0
  113. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/c/0/0/0 +0 -0
  114. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/c/0/0/0 +0 -0
  115. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/c/0/0/0 +0 -0
  116. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/c/0/0/0 +0 -0
  117. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/c/0/0/0 +0 -0
  118. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/c/0/0/0 +0 -0
  119. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/c/0/0/0 +0 -0
  120. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/c/0/0/0 +0 -0
  121. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zarr.json +406 -406
  122. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/c/0/0/0 +0 -0
  123. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/c/0/0/0 +0 -0
  124. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/c/0/0/0 +0 -0
  125. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/c/0/0/0 +0 -0
  126. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/c/0/0/0 +0 -0
  127. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/c/0/0/0 +0 -0
  128. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/c/0/0/0 +0 -0
  129. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/c/0/0/0 +0 -0
  130. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/c/0/0/0 +0 -0
  131. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/c/0/0/0 +0 -0
  132. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/c/0/0/0 +0 -0
  133. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/c/0/0/0 +0 -0
  134. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/c/0/0/0 +0 -0
  135. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_south/c/0/0/0 +0 -0
  136. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/c/0/0/0 +0 -0
  137. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/c/0/0 +0 -0
  138. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/c/0/0 +0 -0
  139. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_south/c/0/0 +0 -0
  140. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/c/0/0 +0 -0
  141. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/c/0/0/0 +0 -0
  142. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/c/0/0/0 +0 -0
  143. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/c/0/0/0 +0 -0
  144. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/c/0/0/0 +0 -0
  145. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/c/0/0 +0 -0
  146. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/c/0/0 +0 -0
  147. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/c/0/0 +0 -0
  148. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/c/0/0 +0 -0
  149. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/zarr.json +182 -182
  150. roms_tools/tests/test_setup/test_data/grid.zarr/h/c/0/0 +0 -0
  151. roms_tools/tests/test_setup/test_data/grid.zarr/zarr.json +191 -191
  152. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/c/0/0 +0 -0
  153. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/zarr.json +210 -210
  154. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/c/0/0/0/0 +0 -0
  155. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/c/0/0/0/0 +0 -0
  156. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/c/0/0/0/0 +0 -0
  157. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/c/0/0/0/0 +0 -0
  158. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/c/0/0/0/0 +0 -0
  159. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/c/0/0/0/0 +0 -0
  160. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/c/0/0/0/0 +0 -0
  161. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/c/0/0/0/0 +0 -0
  162. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/c/0/0/0/0 +0 -0
  163. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/c/0/0/0/0 +0 -0
  164. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/c/0/0/0/0 +0 -0
  165. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/c/0/0/0/0 +0 -0
  166. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/c/0/0/0/0 +0 -0
  167. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/c/0/0/0/0 +0 -0
  168. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/c/0/0/0/0 +0 -0
  169. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/c/0/0/0/0 +0 -0
  170. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/c/0/0/0/0 +0 -0
  171. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/c/0/0/0/0 +0 -0
  172. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/c/0/0/0/0 +0 -0
  173. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/c/0/0/0/0 +0 -0
  174. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/c/0/0/0/0 +0 -0
  175. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/c/0/0/0/0 +0 -0
  176. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/c/0/0/0/0 +0 -0
  177. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/c/0/0/0/0 +0 -0
  178. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/c/0/0/0/0 +0 -0
  179. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/c/0/0/0/0 +0 -0
  180. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  181. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/c/0/0/0/0 +0 -0
  182. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/c/0/0/0/0 +0 -0
  183. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/c/0/0/0/0 +0 -0
  184. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/c/0/0/0/0 +0 -0
  185. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/c/0/0/0/0 +0 -0
  186. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  187. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  188. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  189. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  190. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  191. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zarr.json +182 -182
  192. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/c/0/0/0/0 +0 -0
  193. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/salt/c/0/0/0/0 +0 -0
  194. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/temp/c/0/0/0/0 +0 -0
  195. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/u/c/0/0/0/0 +0 -0
  196. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/ubar/c/0/0/0 +0 -0
  197. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/v/c/0/0/0/0 +0 -0
  198. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/vbar/c/0/0/0 +0 -0
  199. roms_tools/tests/test_setup/test_data/initial_conditions_with_unified_bgc_from_climatology.zarr/zarr.json +187 -187
  200. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/c/0/0/0 +0 -0
  201. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/c/0/0/0 +0 -0
  202. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/c/0/0/0 +0 -0
  203. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/c/0/0/0 +0 -0
  204. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/zarr.json +66 -66
  205. roms_tools/tests/test_setup/test_grid.py +236 -115
  206. roms_tools/tests/test_setup/test_initial_conditions.py +94 -41
  207. roms_tools/tests/test_setup/{test_datasets.py → test_lat_lon_datasets.py} +409 -100
  208. roms_tools/tests/test_setup/test_nesting.py +119 -31
  209. roms_tools/tests/test_setup/test_river_datasets.py +48 -0
  210. roms_tools/tests/test_setup/test_surface_forcing.py +2 -1
  211. roms_tools/tests/test_setup/test_utils.py +92 -2
  212. roms_tools/tests/test_setup/utils.py +71 -0
  213. roms_tools/tests/test_tiling/test_join.py +241 -0
  214. roms_tools/tests/test_utils.py +139 -17
  215. roms_tools/tiling/join.py +189 -0
  216. roms_tools/utils.py +131 -99
  217. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/METADATA +12 -2
  218. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/RECORD +221 -211
  219. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/WHEEL +0 -0
  220. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/licenses/LICENSE +0 -0
  221. {roms_tools-3.1.2.dist-info → roms_tools-3.3.0.dist-info}/top_level.txt +0 -0
@@ -121,6 +121,33 @@ def grid_that_straddles_180_degree_meridian_with_global_srtm15_data():
121
121
  return grid
122
122
 
123
123
 
124
+ @pytest.fixture()
125
+ def grid_with_gshhs_coastlines():
126
+ iceland_fjord_kwargs = {
127
+ "nx": 80,
128
+ "ny": 40,
129
+ "size_x": 40,
130
+ "size_y": 20,
131
+ "center_lon": -21.76,
132
+ "center_lat": 64.325,
133
+ "rot": 0,
134
+ "N": 3,
135
+ }
136
+
137
+ # Make sure all 4 L1 files are downloaded
138
+ _ = download_test_data("GSHHS_l_L1.dbf")
139
+ _ = download_test_data("GSHHS_l_L1.prj")
140
+ _ = download_test_data("GSHHS_l_L1.shx")
141
+ shapefile = download_test_data("GSHHS_l_L1.shp")
142
+
143
+ grid = Grid(
144
+ **iceland_fjord_kwargs,
145
+ mask_shapefile=shapefile,
146
+ )
147
+
148
+ return grid
149
+
150
+
124
151
  def test_grid_creation(grid):
125
152
  assert grid.nx == 1
126
153
  assert grid.ny == 1
@@ -175,11 +202,33 @@ def test_coords_relation(grid_fixture, request):
175
202
  "grid_that_straddles_180_degree_meridian_with_shifted_global_etopo_data",
176
203
  "grid_that_straddles_dateline_with_global_srtm15_data",
177
204
  "grid_that_straddles_180_degree_meridian_with_global_srtm15_data",
205
+ "grid_with_gshhs_coastlines",
178
206
  ],
179
207
  )
180
208
  def test_successful_initialization_with_topography(grid_fixture, request):
181
209
  grid = request.getfixturevalue(grid_fixture)
182
- assert grid is not None
210
+
211
+ expected_attrs = [
212
+ "nx",
213
+ "ny",
214
+ "size_x",
215
+ "size_y",
216
+ "center_lon",
217
+ "center_lat",
218
+ "rot",
219
+ "N",
220
+ "theta_s",
221
+ "theta_b",
222
+ "hc",
223
+ "topography_source",
224
+ "hmin",
225
+ "mask_shapefile",
226
+ "verbose",
227
+ "straddle",
228
+ ]
229
+
230
+ for attr in expected_attrs:
231
+ assert hasattr(grid, attr), f"Missing attribute: {attr}"
183
232
 
184
233
 
185
234
  def test_plot(grid_that_straddles_180_degree_meridian):
@@ -187,6 +236,20 @@ def test_plot(grid_that_straddles_180_degree_meridian):
187
236
  grid_that_straddles_180_degree_meridian.plot(with_dim_names=True)
188
237
 
189
238
 
239
+ def test_plot_wide_grid():
240
+ # This grid should be handled via different cartopy projection
241
+ grid = Grid(
242
+ nx=10,
243
+ ny=10,
244
+ size_x=15000,
245
+ size_y=15000,
246
+ center_lon=-161,
247
+ center_lat=14.4,
248
+ rot=-3,
249
+ )
250
+ grid.plot()
251
+
252
+
190
253
  @pytest.mark.skipif(xesmf is None, reason="xesmf required")
191
254
  def test_plot_along_lat_lon(grid_that_straddles_180_degree_meridian):
192
255
  grid_that_straddles_180_degree_meridian.plot(lat=61)
@@ -280,6 +343,7 @@ def test_grid_straddle_crosses_meridian():
280
343
  "grid",
281
344
  "grid_that_straddles_dateline_with_shifted_global_etopo_data",
282
345
  "grid_that_straddles_dateline_with_global_srtm15_data",
346
+ "grid_with_gshhs_coastlines",
283
347
  ],
284
348
  )
285
349
  def test_roundtrip_netcdf(grid_fixture, tmp_path, request):
@@ -301,8 +365,8 @@ def test_roundtrip_netcdf(grid_fixture, tmp_path, request):
301
365
  # Load the grid from the file
302
366
  grid_from_file = Grid.from_file(filepath.with_suffix(".nc"))
303
367
 
304
- # Assert that the initial grid and the loaded grid are equivalent (including the 'ds' attribute)
305
368
  assert grid == grid_from_file
369
+ xr.testing.assert_equal(grid.ds, grid_from_file.ds)
306
370
 
307
371
  # Clean up the .nc file
308
372
  (filepath.with_suffix(".nc")).unlink()
@@ -314,6 +378,7 @@ def test_roundtrip_netcdf(grid_fixture, tmp_path, request):
314
378
  "grid",
315
379
  "grid_that_straddles_dateline_with_shifted_global_etopo_data",
316
380
  "grid_that_straddles_dateline_with_global_srtm15_data",
381
+ "grid_with_gshhs_coastlines",
317
382
  ],
318
383
  )
319
384
  def test_roundtrip_yaml(grid_fixture, tmp_path, request):
@@ -332,8 +397,8 @@ def test_roundtrip_yaml(grid_fixture, tmp_path, request):
332
397
 
333
398
  grid_from_file = Grid.from_yaml(filepath)
334
399
 
335
- # Assert that the initial grid and the loaded grid are equivalent (including the 'ds' attribute)
336
400
  assert grid == grid_from_file
401
+ xr.testing.assert_equal(grid.ds, grid_from_file.ds)
337
402
 
338
403
  filepath = Path(filepath)
339
404
  filepath.unlink()
@@ -345,6 +410,7 @@ def test_roundtrip_yaml(grid_fixture, tmp_path, request):
345
410
  "grid",
346
411
  "grid_that_straddles_dateline_with_shifted_global_etopo_data",
347
412
  "grid_that_straddles_dateline_with_global_srtm15_data",
413
+ "grid_with_gshhs_coastlines",
348
414
  ],
349
415
  )
350
416
  def test_roundtrip_from_file_yaml(grid_fixture, tmp_path, request):
@@ -359,30 +425,33 @@ def test_roundtrip_from_file_yaml(grid_fixture, tmp_path, request):
359
425
  filepath_yaml = Path(tmp_path / "test.yaml")
360
426
  grid_from_file.to_yaml(filepath_yaml)
361
427
 
428
+ grid_from_yaml = Grid.from_yaml(filepath_yaml)
429
+
430
+ assert grid_from_yaml == grid
431
+ xr.testing.assert_equal(grid.ds, grid_from_yaml.ds)
432
+
362
433
  filepath.unlink()
363
434
  filepath_yaml.unlink()
364
435
 
365
436
 
366
- def test_files_have_same_hash(tmp_path):
367
- # Initialize a Grid object using the initializer
368
- grid_init = Grid(
369
- nx=10,
370
- ny=15,
371
- size_x=100.0,
372
- size_y=150.0,
373
- center_lon=0.0,
374
- center_lat=0.0,
375
- rot=0.0,
376
- topography_source={"name": "ETOPO5"},
377
- hmin=5.0,
378
- )
437
+ @pytest.mark.parametrize(
438
+ "grid_fixture",
439
+ [
440
+ "grid",
441
+ "grid_that_straddles_dateline_with_shifted_global_etopo_data",
442
+ "grid_that_straddles_dateline_with_global_srtm15_data",
443
+ "grid_with_gshhs_coastlines",
444
+ ],
445
+ )
446
+ def test_files_have_same_hash(grid_fixture, tmp_path, request):
447
+ grid = request.getfixturevalue(grid_fixture)
379
448
 
380
449
  yaml_filepath = tmp_path / "test_yaml"
381
450
  filepath1 = tmp_path / "test1.nc"
382
451
  filepath2 = tmp_path / "test2.nc"
383
452
 
384
- grid_init.to_yaml(yaml_filepath)
385
- grid_init.save(filepath1)
453
+ grid.to_yaml(yaml_filepath)
454
+ grid.save(filepath1)
386
455
 
387
456
  grid_from_file = Grid.from_yaml(yaml_filepath)
388
457
  grid_from_file.save(filepath2)
@@ -505,6 +574,9 @@ def test_from_yaml_version_mismatch(tmp_path, caplog):
505
574
  yaml_filepath.unlink()
506
575
 
507
576
 
577
+ # Vertical coordinate tests
578
+
579
+
508
580
  def test_invalid_theta_s_value():
509
581
  """Test the validation of the theta_s value."""
510
582
  with pytest.raises(ValueError):
@@ -608,6 +680,152 @@ def test_plot_vertical_coordinate():
608
680
  grid.plot_vertical_coordinate(eta=-1, xi=0, s=-1)
609
681
 
610
682
 
683
+ # Topography tests
684
+
685
+
686
+ def test_enclosed_regions():
687
+ """Test that there are only two connected regions, one dry and one wet."""
688
+ grid = Grid(
689
+ nx=100,
690
+ ny=100,
691
+ size_x=1800,
692
+ size_y=2400,
693
+ center_lon=30,
694
+ center_lat=61,
695
+ rot=20,
696
+ )
697
+
698
+ reg, nreg = label(grid.ds.mask_rho)
699
+ npt.assert_equal(nreg, 2)
700
+
701
+
702
+ def test_rmax_criterion():
703
+ grid = Grid(
704
+ nx=100,
705
+ ny=100,
706
+ size_x=1800,
707
+ size_y=2400,
708
+ center_lon=30,
709
+ center_lat=61,
710
+ rot=20,
711
+ )
712
+ r_eta, r_xi = _compute_rfactor(grid.ds.h)
713
+ rmax0 = np.max([r_eta.max(), r_xi.max()])
714
+ npt.assert_array_less(rmax0, 0.2)
715
+
716
+
717
+ def test_hmin_criterion_and_update_topography():
718
+ grid = Grid(
719
+ nx=100,
720
+ ny=100,
721
+ size_x=1800,
722
+ size_y=2400,
723
+ center_lon=30,
724
+ center_lat=61,
725
+ rot=20,
726
+ hmin=5.0,
727
+ )
728
+
729
+ assert grid.hmin == 5.0
730
+ assert np.less_equal(grid.hmin, grid.ds.h.min())
731
+
732
+ grid.update_topography(hmin=10.0)
733
+
734
+ assert grid.hmin == 10.0
735
+ assert np.less_equal(grid.hmin, grid.ds.h.min())
736
+
737
+ # this should not do anything
738
+ grid.update_topography()
739
+
740
+ assert grid.hmin == 10.0
741
+ assert np.less_equal(grid.hmin, grid.ds.h.min())
742
+
743
+
744
+ # Mask tests
745
+
746
+
747
+ def test_update_mask():
748
+ iceland_fjord_kwargs = {
749
+ "nx": 80,
750
+ "ny": 40,
751
+ "size_x": 40,
752
+ "size_y": 20,
753
+ "center_lon": -21.76,
754
+ "center_lat": 64.325,
755
+ "rot": 0,
756
+ "N": 3,
757
+ }
758
+
759
+ # Make sure all 4 L1 files are downloaded
760
+ _ = download_test_data("GSHHS_l_L1.dbf")
761
+ _ = download_test_data("GSHHS_l_L1.prj")
762
+ _ = download_test_data("GSHHS_l_L1.shx")
763
+ shapefile = download_test_data("GSHHS_l_L1.shp")
764
+
765
+ grid = Grid(
766
+ **iceland_fjord_kwargs,
767
+ mask_shapefile=shapefile,
768
+ )
769
+
770
+ assert grid.mask_shapefile == shapefile
771
+
772
+ # Save original mask
773
+ mask_orig = grid.ds.mask_rho.copy()
774
+
775
+ # Update mask (switches to Natural Earth)
776
+ grid.update_mask()
777
+
778
+ assert grid.mask_shapefile is None
779
+
780
+ # New mask after update
781
+ mask_new = grid.ds.mask_rho.copy()
782
+
783
+ assert abs(mask_new - mask_orig).max() == 1, (
784
+ "Mask should change after update_mask()"
785
+ )
786
+
787
+
788
+ # Boundary tests
789
+
790
+
791
+ def test_mask_topography_boundary():
792
+ """Test that the mask and topography along the grid boundaries (north, south, east,
793
+ west) are identical to the adjacent inland cells.
794
+ """
795
+ # Create a grid with some land along the northern boundary
796
+ grid = Grid(
797
+ nx=10, ny=10, size_x=1000, size_y=1000, center_lon=-20, center_lat=60, rot=0
798
+ )
799
+
800
+ # Toopography
801
+ np.testing.assert_array_equal(
802
+ grid.ds.h.isel(eta_rho=0).data, grid.ds.h.isel(eta_rho=1).data
803
+ )
804
+ np.testing.assert_array_equal(
805
+ grid.ds.h.isel(eta_rho=-1).data, grid.ds.h.isel(eta_rho=-2).data
806
+ )
807
+ np.testing.assert_array_equal(
808
+ grid.ds.h.isel(xi_rho=0).data, grid.ds.h.isel(xi_rho=1).data
809
+ )
810
+ np.testing.assert_array_equal(
811
+ grid.ds.h.isel(xi_rho=-1).data, grid.ds.h.isel(xi_rho=-2).data
812
+ )
813
+
814
+ # Mask
815
+ np.testing.assert_array_equal(
816
+ grid.ds.mask_rho.isel(eta_rho=0).data, grid.ds.mask_rho.isel(eta_rho=1).data
817
+ )
818
+ np.testing.assert_array_equal(
819
+ grid.ds.mask_rho.isel(eta_rho=-1).data, grid.ds.mask_rho.isel(eta_rho=-2).data
820
+ )
821
+ np.testing.assert_array_equal(
822
+ grid.ds.mask_rho.isel(xi_rho=0).data, grid.ds.mask_rho.isel(xi_rho=1).data
823
+ )
824
+ np.testing.assert_array_equal(
825
+ grid.ds.mask_rho.isel(xi_rho=-1).data, grid.ds.mask_rho.isel(xi_rho=-2).data
826
+ )
827
+
828
+
611
829
  # More Grid.from_file() tests
612
830
 
613
831
 
@@ -723,100 +941,3 @@ def test_from_file_partial_parameters_raises_error(grid, tmp_path):
723
941
 
724
942
  with pytest.raises(ValueError, match="must provide all of"):
725
943
  Grid.from_file(path, theta_s=5.0)
726
-
727
-
728
- # Topography tests
729
- def test_enclosed_regions():
730
- """Test that there are only two connected regions, one dry and one wet."""
731
- grid = Grid(
732
- nx=100,
733
- ny=100,
734
- size_x=1800,
735
- size_y=2400,
736
- center_lon=30,
737
- center_lat=61,
738
- rot=20,
739
- )
740
-
741
- reg, nreg = label(grid.ds.mask_rho)
742
- npt.assert_equal(nreg, 2)
743
-
744
-
745
- def test_rmax_criterion():
746
- grid = Grid(
747
- nx=100,
748
- ny=100,
749
- size_x=1800,
750
- size_y=2400,
751
- center_lon=30,
752
- center_lat=61,
753
- rot=20,
754
- )
755
- r_eta, r_xi = _compute_rfactor(grid.ds.h)
756
- rmax0 = np.max([r_eta.max(), r_xi.max()])
757
- npt.assert_array_less(rmax0, 0.2)
758
-
759
-
760
- def test_hmin_criterion():
761
- grid = Grid(
762
- nx=100,
763
- ny=100,
764
- size_x=1800,
765
- size_y=2400,
766
- center_lon=30,
767
- center_lat=61,
768
- rot=20,
769
- hmin=5.0,
770
- )
771
-
772
- assert grid.hmin == 5.0
773
- assert np.less_equal(grid.hmin, grid.ds.h.min())
774
-
775
- grid.update_topography(hmin=10.0)
776
-
777
- assert grid.hmin == 10.0
778
- assert np.less_equal(grid.hmin, grid.ds.h.min())
779
-
780
- # this should not do anything
781
- grid.update_topography()
782
-
783
- assert grid.hmin == 10.0
784
- assert np.less_equal(grid.hmin, grid.ds.h.min())
785
-
786
-
787
- def test_mask_topography_boundary():
788
- """Test that the mask and topography along the grid boundaries (north, south, east,
789
- west) are identical to the adjacent inland cells.
790
- """
791
- # Create a grid with some land along the northern boundary
792
- grid = Grid(
793
- nx=10, ny=10, size_x=1000, size_y=1000, center_lon=-20, center_lat=60, rot=0
794
- )
795
-
796
- # Toopography
797
- np.testing.assert_array_equal(
798
- grid.ds.h.isel(eta_rho=0).data, grid.ds.h.isel(eta_rho=1).data
799
- )
800
- np.testing.assert_array_equal(
801
- grid.ds.h.isel(eta_rho=-1).data, grid.ds.h.isel(eta_rho=-2).data
802
- )
803
- np.testing.assert_array_equal(
804
- grid.ds.h.isel(xi_rho=0).data, grid.ds.h.isel(xi_rho=1).data
805
- )
806
- np.testing.assert_array_equal(
807
- grid.ds.h.isel(xi_rho=-1).data, grid.ds.h.isel(xi_rho=-2).data
808
- )
809
-
810
- # Mask
811
- np.testing.assert_array_equal(
812
- grid.ds.mask_rho.isel(eta_rho=0).data, grid.ds.mask_rho.isel(eta_rho=1).data
813
- )
814
- np.testing.assert_array_equal(
815
- grid.ds.mask_rho.isel(eta_rho=-1).data, grid.ds.mask_rho.isel(eta_rho=-2).data
816
- )
817
- np.testing.assert_array_equal(
818
- grid.ds.mask_rho.isel(xi_rho=0).data, grid.ds.mask_rho.isel(xi_rho=1).data
819
- )
820
- np.testing.assert_array_equal(
821
- grid.ds.mask_rho.isel(xi_rho=-1).data, grid.ds.mask_rho.isel(xi_rho=-2).data
822
- )
@@ -11,7 +11,35 @@ import xarray as xr
11
11
  from conftest import calculate_data_hash
12
12
  from roms_tools import Grid, InitialConditions
13
13
  from roms_tools.download import download_test_data
14
- from roms_tools.setup.datasets import CESMBGCDataset, UnifiedBGCDataset
14
+ from roms_tools.setup.lat_lon_datasets import (
15
+ CESMBGCDataset,
16
+ UnifiedBGCDataset,
17
+ )
18
+ from roms_tools.tests.test_setup.utils import download_regional_and_bigger
19
+
20
+ try:
21
+ import copernicusmarine # type: ignore
22
+ except ImportError:
23
+ copernicusmarine = None
24
+
25
+
26
+ @pytest.fixture
27
+ def example_grid():
28
+ grid = Grid(
29
+ nx=2,
30
+ ny=2,
31
+ size_x=500,
32
+ size_y=1000,
33
+ center_lon=0,
34
+ center_lat=55,
35
+ rot=10,
36
+ N=3, # number of vertical levels
37
+ theta_s=5.0, # surface control parameter
38
+ theta_b=2.0, # bottom control parameter
39
+ hc=250.0, # critical depth
40
+ )
41
+
42
+ return grid
15
43
 
16
44
 
17
45
  @pytest.mark.parametrize(
@@ -25,7 +53,9 @@ from roms_tools.setup.datasets import CESMBGCDataset, UnifiedBGCDataset
25
53
  "initial_conditions_with_unified_bgc_from_climatology",
26
54
  ],
27
55
  )
28
- def test_initial_conditions_creation(ic_fixture, request):
56
+ def test_initial_conditions_creation_with_nondefault_glorys_dataset(
57
+ ic_fixture, request
58
+ ):
29
59
  """Test the creation of the InitialConditions object."""
30
60
  ic = request.getfixturevalue(ic_fixture)
31
61
 
@@ -37,12 +67,65 @@ def test_initial_conditions_creation(ic_fixture, request):
37
67
  }
38
68
  assert hasattr(ic.ds, "adjust_depth_for_sea_surface_height")
39
69
  assert isinstance(ic.ds, xr.Dataset)
40
- assert "temp" in ic.ds
41
- assert "salt" in ic.ds
42
- assert "u" in ic.ds
43
- assert "v" in ic.ds
44
- assert "zeta" in ic.ds
45
70
  assert ic.ds.coords["ocean_time"].attrs["units"] == "seconds"
71
+ expected_vars = {"temp", "salt", "u", "v", "zeta", "ubar", "vbar"}
72
+ assert set(ic.ds.data_vars).issuperset(expected_vars)
73
+
74
+
75
+ @pytest.mark.stream
76
+ @pytest.mark.use_copernicus
77
+ @pytest.mark.use_dask
78
+ def test_initial_conditions_creation_with_default_glorys_dataset(example_grid: Grid):
79
+ """Verify the default GLORYS dataset is loaded when a path is not provided."""
80
+ ic = InitialConditions(
81
+ grid=example_grid,
82
+ ini_time=datetime(2021, 6, 29),
83
+ source={"name": "GLORYS"},
84
+ use_dask=True,
85
+ bypass_validation=True,
86
+ )
87
+ expected_vars = {"temp", "salt", "u", "v", "zeta", "ubar", "vbar"}
88
+ assert set(ic.ds.data_vars).issuperset(expected_vars)
89
+
90
+
91
+ @pytest.mark.use_copernicus
92
+ @pytest.mark.skipif(copernicusmarine is None, reason="copernicusmarine required")
93
+ @pytest.mark.parametrize(
94
+ "grid_fixture",
95
+ [
96
+ "tiny_grid_that_straddles_dateline",
97
+ "tiny_grid_that_straddles_180_degree_meridian",
98
+ "tiny_rotated_grid",
99
+ ],
100
+ )
101
+ def test_invariance_to_get_glorys_bounds(tmp_path, grid_fixture, use_dask, request):
102
+ ini_time = datetime(2012, 1, 1)
103
+ grid = request.getfixturevalue(grid_fixture)
104
+ regional_file, bigger_regional_file = download_regional_and_bigger(
105
+ tmp_path, grid, ini_time
106
+ )
107
+
108
+ ic_from_regional = InitialConditions(
109
+ grid=grid,
110
+ source={"name": "GLORYS", "path": str(regional_file)},
111
+ ini_time=ini_time,
112
+ use_dask=use_dask,
113
+ )
114
+ ic_from_bigger_regional = InitialConditions(
115
+ grid=grid,
116
+ source={"name": "GLORYS", "path": str(bigger_regional_file)},
117
+ ini_time=ini_time,
118
+ use_dask=use_dask,
119
+ )
120
+
121
+ # Use assert_allclose instead of equals: necessary for grids that straddle the 180° meridian.
122
+ # Copernicus returns data on [-180, 180] by default, but if you request a range
123
+ # like [170, 190], it remaps longitudes. That remapping introduces tiny floating
124
+ # point differences in the longitude coordinate, which will then propagate into further differences once you do regridding.
125
+ # Need to adjust the tolerances for these grids that straddle the 180° meridian.
126
+ xr.testing.assert_allclose(
127
+ ic_from_bigger_regional.ds, ic_from_regional.ds, rtol=1e-4, atol=1e-5
128
+ )
46
129
 
47
130
 
48
131
  def test_initial_conditions_creation_with_duplicates(use_dask: bool) -> None:
@@ -67,6 +150,7 @@ def test_initial_conditions_creation_with_duplicates(use_dask: bool) -> None:
67
150
  grid=grid,
68
151
  ini_time=datetime(2012, 1, 1),
69
152
  source={"path": [fname1, fname2], "name": "GLORYS"},
153
+ allow_flex_time=True,
70
154
  use_dask=use_dask,
71
155
  )
72
156
 
@@ -74,6 +158,7 @@ def test_initial_conditions_creation_with_duplicates(use_dask: bool) -> None:
74
158
  grid=grid,
75
159
  ini_time=datetime(2012, 1, 1),
76
160
  source={"path": [fname1, fname1, fname2], "name": "GLORYS"},
161
+ allow_flex_time=True,
77
162
  use_dask=use_dask,
78
163
  )
79
164
 
@@ -134,28 +219,9 @@ def test_initial_condition_creation_with_bgc(ic_fixture, request):
134
219
  assert var in ic.ds
135
220
 
136
221
 
137
- @pytest.fixture
138
- def example_grid():
139
- grid = Grid(
140
- nx=2,
141
- ny=2,
142
- size_x=500,
143
- size_y=1000,
144
- center_lon=0,
145
- center_lat=55,
146
- rot=10,
147
- N=3, # number of vertical levels
148
- theta_s=5.0, # surface control parameter
149
- theta_b=2.0, # bottom control parameter
150
- hc=250.0, # critical depth
151
- )
152
-
153
- return grid
154
-
155
-
156
222
  # Test initialization with missing 'name' in source
157
223
  def test_initial_conditions_missing_physics_name(example_grid, use_dask):
158
- with pytest.raises(ValueError, match="`source` must include a 'name'."):
224
+ with pytest.raises(ValueError, match="`source` must include a 'name'"):
159
225
  InitialConditions(
160
226
  grid=example_grid,
161
227
  ini_time=datetime(2021, 6, 29),
@@ -164,23 +230,10 @@ def test_initial_conditions_missing_physics_name(example_grid, use_dask):
164
230
  )
165
231
 
166
232
 
167
- # Test initialization with missing 'path' in source
168
- def test_initial_conditions_missing_physics_path(example_grid, use_dask):
169
- with pytest.raises(ValueError, match="`source` must include a 'path'."):
170
- InitialConditions(
171
- grid=example_grid,
172
- ini_time=datetime(2021, 6, 29),
173
- source={"name": "GLORYS"},
174
- use_dask=use_dask,
175
- )
176
-
177
-
178
233
  # Test initialization with missing 'name' in bgc_source
179
234
  def test_initial_conditions_missing_bgc_name(example_grid, use_dask):
180
235
  fname = Path(download_test_data("GLORYS_coarse_test_data.nc"))
181
- with pytest.raises(
182
- ValueError, match="`bgc_source` must include a 'name' if it is provided."
183
- ):
236
+ with pytest.raises(ValueError, match="`bgc_source` must include a 'name'"):
184
237
  InitialConditions(
185
238
  grid=example_grid,
186
239
  ini_time=datetime(2021, 6, 29),