Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 3, 2023
1 parent 17a806f commit 2d79622
Show file tree
Hide file tree
Showing 17 changed files with 305 additions and 104 deletions.
9 changes: 7 additions & 2 deletions latest/_modules/compass/ocean/iceshelf.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ <h1>Source code for compass.ocean.iceshelf</h1><div class="highlight"><pre>


<div class="viewcode-block" id="adjust_ssh"><a class="viewcode-back" href="../../../developers_guide/ocean/generated/compass.ocean.iceshelf.adjust_ssh.html#compass.ocean.iceshelf.adjust_ssh">[docs]</a><span class="k">def</span> <span class="nf">adjust_ssh</span><span class="p">(</span><span class="n">variable</span><span class="p">,</span> <span class="n">iteration_count</span><span class="p">,</span> <span class="n">step</span><span class="p">,</span> <span class="n">update_pio</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">convert_to_cdf5</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="n">convert_to_cdf5</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">delta_ssh_threshold</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Adjust the sea surface height or land-ice pressure to be dynamically</span>
<span class="sd"> consistent with one another. A series of short model runs are performed,</span>
Expand Down Expand Up @@ -282,6 +282,7 @@ <h1>Source code for compass.ocean.iceshelf</h1><div class="highlight"><pre>
<span class="n">iCell</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">deltaSSH</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">mask</span><span class="p">))</span><span class="o">.</span><span class="n">argmax</span><span class="p">()</span><span class="o">.</span><span class="n">values</span>

<span class="n">ds_cell</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">isel</span><span class="p">(</span><span class="n">nCells</span><span class="o">=</span><span class="n">iCell</span><span class="p">)</span>
<span class="n">deltaSSHMax</span> <span class="o">=</span> <span class="n">deltaSSH</span><span class="o">.</span><span class="n">isel</span><span class="p">(</span><span class="n">nCells</span><span class="o">=</span><span class="n">iCell</span><span class="p">)</span><span class="o">.</span><span class="n">values</span>

<span class="k">if</span> <span class="n">on_a_sphere</span><span class="p">:</span>
<span class="n">coords</span> <span class="o">=</span> <span class="p">(</span><span class="sa">f</span><span class="s1">&#39;lon/lat: &#39;</span>
Expand All @@ -291,7 +292,7 @@ <h1>Source code for compass.ocean.iceshelf</h1><div class="highlight"><pre>
<span class="n">coords</span> <span class="o">=</span> <span class="p">(</span><span class="sa">f</span><span class="s1">&#39;x/y: </span><span class="si">{</span><span class="mf">1e-3</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">ds_cell</span><span class="o">.</span><span class="n">xCell</span><span class="o">.</span><span class="n">values</span><span class="si">:</span><span class="s1">f</span><span class="si">}</span><span class="s1"> &#39;</span>
<span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="mf">1e-3</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">ds_cell</span><span class="o">.</span><span class="n">yCell</span><span class="o">.</span><span class="n">values</span><span class="si">:</span><span class="s1">f</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">string</span> <span class="o">=</span> <span class="p">(</span><span class="sa">f</span><span class="s1">&#39;deltaSSHMax: &#39;</span>
<span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">deltaSSH</span><span class="o">.</span><span class="n">isel</span><span class="p">(</span><span class="n">nCells</span><span class="o">=</span><span class="n">iCell</span><span class="p">)</span><span class="o">.</span><span class="n">values</span><span class="si">:</span><span class="s1">g</span><span class="si">}</span><span class="s1">, </span><span class="si">{</span><span class="n">coords</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">deltaSSHMax</span><span class="si">:</span><span class="s1">g</span><span class="si">}</span><span class="s1">, </span><span class="si">{</span><span class="n">coords</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39; </span><span class="si">{</span><span class="n">string</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">log_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">string</span><span class="si">}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">string</span> <span class="o">=</span> <span class="p">(</span><span class="sa">f</span><span class="s1">&#39;ssh: </span><span class="si">{</span><span class="n">finalSSH</span><span class="o">.</span><span class="n">isel</span><span class="p">(</span><span class="n">nCells</span><span class="o">=</span><span class="n">iCell</span><span class="p">)</span><span class="o">.</span><span class="n">values</span><span class="si">:</span><span class="s1">g</span><span class="si">}</span><span class="s1">, &#39;</span>
Expand All @@ -300,6 +301,10 @@ <h1>Source code for compass.ocean.iceshelf</h1><div class="highlight"><pre>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39; </span><span class="si">{</span><span class="n">string</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">log_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">string</span><span class="si">}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">delta_ssh_threshold</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">deltaSSHMax</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">delta_ssh_threshold</span><span class="p">:</span>
<span class="k">break</span>

<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot; - Complete</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">out_filename</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
Expand Down
33 changes: 21 additions & 12 deletions latest/_modules/compass/ocean/tests/ice_shelf_2d.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ <h1>Source code for compass.ocean.tests.ice_shelf_2d</h1><div class="highlight">
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">mpas_core</span><span class="o">=</span><span class="n">mpas_core</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;ice_shelf_2d&#39;</span><span class="p">)</span>

<span class="k">for</span> <span class="n">resolution</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;5km&#39;</span><span class="p">]:</span>
<span class="k">for</span> <span class="n">coord_type</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;z-star&#39;</span><span class="p">,</span> <span class="s1">&#39;z-level&#39;</span><span class="p">]:</span>
<span class="k">for</span> <span class="n">resolution</span> <span class="ow">in</span> <span class="p">[</span><span class="mf">2e3</span><span class="p">,</span> <span class="mf">5e3</span><span class="p">]:</span>
<span class="k">for</span> <span class="n">coord_type</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;z-star&#39;</span><span class="p">,</span> <span class="s1">&#39;z-level&#39;</span><span class="p">,</span> <span class="s1">&#39;single_layer&#39;</span><span class="p">]:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_test_case</span><span class="p">(</span>
<span class="n">Default</span><span class="p">(</span><span class="n">test_group</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">resolution</span><span class="o">=</span><span class="n">resolution</span><span class="p">,</span>
<span class="n">coord_type</span><span class="o">=</span><span class="n">coord_type</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_test_case</span><span class="p">(</span>
<span class="n">Default</span><span class="p">(</span><span class="n">test_group</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">resolution</span><span class="o">=</span><span class="n">resolution</span><span class="p">,</span>
<span class="n">coord_type</span><span class="o">=</span><span class="n">coord_type</span><span class="p">,</span> <span class="n">tidal_forcing</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_test_case</span><span class="p">(</span>
<span class="n">RestartTest</span><span class="p">(</span><span class="n">test_group</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">resolution</span><span class="o">=</span><span class="n">resolution</span><span class="p">,</span>
<span class="n">coord_type</span><span class="o">=</span><span class="n">coord_type</span><span class="p">))</span></div></div>
Expand All @@ -144,28 +147,34 @@ <h1>Source code for compass.ocean.tests.ice_shelf_2d</h1><div class="highlight">

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> resolution : str</span>
<span class="sd"> The resolution of the test case</span>
<span class="sd"> resolution : float</span>
<span class="sd"> The resolution of the test case in meters</span>

<span class="sd"> coord_type : str</span>
<span class="sd"> The type of vertical coordinate (``z-star``, ``z-level``, etc.)</span>

<span class="sd"> config : compass.config.CompassConfigParser</span>
<span class="sd"> Configuration options for this test case</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">res_params</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;5km&#39;</span><span class="p">:</span> <span class="p">{</span><span class="s1">&#39;nx&#39;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s1">&#39;ny&#39;</span><span class="p">:</span> <span class="mi">44</span><span class="p">,</span> <span class="s1">&#39;dc&#39;</span><span class="p">:</span> <span class="mf">5e3</span><span class="p">}}</span>
<span class="n">dx</span> <span class="o">=</span> <span class="mf">50e3</span> <span class="c1"># width of domain in m</span>
<span class="n">dy</span> <span class="o">=</span> <span class="mf">220e3</span> <span class="c1"># length of domain in m</span>
<span class="n">dc</span> <span class="o">=</span> <span class="n">resolution</span>
<span class="n">nx</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">dx</span> <span class="o">/</span> <span class="n">resolution</span><span class="p">)</span>
<span class="c1"># ny needs to be even because it is nonperiodic</span>
<span class="n">ny</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="nb">int</span><span class="p">(</span><span class="n">dy</span> <span class="o">/</span> <span class="p">(</span><span class="mf">2.</span> <span class="o">*</span> <span class="n">resolution</span><span class="p">))</span>

<span class="k">if</span> <span class="n">resolution</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">res_params</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Unsupported resolution </span><span class="si">{}</span><span class="s1">. Supported values are: &#39;</span>
<span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">resolution</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">res_params</span><span class="p">)))</span>
<span class="n">res_params</span> <span class="o">=</span> <span class="n">res_params</span><span class="p">[</span><span class="n">resolution</span><span class="p">]</span>
<span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">res_params</span><span class="p">:</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;ice_shelf_2d&#39;</span><span class="p">,</span> <span class="n">param</span><span class="p">,</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">res_params</span><span class="p">[</span><span class="n">param</span><span class="p">]))</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;ice_shelf_2d&#39;</span><span class="p">,</span> <span class="s1">&#39;nx&#39;</span><span class="p">,</span> <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">nx</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;ice_shelf_2d&#39;</span><span class="p">,</span> <span class="s1">&#39;ny&#39;</span><span class="p">,</span> <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">ny</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;ice_shelf_2d&#39;</span><span class="p">,</span> <span class="s1">&#39;dc&#39;</span><span class="p">,</span> <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">dc</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>

<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;vertical_grid&#39;</span><span class="p">,</span> <span class="s1">&#39;coord_type&#39;</span><span class="p">,</span> <span class="n">coord_type</span><span class="p">)</span>
<span class="k">if</span> <span class="n">coord_type</span> <span class="o">==</span> <span class="s1">&#39;z-level&#39;</span><span class="p">:</span>
<span class="c1"># we need more vertical resolution</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;vertical_grid&#39;</span><span class="p">,</span> <span class="s1">&#39;vert_levels&#39;</span><span class="p">,</span> <span class="s1">&#39;100&#39;</span><span class="p">)</span></div>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;vertical_grid&#39;</span><span class="p">,</span> <span class="s1">&#39;vert_levels&#39;</span><span class="p">,</span> <span class="s1">&#39;100&#39;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">coord_type</span> <span class="o">==</span> <span class="s1">&#39;single_layer&#39;</span><span class="p">:</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;vertical_grid&#39;</span><span class="p">,</span> <span class="s1">&#39;vert_levels&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;vertical_grid&#39;</span><span class="p">,</span> <span class="s1">&#39;coord_type&#39;</span><span class="p">,</span> <span class="s1">&#39;z-level&#39;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;vertical_grid&#39;</span><span class="p">,</span> <span class="s1">&#39;partial_cell_type&#39;</span><span class="p">,</span> <span class="s1">&#39;None&#39;</span><span class="p">)</span></div>
</pre></div>

</div>
Expand Down
Loading

0 comments on commit 2d79622

Please sign in to comment.