rompy 0.2.3__tar.gz → 0.2.4__tar.gz

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 (263) hide show
  1. {rompy-0.2.3/rompy.egg-info → rompy-0.2.4}/PKG-INFO +2 -1
  2. {rompy-0.2.3 → rompy-0.2.4}/pyproject.toml +1 -0
  3. {rompy-0.2.3 → rompy-0.2.4}/rompy/__init__.py +1 -1
  4. {rompy-0.2.3 → rompy-0.2.4}/rompy/cli.py +13 -19
  5. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/time.py +35 -18
  6. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/types.py +17 -8
  7. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/config.py +38 -1
  8. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/grid.py +167 -7
  9. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/schism.py +14 -1
  10. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/output.py +1 -1
  11. {rompy-0.2.3 → rompy-0.2.4/rompy.egg-info}/PKG-INFO +2 -1
  12. {rompy-0.2.3 → rompy-0.2.4}/rompy.egg-info/SOURCES.txt +1 -0
  13. {rompy-0.2.3 → rompy-0.2.4}/rompy.egg-info/requires.txt +1 -0
  14. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/test_swan_model.py +3 -2
  15. rompy-0.2.4/tests/test_serilization.py +128 -0
  16. {rompy-0.2.3 → rompy-0.2.4}/tests/test_time.py +35 -0
  17. {rompy-0.2.3 → rompy-0.2.4}/LICENSE +0 -0
  18. {rompy-0.2.3 → rompy-0.2.4}/MANIFEST.in +0 -0
  19. {rompy-0.2.3 → rompy-0.2.4}/README.md +0 -0
  20. {rompy-0.2.3 → rompy-0.2.4}/docs/Makefile +0 -0
  21. {rompy-0.2.3 → rompy-0.2.4}/docs/make.bat +0 -0
  22. {rompy-0.2.3 → rompy-0.2.4}/docs/source/api.rst +0 -0
  23. {rompy-0.2.3 → rompy-0.2.4}/docs/source/conf.py +0 -0
  24. {rompy-0.2.3 → rompy-0.2.4}/docs/source/core_concepts.rst +0 -0
  25. {rompy-0.2.3 → rompy-0.2.4}/docs/source/demo.rst +0 -0
  26. {rompy-0.2.3 → rompy-0.2.4}/docs/source/index.rst +0 -0
  27. {rompy-0.2.3 → rompy-0.2.4}/docs/source/models.rst +0 -0
  28. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/demo.ipynb +0 -0
  29. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/oceanum_example.ipynb +0 -0
  30. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/physics.ipynb +0 -0
  31. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/schism_procedural.ipynb +0 -0
  32. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/.gitignore +0 -0
  33. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/boundary/boundnest1.ipynb +0 -0
  34. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/boundary/boundspec_segment.ipynb +0 -0
  35. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/boundary/boundspec_side.ipynb +0 -0
  36. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/components/output.ipynb +0 -0
  37. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/example_declarative.ipynb +0 -0
  38. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/example_declarative.yml +0 -0
  39. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/example_procedural.ipynb +0 -0
  40. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/example_sensitivity.ipynb +0 -0
  41. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan/example_sensitivity.yml +0 -0
  42. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan-config-components.ipynb +0 -0
  43. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/swan-config-components.yml +0 -0
  44. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/templates/swan-physics-predefined/{{runtime.run_id}}/INPUT +0 -0
  45. {rompy-0.2.3 → rompy-0.2.4}/docs/source/notebooks/templates_demo.ipynb +0 -0
  46. {rompy-0.2.3 → rompy-0.2.4}/docs/source/quickstart.rst +0 -0
  47. {rompy-0.2.3 → rompy-0.2.4}/docs/source/schism/index.rst +0 -0
  48. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/boundary.rst +0 -0
  49. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/cgrid.rst +0 -0
  50. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/group.rst +0 -0
  51. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/inpgrid.rst +0 -0
  52. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/lockup.rst +0 -0
  53. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/numerics.rst +0 -0
  54. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/output.rst +0 -0
  55. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/physics.rst +0 -0
  56. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/components/startup.rst +0 -0
  57. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/index.rst +0 -0
  58. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/base.rst +0 -0
  59. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/boundary.rst +0 -0
  60. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/cgrid.rst +0 -0
  61. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/numerics.rst +0 -0
  62. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/output.rst +0 -0
  63. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/physics.rst +0 -0
  64. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/readgrid.rst +0 -0
  65. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/spectrum.rst +0 -0
  66. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/startup.rst +0 -0
  67. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/subcomponents/time.rst +0 -0
  68. {rompy-0.2.3 → rompy-0.2.4}/docs/source/swan/types.rst +0 -0
  69. {rompy-0.2.3 → rompy-0.2.4}/notebooks/components/swan-config-components.yml +0 -0
  70. {rompy-0.2.3 → rompy-0.2.4}/notebooks/schism/demo.yaml +0 -0
  71. {rompy-0.2.3 → rompy-0.2.4}/notebooks/swan/example_declarative.yml +0 -0
  72. {rompy-0.2.3 → rompy-0.2.4}/notebooks/swan/example_sensitivity.yml +0 -0
  73. {rompy-0.2.3 → rompy-0.2.4}/rompy/.github/default.yml +0 -0
  74. {rompy-0.2.3 → rompy-0.2.4}/rompy/_version.py +0 -0
  75. {rompy-0.2.3 → rompy-0.2.4}/rompy/archive/filesystem.py +0 -0
  76. {rompy-0.2.3 → rompy-0.2.4}/rompy/archive/model.py +0 -0
  77. {rompy-0.2.3 → rompy-0.2.4}/rompy/archive/test_filesystem.py +0 -0
  78. {rompy-0.2.3 → rompy-0.2.4}/rompy/archive/test_model.py +0 -0
  79. {rompy-0.2.3 → rompy-0.2.4}/rompy/archive/test_transform.py +0 -0
  80. {rompy-0.2.3 → rompy-0.2.4}/rompy/archive/transform.py +0 -0
  81. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/aodn.yaml +0 -0
  82. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/bom.yaml +0 -0
  83. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/csiro.yaml +0 -0
  84. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/dot_wa.yaml +0 -0
  85. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/gfs.yml +0 -0
  86. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/master.yaml +0 -0
  87. {rompy-0.2.3 → rompy-0.2.4}/rompy/catalogs/oceanum.yaml +0 -0
  88. {rompy-0.2.3 → rompy-0.2.4}/rompy/configuration/base.py +0 -0
  89. {rompy-0.2.3 → rompy-0.2.4}/rompy/configuration/swan.py +0 -0
  90. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/__init__.py +0 -0
  91. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/boundary.py +0 -0
  92. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/config.py +0 -0
  93. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/data.py +0 -0
  94. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/filters.py +0 -0
  95. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/grid.py +0 -0
  96. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/render.py +0 -0
  97. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/source.py +0 -0
  98. {rompy-0.2.3 → rompy-0.2.4}/rompy/core/spectrum.py +0 -0
  99. {rompy-0.2.3 → rompy-0.2.4}/rompy/model.py +0 -0
  100. {rompy-0.2.3 → rompy-0.2.4}/rompy/plotting.py +0 -0
  101. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/__init__.py +0 -0
  102. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/data.py +0 -0
  103. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/interface.py +0 -0
  104. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/__init__.py +0 -0
  105. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/basemodel.py +0 -0
  106. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/ice.py +0 -0
  107. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/icm.py +0 -0
  108. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/mice.py +0 -0
  109. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/param.py +0 -0
  110. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/sediment.py +0 -0
  111. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/wwminput_WW3.py +0 -0
  112. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/claude_full/wwminput_spectra.py +0 -0
  113. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/cosine.py +0 -0
  114. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/example_nml.py +0 -0
  115. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/generate_models.py +0 -0
  116. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/generate_models_llm.py +0 -0
  117. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/generate_models_llm_sections.py +0 -0
  118. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/generate_models_llmv2.py +0 -0
  119. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/handwritten/cosine.py +0 -0
  120. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/handwritten/ice.py +0 -0
  121. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/handwritten/icm.py +0 -0
  122. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/handwritten/param.py +0 -0
  123. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/handwritten/sediment.py +0 -0
  124. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/ice.py +0 -0
  125. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/icm.py +0 -0
  126. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/mice.py +0 -0
  127. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/param.py +0 -0
  128. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/sample_inputs/create_model.py +0 -0
  129. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/sample_inputs/render.py +0 -0
  130. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/sediment.py +0 -0
  131. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/sflux.py +0 -0
  132. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/wwminput.py +0 -0
  133. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/wwminput_WW3.py +0 -0
  134. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/namelists/wwminput_spectra.py +0 -0
  135. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/dates.py +0 -0
  136. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/__init__.py +0 -0
  137. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/base.py +0 -0
  138. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/__init__.py +0 -0
  139. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/base.py +0 -0
  140. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/bctides.py +0 -0
  141. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/fes2014.py +0 -0
  142. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/hamtide.py +0 -0
  143. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/tides.py +0 -0
  144. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/tpxo.py +0 -0
  145. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/__init__.py +0 -0
  146. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/base.py +0 -0
  147. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/gofs.py +0 -0
  148. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/hycom2schism.py +0 -0
  149. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/rtofs2schism.py +0 -0
  150. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/__init__.py +0 -0
  151. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/base.py +0 -0
  152. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/boundaries.py +0 -0
  153. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/fgrid.py +0 -0
  154. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/figures.py +0 -0
  155. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/gridgr3.py +0 -0
  156. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/hgrid.py +0 -0
  157. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/parsers/__init__.py +0 -0
  158. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/parsers/grd.py +0 -0
  159. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/parsers/sms2dm.py +0 -0
  160. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/prop.py +0 -0
  161. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/pyschism/mesh/vgrid.py +0 -0
  162. {rompy-0.2.3 → rompy-0.2.4}/rompy/schism/utils.py +0 -0
  163. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/__init__.py +0 -0
  164. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/boundary.py +0 -0
  165. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/__init__.py +0 -0
  166. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/base.py +0 -0
  167. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/boundary.py +0 -0
  168. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/cgrid.py +0 -0
  169. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/group.py +0 -0
  170. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/inpgrid.py +0 -0
  171. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/lockup.py +0 -0
  172. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/numerics.py +0 -0
  173. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/physics.py +0 -0
  174. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/components/startup.py +0 -0
  175. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/config.py +0 -0
  176. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/data.py +0 -0
  177. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/grid.py +0 -0
  178. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/interface.py +0 -0
  179. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/legacy.py +0 -0
  180. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/__init__.py +0 -0
  181. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/base.py +0 -0
  182. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/boundary.py +0 -0
  183. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/numerics.py +0 -0
  184. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/output.py +0 -0
  185. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/physics.py +0 -0
  186. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/readgrid.py +0 -0
  187. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/spectrum.py +0 -0
  188. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/startup.py +0 -0
  189. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/subcomponents/time.py +0 -0
  190. {rompy-0.2.3 → rompy-0.2.4}/rompy/swan/types.py +0 -0
  191. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/base/{{runtime.run_id}}/INPUT +0 -0
  192. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/base/{{runtime.run_id}}/datasets/readme.md +0 -0
  193. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/base/{{runtime.run_id}}/outputs/readme.md +0 -0
  194. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/README +0 -0
  195. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/datasets/readme.md +0 -0
  196. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/outputs/readme.md +0 -0
  197. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/sflux/README +0 -0
  198. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/README +0 -0
  199. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/datasets/readme.md +0 -0
  200. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/outputs/readme.md +0 -0
  201. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/param.nml +0 -0
  202. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/sflux/README +0 -0
  203. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/wwminput.nml +0 -0
  204. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swan/cookiecutter.json +0 -0
  205. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/INPUT +0 -0
  206. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/datasets/readme.md +0 -0
  207. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/out.loc +0 -0
  208. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/outputs/readme.md +0 -0
  209. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swanbasic/{{runtime.run_id}}/INPUT +0 -0
  210. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swanbasic/{{runtime.run_id}}/datasets/readme.md +0 -0
  211. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swanbasic/{{runtime.run_id}}/outputs/readme.md +0 -0
  212. {rompy-0.2.3 → rompy-0.2.4}/rompy/templates/swancomp/{{runtime.run_id}}/INPUT +0 -0
  213. {rompy-0.2.3 → rompy-0.2.4}/rompy/utils.py +0 -0
  214. {rompy-0.2.3 → rompy-0.2.4}/rompy.egg-info/dependency_links.txt +0 -0
  215. {rompy-0.2.3 → rompy-0.2.4}/rompy.egg-info/entry_points.txt +0 -0
  216. {rompy-0.2.3 → rompy-0.2.4}/rompy.egg-info/top_level.txt +0 -0
  217. {rompy-0.2.3 → rompy-0.2.4}/scripts/ci/environment-pip.yml +0 -0
  218. {rompy-0.2.3 → rompy-0.2.4}/setup.cfg +0 -0
  219. {rompy-0.2.3 → rompy-0.2.4}/tests/data/catalog.yaml +0 -0
  220. {rompy-0.2.3 → rompy-0.2.4}/tests/data/wind.csv +0 -0
  221. {rompy-0.2.3 → rompy-0.2.4}/tests/example_configs/make_full_yaml.py +0 -0
  222. {rompy-0.2.3 → rompy-0.2.4}/tests/example_configs/test.yaml +0 -0
  223. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/configs/csiro.yaml +0 -0
  224. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_data/download_era5_datamesh.py +0 -0
  225. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_data/download_hycom.py +0 -0
  226. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_data/download_tides.py +0 -0
  227. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_grid.py +0 -0
  228. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_namelists.py +0 -0
  229. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_nml.py +0 -0
  230. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_schism_csiro.py +0 -0
  231. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_schism_csiro_migration.py +0 -0
  232. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_schism_data.py +0 -0
  233. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_schism_nml.py +0 -0
  234. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/test_vgridgenerators.py +0 -0
  235. {rompy-0.2.3 → rompy-0.2.4}/tests/schism/utils.py +0 -0
  236. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_base.py +0 -0
  237. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_boundary.py +0 -0
  238. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_cgrid.py +0 -0
  239. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_inpgrid.py +0 -0
  240. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_lockup.py +0 -0
  241. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_output.py +0 -0
  242. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_physics.py +0 -0
  243. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/components/test_startup.py +0 -0
  244. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_boundary.py +0 -0
  245. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_physics.py +0 -0
  246. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_readgrid.py +0 -0
  247. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_shape.py +0 -0
  248. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_time.py +0 -0
  249. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/swan_model.yml +0 -0
  250. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/test_swan_config.py +0 -0
  251. {rompy-0.2.3 → rompy-0.2.4}/tests/swan/test_swan_types.py +0 -0
  252. {rompy-0.2.3 → rompy-0.2.4}/tests/test_basegrid.py +0 -0
  253. {rompy-0.2.3 → rompy-0.2.4}/tests/test_basemodel.py +0 -0
  254. {rompy-0.2.3 → rompy-0.2.4}/tests/test_data.py +0 -0
  255. {rompy-0.2.3 → rompy-0.2.4}/tests/test_intake_driver.py +0 -0
  256. {rompy-0.2.3 → rompy-0.2.4}/tests/test_swanbasic.py +0 -0
  257. {rompy-0.2.3 → rompy-0.2.4}/tests/test_swanboundary.py +0 -0
  258. {rompy-0.2.3 → rompy-0.2.4}/tests/test_swandata.py +0 -0
  259. {rompy-0.2.3 → rompy-0.2.4}/tests/test_swangrid.py +0 -0
  260. {rompy-0.2.3 → rompy-0.2.4}/tests/test_swanmodel.py +0 -0
  261. {rompy-0.2.3 → rompy-0.2.4}/tests/test_swantemplate.py +0 -0
  262. {rompy-0.2.3 → rompy-0.2.4}/tests/test_templates.py +0 -0
  263. {rompy-0.2.3 → rompy-0.2.4}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rompy
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Relocatable Ocean Modelling in PYthon (rompy)
5
5
  Author-email: CSIRO <paul.branson@csiro.au>
6
6
  Maintainer-email: Paul Branson <paul.branson@csiro.au>, Tom Durrant <t.durrant@oceanum.science>, Rafael Guedes <r.guedes@oceanum.science>
@@ -77,6 +77,7 @@ Requires-Dist: scipy
77
77
  Requires-Dist: tqdm
78
78
  Requires-Dist: xarray
79
79
  Requires-Dist: wavespectra
80
+ Requires-Dist: isodate
80
81
  Provides-Extra: test
81
82
  Requires-Dist: pytest; extra == "test"
82
83
  Requires-Dist: envyaml; extra == "test"
@@ -55,6 +55,7 @@ dependencies = [
55
55
  "tqdm",
56
56
  "xarray",
57
57
  "wavespectra",
58
+ "isodate",
58
59
  ]
59
60
  dynamic = ["version"]
60
61
 
@@ -14,7 +14,7 @@ from pathlib import Path
14
14
  logger = logging.getLogger(__name__)
15
15
 
16
16
  # __version__ = _version.get_versions()["version"]
17
- __version__ = "0.2.3"
17
+ __version__ = "0.2.4"
18
18
 
19
19
  ROOT_DIR = Path(__file__).parent.resolve()
20
20
  TEMPLATES_DIR = ROOT_DIR / "templates"
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ import json
3
4
  import logging
4
5
  from importlib.metadata import entry_points
5
6
 
@@ -17,34 +18,27 @@ installed = entry_points(group="rompy.config").names
17
18
  @click.argument("model", type=click.Choice(installed), envvar="ROMPY_MODEL")
18
19
  @click.argument("config", envvar="ROMPY_CONFIG")
19
20
  @click.option("zip", "--zip/--no-zip", default=False, envvar="ROMPY_ZIP")
20
- @click.option(
21
- "--kwargs",
22
- "-k",
23
- multiple=True,
24
- help="additional key value pairs in the format key:value",
25
- )
26
- def main(model, config, zip, kwargs):
21
+ def main(model, config, zip):
27
22
  """Run model
28
23
  Usage: rompy <model> config.yml
29
24
  Args:
30
25
  model(str): model type
31
- config(str): yaml config file
26
+ config(str): yaml or json config file
32
27
  """
33
28
  try:
34
29
  # First try to open it as a file
35
30
  with open(config, "r") as f:
36
- args = yaml.load(f, Loader=yaml.Loader)
31
+ content = f.read()
37
32
  except (FileNotFoundError, IsADirectoryError, OSError):
38
- # If not a file, treat it as raw YAML content
39
- args = yaml.load(config, Loader=yaml.Loader)
40
-
41
- kw = {}
42
- for item in kwargs:
43
- split = item.split(":")
44
- kw.update({split[0]: split[1]})
45
- current = getattr(instance, split[0])
46
- setattr(instance, split[0], type(current)(split[1]))
47
- model = ModelRun(**args, **kw)
33
+ # If not a file, treat it as raw content
34
+ content = config
35
+
36
+ try:
37
+ # Try to parse as yaml
38
+ args = yaml.load(content, Loader=yaml.Loader)
39
+ model = ModelRun(**args)
40
+ except TypeError:
41
+ model = ModelRun.model_validate_json(json.loads(content))
48
42
  model()
49
43
  if zip:
50
44
  model.zip()
@@ -1,7 +1,16 @@
1
1
  from datetime import datetime, timedelta
2
- from typing import Any, Optional, Union
3
-
4
- from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
2
+ from typing import Any, Callable, Dict, Optional, Set, Union
3
+
4
+ import isodate
5
+ from pydantic import (
6
+ BaseModel,
7
+ ConfigDict,
8
+ Field,
9
+ field_validator,
10
+ model_serializer,
11
+ model_validator,
12
+ )
13
+ from pydantic.json_schema import core_schema
5
14
 
6
15
  time_units = {
7
16
  "h": "hours",
@@ -62,13 +71,16 @@ class TimeRange(BaseModel):
62
71
  if isinstance(v, timedelta):
63
72
  return v
64
73
  elif isinstance(v, str):
65
- if v[-1] not in time_units:
66
- raise ValueError(
67
- "Invalid duration unit. Must be one of: h, m, s, d, w, y"
68
- )
69
- time_delta_unit = v[-1]
70
- time_delta_value = int(v[:-1])
71
- return timedelta(**{time_units[time_delta_unit]: time_delta_value})
74
+ try:
75
+ return isodate.parse_duration(v)
76
+ except isodate.ISO8601Error:
77
+ if v[-1] not in time_units:
78
+ raise ValueError(
79
+ "Invalid duration unit. Must be one isoformat or one of: h, m, s, d, w, y"
80
+ )
81
+ time_delta_unit = v[-1]
82
+ time_delta_value = int(v[:-1])
83
+ return timedelta(**{time_units[time_delta_unit]: time_delta_value})
72
84
 
73
85
  @field_validator("start", "end", mode="before")
74
86
  @classmethod
@@ -121,15 +133,20 @@ class TimeRange(BaseModel):
121
133
  self.start = self.end - self.duration
122
134
  return self
123
135
 
124
- def model_dump(self, *args, **kwargs):
125
- excludable_fields = {"duration"} if self.start and self.end else set()
126
- return super().model_dump(*args, **{**kwargs, "exclude": excludable_fields})
136
+ model_config = ConfigDict(validate_default=True)
127
137
 
128
- def model_dump_json(self, *args, **kwargs):
129
- excludable_fields = {"duration"} if self.start and self.end else set()
130
- return super().model_dump_json(
131
- *args, **{**kwargs, "exclude": excludable_fields}
132
- )
138
+ @model_serializer
139
+ def serialize_model(self) -> dict:
140
+ # This replaces default serialization for the whole model
141
+ # It works for both direct serialization and nested serialization
142
+ result = {}
143
+ for key, value in self.__dict__.items():
144
+ # Skip 'duration' if both start and end are present
145
+ if key == "duration" and self.start and self.end:
146
+ continue
147
+ # Include all other fields
148
+ result[key] = value
149
+ return result
133
150
 
134
151
  @property
135
152
  def date_range(self) -> list[datetime]:
@@ -1,20 +1,29 @@
1
1
  """Rompy types."""
2
2
 
3
- from typing import Any, Optional, Union
3
+ import json
4
4
  from datetime import datetime
5
- from pydantic import (
6
- field_validator,
7
- model_validator,
8
- ConfigDict,
9
- BaseModel,
10
- Field,
11
- )
5
+ from typing import Any, Optional, Union
6
+
7
+ from pydantic import (BaseModel, ConfigDict, Field, field_validator,
8
+ model_validator)
12
9
 
13
10
 
14
11
  class RompyBaseModel(BaseModel):
15
12
  # The config below prevents https://github.com/pydantic/pydantic/discussions/7121
16
13
  model_config = ConfigDict(protected_namespaces=(), extra="forbid")
17
14
 
15
+ def __init__(self, **data: Any):
16
+ super().__init__(**data)
17
+ self._original_inputs = data
18
+
19
+ def dump_inputs_dict(self) -> dict:
20
+ """Return the original inputs as a dictionary."""
21
+ return self._original_inputs
22
+
23
+ def dump_inputs_json(self) -> str:
24
+ """Return the original inputs as a JSON string."""
25
+ return json.dumps((self._original_inputs))
26
+
18
27
 
19
28
  class Latitude(BaseModel):
20
29
  """Latitude"""
@@ -2,7 +2,7 @@ import logging
2
2
  from pathlib import Path
3
3
  from typing import Literal, Optional, Union
4
4
 
5
- from pydantic import Field, model_validator
5
+ from pydantic import Field, model_validator, model_serializer
6
6
 
7
7
  from rompy.core import BaseConfig, DataBlob, RompyBaseModel, Spectrum, TimeRange
8
8
 
@@ -524,6 +524,43 @@ class SCHISMConfig(BaseConfig):
524
524
  description="The path to the model template",
525
525
  default=SCHISM_TEMPLATE,
526
526
  )
527
+
528
+ @model_serializer
529
+ def serialize_model(self, **kwargs):
530
+ """Custom serializer to handle proper serialization of nested components."""
531
+ from rompy.schism.grid import GR3Generator
532
+
533
+ result = {}
534
+
535
+ # Explicitly handle required fields
536
+ result["model_type"] = self.model_type
537
+
538
+ # Handle grid separately to process GR3Generator objects
539
+ if self.grid is not None:
540
+ grid_dict = {}
541
+ for field_name in self.grid.model_fields:
542
+ value = getattr(self.grid, field_name, None)
543
+
544
+ # Special handling for GR3Generator objects
545
+ if value is not None and isinstance(value, GR3Generator):
546
+ # For GR3Generator objects, extract just the value field
547
+ grid_dict[field_name] = value.value
548
+ elif value is not None and not field_name.startswith('_'):
549
+ grid_dict[field_name] = value
550
+
551
+ result["grid"] = grid_dict
552
+
553
+ # Add optional fields that are not None
554
+ if self.data is not None:
555
+ result["data"] = self.data
556
+
557
+ if self.nml is not None:
558
+ result["nml"] = self.nml
559
+
560
+ if self.template is not None:
561
+ result["template"] = self.template
562
+
563
+ return result
527
564
 
528
565
  def __call__(self, runtime) -> str:
529
566
  if self.grid is not None:
@@ -4,7 +4,7 @@ from typing import Literal, Optional, Union
4
4
 
5
5
  import numpy as np
6
6
  import pandas as pd
7
- from pydantic import Field, PrivateAttr, field_validator, model_validator
7
+ from pydantic import Field, PrivateAttr, field_validator, model_validator, model_serializer
8
8
  from shapely.geometry import MultiPoint, Polygon
9
9
 
10
10
  from rompy.core import DataBlob, RompyBaseModel
@@ -43,6 +43,7 @@ class GeneratorBase(RompyBaseModel):
43
43
 
44
44
 
45
45
  class GR3Generator(GeneratorBase):
46
+ model_type: Literal["gr3_generator"] = Field("gr3_generator", description="Model discriminator")
46
47
  hgrid: DataBlob | Path = Field(..., description="Path to hgrid.gr3 file")
47
48
  gr3_type: str = Field(
48
49
  ...,
@@ -50,6 +51,36 @@ class GR3Generator(GeneratorBase):
50
51
  )
51
52
  value: float = Field(None, description="Constant value to set in gr3 file")
52
53
  crs: str = Field("epsg:4326", description="Coordinate reference system")
54
+
55
+ @classmethod
56
+ def model_json_schema(cls, *args, **kwargs):
57
+ """Add discriminator to JSON schema"""
58
+ schema = super().model_json_schema(*args, **kwargs)
59
+ schema["discriminator"] = {"propertyName": "model_type"}
60
+ return schema
61
+
62
+ @model_serializer
63
+ def serialize_model(self, **kwargs):
64
+ """Custom serializer to ensure proper serialization when used in other models."""
65
+ result = {}
66
+ result["model_type"] = self.model_type
67
+
68
+ # Explicitly include the value field to ensure it's correctly serialized
69
+ if hasattr(self, 'value') and self.value is not None:
70
+ result['value'] = self.value
71
+
72
+ # Include other non-private fields
73
+ for field_name in self.model_fields:
74
+ if not field_name.startswith('_') and getattr(self, field_name, None) is not None:
75
+ if field_name not in ['value', 'model_type']: # Already handled above
76
+ result[field_name] = getattr(self, field_name)
77
+
78
+ # Remove any private attributes
79
+ for key in list(result.keys()):
80
+ if key.startswith('_'):
81
+ del result[key]
82
+
83
+ return result
53
84
 
54
85
  @field_validator("gr3_type")
55
86
  def gr3_type_validator(cls, v):
@@ -90,8 +121,21 @@ class GR3Generator(GeneratorBase):
90
121
 
91
122
  class Vgrid2D(GeneratorBase):
92
123
  model_type: Literal["vgrid2D_generator"] = Field(
93
- "LSC2_generator", description="Model descriminator"
124
+ "vgrid2D_generator", description="Model descriminator"
94
125
  )
126
+
127
+ @model_serializer
128
+ def serialize_model(self, **kwargs):
129
+ """Custom serializer to handle proper serialization."""
130
+ result = {field_name: getattr(self, field_name) for field_name in self.model_fields
131
+ if getattr(self, field_name, None) is not None}
132
+
133
+ # Remove private attributes
134
+ for key in list(result.keys()):
135
+ if key.startswith('_'):
136
+ del result[key]
137
+
138
+ return result
95
139
 
96
140
  def generate(self, destdir: str | Path, hgrid=None) -> Path:
97
141
  dest = Path(destdir) / "vgrid.in"
@@ -119,8 +163,21 @@ class Vgrid2D(GeneratorBase):
119
163
 
120
164
  class Vgrid3D_LSC2(GeneratorBase):
121
165
  model_type: Literal["vgrid3D_lsc2"] = Field(
122
- "LSC2_generator", description="Model descriminator"
166
+ "vgrid3D_lsc2", description="Model descriminator"
123
167
  )
168
+
169
+ @model_serializer
170
+ def serialize_model(self, **kwargs):
171
+ """Custom serializer to handle proper serialization."""
172
+ result = {field_name: getattr(self, field_name) for field_name in self.model_fields
173
+ if getattr(self, field_name, None) is not None}
174
+
175
+ # Remove private attributes
176
+ for key in list(result.keys()):
177
+ if key.startswith('_'):
178
+ del result[key]
179
+
180
+ return result
124
181
  hgrid: DataBlob | Path = Field(..., description="Path to hgrid.gr3 file")
125
182
  hsm: list[float] = Field(..., description="Depth for each master grid")
126
183
  nv: list[int] = Field(..., description="Total number of vertical levels")
@@ -155,8 +212,21 @@ class Vgrid3D_LSC2(GeneratorBase):
155
212
 
156
213
  class Vgrid3D_SZ(GeneratorBase):
157
214
  model_type: Literal["vgrid3D_sz"] = Field(
158
- "LSC2_generator", description="Model descriminator"
215
+ "vgrid3D_sz", description="Model descriminator"
159
216
  )
217
+
218
+ @model_serializer
219
+ def serialize_model(self, **kwargs):
220
+ """Custom serializer to handle proper serialization."""
221
+ result = {field_name: getattr(self, field_name) for field_name in self.model_fields
222
+ if getattr(self, field_name, None) is not None}
223
+
224
+ # Remove private attributes
225
+ for key in list(result.keys()):
226
+ if key.startswith('_'):
227
+ del result[key]
228
+
229
+ return result
160
230
  hgrid: DataBlob | Path = Field(..., description="Path to hgrid.gr3 file")
161
231
  h_s: float = Field(..., description="Depth for each master grid")
162
232
  ztot: list[int] = Field(..., description="Total number of vertical levels")
@@ -194,17 +264,31 @@ class VgridGenerator(GeneratorBase):
194
264
  This is all hardcoded for now, may look at making this more flexible in the future.
195
265
  """
196
266
 
197
- # model_type: Literal["vgrid_generator"] = Field(
198
- # "vgrid_generator", description="Model descriminator"
199
- # )
267
+ model_type: Literal["vgrid_generator"] = Field(
268
+ "vgrid_generator", description="Model descriminator"
269
+ )
200
270
  vgrid: Union[Vgrid2D, Vgrid3D_LSC2, Vgrid3D_SZ] = Field(
201
271
  ...,
202
272
  default_factory=Vgrid2D,
203
273
  description="Type of vgrid to generate. 2d will create the minimum required for a 2d model. LSC2 will create a full vgrid for a 3d model using pyschsim's LSC2 class",
204
274
  )
275
+
276
+ @model_serializer
277
+ def serialize_model(self, **kwargs):
278
+ """Custom serializer to handle proper serialization of the vgrid field."""
279
+ result = {field_name: getattr(self, field_name) for field_name in self.model_fields
280
+ if getattr(self, field_name, None) is not None}
281
+
282
+ # Remove private attributes
283
+ for key in list(result.keys()):
284
+ if key.startswith('_'):
285
+ del result[key]
286
+
287
+ return result
205
288
 
206
289
  def generate(self, destdir: str | Path) -> Path:
207
290
  dest = self.vgrid.generate(destdir=destdir)
291
+ return dest
208
292
 
209
293
  def generate_legacy(self, destdir: str | Path) -> Path:
210
294
  dest = Path(destdir) / "vgrid.in"
@@ -231,11 +315,32 @@ class VgridGenerator(GeneratorBase):
231
315
 
232
316
 
233
317
  class WWMBNDGR3Generator(GeneratorBase):
318
+ model_type: Literal["wwmbnd_generator"] = Field("wwmbnd_generator", description="Model discriminator")
234
319
  hgrid: DataBlob | Path = Field(..., description="Path to hgrid.gr3 file")
235
320
  bcflags: list[int] = Field(
236
321
  None,
237
322
  description="List of boundary condition flags. This replicates the functionality of the gen_wwmbnd.in file. Must be the same length as the number of open boundaries in the hgrid.gr3 file. If not specified, it is assumed that all open hgrid files are open to waves",
238
323
  )
324
+
325
+ @classmethod
326
+ def model_json_schema(cls, *args, **kwargs):
327
+ """Add discriminator to JSON schema"""
328
+ schema = super().model_json_schema(*args, **kwargs)
329
+ schema["discriminator"] = {"propertyName": "model_type"}
330
+ return schema
331
+
332
+ @model_serializer
333
+ def serialize_model(self, **kwargs):
334
+ """Custom serializer to ensure proper serialization when used in other models."""
335
+ result = {}
336
+ result["model_type"] = self.model_type
337
+
338
+ # Include other non-private fields
339
+ for field_name in self.model_fields:
340
+ if not field_name.startswith('_') and field_name != "model_type" and getattr(self, field_name, None) is not None:
341
+ result[field_name] = getattr(self, field_name)
342
+
343
+ return result
239
344
 
240
345
  def generate(self, destdir: str | Path, name: str = None) -> Path:
241
346
  # Adapted from https://github.com/schism-dev/schism/blob/master/src/Utility/Pre-Processing/gen_wwmbnd.f90
@@ -339,6 +444,47 @@ class SCHISMGrid(BaseGrid):
339
444
  description="Path to vgrid.in file",
340
445
  validate_default=True,
341
446
  )
447
+
448
+ @model_validator(mode='after')
449
+ def validate_gr3_fields(self):
450
+ """Custom validator to handle GR3Generator conversion during deserialization."""
451
+ # Convert GR3Generator fields that might have been serialized as simple values
452
+ gr3_fields = ['drag', 'diffmin', 'diffmax', 'albedo', 'watertype', 'windrot_geo2proj']
453
+
454
+ for field in gr3_fields:
455
+ value = getattr(self, field, None)
456
+ if value is not None and not isinstance(value, (DataBlob, GR3Generator)) and isinstance(value, (int, float)):
457
+ # Create a GR3Generator instance instead of using the raw value
458
+ gr3_generator = GR3Generator(
459
+ hgrid=self.hgrid,
460
+ gr3_type=field,
461
+ value=value,
462
+ )
463
+ setattr(self, field, gr3_generator)
464
+
465
+ return self
466
+
467
+ @model_serializer
468
+ def serialize_model(self, **kwargs):
469
+ """Custom serializer to handle proper serialization."""
470
+ result = {}
471
+
472
+ # Add fields to the result dictionary
473
+ for field_name in self.model_fields:
474
+ value = getattr(self, field_name, None)
475
+
476
+ # Special handling for GR3Generator fields
477
+ if value is not None and isinstance(value, GR3Generator):
478
+ # For GR3Generator objects, just use the value field
479
+ result[field_name] = value.value
480
+ # Skip wwmbnd field if it's a WWMBNDGR3Generator (similar to TimeRange behavior in memory)
481
+ elif field_name == 'wwmbnd' and value is not None and isinstance(value, WWMBNDGR3Generator):
482
+ # Skip this field to prevent validation errors as it's complex to serialize/deserialize
483
+ pass
484
+ elif value is not None and not field_name.startswith('_'):
485
+ result[field_name] = value
486
+
487
+ return result
342
488
  drag: Optional[DataBlob | float | GR3Generator] = Field(
343
489
  default=None, description="Path to drag.gr3 file"
344
490
  )
@@ -603,6 +749,20 @@ class SCHISMGrid(BaseGrid):
603
749
 
604
750
  def boundary_points(self, spacing=None) -> tuple:
605
751
  return self.ocean_boundary()
752
+
753
+ @model_serializer
754
+ def serialize_model(self, **kwargs):
755
+ """Custom serializer to handle optional fields properly during serialization."""
756
+ # Start with all fields that have values
757
+ result = {field_name: getattr(self, field_name) for field_name in self.model_fields
758
+ if getattr(self, field_name, None) is not None or field_name in ['grid_type', 'hgrid', 'crs']}
759
+
760
+ # Remove private attributes that shouldn't be in the serialized output
761
+ for key in list(result.keys()):
762
+ if key.startswith('_'):
763
+ del result[key]
764
+
765
+ return result
606
766
 
607
767
 
608
768
  if __name__ == "__main__":
@@ -2,7 +2,7 @@ import logging
2
2
  from pathlib import Path
3
3
  from typing import Optional
4
4
 
5
- from pydantic import Field
5
+ from pydantic import Field, model_serializer
6
6
 
7
7
  from rompy.core import TimeRange
8
8
  from rompy.schism.namelists.basemodel import NamelistBaseModel
@@ -32,6 +32,19 @@ class NML(NamelistBaseModel):
32
32
  wwminput: Optional[Wwminput] = Field(
33
33
  description="Wave model input parameters", default=None
34
34
  )
35
+
36
+ @model_serializer
37
+ def serialize_model(self, **kwargs):
38
+ """Custom serializer to handle proper serialization of namelist components."""
39
+ result = {}
40
+
41
+ # Include only non-None fields in the serialized output
42
+ for field_name in self.model_fields:
43
+ value = getattr(self, field_name, None)
44
+ if value is not None:
45
+ result[field_name] = value
46
+
47
+ return result
35
48
 
36
49
  def update_times(self, period=TimeRange):
37
50
  """
@@ -1239,7 +1239,7 @@ class BLOCK(BaseWrite):
1239
1239
  @field_validator("idla")
1240
1240
  @classmethod
1241
1241
  def validate_idla(cls, idla: IDLA) -> IDLA:
1242
- if idla not in (1, 3, 4):
1242
+ if idla is not None and idla not in (1, 3, 4):
1243
1243
  raise ValueError(
1244
1244
  f"Only IDLA options (1, 3, 4) are supported in BLOCK, got {idla}"
1245
1245
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rompy
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Relocatable Ocean Modelling in PYthon (rompy)
5
5
  Author-email: CSIRO <paul.branson@csiro.au>
6
6
  Maintainer-email: Paul Branson <paul.branson@csiro.au>, Tom Durrant <t.durrant@oceanum.science>, Rafael Guedes <r.guedes@oceanum.science>
@@ -77,6 +77,7 @@ Requires-Dist: scipy
77
77
  Requires-Dist: tqdm
78
78
  Requires-Dist: xarray
79
79
  Requires-Dist: wavespectra
80
+ Requires-Dist: isodate
80
81
  Provides-Extra: test
81
82
  Requires-Dist: pytest; extra == "test"
82
83
  Requires-Dist: envyaml; extra == "test"
@@ -217,6 +217,7 @@ tests/test_basegrid.py
217
217
  tests/test_basemodel.py
218
218
  tests/test_data.py
219
219
  tests/test_intake_driver.py
220
+ tests/test_serilization.py
220
221
  tests/test_swanbasic.py
221
222
  tests/test_swanboundary.py
222
223
  tests/test_swandata.py
@@ -21,6 +21,7 @@ scipy
21
21
  tqdm
22
22
  xarray
23
23
  wavespectra
24
+ isodate
24
25
 
25
26
  [docs]
26
27
  autodoc_pydantic
@@ -1,15 +1,16 @@
1
1
  """Test swan_config class."""
2
2
 
3
3
  import logging
4
+ import os
4
5
  from pathlib import Path
6
+
5
7
  import pytest
6
- import os
7
8
  from envyaml import EnvYAML
8
9
 
9
10
  from rompy.core.source import SourceIntake
10
11
  from rompy.model import ModelRun
11
- from rompy.swan.config import SwanConfigComponents
12
12
  from rompy.swan import Boundnest1
13
+ from rompy.swan.config import SwanConfigComponents
13
14
  from rompy.swan.interface import BoundaryInterface
14
15
 
15
16
  logger = logging.getLogger(__name__)