rompy 0.2.2__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.
- {rompy-0.2.2/rompy.egg-info → rompy-0.2.4}/PKG-INFO +2 -6
- {rompy-0.2.2 → rompy-0.2.4}/README.md +0 -5
- {rompy-0.2.2 → rompy-0.2.4}/pyproject.toml +1 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/__init__.py +1 -1
- rompy-0.2.4/rompy/cli.py +48 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/time.py +35 -18
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/types.py +17 -8
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/config.py +38 -1
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/grid.py +167 -7
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/schism.py +14 -1
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/output.py +1 -1
- {rompy-0.2.2 → rompy-0.2.4/rompy.egg-info}/PKG-INFO +2 -6
- {rompy-0.2.2 → rompy-0.2.4}/rompy.egg-info/SOURCES.txt +1 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy.egg-info/requires.txt +1 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/test_swan_model.py +3 -2
- rompy-0.2.4/tests/test_serilization.py +128 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_time.py +35 -0
- rompy-0.2.2/rompy/cli.py +0 -48
- {rompy-0.2.2 → rompy-0.2.4}/LICENSE +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/MANIFEST.in +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/Makefile +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/make.bat +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/api.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/conf.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/core_concepts.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/demo.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/index.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/models.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/demo.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/oceanum_example.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/physics.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/schism_procedural.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/.gitignore +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/boundary/boundnest1.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/boundary/boundspec_segment.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/boundary/boundspec_side.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/components/output.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/example_declarative.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/example_declarative.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/example_procedural.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/example_sensitivity.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan/example_sensitivity.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan-config-components.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/swan-config-components.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/templates/swan-physics-predefined/{{runtime.run_id}}/INPUT +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/notebooks/templates_demo.ipynb +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/quickstart.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/schism/index.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/boundary.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/cgrid.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/group.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/inpgrid.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/lockup.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/numerics.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/output.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/physics.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/components/startup.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/index.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/base.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/boundary.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/cgrid.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/numerics.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/output.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/physics.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/readgrid.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/spectrum.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/startup.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/subcomponents/time.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/docs/source/swan/types.rst +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/notebooks/components/swan-config-components.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/notebooks/schism/demo.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/notebooks/swan/example_declarative.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/notebooks/swan/example_sensitivity.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/.github/default.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/_version.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/archive/filesystem.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/archive/model.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/archive/test_filesystem.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/archive/test_model.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/archive/test_transform.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/archive/transform.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/aodn.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/bom.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/csiro.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/dot_wa.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/gfs.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/master.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/catalogs/oceanum.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/configuration/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/configuration/swan.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/boundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/config.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/data.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/filters.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/grid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/render.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/source.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/core/spectrum.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/model.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/plotting.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/data.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/interface.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/basemodel.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/ice.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/icm.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/mice.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/param.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/sediment.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/wwminput_WW3.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/claude_full/wwminput_spectra.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/cosine.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/example_nml.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/generate_models.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/generate_models_llm.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/generate_models_llm_sections.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/generate_models_llmv2.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/handwritten/cosine.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/handwritten/ice.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/handwritten/icm.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/handwritten/param.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/handwritten/sediment.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/ice.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/icm.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/mice.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/param.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/sample_inputs/create_model.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/sample_inputs/render.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/sediment.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/sflux.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/wwminput.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/wwminput_WW3.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/namelists/wwminput_spectra.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/dates.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/bctides.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/fes2014.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/hamtide.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/tides.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/bctides/tpxo.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/gofs.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/hycom2schism.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/forcing/hycom/rtofs2schism.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/boundaries.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/fgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/figures.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/gridgr3.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/hgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/parsers/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/parsers/grd.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/parsers/sms2dm.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/prop.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/pyschism/mesh/vgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/schism/utils.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/boundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/boundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/cgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/group.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/inpgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/lockup.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/numerics.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/physics.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/components/startup.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/config.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/data.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/grid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/interface.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/legacy.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/__init__.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/boundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/numerics.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/output.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/physics.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/readgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/spectrum.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/startup.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/subcomponents/time.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/swan/types.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/base/{{runtime.run_id}}/INPUT +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/base/{{runtime.run_id}}/datasets/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/base/{{runtime.run_id}}/outputs/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/README +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/datasets/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/outputs/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schism/{{runtime.run_id}}/sflux/README +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/README +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/datasets/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/outputs/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/param.nml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/sflux/README +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/schismcsiro/{{runtime.run_id}}/wwminput.nml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swan/cookiecutter.json +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/INPUT +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/datasets/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/out.loc +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swan/{{runtime.run_id}}/outputs/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swanbasic/{{runtime.run_id}}/INPUT +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swanbasic/{{runtime.run_id}}/datasets/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swanbasic/{{runtime.run_id}}/outputs/readme.md +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/templates/swancomp/{{runtime.run_id}}/INPUT +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy/utils.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy.egg-info/dependency_links.txt +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy.egg-info/entry_points.txt +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/rompy.egg-info/top_level.txt +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/scripts/ci/environment-pip.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/setup.cfg +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/data/catalog.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/data/wind.csv +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/example_configs/make_full_yaml.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/example_configs/test.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/configs/csiro.yaml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_data/download_era5_datamesh.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_data/download_hycom.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_data/download_tides.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_grid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_namelists.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_nml.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_schism_csiro.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_schism_csiro_migration.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_schism_data.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_schism_nml.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/test_vgridgenerators.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/schism/utils.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_base.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_boundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_cgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_inpgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_lockup.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_output.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_physics.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/components/test_startup.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_boundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_physics.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_readgrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_shape.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/subcomponents/test_subcomponent_time.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/swan_model.yml +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/test_swan_config.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/swan/test_swan_types.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_basegrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_basemodel.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_data.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_intake_driver.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_swanbasic.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_swanboundary.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_swandata.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_swangrid.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_swanmodel.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_swantemplate.py +0 -0
- {rompy-0.2.2 → rompy-0.2.4}/tests/test_templates.py +0 -0
- {rompy-0.2.2 → 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
|
+
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"
|
|
@@ -102,15 +103,10 @@ title: "Relocatable Ocean Modelling in PYthon (rompy)"
|
|
|
102
103
|
---
|
|
103
104
|
|
|
104
105
|
[](https://rom-py.github.io/rompy/)
|
|
105
|
-
|
|
106
106
|
[](https://pypi.org/project/rompy/)
|
|
107
|
-
|
|
108
107
|
[](https://github.com/rom-py/rompy/actions)
|
|
109
|
-
|
|
110
108
|
[](https://pypistats.org/packages/rompy)
|
|
111
|
-
|
|
112
109
|
[](https://github.com/python/black)
|
|
113
|
-
|
|
114
110
|
[](https://pypi.org/project/rompy/)
|
|
115
111
|
|
|
116
112
|
# Introduction
|
|
@@ -3,15 +3,10 @@ title: "Relocatable Ocean Modelling in PYthon (rompy)"
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
[](https://rom-py.github.io/rompy/)
|
|
6
|
-
|
|
7
6
|
[](https://pypi.org/project/rompy/)
|
|
8
|
-
|
|
9
7
|
[](https://github.com/rom-py/rompy/actions)
|
|
10
|
-
|
|
11
8
|
[](https://pypistats.org/packages/rompy)
|
|
12
|
-
|
|
13
9
|
[](https://github.com/python/black)
|
|
14
|
-
|
|
15
10
|
[](https://pypi.org/project/rompy/)
|
|
16
11
|
|
|
17
12
|
# Introduction
|
|
@@ -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.
|
|
17
|
+
__version__ = "0.2.4"
|
|
18
18
|
|
|
19
19
|
ROOT_DIR = Path(__file__).parent.resolve()
|
|
20
20
|
TEMPLATES_DIR = ROOT_DIR / "templates"
|
rompy-0.2.4/rompy/cli.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
from importlib.metadata import entry_points
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
import yaml
|
|
9
|
+
|
|
10
|
+
from .model import ModelRun
|
|
11
|
+
|
|
12
|
+
logging.basicConfig(level=logging.INFO)
|
|
13
|
+
|
|
14
|
+
installed = entry_points(group="rompy.config").names
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.command()
|
|
18
|
+
@click.argument("model", type=click.Choice(installed), envvar="ROMPY_MODEL")
|
|
19
|
+
@click.argument("config", envvar="ROMPY_CONFIG")
|
|
20
|
+
@click.option("zip", "--zip/--no-zip", default=False, envvar="ROMPY_ZIP")
|
|
21
|
+
def main(model, config, zip):
|
|
22
|
+
"""Run model
|
|
23
|
+
Usage: rompy <model> config.yml
|
|
24
|
+
Args:
|
|
25
|
+
model(str): model type
|
|
26
|
+
config(str): yaml or json config file
|
|
27
|
+
"""
|
|
28
|
+
try:
|
|
29
|
+
# First try to open it as a file
|
|
30
|
+
with open(config, "r") as f:
|
|
31
|
+
content = f.read()
|
|
32
|
+
except (FileNotFoundError, IsADirectoryError, OSError):
|
|
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))
|
|
42
|
+
model()
|
|
43
|
+
if zip:
|
|
44
|
+
model.zip()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
main()
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
from datetime import datetime, timedelta
|
|
2
|
-
from typing import Any, Optional, Union
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
3
|
+
import json
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
|
|
198
|
-
|
|
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
|
+
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"
|
|
@@ -102,15 +103,10 @@ title: "Relocatable Ocean Modelling in PYthon (rompy)"
|
|
|
102
103
|
---
|
|
103
104
|
|
|
104
105
|
[](https://rom-py.github.io/rompy/)
|
|
105
|
-
|
|
106
106
|
[](https://pypi.org/project/rompy/)
|
|
107
|
-
|
|
108
107
|
[](https://github.com/rom-py/rompy/actions)
|
|
109
|
-
|
|
110
108
|
[](https://pypistats.org/packages/rompy)
|
|
111
|
-
|
|
112
109
|
[](https://github.com/python/black)
|
|
113
|
-
|
|
114
110
|
[](https://pypi.org/project/rompy/)
|
|
115
111
|
|
|
116
112
|
# Introduction
|
|
@@ -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__)
|