Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for config #217

Merged
merged 14 commits into from
Oct 22, 2024
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[![Documentation Status](https://readthedocs.org/projects/fwl-proteus/badge/?version=latest)](https://fwl-proteus.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

![PROTEUS banner](https://raw.githubusercontent.com/FormingWorlds/PROTEUS/main/docs/images/PROTEUS_white.png#gh-light-mode-only)
![PROTEUS banner](https://raw.githubusercontent.com/FormingWorlds/PROTEUS/main/docs/images/PROTEUS_black.png#gh-dark-mode-only)
![PROTEUS banner](https://raw.githubusercontent.com/FormingWorlds/PROTEUS/main/docs/assets/PROTEUS_white.png#gh-light-mode-only)
![PROTEUS banner](https://raw.githubusercontent.com/FormingWorlds/PROTEUS/main/docs/assets/PROTEUS_black.png#gh-dark-mode-only)

# PROTEUS Framework for Planetary Evolution

Expand Down Expand Up @@ -42,13 +42,11 @@ Hamish Innes | hamish.innes[at]fu-berlin.de |

| Object | Description |
| - | - |
| `start_proteus.py` | Main PROTEUS Python script |
| `README.md` | Overview file |
| `pyproject.toml` | Project configuration file |
| `CODE_OF_CONDUCT.md` | Project code of conduct |
| `LICENSE.txt` | Project license |
| `src/proteus` | Source code for PROTEUS |
| `SPIDER/` | Submodule SPIDER |
| `output/` | Output folder with subfolders for each model run |
| `input/` | Input folder (e.g. stellar spectra, example configs) |
| `docs/` | Documentation source files |
Expand Down
File renamed without changes
File renamed without changes
Binary file added docs/assets/spectral_files.pdf
Binary file not shown.
140 changes: 140 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Configuration file

PROTEUS uses [TOML](https://toml.io/en/) to structure its configuration files.

All of the parameters required to run the model are
listed below with short explanations of their purpose and the values
they accept. Configuration files can contain blank lines. Comments are
indicated with a `#` symbol. Whitespace indentation is purely stylistic.

Not all of these parameters will be used, depending on the
configuration, but they must all be provided.

## Adding a new parameter

So, you are developing a new model and want to add some parameters?
Follow these steps:

1. Decide on a good parameter name (*e.g.* `my_star_var`), and under which section to place it (*e.g.* `star`).
Add the new variable to the [config submodule](https://github.com/FormingWorlds/PROTEUS/tree/main/src/proteus/config/_star.py).
2. Add the type for your variable, *e.g.* [float][], [int][], [str][].
You can also add complex types, please check the [code](https://github.com/FormingWorlds/PROTEUS/tree/main/src/proteus/config) for inspiration.
3. Add a [validator](https://www.attrs.org/en/stable/api.html#module-attrs.validators)!
If your variable has a maximum value (*e.g.* 10), you can add a validator to make sure
that any values above 10 are rejected: `my_star_var: float = field(validator=attrs.validators.le(10))`
4. Add a description for your new variable under `Attributes` in the docstring.
The documentation uses the description to generate this documentation.
5. Update the example [input configs](https://github.com/FormingWorlds/PROTEUS/tree/main/input).
Proteus checks tests all input configs in this directory are valid.
6. Use your parameter in your code, *i.e.*: `config.star.my_star_var`

```python title="src/proteus/config/_star.py"
class Star:
"""Stellar parameters.

Attributes
----------
my_star_var: float
Star variable, must be 10 or lower!
"""
my_star_var: float = field(validator=attrs.validators.le(10))
```

Proteus uses [attrs](https://www.attrs.org) for its
parameter handling. Please see the [examples](https://www.attrs.org/en/stable/examples.html)
for more information how to work with attrs.

### Examples

Have a look at the [input configs](https://github.com/FormingWorlds/PROTEUS/tree/main/input)
for ideas of how to set up your config in practice.

## Root parameters

::: proteus.config._config
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## General parameters

::: proteus.config._params
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Star

::: proteus.config._star
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Star system and planetary orbit

::: proteus.config._orbit
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Planetary structure

::: proteus.config._struct
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Atmosphere climate

::: proteus.config._atmos_clim
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Atmospheric escape

::: proteus.config._escape
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Magma ocean / mantle

::: proteus.config._interior
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Outgassing

::: proteus.config._outgas
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source

## Delivery

::: proteus.config._delivery
options:
heading_level: 3
show_root_heading: False
show_root_toc_entry: False
members_order: source
Loading
Loading