roms-tools 1.4.0__py3-none-any.whl → 1.4.2__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 (250) hide show
  1. ci/environment.yml +1 -8
  2. roms_tools/_version.py +1 -1
  3. roms_tools/setup/boundary_forcing.py +77 -70
  4. roms_tools/setup/datasets.py +38 -59
  5. roms_tools/setup/download.py +3 -6
  6. roms_tools/setup/fill.py +8 -16
  7. roms_tools/setup/grid.py +147 -102
  8. roms_tools/setup/initial_conditions.py +43 -36
  9. roms_tools/setup/mixins.py +10 -14
  10. roms_tools/setup/surface_forcing.py +35 -33
  11. roms_tools/setup/tides.py +37 -41
  12. roms_tools/setup/topography.py +36 -18
  13. roms_tools/setup/utils.py +19 -40
  14. roms_tools/setup/vertical_coordinate.py +4 -6
  15. roms_tools/tests/test_setup/test_boundary_forcing.py +6 -13
  16. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_east/0.0.0 +0 -0
  17. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_north/0.0.0 +0 -0
  18. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_south/0.0.0 +0 -0
  19. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_ALT_CO2_west/0.0.0 +0 -0
  20. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_east/0.0.0 +0 -0
  21. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_north/0.0.0 +0 -0
  22. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_south/0.0.0 +0 -0
  23. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/ALK_west/0.0.0 +0 -0
  24. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_east/0.0.0 +0 -0
  25. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_north/0.0.0 +0 -0
  26. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_south/0.0.0 +0 -0
  27. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_ALT_CO2_west/0.0.0 +0 -0
  28. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_east/0.0.0 +0 -0
  29. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_north/0.0.0 +0 -0
  30. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_south/0.0.0 +0 -0
  31. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DIC_west/0.0.0 +0 -0
  32. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_east/0.0.0 +0 -0
  33. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_north/0.0.0 +0 -0
  34. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_south/0.0.0 +0 -0
  35. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOC_west/0.0.0 +0 -0
  36. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_east/0.0.0 +0 -0
  37. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_north/0.0.0 +0 -0
  38. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_south/0.0.0 +0 -0
  39. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOCr_west/0.0.0 +0 -0
  40. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_east/0.0.0 +0 -0
  41. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_north/0.0.0 +0 -0
  42. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_south/0.0.0 +0 -0
  43. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DON_west/0.0.0 +0 -0
  44. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_east/0.0.0 +0 -0
  45. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_north/0.0.0 +0 -0
  46. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_south/0.0.0 +0 -0
  47. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DONr_west/0.0.0 +0 -0
  48. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_east/0.0.0 +0 -0
  49. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_north/0.0.0 +0 -0
  50. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_south/0.0.0 +0 -0
  51. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOP_west/0.0.0 +0 -0
  52. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_east/0.0.0 +0 -0
  53. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_north/0.0.0 +0 -0
  54. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_south/0.0.0 +0 -0
  55. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/DOPr_west/0.0.0 +0 -0
  56. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_east/0.0.0 +0 -0
  57. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_north/0.0.0 +0 -0
  58. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_south/0.0.0 +0 -0
  59. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Fe_west/0.0.0 +0 -0
  60. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_east/0.0.0 +0 -0
  61. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_north/0.0.0 +0 -0
  62. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_south/0.0.0 +0 -0
  63. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/Lig_west/0.0.0 +0 -0
  64. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_east/0.0.0 +0 -0
  65. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_north/0.0.0 +0 -0
  66. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_south/0.0.0 +0 -0
  67. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NH4_west/0.0.0 +0 -0
  68. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_east/0.0.0 +0 -0
  69. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_north/0.0.0 +0 -0
  70. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_south/0.0.0 +0 -0
  71. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/NO3_west/0.0.0 +0 -0
  72. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_east/0.0.0 +0 -0
  73. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_north/0.0.0 +0 -0
  74. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_south/0.0.0 +0 -0
  75. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/O2_west/0.0.0 +0 -0
  76. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_east/0.0.0 +0 -0
  77. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_north/0.0.0 +0 -0
  78. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_south/0.0.0 +0 -0
  79. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/PO4_west/0.0.0 +0 -0
  80. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_east/0.0.0 +0 -0
  81. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_north/0.0.0 +0 -0
  82. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_south/0.0.0 +0 -0
  83. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/SiO3_west/0.0.0 +0 -0
  84. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_east/0.0.0 +0 -0
  85. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_north/0.0.0 +0 -0
  86. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_south/0.0.0 +0 -0
  87. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatC_west/0.0.0 +0 -0
  88. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_east/0.0.0 +0 -0
  89. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_north/0.0.0 +0 -0
  90. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_south/0.0.0 +0 -0
  91. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatChl_west/0.0.0 +0 -0
  92. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_east/0.0.0 +0 -0
  93. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_north/0.0.0 +0 -0
  94. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_south/0.0.0 +0 -0
  95. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatFe_west/0.0.0 +0 -0
  96. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_east/0.0.0 +0 -0
  97. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_north/0.0.0 +0 -0
  98. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_south/0.0.0 +0 -0
  99. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatP_west/0.0.0 +0 -0
  100. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_east/0.0.0 +0 -0
  101. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_north/0.0.0 +0 -0
  102. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_south/0.0.0 +0 -0
  103. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diatSi_west/0.0.0 +0 -0
  104. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_east/0.0.0 +0 -0
  105. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_north/0.0.0 +0 -0
  106. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_south/0.0.0 +0 -0
  107. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazC_west/0.0.0 +0 -0
  108. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_east/0.0.0 +0 -0
  109. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_north/0.0.0 +0 -0
  110. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_south/0.0.0 +0 -0
  111. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazChl_west/0.0.0 +0 -0
  112. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_east/0.0.0 +0 -0
  113. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_north/0.0.0 +0 -0
  114. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_south/0.0.0 +0 -0
  115. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazFe_west/0.0.0 +0 -0
  116. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_east/0.0.0 +0 -0
  117. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_north/0.0.0 +0 -0
  118. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_south/0.0.0 +0 -0
  119. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/diazP_west/0.0.0 +0 -0
  120. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_east/0.0.0 +0 -0
  121. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_north/0.0.0 +0 -0
  122. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_south/0.0.0 +0 -0
  123. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spC_west/0.0.0 +0 -0
  124. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_east/0.0.0 +0 -0
  125. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_north/0.0.0 +0 -0
  126. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_south/0.0.0 +0 -0
  127. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spCaCO3_west/0.0.0 +0 -0
  128. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_east/0.0.0 +0 -0
  129. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_north/0.0.0 +0 -0
  130. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_south/0.0.0 +0 -0
  131. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spChl_west/0.0.0 +0 -0
  132. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_east/0.0.0 +0 -0
  133. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_north/0.0.0 +0 -0
  134. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_south/0.0.0 +0 -0
  135. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spFe_west/0.0.0 +0 -0
  136. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_east/0.0.0 +0 -0
  137. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_north/0.0.0 +0 -0
  138. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_south/0.0.0 +0 -0
  139. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/spP_west/0.0.0 +0 -0
  140. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_east/0.0.0 +0 -0
  141. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_north/0.0.0 +0 -0
  142. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_south/0.0.0 +0 -0
  143. roms_tools/tests/test_setup/test_data/bgc_boundary_forcing_from_climatology.zarr/zooC_west/0.0.0 +0 -0
  144. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_east/0.0.0 +0 -0
  145. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_north/0.0.0 +0 -0
  146. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_south/0.0.0 +0 -0
  147. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/salt_west/0.0.0 +0 -0
  148. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_east/0.0.0 +0 -0
  149. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_north/0.0.0 +0 -0
  150. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_south/0.0.0 +0 -0
  151. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/temp_west/0.0.0 +0 -0
  152. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_east/0.0.0 +0 -0
  153. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_north/0.0.0 +0 -0
  154. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/u_west/0.0.0 +0 -0
  155. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_east/0.0 +0 -0
  156. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_north/0.0 +0 -0
  157. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/ubar_west/0.0 +0 -0
  158. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_east/0.0.0 +0 -0
  159. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_north/0.0.0 +0 -0
  160. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_south/0.0.0 +0 -0
  161. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/v_west/0.0.0 +0 -0
  162. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_east/0.0 +0 -0
  163. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_north/0.0 +0 -0
  164. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_south/0.0 +0 -0
  165. roms_tools/tests/test_setup/test_data/boundary_forcing.zarr/vbar_west/0.0 +0 -0
  166. roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +1 -1
  167. roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +1 -1
  168. roms_tools/tests/test_setup/test_data/grid.zarr/angle/0.0 +0 -0
  169. roms_tools/tests/test_setup/test_data/grid.zarr/angle_coarse/0.0 +0 -0
  170. roms_tools/tests/test_setup/test_data/grid.zarr/f/0.0 +0 -0
  171. roms_tools/tests/test_setup/test_data/grid.zarr/h/0.0 +0 -0
  172. roms_tools/tests/test_setup/test_data/grid.zarr/lat_coarse/0.0 +0 -0
  173. roms_tools/tests/test_setup/test_data/grid.zarr/lat_rho/0.0 +0 -0
  174. roms_tools/tests/test_setup/test_data/grid.zarr/lat_u/0.0 +0 -0
  175. roms_tools/tests/test_setup/test_data/grid.zarr/lat_v/0.0 +0 -0
  176. roms_tools/tests/test_setup/test_data/grid.zarr/lon_u/0.0 +0 -0
  177. roms_tools/tests/test_setup/test_data/grid.zarr/pm/0.0 +0 -0
  178. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +1 -1
  179. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +1 -1
  180. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle/0.0 +0 -0
  181. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/angle_coarse/0.0 +0 -0
  182. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/f/0.0 +0 -0
  183. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/h/0.0 +0 -0
  184. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_coarse/0.0 +0 -0
  185. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_rho/0.0 +0 -0
  186. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_u/0.0 +0 -0
  187. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_v/0.0 +0 -0
  188. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_coarse/0.0 +0 -0
  189. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_rho/0.0 +0 -0
  190. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_u/0.0 +0 -0
  191. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_v/0.0 +0 -0
  192. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pm/0.0 +0 -0
  193. roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/pn/0.0 +0 -0
  194. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK/0.0.0.0 +0 -0
  195. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ALK_ALT_CO2/0.0.0.0 +0 -0
  196. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC/0.0.0.0 +0 -0
  197. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DIC_ALT_CO2/0.0.0.0 +0 -0
  198. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOC/0.0.0.0 +0 -0
  199. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOCr/0.0.0.0 +0 -0
  200. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DON/0.0.0.0 +0 -0
  201. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DONr/0.0.0.0 +0 -0
  202. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOP/0.0.0.0 +0 -0
  203. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/DOPr/0.0.0.0 +0 -0
  204. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Fe/0.0.0.0 +0 -0
  205. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/Lig/0.0.0.0 +0 -0
  206. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NH4/0.0.0.0 +0 -0
  207. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/NO3/0.0.0.0 +0 -0
  208. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/O2/0.0.0.0 +0 -0
  209. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/PO4/0.0.0.0 +0 -0
  210. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/SiO3/0.0.0.0 +0 -0
  211. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatC/0.0.0.0 +0 -0
  212. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatChl/0.0.0.0 +0 -0
  213. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatFe/0.0.0.0 +0 -0
  214. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatP/0.0.0.0 +0 -0
  215. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diatSi/0.0.0.0 +0 -0
  216. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazC/0.0.0.0 +0 -0
  217. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazChl/0.0.0.0 +0 -0
  218. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazFe/0.0.0.0 +0 -0
  219. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/diazP/0.0.0.0 +0 -0
  220. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/salt/0.0.0.0 +0 -0
  221. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spC/0.0.0.0 +0 -0
  222. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spCaCO3/0.0.0.0 +0 -0
  223. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spChl/0.0.0.0 +0 -0
  224. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spFe/0.0.0.0 +0 -0
  225. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/spP/0.0.0.0 +0 -0
  226. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/temp/0.0.0.0 +0 -0
  227. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/u/0.0.0.0 +0 -0
  228. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/ubar/0.0.0 +0 -0
  229. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/v/0.0.0.0 +0 -0
  230. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/vbar/0.0.0 +0 -0
  231. roms_tools/tests/test_setup/test_data/initial_conditions_with_bgc_from_climatology.zarr/zooC/0.0.0.0 +0 -0
  232. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Im/0.0.0 +0 -0
  233. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/u_Re/0.0.0 +0 -0
  234. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Im/0.0.0 +0 -0
  235. roms_tools/tests/test_setup/test_data/tidal_forcing.zarr/v_Re/0.0.0 +0 -0
  236. roms_tools/tests/test_setup/test_datasets.py +8 -18
  237. roms_tools/tests/test_setup/test_grid.py +58 -2
  238. roms_tools/tests/test_setup/test_initial_conditions.py +4 -7
  239. roms_tools/tests/test_setup/test_surface_forcing.py +58 -58
  240. roms_tools/tests/test_setup/test_tides.py +6 -10
  241. roms_tools/tests/test_setup/test_topography.py +38 -0
  242. roms_tools/tests/test_setup/test_vertical_coordinate.py +2 -6
  243. roms_tools/tests/test_utils.py +30 -0
  244. roms_tools/utils.py +45 -10
  245. roms_tools-1.4.2.dist-info/LICENSE +201 -0
  246. {roms_tools-1.4.0.dist-info → roms_tools-1.4.2.dist-info}/METADATA +3 -1
  247. {roms_tools-1.4.0.dist-info → roms_tools-1.4.2.dist-info}/RECORD +249 -249
  248. {roms_tools-1.4.0.dist-info → roms_tools-1.4.2.dist-info}/WHEEL +1 -1
  249. roms_tools-1.4.0.dist-info/LICENSE +0 -674
  250. {roms_tools-1.4.0.dist-info → roms_tools-1.4.2.dist-info}/top_level.txt +0 -0
roms_tools/setup/fill.py CHANGED
@@ -6,9 +6,8 @@ from scipy import sparse
6
6
 
7
7
  class LateralFill:
8
8
  def __init__(self, mask, dims, tol=1.0e-4):
9
- """
10
- Initializes the LateralFill class, which fills NaN values in a DataArray
11
- by iteratively solving a Poisson equation using a lateral diffusion approach.
9
+ """Initializes the LateralFill class, which fills NaN values in a DataArray by
10
+ iteratively solving a Poisson equation using a lateral diffusion approach.
12
11
 
13
12
  Parameters
14
13
  ----------
@@ -51,8 +50,7 @@ class LateralFill:
51
50
  self.tol = tol
52
51
 
53
52
  def apply(self, var):
54
- """
55
- Fills NaN values in an xarray DataArray using iterative lateral diffusion.
53
+ """Fills NaN values in an xarray DataArray using iterative lateral diffusion.
56
54
 
57
55
  Parameters
58
56
  ----------
@@ -65,7 +63,6 @@ class LateralFill:
65
63
  var_filled : xarray.DataArray
66
64
  A DataArray with NaN values filled by iterative smoothing, while preserving
67
65
  non-NaN values.
68
-
69
66
  """
70
67
  # Apply fill to anomaly field
71
68
  mean = var.mean(dim=self.dims, skipna=True)
@@ -96,11 +93,9 @@ class LateralFill:
96
93
 
97
94
 
98
95
  def _lateral_fill_np_array(x0, b, ml, tol=1.0e-4):
99
- """
100
- Fills all NaN values in a 2D NumPy array using an iterative solver,
101
- while preserving the existing non-NaN values.
102
- The filling process uses an AMG solver to efficiently perform smoothing
103
- based on the Laplace operator.
96
+ """Fills all NaN values in a 2D NumPy array using an iterative solver, while
97
+ preserving the existing non-NaN values. The filling process uses an AMG solver to
98
+ efficiently perform smoothing based on the Laplace operator.
104
99
 
105
100
  Parameters
106
101
  ----------
@@ -136,8 +131,7 @@ def _lateral_fill_np_array(x0, b, ml, tol=1.0e-4):
136
131
 
137
132
 
138
133
  def laplacian(grid, mask, dtype=float, format=None):
139
- """
140
- Return a sparse matrix for solving a 2-dimensional Poisson problem.
134
+ """Return a sparse matrix for solving a 2-dimensional Poisson problem.
141
135
 
142
136
  This function generates a finite difference approximation of the Laplacian operator
143
137
  on a 2-dimensional grid with unit grid spacing and Dirichlet boundary conditions.
@@ -164,7 +158,6 @@ def laplacian(grid, mask, dtype=float, format=None):
164
158
  sparse matrix
165
159
  A sparse matrix representing the finite difference Laplacian operator for
166
160
  the given grid.
167
-
168
161
  """
169
162
  grid = tuple(grid)
170
163
 
@@ -180,8 +173,7 @@ def laplacian(grid, mask, dtype=float, format=None):
180
173
 
181
174
 
182
175
  def stencil_grid_mod(S, grid, msk, dtype=None, format=None):
183
- """
184
- Construct a sparse matrix from a local matrix stencil.
176
+ """Construct a sparse matrix from a local matrix stencil.
185
177
 
186
178
  This function generates a sparse matrix that represents an operator
187
179
  by applying the given stencil `S` at each vertex of a regular grid with
roms_tools/setup/grid.py CHANGED
@@ -21,29 +21,28 @@ RADIUS_OF_EARTH = 6371315.0 # in m
21
21
 
22
22
  @dataclass(frozen=True, kw_only=True)
23
23
  class Grid:
24
- """
25
- A single ROMS grid.
26
-
27
- Used for creating, plotting, and then saving a new ROMS domain grid.
28
-
29
- Parameters
30
- ----------
31
- nx : int
32
- Number of grid points in the x-direction.
33
- ny : int
34
- Number of grid points in the y-direction.
35
- size_x : float
36
- Domain size in the x-direction (in kilometers).
37
- size_y : float
38
- Domain size in the y-direction (in kilometers).
39
- center_lon : float
40
- Longitude of grid center.
41
- center_lat : float
42
- Latitude of grid center.
43
- rot : float, optional
44
- Rotation of grid x-direction from lines of constant latitude, measured in degrees.
45
- Positive values represent a counterclockwise rotation.
46
- The default is 0, which means that the x-direction of the grid is aligned with lines of constant latitude.
24
+ """A single ROMS grid.
25
+
26
+ Used for creating, plotting, and then saving a new ROMS domain grid.
27
+
28
+ Parameters
29
+ ----------
30
+ nx : int
31
+ Number of grid points in the x-direction.
32
+ ny : int
33
+ Number of grid points in the y-direction.
34
+ size_x : float
35
+ Domain size in the x-direction (in kilometers).
36
+ size_y : float
37
+ Domain size in the y-direction (in kilometers).
38
+ center_lon : float
39
+ Longitude of grid center.
40
+ center_lat : float
41
+ Latitude of grid center.
42
+ rot : float, optional
43
+ Rotation of grid x-direction from lines of constant latitude, measured in degrees.
44
+ Positive values represent a counterclockwise rotation.
45
+ The default is 0, which means that the x-direction of the grid is aligned with lines of constant latitude.
47
46
  N : int, optional
48
47
  The number of vertical levels. The default is 100.
49
48
  theta_s : float, optional
@@ -58,44 +57,10 @@ class Grid:
58
57
  hmin : float, optional
59
58
  The minimum ocean depth (in meters). The default is 5.0.
60
59
 
61
- Attributes
62
- ----------
63
- nx : int
64
- Number of grid points in the x-direction.
65
- ny : int
66
- Number of grid points in the y-direction.
67
- size_x : float
68
- Domain size in the x-direction (in kilometers).
69
- size_y : float
70
- Domain size in the y-direction (in kilometers).
71
- center_lon : float
72
- Longitude of grid center.
73
- center_lat : float
74
- Latitude of grid center.
75
- rot : float
76
- Rotation of grid x-direction from lines of constant latitude.
77
- N : int
78
- The number of vertical levels.
79
- theta_s : float
80
- The surface control parameter.
81
- theta_b : float
82
- The bottom control parameter.
83
- hc : float
84
- The critical depth (in meters).
85
- topography_source : str
86
- Data source used for the topography.
87
- hmin : float
88
- Minimum ocean depth (in meters).
89
- ds : xr.Dataset
90
- The xarray Dataset containing the grid data.
91
- straddle : bool
92
- Indicates if the Greenwich meridian (0° longitude) intersects the domain.
93
- `True` if it does, `False` otherwise.
94
-
95
- Raises
96
- ------
97
- ValueError
98
- If you try to create a grid with domain size larger than 20000 km.
60
+ Raises
61
+ ------
62
+ ValueError
63
+ If you try to create a grid with domain size larger than 20000 km.
99
64
  """
100
65
 
101
66
  nx: int
@@ -137,7 +102,6 @@ class Grid:
137
102
  # Check if the Greenwich meridian goes through the domain.
138
103
  self._straddle()
139
104
 
140
- ds = _add_lat_lon_at_velocity_points(self.ds, self.straddle)
141
105
  object.__setattr__(self, "ds", ds)
142
106
 
143
107
  # Update the grid by adding grid variables that are coarsened versions of the original grid variables
@@ -148,8 +112,8 @@ class Grid:
148
112
  )
149
113
 
150
114
  def update_topography_and_mask(self, hmin, topography_source="ETOPO5") -> None:
151
- """
152
- Update the grid dataset by adding or overwriting the topography and land/sea mask.
115
+ """Update the grid dataset by adding or overwriting the topography and land/sea
116
+ mask.
153
117
 
154
118
  This method processes the topography data and generates a land/sea mask.
155
119
  It applies several steps, including interpolating topography, smoothing
@@ -177,8 +141,7 @@ class Grid:
177
141
  object.__setattr__(self, "hmin", hmin)
178
142
 
179
143
  def _straddle(self) -> None:
180
- """
181
- Check if the Greenwich meridian goes through the domain.
144
+ """Check if the Greenwich meridian goes through the domain.
182
145
 
183
146
  This method sets the `straddle` attribute to `True` if the Greenwich meridian
184
147
  (0° longitude) intersects the domain defined by `lon_rho`. Otherwise, it sets
@@ -197,9 +160,8 @@ class Grid:
197
160
  object.__setattr__(self, "straddle", False)
198
161
 
199
162
  def _coarsen(self):
200
- """
201
- Update the grid by adding grid variables that are coarsened versions of the original
202
- fine-resoluion grid variables. The coarsening is by a factor of two.
163
+ """Update the grid by adding grid variables that are coarsened versions of the
164
+ original fine-resoluion grid variables. The coarsening is by a factor of two.
203
165
 
204
166
  The specific variables being coarsened are:
205
167
  - `lon_rho` -> `lon_coarse`: Longitude at rho points.
@@ -250,8 +212,7 @@ class Grid:
250
212
  self.ds[coarse_var].attrs["units"] = self.ds[fine_var].attrs["units"]
251
213
 
252
214
  def update_vertical_coordinate(self, N, theta_s, theta_b, hc) -> None:
253
- """
254
- Create vertical coordinate variables for the ROMS grid.
215
+ """Create vertical coordinate variables for the ROMS grid.
255
216
 
256
217
  This method computes the S-coordinate stretching curves and depths
257
218
  at various grid points (rho, u, v) using the specified parameters.
@@ -354,8 +315,7 @@ class Grid:
354
315
  object.__setattr__(self, "N", N)
355
316
 
356
317
  def plot(self, bathymetry: bool = False) -> None:
357
- """
358
- Plot the grid.
318
+ """Plot the grid.
359
319
 
360
320
  Parameters
361
321
  ----------
@@ -366,7 +326,6 @@ class Grid:
366
326
  -------
367
327
  None
368
328
  This method does not return any value. It generates and displays a plot.
369
-
370
329
  """
371
330
 
372
331
  if bathymetry:
@@ -397,19 +356,20 @@ class Grid:
397
356
  eta=None,
398
357
  xi=None,
399
358
  ) -> None:
400
- """
401
- Plot the vertical coordinate system for a given eta-, xi-, or s-slice.
359
+ """Plot the vertical coordinate system for a given eta-, xi-, or s-slice.
402
360
 
403
361
  Parameters
404
362
  ----------
405
363
  varname : str, optional
406
364
  The vertical coordinate field to plot. Options include:
365
+
407
366
  - "layer_depth_rho": Layer depth at rho-points.
408
367
  - "layer_depth_u": Layer depth at u-points.
409
368
  - "layer_depth_v": Layer depth at v-points.
410
369
  - "interface_depth_rho": Interface depth at rho-points.
411
370
  - "interface_depth_u": Interface depth at u-points.
412
371
  - "interface_depth_v": Interface depth at v-points.
372
+
413
373
  s: int, optional
414
374
  The s-index to plot. Default is None.
415
375
  eta : int, optional
@@ -527,17 +487,19 @@ class Grid:
527
487
  def save(
528
488
  self, filepath: Union[str, Path], np_eta: int = None, np_xi: int = None
529
489
  ) -> None:
530
- """
531
- Save the grid information to a netCDF4 file.
490
+ """Save the grid information to a netCDF4 file.
532
491
 
533
492
  This method supports saving the dataset in two modes:
534
493
 
535
- 1. **Single File Mode (default)**:
536
- - If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single file at the specified `filepath.nc`.
494
+ 1. **Single File Mode (default)**:
537
495
 
538
- 2. **Partitioned Mode**:
539
- - If either `np_eta` or `np_xi` is specified, the dataset is divided into spatial tiles along the eta-axis and xi-axis.
540
- - The files are saved as `filepath.0.nc`, `filepath.1.nc`, ..., where the numbering corresponds to the partition index.
496
+ If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single netCDF4 file
497
+ with the base filename specified by `filepath.nc`.
498
+
499
+ 2. **Partitioned Mode**:
500
+
501
+ - If either `np_eta` or `np_xi` is specified, the dataset is divided into spatial tiles along the eta-axis and xi-axis.
502
+ - Each spatial tile is saved as a separate netCDF4 file.
541
503
 
542
504
  Parameters
543
505
  ----------
@@ -572,8 +534,7 @@ class Grid:
572
534
 
573
535
  @classmethod
574
536
  def from_file(cls, filepath: Union[str, Path]) -> "Grid":
575
- """
576
- Create a Grid instance from an existing file.
537
+ """Create a Grid instance from an existing file.
577
538
 
578
539
  Parameters
579
540
  ----------
@@ -687,8 +648,8 @@ class Grid:
687
648
  return grid
688
649
 
689
650
  def to_yaml(self, filepath: Union[str, Path]) -> None:
690
- """
691
- Export the parameters of the class to a YAML file, including the version of roms-tools.
651
+ """Export the parameters of the class to a YAML file, including the version of
652
+ roms-tools.
692
653
 
693
654
  Parameters
694
655
  ----------
@@ -722,8 +683,7 @@ class Grid:
722
683
 
723
684
  @classmethod
724
685
  def from_yaml(cls, filepath: Union[str, Path]) -> "Grid":
725
- """
726
- Create an instance of the class from a YAML file.
686
+ """Create an instance of the class from a YAML file.
727
687
 
728
688
  Parameters
729
689
  ----------
@@ -805,7 +765,6 @@ def _make_grid_ds(
805
765
 
806
766
  # rotate coordinate system
807
767
  rotated_lon_lat_vars = _rotate(*initial_lon_lat_vars, rot)
808
- lon, *_ = rotated_lon_lat_vars
809
768
 
810
769
  # translate coordinate system
811
770
  translated_lon_lat_vars = _translate(*rotated_lon_lat_vars, center_lat, center_lon)
@@ -817,7 +776,28 @@ def _make_grid_ds(
817
776
  # compute angle of local grid positive x-axis relative to east
818
777
  ang = _compute_angle(lon, lonu, latu, lonq)
819
778
 
820
- ds = _create_grid_ds(lon, lat, pm, pn, ang, rot, center_lon, center_lat)
779
+ # make sure lons are in [0, 360] range
780
+ lon[lon < 0] = lon[lon < 0] + 2 * np.pi
781
+ lonu[lonu < 0] = lonu[lonu < 0] + 2 * np.pi
782
+ lonv[lonv < 0] = lonv[lonv < 0] + 2 * np.pi
783
+ lonq[lonq < 0] = lonq[lonq < 0] + 2 * np.pi
784
+
785
+ ds = _create_grid_ds(
786
+ lon,
787
+ lat,
788
+ lonu,
789
+ latu,
790
+ lonv,
791
+ latv,
792
+ lonq,
793
+ latq,
794
+ pm,
795
+ pn,
796
+ ang,
797
+ rot,
798
+ center_lon,
799
+ center_lat,
800
+ )
821
801
 
822
802
  ds = _add_global_metadata(ds, size_x, size_y, center_lon, center_lat, rot)
823
803
 
@@ -896,7 +876,7 @@ def _make_initial_lon_lat_ds(size_x, size_y, nx, ny):
896
876
 
897
877
 
898
878
  def _rotate(lon, lat, lonu, latu, lonv, latv, lonq, latq, rot):
899
- """Rotate grid counterclockwise relative to surface of Earth by rot degrees"""
879
+ """Rotate grid counterclockwise relative to surface of Earth by rot degrees."""
900
880
 
901
881
  (lon, lat) = _rot_sphere(lon, lat, rot)
902
882
  (lonu, latu) = _rot_sphere(lonu, latu, rot)
@@ -1036,7 +1016,8 @@ def _tra_sphere(lon, lat, tra):
1036
1016
 
1037
1017
 
1038
1018
  def _compute_coordinate_metrics(lon, lonu, latu, lonv, latv):
1039
- """Compute the curvilinear coordinate metrics pn and pm, defined as 1/grid spacing"""
1019
+ """Compute the curvilinear coordinate metrics pn and pm, defined as 1/grid
1020
+ spacing."""
1040
1021
 
1041
1022
  # pm = 1/dx
1042
1023
  pmu = gc_dist(lonu[:, :-1], latu[:, :-1], lonu[:, 1:], latu[:, 1:])
@@ -1077,7 +1058,7 @@ def gc_dist(lon1, lat1, lon2, lat2):
1077
1058
 
1078
1059
 
1079
1060
  def _compute_angle(lon, lonu, latu, lonq):
1080
- """Compute angles of local grid positive x-axis relative to east"""
1061
+ """Compute angles of local grid positive x-axis relative to east."""
1081
1062
 
1082
1063
  dellat = latu[:, 1:] - latu[:, :-1]
1083
1064
  dellon = lonu[:, 1:] - lonu[:, :-1]
@@ -1096,15 +1077,18 @@ def _compute_angle(lon, lonu, latu, lonq):
1096
1077
  ang[:, 0] = ang[:, 1]
1097
1078
  ang[:, -1] = ang[:, -2]
1098
1079
 
1099
- lon[lon < 0] = lon[lon < 0] + 2 * np.pi
1100
- lonq[lonq < 0] = lonq[lonq < 0] + 2 * np.pi
1101
-
1102
1080
  return ang
1103
1081
 
1104
1082
 
1105
1083
  def _create_grid_ds(
1106
1084
  lon,
1107
1085
  lat,
1086
+ lonu,
1087
+ latu,
1088
+ lonv,
1089
+ latv,
1090
+ lonq,
1091
+ latq,
1108
1092
  pm,
1109
1093
  pn,
1110
1094
  angle,
@@ -1124,8 +1108,49 @@ def _create_grid_ds(
1124
1108
  dims=["eta_rho", "xi_rho"],
1125
1109
  attrs={"long_name": "latitude of rho-points", "units": "degrees North"},
1126
1110
  )
1111
+ lon_u = xr.Variable(
1112
+ data=lonu * 180 / np.pi,
1113
+ dims=["eta_rho", "xi_u"],
1114
+ attrs={"long_name": "longitude of u-points", "units": "degrees East"},
1115
+ )
1116
+ lat_u = xr.Variable(
1117
+ data=latu * 180 / np.pi,
1118
+ dims=["eta_rho", "xi_u"],
1119
+ attrs={"long_name": "latitude of u-points", "units": "degrees North"},
1120
+ )
1121
+ lon_v = xr.Variable(
1122
+ data=lonv * 180 / np.pi,
1123
+ dims=["eta_v", "xi_rho"],
1124
+ attrs={"long_name": "longitude of v-points", "units": "degrees East"},
1125
+ )
1126
+ lat_v = xr.Variable(
1127
+ data=latv * 180 / np.pi,
1128
+ dims=["eta_v", "xi_rho"],
1129
+ attrs={"long_name": "latitude of v-points", "units": "degrees North"},
1130
+ )
1131
+ # lon_q = xr.Variable(
1132
+ # data=lonq * 180 / np.pi,
1133
+ # dims=["eta_psi", "xi_psi"],
1134
+ # attrs={"long_name": "longitude of psi-points", "units": "degrees East"},
1135
+ # )
1136
+ # lat_q = xr.Variable(
1137
+ # data=latq * 180 / np.pi,
1138
+ # dims=["eta_psi", "xi_psi"],
1139
+ # attrs={"long_name": "latitude of psi-points", "units": "degrees North"},
1140
+ # )
1127
1141
 
1128
- ds = ds.assign_coords({"lat_rho": lat_rho, "lon_rho": lon_rho})
1142
+ ds = ds.assign_coords(
1143
+ {
1144
+ "lat_rho": lat_rho,
1145
+ "lon_rho": lon_rho,
1146
+ "lat_u": lat_u,
1147
+ "lon_u": lon_u,
1148
+ "lat_v": lat_v,
1149
+ "lon_v": lon_v,
1150
+ # "lat_psi": lat_q,
1151
+ # "lon_psi": lon_q,
1152
+ }
1153
+ )
1129
1154
 
1130
1155
  ds["angle"] = xr.Variable(
1131
1156
  data=angle,
@@ -1187,8 +1212,7 @@ def _add_global_metadata(ds, size_x, size_y, center_lon, center_lat, rot):
1187
1212
 
1188
1213
 
1189
1214
  def _f2c(f):
1190
- """
1191
- Coarsen input xarray DataArray f in both x- and y-direction.
1215
+ """Coarsen input xarray DataArray f in both x- and y-direction.
1192
1216
 
1193
1217
  Parameters
1194
1218
  ----------
@@ -1211,8 +1235,7 @@ def _f2c(f):
1211
1235
 
1212
1236
 
1213
1237
  def _f2c_xdir(f):
1214
- """
1215
- Coarsen input xarray DataArray f in x-direction.
1238
+ """Coarsen input xarray DataArray f in x-direction.
1216
1239
 
1217
1240
  Parameters
1218
1241
  ----------
@@ -1242,7 +1265,29 @@ def _f2c_xdir(f):
1242
1265
 
1243
1266
 
1244
1267
  def _add_lat_lon_at_velocity_points(ds, straddle):
1268
+ """Adds latitude and longitude coordinates at velocity points (u and v points) to
1269
+ the dataset. This function computes approximate latitude and longitude values at u
1270
+ and v velocity points based on the rho points (cell centers). If the grid straddles
1271
+ the Greenwich meridian, it adjusts the longitudes to avoid jumps from 360 to 0
1272
+ degrees. The computed coordinates are added to the dataset as new variables with
1273
+ appropriate metadata.
1245
1274
 
1275
+ Parameters
1276
+ ----------
1277
+ ds : xarray.Dataset
1278
+ The input dataset containing rho point coordinates ("lat_rho", "lon_rho").
1279
+ straddle : bool
1280
+ Indicates whether the grid straddles the Greenwich meridian. If True, longitudes are adjusted
1281
+ to avoid discontinuities.
1282
+ Returns
1283
+ -------
1284
+ ds : xarray.Dataset
1285
+ The dataset with added coordinates for u and v points ("lat_u", "lon_u", "lat_v", "lon_v").
1286
+ Notes
1287
+ -----
1288
+ This function only computes approximate latitude and longitude values. It should only be used if
1289
+ more accurate values are not available from grid generation.
1290
+ """
1246
1291
  if straddle:
1247
1292
  # avoid jump from 360 to 0 in interpolation
1248
1293
  lon_rho = xr.where(ds["lon_rho"] > 180, ds["lon_rho"] - 360, ds["lon_rho"])
@@ -21,8 +21,8 @@ from pathlib import Path
21
21
 
22
22
  @dataclass(frozen=True, kw_only=True)
23
23
  class InitialConditions(ROMSToolsMixins):
24
- """
25
- Represents initial conditions for ROMS, including physical and biogeochemical data.
24
+ """Represents initial conditions for ROMS, including physical and biogeochemical
25
+ data.
26
26
 
27
27
  Parameters
28
28
  ----------
@@ -32,27 +32,33 @@ class InitialConditions(ROMSToolsMixins):
32
32
  The date and time at which the initial conditions are set.
33
33
  If no exact match is found, the closest time entry to `ini_time` within the time range [ini_time, ini_time + 24 hours] is selected.
34
34
  source : Dict[str, Union[str, Path, List[Union[str, Path]]], bool]
35
- Dictionary specifying the source of the physical initial condition data:
36
- - "name" (str): Name of the data source (e.g., "GLORYS").
37
- - "path" (Union[str, Path, List[Union[str, Path]]]): The path to the raw data file(s). Can be a single string (with or without wildcards),
38
- a single Path object, or a list of strings or Path objects containing multiple files.
39
- - "climatology" (bool): Indicates if the physical data is climatology data. Defaults to False.
40
- bgc_source : Optional[Dict[str, Union[str, Path, List[Union[str, Path]]], bool]]
41
- Dictionary specifying the source of the biogeochemical (BGC) initial condition data:
42
- - "name" (str): Name of the BGC data source (e.g., "CESM_REGRIDDED").
43
- - "path" (Union[str, Path, List[Union[str, Path]]]): The path to the raw data file(s). Can be a single string (with or without wildcards),
44
- a single Path object, or a list of strings or Path objects containing multiple files.
45
- - "climatology" (bool): Indicates if the BGC data is climatology data. Defaults to False.
35
+
36
+ Dictionary specifying the source of the physical initial condition data. Keys include:
37
+
38
+ - "name" (str): Name of the data source (e.g., "GLORYS").
39
+ - "path" (Union[str, Path, List[Union[str, Path]]]): The path to the raw data file(s). This can be:
40
+
41
+ - A single string (with or without wildcards).
42
+ - A single Path object.
43
+ - A list of strings or Path objects containing multiple files.
44
+ - "climatology" (bool): Indicates if the data is climatology data. Defaults to False.
45
+
46
+ bgc_source : Dict[str, Union[str, Path, List[Union[str, Path]]], bool]
47
+ Dictionary specifying the source of the biogeochemical (BGC) initial condition data. Keys include:
48
+
49
+ - "name" (str): Name of the data source (e.g., "CESM_REGRIDDED").
50
+ - "path" (Union[str, Path, List[Union[str, Path]]]): The path to the raw data file(s). This can be:
51
+
52
+ - A single string (with or without wildcards).
53
+ - A single Path object.
54
+ - A list of strings or Path objects containing multiple files.
55
+ - "climatology" (bool): Indicates if the data is climatology data. Defaults to False.
56
+
46
57
  model_reference_date : datetime, optional
47
58
  The reference date for the model. Defaults to January 1, 2000.
48
59
  use_dask: bool, optional
49
60
  Indicates whether to use dask for processing. If True, data is processed with dask; if False, data is processed eagerly. Defaults to False.
50
61
 
51
- Attributes
52
- ----------
53
- ds : xr.Dataset
54
- Xarray Dataset containing the initial condition data loaded from the specified files.
55
-
56
62
  Examples
57
63
  --------
58
64
  >>> initial_conditions = InitialConditions(
@@ -79,7 +85,7 @@ class InitialConditions(ROMSToolsMixins):
79
85
  def __post_init__(self):
80
86
 
81
87
  self._input_checks()
82
- lon, lat, angle, straddle = super().get_target_lon_lat()
88
+ lon, lat, angle, straddle = super()._get_target_lon_lat()
83
89
 
84
90
  data = self._get_data()
85
91
  data.choose_subdomain(
@@ -91,8 +97,8 @@ class InitialConditions(ROMSToolsMixins):
91
97
 
92
98
  vars_2d = ["zeta"]
93
99
  vars_3d = ["temp", "salt", "u", "v"]
94
- data_vars = super().regrid_data(data, vars_2d, vars_3d, lon, lat)
95
- data_vars = super().process_velocities(data_vars, angle, "u", "v")
100
+ data_vars = super()._regrid_data(data, vars_2d, vars_3d, lon, lat)
101
+ data_vars = super()._process_velocities(data_vars, angle, "u", "v")
96
102
 
97
103
  if self.bgc_source is not None:
98
104
  bgc_data = self._get_bgc_data()
@@ -105,7 +111,7 @@ class InitialConditions(ROMSToolsMixins):
105
111
 
106
112
  vars_2d = []
107
113
  vars_3d = bgc_data.var_names.keys()
108
- bgc_data_vars = super().regrid_data(bgc_data, vars_2d, vars_3d, lon, lat)
114
+ bgc_data_vars = super()._regrid_data(bgc_data, vars_2d, vars_3d, lon, lat)
109
115
 
110
116
  # Ensure time coordinate matches that of physical variables
111
117
  for var in bgc_data_vars.keys():
@@ -277,13 +283,13 @@ class InitialConditions(ROMSToolsMixins):
277
283
  depth_contours=False,
278
284
  layer_contours=False,
279
285
  ) -> None:
280
- """
281
- Plot the initial conditions field for a given eta-, xi-, or s_rho-slice.
286
+ """Plot the initial conditions field for a given eta-, xi-, or s_rho- slice.
282
287
 
283
288
  Parameters
284
289
  ----------
285
290
  varname : str
286
291
  The name of the initial conditions field to plot. Options include:
292
+
287
293
  - "temp": Potential temperature.
288
294
  - "salt": Salinity.
289
295
  - "zeta": Free surface.
@@ -324,6 +330,7 @@ class InitialConditions(ROMSToolsMixins):
324
330
  - "diazC": Diazotroph Carbon (mmol/m³).
325
331
  - "diazP": Diazotroph Phosphorus (mmol/m³).
326
332
  - "diazFe": Diazotroph Iron (mmol/m³).
333
+
327
334
  s : int, optional
328
335
  The index of the vertical layer (`s_rho`) to plot. If not specified, the plot
329
336
  will represent a horizontal slice (eta- or xi- plane). Default is None.
@@ -354,7 +361,6 @@ class InitialConditions(ROMSToolsMixins):
354
361
  If the specified `varname` is not one of the valid options.
355
362
  If the field specified by `varname` is 3D and none of `s`, `eta`, or `xi` are specified.
356
363
  If the field specified by `varname` is 2D and both `eta` and `xi` are specified.
357
-
358
364
  """
359
365
 
360
366
  if len(self.ds[varname].squeeze().dims) == 3 and not any(
@@ -492,17 +498,19 @@ class InitialConditions(ROMSToolsMixins):
492
498
  def save(
493
499
  self, filepath: Union[str, Path], np_eta: int = None, np_xi: int = None
494
500
  ) -> None:
495
- """
496
- Save the initial conditions information to a netCDF4 file.
501
+ """Save the initial conditions information to a netCDF4 file.
497
502
 
498
503
  This method supports saving the dataset in two modes:
499
504
 
500
- 1. **Single File Mode (default)**:
501
- - If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single file at the specified `filepath.nc`.
505
+ 1. **Single File Mode (default)**:
502
506
 
503
- 2. **Partitioned Mode**:
504
- - If either `np_eta` or `np_xi` is specified, the dataset is divided into spatial tiles along the eta-axis and xi-axis.
505
- - The files are saved as `filepath.0.nc`, `filepath.1.nc`, ..., where the numbering corresponds to the partition index.
507
+ If both `np_eta` and `np_xi` are `None`, the entire dataset is saved as a single netCDF4 file
508
+ with the base filename specified by `filepath.nc`.
509
+
510
+ 2. **Partitioned Mode**:
511
+
512
+ - If either `np_eta` or `np_xi` is specified, the dataset is divided into spatial tiles along the eta-axis and xi-axis.
513
+ - Each spatial tile is saved as a separate netCDF4 file.
506
514
 
507
515
  Parameters
508
516
  ----------
@@ -536,8 +544,8 @@ class InitialConditions(ROMSToolsMixins):
536
544
  return saved_filenames
537
545
 
538
546
  def to_yaml(self, filepath: Union[str, Path]) -> None:
539
- """
540
- Export the parameters of the class to a YAML file, including the version of roms-tools.
547
+ """Export the parameters of the class to a YAML file, including the version of
548
+ roms-tools.
541
549
 
542
550
  Parameters
543
551
  ----------
@@ -588,8 +596,7 @@ class InitialConditions(ROMSToolsMixins):
588
596
  def from_yaml(
589
597
  cls, filepath: Union[str, Path], use_dask: bool = False
590
598
  ) -> "InitialConditions":
591
- """
592
- Create an instance of the InitialConditions class from a YAML file.
599
+ """Create an instance of the InitialConditions class from a YAML file.
593
600
 
594
601
  Parameters
595
602
  ----------