diff --git a/doc/sphinx_files/Makefile b/doc/sphinx_files/Makefile new file mode 100644 index 00000000..d0c3cbf1 --- /dev/null +++ b/doc/sphinx_files/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/sphinx_files/docs/source/modules.rst b/doc/sphinx_files/docs/source/modules.rst new file mode 100644 index 00000000..08a26361 --- /dev/null +++ b/doc/sphinx_files/docs/source/modules.rst @@ -0,0 +1,6 @@ +docs +==== + +.. toctree:: + :maxdepth: 4 + diff --git a/doc/sphinx_files/make.bat b/doc/sphinx_files/make.bat new file mode 100644 index 00000000..747ffb7b --- /dev/null +++ b/doc/sphinx_files/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/doc/sphinx_files/source/acom_music_box.rst b/doc/sphinx_files/source/acom_music_box.rst new file mode 100644 index 00000000..13ad4619 --- /dev/null +++ b/doc/sphinx_files/source/acom_music_box.rst @@ -0,0 +1,117 @@ +acom\_music\_box package +======================== + +Submodules +---------- + +acom\_music\_box.music\_box module +---------------------------------- + +.. automodule:: acom_music_box.music_box + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_conditions module +---------------------------------------------- + +.. automodule:: acom_music_box.music_box_conditions + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_evolving\_conditions module +-------------------------------------------------------- + +.. automodule:: acom_music_box.music_box_evolving_conditions + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_model\_options module +-------------------------------------------------- + +.. automodule:: acom_music_box.music_box_model_options + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_product module +------------------------------------------- + +.. automodule:: acom_music_box.music_box_product + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_reactant module +-------------------------------------------- + +.. automodule:: acom_music_box.music_box_reactant + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_reaction module +-------------------------------------------- + +.. automodule:: acom_music_box.music_box_reaction + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_reaction\_list module +-------------------------------------------------- + +.. automodule:: acom_music_box.music_box_reaction_list + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_reaction\_rate module +-------------------------------------------------- + +.. automodule:: acom_music_box.music_box_reaction_rate + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_species module +------------------------------------------- + +.. automodule:: acom_music_box.music_box_species + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_species\_concentration module +---------------------------------------------------------- + +.. automodule:: acom_music_box.music_box_species_concentration + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.music\_box\_species\_list module +------------------------------------------------- + +.. automodule:: acom_music_box.music_box_species_list + :members: + :undoc-members: + :show-inheritance: + +acom\_music\_box.utils module +----------------------------- + +.. automodule:: acom_music_box.utils + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: acom_music_box + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/sphinx_files/source/conf.py b/doc/sphinx_files/source/conf.py new file mode 100644 index 00000000..109e52b7 --- /dev/null +++ b/doc/sphinx_files/source/conf.py @@ -0,0 +1,30 @@ +import sys +import os +sys.path.insert(0, os.path.abspath('..')) +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'acom_music_box' +copyright = '2024, NCAR' +author = 'NCAR' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = ['sphinx.ext.autodoc'] + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +html_static_path = ['_static'] diff --git a/doc/sphinx_files/source/index.rst b/doc/sphinx_files/source/index.rst new file mode 100644 index 00000000..12a1a1a3 --- /dev/null +++ b/doc/sphinx_files/source/index.rst @@ -0,0 +1,22 @@ +.. acom_music_box documentation master file, created by + sphinx-quickstart on Mon Apr 29 18:31:30 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to acom_music_box's documentation! +========================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + modules + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/doc/sphinx_files/source/modules.rst b/doc/sphinx_files/source/modules.rst new file mode 100644 index 00000000..028d78a5 --- /dev/null +++ b/doc/sphinx_files/source/modules.rst @@ -0,0 +1,7 @@ +acom_music_box +============== + +.. toctree:: + :maxdepth: 4 + + acom_music_box diff --git a/src/acom_music_box/music_box.py b/src/acom_music_box/music_box.py index 02f6b924..f9b2b112 100644 --- a/src/acom_music_box/music_box.py +++ b/src/acom_music_box/music_box.py @@ -601,6 +601,18 @@ def readFromUIJsonString(self, data): self.evolving_conditions = EvolvingConditions.from_UI_JSON(data, self.species_list, self.reaction_list) def readConditionsFromJson(self, path_to_json): + """ + Reads and parses a JSON file from the CAMP JSON file to set up the box model simulation. + + Args: + path_to_json (str): The JSON path to the JSON file. + + Returns: + None + + Raises: + ValueError: If the JSON string cannot be parsed. + """ with open(path_to_json, 'r') as json_file: data = json.load(json_file) diff --git a/src/acom_music_box/music_box_reaction_list.py b/src/acom_music_box/music_box_reaction_list.py index 216c1817..512ed5ba 100644 --- a/src/acom_music_box/music_box_reaction_list.py +++ b/src/acom_music_box/music_box_reaction_list.py @@ -98,6 +98,20 @@ def add_reaction(self, reaction): @classmethod def get_reactants_from_JSON(self, reaction, species_list): + """ + Retrieves reactants from a JSON object. + + This method iterates over the 'reactants' field of the provided JSON object, + matches each reactant with a species from the provided species list, and + creates a Reactant object for each one. + + Args: + reaction (dict): A dictionary representing a reaction, as parsed from JSON. + species_list (SpeciesList): A list of all possible species. + + Returns: + list: A list of Reactant objects representing the reactants of the reaction. + """ reactants = [] for reactant, reactant_info in reaction['reactants'].items(): @@ -110,6 +124,21 @@ def get_reactants_from_JSON(self, reaction, species_list): @classmethod def get_products_from_JSON(self, reaction, species_list): + """ + Extracts products from a JSON object. + + This method checks if the 'products' field is present in the provided JSON object. + If it is, the method iterates over the 'products' field, matches each product with + a species from the provided species list, and creates a Product object for each one. + + Args: + reaction (dict): A dictionary representing a reaction, as parsed from JSON. + species_list (SpeciesList): A list of all possible species. + + Returns: + list: A list of Product objects representing the products of the reaction, or + an empty list if the 'products' field is not present in the JSON object. + """ products = [] if 'products' in reaction: for product, product_info in reaction['products'].items():