Skip to content

Commit a305e74

Browse files
committed
added some topics to the documentation. Expecially the structure subsection is still work in progress, but we need a place to start describing thing...
1 parent 4ca07f0 commit a305e74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5520
-485
lines changed

build_docs/source/_static/README

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This directory is intended for static html or javascript.
2+
It should not be used for manually created *.rst files
3+
put them in source/manual.
4+

build_docs/source/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ Python package to collect compartmental models of the form
1111

1212
.. math:: \frac{d}{dt}\,x(t) = B(x(t),t)\,x(t) + u(t).
1313

14+
Topics:
15+
-------
16+
.. toctree::
17+
:maxdepth: 2
18+
19+
manual/usage
20+
manual/structure
21+
1422
Available models
1523
----------------
1624

build_docs/source_2020_09_15/structure.rst build_docs/source/manual/structure.rst

+24-15
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,58 @@ Structure
22
=========
33
* Schema
44
The package represents domain knowledge by two sets:
5+
56
* A set of variables called `MVars` and
67
* A set of functions called `Computers`, operating on sets of instaces of these types.
78

8-
The instance sets form the nodes and the computers the edges of a directed graph G.
9+
Sets of `MVars` form the nodes and the computers the edges of a directed graph G.
910
We call G the computability graph because a desired `Mvar` (target) can be computed from
1011
a set of `Mvars` (src) if there is a path from src to target.
11-
We can also use
12-
13-
defined (or instanciated) in the user provided model descritpion in `models/NameOfTheModel/source.py` by the users and the (growing) set of computers represented by the `bgc_md/resolve/MvarsAndComputers.py`
14-
Every model folder contains at least one file
15-
```bash
16-
source.py
17-
```
18-
That can contain import other module that can live in the same directory or be accessible globally.
19-
The (minimal) purpose of the model file is usually that an instance of either a CompartmentalModel or a ModelRun can be created.
20-
This can be done
21-
* directly, by calling one of the constructors (of a CompartmentalModels) or
22-
* indirectly by some definitions of variables with special names from which the ingredients for the constructor calls can be infered.
23-
12+
13+
`MVars` are instanciated and combined into `MVarSets` by user provided python code, typically placed in a file `models/NameOfTheModel/source.py`.
14+
This is however just a convention (with some support by helper functions). It is also possible to place the code elsewhere.
15+
The `models` submodule of `bgc_md2` can thus be seen as a set of examples
16+
The (minimal) purpose of the model file is usually that an instance of
17+
either a CompartmentalModel or a ModelRun can be created.
18+
This can be done
19+
* directly, by calling one of the constructors (of a CompartmentalModels) or
20+
21+
* indirectly by some definitions of variables with special names from which the ingredients for the constructor calls can be infered.
22+
23+
The set of computers represented by the `bgc_md/resolve/MvarsAndComputers.py`
24+
25+
2426
The package does not use standard database technology like SQL but stores available data connected to a model as a set of
2527
variables of predefined types (from now on called MVars).
2628
In terms of a database one can think of every Mvar type as a table
2729
with two columns model_id
30+
2831
* Models
32+
2933
* Notebooks
34+
3035
* For single models
36+
3137
* For model comparisons
3238

3339
* Notes on implementation
40+
3441
* Library vs. Framework
3542
CompartmentalSystems and LAPM can be considered
3643
libraries that can be called in different parallelisation scenarios and with
3744
different data.
3845
bgc-md has both library and framework characteristics.
46+
3947
* The (types) of MVars and computers (functions) connecting them represents a domain knowledge
4048
in form of a library.
49+
4150
* The collection of different models enforces some rules on the way a
4251
single model has to be formulated in order to be comparable to other
4352
models.
4453
In this sense it comprises a framework into which different models can be
4554
plugged.
4655

47-
* Viewed from a high level of abstraction models (symbolic) models and (climatic driver) data seem to be orthogonal to each other.
56+
* Viewed from a high level of abstraction (symbolic) models and (climatic driver) data seem to be orthogonal to each other.
4857
but they are also connected by a mapping between the dataset and the models realized by model specific data preparation code.
4958
A model with more pools and connections we will
5059
need more data and will connect the data to different pools or fluxes.
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
Usecases / Objectives
22
=====================
33
* Exploration of existing models:
4-
The package is supposed to assist in the creation of 'reports' in the form of jupyter notebooks.
5-
The notebooks will be of the following types:
6-
* Investigations of a single model (or modelrun).
74

8-
* Comparisons between models (modelruns).
5+
The package is supposed to assist in the creation of 'reports' in the form of jupyter notebooks. The notebooks will be of the following types:
6+
7+
* Investigations of a single model (or modelrun).
8+
9+
* Comparisons between models (modelruns).
910

1011
* Assistence in the formulation of new models in a step by step process.
12+
1113
To this end the framework implements some powerfull interactive tools.
1214
In this scenario the role of the `bgc_md` package is to guide the user (=
1315
author of a particular notebook concerned with a particular model, and
1416
simultaniously author of the `source.py` of that model) by using the
15-
computability graph (as represented by `bgc_md/resolve/MvarsAndComputers.py`)
17+
computability graph (as represented by `bgc_md/resolve/computers.py`)
1618
to either
19+
1720
* show which addidional results can be computed, given the
1821
information already present in the models `source.py` or
19-
* show which additional information has to be provided in the models `source.py`
20-
to be able to obtain a desired result.
22+
23+
* show which additional information has to be provided in the models `source.py` to be able to obtain a desired result.
2124

docs/_autosummary/bgc_md2.models.CARDAMOM.html

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ <h1 class="logo"><a href="../index.html">Biogeochemical model database</a></h1>
5454

5555

5656
<h3>Navigation</h3>
57+
<ul>
58+
<li class="toctree-l1"><a class="reference internal" href="../manual/usage.html">Usecases / Objectives</a></li>
59+
<li class="toctree-l1"><a class="reference internal" href="../manual/structure.html">Structure</a></li>
60+
</ul>
5761
<ul class="current">
5862
<li class="toctree-l1"><a class="reference internal" href="bgc_md2.models.Williams2005GCB.html">bgc_md2.models.Williams2005GCB</a></li>
5963
<li class="toctree-l1"><a class="reference internal" href="bgc_md2.models.ELM.html">bgc_md2.models.ELM</a></li>

docs/_autosummary/bgc_md2.models.ELM.html

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ <h1 class="logo"><a href="../index.html">Biogeochemical model database</a></h1>
5555

5656

5757
<h3>Navigation</h3>
58+
<ul>
59+
<li class="toctree-l1"><a class="reference internal" href="../manual/usage.html">Usecases / Objectives</a></li>
60+
<li class="toctree-l1"><a class="reference internal" href="../manual/structure.html">Structure</a></li>
61+
</ul>
5862
<ul class="current">
5963
<li class="toctree-l1"><a class="reference internal" href="bgc_md2.models.Williams2005GCB.html">bgc_md2.models.Williams2005GCB</a></li>
6064
<li class="toctree-l1 current"><a class="current reference internal" href="#">bgc_md2.models.ELM</a></li>

docs/_autosummary/bgc_md2.models.Williams2005GCB.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<link rel="index" title="Index" href="../genindex.html" />
1818
<link rel="search" title="Search" href="../search.html" />
1919
<link rel="next" title="bgc_md2.models.ELM" href="bgc_md2.models.ELM.html" />
20-
<link rel="prev" title="Biogeochemical model database’s documentation!" href="../index.html" />
20+
<link rel="prev" title="Structure" href="../manual/structure.html" />
2121

2222
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
2323

@@ -55,6 +55,10 @@ <h1 class="logo"><a href="../index.html">Biogeochemical model database</a></h1>
5555

5656

5757
<h3>Navigation</h3>
58+
<ul>
59+
<li class="toctree-l1"><a class="reference internal" href="../manual/usage.html">Usecases / Objectives</a></li>
60+
<li class="toctree-l1"><a class="reference internal" href="../manual/structure.html">Structure</a></li>
61+
</ul>
5862
<ul class="current">
5963
<li class="toctree-l1 current"><a class="current reference internal" href="#">bgc_md2.models.Williams2005GCB</a></li>
6064
<li class="toctree-l1"><a class="reference internal" href="bgc_md2.models.ELM.html">bgc_md2.models.ELM</a></li>
@@ -65,7 +69,7 @@ <h3>Navigation</h3>
6569
<h3>Related Topics</h3>
6670
<ul>
6771
<li><a href="../index.html">Documentation overview</a><ul>
68-
<li>Previous: <a href="../index.html" title="previous chapter">Biogeochemical model database’s documentation!</a></li>
72+
<li>Previous: <a href="../manual/structure.html" title="previous chapter">Structure</a></li>
6973
<li>Next: <a href="bgc_md2.models.ELM.html" title="next chapter">bgc_md2.models.ELM</a></li>
7074
</ul></li>
7175
</ul>

docs/_modules/bgc_md2/ModelDataObject.html

+46-42
Original file line numberDiff line numberDiff line change
@@ -630,48 +630,48 @@ <h1>Source code for bgc_md2.ModelDataObject</h1><div class="highlight"><pre>
630630
<span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
631631
<span class="n">data</span><span class="o">=</span><span class="n">Fs</span><span class="p">[:,</span> <span class="n">pool_nr_to</span><span class="p">,</span> <span class="n">pool_nr_from</span><span class="p">],</span>
632632
<span class="n">unit</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">stock_unit</span>
633-
<span class="p">)</span></div>
634-
635-
<div class="viewcode-block" id="ModelDataObject.get_netcdf"><a class="viewcode-back" href="../../bgc_md2.html#bgc_md2.ModelDataObject.ModelDataObject.get_netcdf">[docs]</a> <span class="k">def</span> <span class="nf">get_netcdf</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mr</span><span class="p">):</span>
636-
<span class="n">ds_attrs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;time_unit&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">time_agg</span><span class="o">.</span><span class="n">unit</span><span class="p">}</span>
637-
638-
<span class="n">coords_time</span> <span class="o">=</span> <span class="n">mr</span><span class="o">.</span><span class="n">times</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
639-
<span class="n">coords_pool</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="n">mr</span><span class="o">.</span><span class="n">nr_pools</span><span class="p">)</span>
640-
<span class="n">coords</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;time&#39;</span><span class="p">:</span> <span class="n">coords_time</span><span class="p">,</span> <span class="s1">&#39;pool&#39;</span><span class="p">:</span> <span class="n">coords_pool</span><span class="p">}</span>
641-
<span class="n">data_vars</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
642-
643-
<span class="n">start_values</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">DataArray</span><span class="p">(</span>
644-
<span class="n">data</span><span class="o">=</span><span class="n">mr</span><span class="o">.</span><span class="n">start_values</span><span class="p">,</span>
645-
<span class="n">dims</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;pool&#39;</span><span class="p">],</span>
646-
<span class="n">coords</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;pool&#39;</span><span class="p">:</span> <span class="n">coords_pool</span><span class="p">},</span>
647-
<span class="n">attrs</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;units&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">stock_unit</span><span class="p">}</span>
648-
<span class="p">)</span>
649-
<span class="n">data_vars</span><span class="p">[</span><span class="s1">&#39;start_values&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">start_values</span>
650-
651-
<span class="n">us</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">DataArray</span><span class="p">(</span>
652-
<span class="n">data</span><span class="o">=</span><span class="n">mr</span><span class="o">.</span><span class="n">us</span><span class="p">,</span>
653-
<span class="n">dims</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="s1">&#39;pool&#39;</span><span class="p">],</span>
654-
<span class="n">coords</span><span class="o">=</span><span class="n">coords</span><span class="p">,</span>
655-
<span class="n">attrs</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;units&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">stock_unit</span><span class="o">+</span><span class="s1">&#39;/&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">time_agg</span><span class="o">.</span><span class="n">unit</span><span class="p">}</span>
656-
<span class="p">)</span>
657-
<span class="n">data_vars</span><span class="p">[</span><span class="s1">&#39;us&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">us</span>
658-
659-
<span class="n">Bs</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">DataArray</span><span class="p">(</span>
660-
<span class="n">data</span><span class="o">=</span><span class="n">mr</span><span class="o">.</span><span class="n">Bs</span><span class="p">,</span>
661-
<span class="n">dims</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="s1">&#39;pool_to&#39;</span><span class="p">,</span> <span class="s1">&#39;pool_from&#39;</span><span class="p">],</span>
662-
<span class="n">coords</span><span class="o">=</span><span class="p">[</span><span class="n">coords_time</span><span class="p">,</span> <span class="n">coords_pool</span><span class="p">,</span> <span class="n">coords_pool</span><span class="p">],</span>
663-
<span class="n">attrs</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;units&#39;</span><span class="p">:</span> <span class="s1">&#39;1/&#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">time_agg</span><span class="o">.</span><span class="n">unit</span><span class="p">}</span>
664-
<span class="p">)</span>
665-
<span class="n">data_vars</span><span class="p">[</span><span class="s1">&#39;Bs&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Bs</span>
666-
667-
<span class="n">ds_mr</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">Dataset</span><span class="p">(</span>
668-
<span class="n">coords</span><span class="o">=</span><span class="n">coords</span><span class="p">,</span>
669-
<span class="n">data_vars</span><span class="o">=</span><span class="n">data_vars</span><span class="p">,</span>
670-
<span class="n">attrs</span><span class="o">=</span><span class="n">ds_attrs</span>
671-
<span class="p">)</span>
672-
<span class="c1"># ds_mr.to_netcdf(file_path)</span>
673-
<span class="c1"># ds_mr.close()</span>
674-
<span class="k">return</span> <span class="n">ds_mr</span></div></div>
633+
<span class="p">)</span></div></div>
634+
635+
<span class="c1"># def get_netcdf(self, mr):</span>
636+
<span class="c1">## ds_attrs = {&#39;time_unit&#39;: self.time_agg.unit}</span>
637+
<span class="c1">#</span>
638+
<span class="c1">## coords_pool = [d[&#39;pool_name&#39;] for d in self.model_structure.pool_structure]</span>
639+
<span class="c1">#</span>
640+
<span class="c1"># data_vars = dict()</span>
641+
<span class="c1"># </span>
642+
<span class="c1"># data = mr.start_values</span>
643+
<span class="c1"># start_values = xr.DataArray(</span>
644+
<span class="c1"># data=mr.start_values,</span>
645+
<span class="c1"># dims=[&#39;pool&#39;],</span>
646+
<span class="c1">## coords={&#39;pool&#39;: coords_pool},</span>
647+
<span class="c1"># attrs={&#39;units&#39;: self.stock_unit}</span>
648+
<span class="c1"># )</span>
649+
<span class="c1"># data_vars[&#39;start_values&#39;] = start_values</span>
650+
<span class="c1">#</span>
651+
<span class="c1"># us = xr.DataArray(</span>
652+
<span class="c1"># data=mr.us,</span>
653+
<span class="c1"># dims=[&#39;time&#39;, &#39;pool&#39;],</span>
654+
<span class="c1"># coords={&#39;pool&#39;: coords_pool},</span>
655+
<span class="c1"># attrs={&#39;units&#39;: self.stock_unit+&#39;/&#39;+self.time_agg.unit}</span>
656+
<span class="c1"># )</span>
657+
<span class="c1"># data_vars[&#39;us&#39;] = us</span>
658+
<span class="c1">#</span>
659+
<span class="c1"># Bs = xr.DataArray(</span>
660+
<span class="c1"># data=mr.Bs,</span>
661+
<span class="c1"># dims=[&#39;time&#39;, &#39;pool_to&#39;, &#39;pool_from&#39;],</span>
662+
<span class="c1"># coords={&#39;pool_to&#39;: coords_pool, &#39;pool_from&#39;: coords_pool],</span>
663+
<span class="c1"># attrs={&#39;units&#39;: &#39;1/&#39;+self.time_agg.unit}</span>
664+
<span class="c1"># )</span>
665+
<span class="c1"># data_vars[&#39;Bs&#39;] = Bs</span>
666+
<span class="c1">#</span>
667+
<span class="c1"># ds_mr = xr.Dataset(</span>
668+
<span class="c1">## coords=coords,</span>
669+
<span class="c1"># data_vars=data_vars,</span>
670+
<span class="c1">## attrs=ds_attrs</span>
671+
<span class="c1"># )</span>
672+
<span class="c1">## ds_mr.to_netcdf(file_path)</span>
673+
<span class="c1">## ds_mr.close()</span>
674+
<span class="c1"># return ds_mr</span>
675675
</pre></div>
676676

677677
</div>
@@ -691,6 +691,10 @@ <h1 class="logo"><a href="../../index.html">Biogeochemical model database</a></h
691691

692692
<h3>Navigation</h3>
693693
<ul>
694+
<li class="toctree-l1"><a class="reference internal" href="../../manual/usage.html">Usecases / Objectives</a></li>
695+
<li class="toctree-l1"><a class="reference internal" href="../../manual/structure.html">Structure</a></li>
696+
</ul>
697+
<ul>
694698
<li class="toctree-l1"><a class="reference internal" href="../../_autosummary/bgc_md2.models.Williams2005GCB.html">bgc_md2.models.Williams2005GCB</a></li>
695699
<li class="toctree-l1"><a class="reference internal" href="../../_autosummary/bgc_md2.models.ELM.html">bgc_md2.models.ELM</a></li>
696700
<li class="toctree-l1"><a class="reference internal" href="../../_autosummary/bgc_md2.models.CARDAMOM.html">bgc_md2.models.CARDAMOM</a></li>

docs/_modules/bgc_md2/ModelStructure.html

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ <h1 class="logo"><a href="../../index.html">Biogeochemical model database</a></h
171171

172172
<h3>Navigation</h3>
173173
<ul>
174+
<li class="toctree-l1"><a class="reference internal" href="../../manual/usage.html">Usecases / Objectives</a></li>
175+
<li class="toctree-l1"><a class="reference internal" href="../../manual/structure.html">Structure</a></li>
176+
</ul>
177+
<ul>
174178
<li class="toctree-l1"><a class="reference internal" href="../../_autosummary/bgc_md2.models.Williams2005GCB.html">bgc_md2.models.Williams2005GCB</a></li>
175179
<li class="toctree-l1"><a class="reference internal" href="../../_autosummary/bgc_md2.models.ELM.html">bgc_md2.models.ELM</a></li>
176180
<li class="toctree-l1"><a class="reference internal" href="../../_autosummary/bgc_md2.models.CARDAMOM.html">bgc_md2.models.CARDAMOM</a></li>

0 commit comments

Comments
 (0)