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 Jun 30, 2024
1 parent ce292a7 commit d52d765
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions latest/_modules/compass/ocean/tests/utility/combine_topo.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,10 @@ <h1>Source code for compass.ocean.tests.utility.combine_topo</h1><div class="hig
<span class="n">grounded_mask</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">logical_or</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">logical_or</span><span class="p">(</span><span class="n">mask</span> <span class="o">==</span> <span class="mi">1</span><span class="p">,</span> <span class="n">mask</span> <span class="o">==</span> <span class="mi">2</span><span class="p">),</span>
<span class="n">mask</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>

<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="o">.</span><span class="n">bed</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">ocean_mask</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;ice_draft&#39;</span><span class="p">]</span> <span class="o">=</span> \
<span class="p">(</span><span class="n">bedmachine</span><span class="o">.</span><span class="n">surface</span> <span class="o">-</span>
<span class="n">bedmachine</span><span class="o">.</span><span class="n">thickness</span><span class="p">)</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">ocean_mask</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="o">.</span><span class="n">bed</span>
<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;ice_draft&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="o">.</span><span class="n">surface</span> <span class="o">-</span> <span class="n">bedmachine</span><span class="o">.</span><span class="n">thickness</span>
<span class="n">bedmachine</span><span class="o">.</span><span class="n">ice_draft</span><span class="o">.</span><span class="n">attrs</span><span class="p">[</span><span class="s1">&#39;units&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;meters&#39;</span>
<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;thickness&#39;</span><span class="p">]</span> <span class="o">=</span> \
<span class="n">bedmachine</span><span class="o">.</span><span class="n">thickness</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">ocean_mask</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;thickness&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="o">.</span><span class="n">thickness</span>

<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;ice_mask&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ice_mask</span>
<span class="n">bedmachine</span><span class="p">[</span><span class="s1">&#39;grounded_mask&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">grounded_mask</span>
Expand Down Expand Up @@ -362,11 +359,6 @@ <h1>Source code for compass.ocean.tests.utility.combine_topo</h1><div class="hig
<span class="n">logger</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">logger</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Remap BedMachineAntarctica to GEBCO 1/80 deg grid&#39;</span><span class="p">)</span>

<span class="n">config</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">config</span>

<span class="n">section</span> <span class="o">=</span> <span class="n">config</span><span class="p">[</span><span class="s1">&#39;combine_topo&#39;</span><span class="p">]</span>
<span class="n">renorm_thresh</span> <span class="o">=</span> <span class="n">section</span><span class="o">.</span><span class="n">getfloat</span><span class="p">(</span><span class="s1">&#39;renorm_thresh&#39;</span><span class="p">)</span>

<span class="n">in_filename</span> <span class="o">=</span> <span class="s1">&#39;BedMachineAntarctica-v3_mod.nc&#39;</span>
<span class="n">out_filename</span> <span class="o">=</span> <span class="s1">&#39;BedMachineAntarctica_on_GEBCO_low.nc&#39;</span>
<span class="n">gebco_filename</span> <span class="o">=</span> <span class="s1">&#39;GEBCO_2023_0.0125_degree.nc&#39;</span>
Expand Down Expand Up @@ -396,16 +388,6 @@ <h1>Source code for compass.ocean.tests.utility.combine_topo</h1><div class="hig
<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">,</span> <span class="s1">&#39;ice_draft&#39;</span><span class="p">,</span> <span class="s1">&#39;thickness&#39;</span><span class="p">]:</span>
<span class="n">bedmachine_on_gebco_low</span><span class="p">[</span><span class="n">field</span><span class="p">]</span><span class="o">.</span><span class="n">attrs</span><span class="p">[</span><span class="s1">&#39;unit&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;meters&#39;</span>

<span class="c1"># renormalize the fields based on the ocean masks</span>
<span class="n">ocean_mask</span> <span class="o">=</span> <span class="n">bedmachine_on_gebco_low</span><span class="o">.</span><span class="n">ocean_mask</span>

<span class="n">valid</span> <span class="o">=</span> <span class="n">ocean_mask</span> <span class="o">&gt;</span> <span class="n">renorm_thresh</span>
<span class="n">norm</span> <span class="o">=</span> <span class="n">ocean_mask</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">valid</span><span class="p">,</span> <span class="mf">1.</span><span class="p">)</span>
<span class="n">norm</span> <span class="o">=</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">norm</span>
<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">,</span> <span class="s1">&#39;ice_draft&#39;</span><span class="p">,</span> <span class="s1">&#39;thickness&#39;</span><span class="p">]:</span>
<span class="n">bedmachine_on_gebco_low</span><span class="p">[</span><span class="n">field</span><span class="p">]</span> <span class="o">=</span> \
<span class="n">norm</span> <span class="o">*</span> <span class="n">bedmachine_on_gebco_low</span><span class="p">[</span><span class="n">field</span><span class="p">]</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">valid</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>

<span class="n">bedmachine_on_gebco_low</span><span class="o">.</span><span class="n">to_netcdf</span><span class="p">(</span><span class="n">out_filename</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="s1">&#39; Done.&#39;</span><span class="p">)</span>

Expand Down Expand Up @@ -436,17 +418,22 @@ <h1>Source code for compass.ocean.tests.utility.combine_topo</h1><div class="hig
<span class="n">bedmachine_bathy</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="o">.</span><span class="n">bathymetry</span>
<span class="n">valid</span> <span class="o">=</span> <span class="n">bedmachine_bathy</span><span class="o">.</span><span class="n">notnull</span><span class="p">()</span>
<span class="n">bedmachine_bathy</span> <span class="o">=</span> <span class="n">bedmachine_bathy</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">valid</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
<span class="n">bedmachine_bathy</span> <span class="o">=</span> <span class="n">bedmachine_bathy</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">bedmachine_bathy</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>

<span class="n">combined</span><span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">]</span> <span class="o">=</span> \
<span class="n">alpha</span> <span class="o">*</span> <span class="n">gebco</span><span class="o">.</span><span class="n">bathymetry</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">gebco</span><span class="o">.</span><span class="n">bathymetry</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span> <span class="o">+</span> \
<span class="n">alpha</span> <span class="o">*</span> <span class="n">gebco</span><span class="o">.</span><span class="n">bathymetry</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">gebco</span><span class="o">.</span><span class="n">bathymetry</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span> <span class="o">+</span> \
<span class="p">(</span><span class="mf">1.0</span> <span class="o">-</span> <span class="n">alpha</span><span class="p">)</span> <span class="o">*</span> <span class="n">bedmachine_bathy</span>
<span class="n">bathy_mask</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">combined</span><span class="o">.</span><span class="n">bathymetry</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span>

<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;ice_draft&#39;</span><span class="p">,</span> <span class="s1">&#39;thickness&#39;</span><span class="p">]:</span>
<span class="n">combined</span><span class="p">[</span><span class="n">field</span><span class="p">]</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="p">[</span><span class="n">field</span><span class="p">]</span>
<span class="n">combined</span><span class="p">[</span><span class="n">field</span><span class="p">]</span> <span class="o">=</span> <span class="n">bathy_mask</span> <span class="o">*</span> <span class="n">bedmachine</span><span class="p">[</span><span class="n">field</span><span class="p">]</span>
<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">,</span> <span class="s1">&#39;ice_draft&#39;</span><span class="p">,</span> <span class="s1">&#39;thickness&#39;</span><span class="p">]:</span>
<span class="n">combined</span><span class="p">[</span><span class="n">field</span><span class="p">]</span><span class="o">.</span><span class="n">attrs</span><span class="p">[</span><span class="s1">&#39;unit&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;meters&#39;</span>

<span class="n">fill</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;ice_mask&#39;</span><span class="p">:</span> <span class="mf">0.</span><span class="p">,</span> <span class="s1">&#39;grounded_mask&#39;</span><span class="p">:</span> <span class="mf">0.</span><span class="p">,</span>
<span class="s1">&#39;ocean_mask&#39;</span><span class="p">:</span> <span class="n">combined</span><span class="p">[</span><span class="s1">&#39;bathymetry&#39;</span><span class="p">]</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">}</span>
<span class="n">combined</span><span class="p">[</span><span class="s1">&#39;bathymetry_mask&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">bathy_mask</span>

<span class="n">fill</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;ice_draft&#39;</span><span class="p">:</span> <span class="mf">0.</span><span class="p">,</span> <span class="s1">&#39;thickness&#39;</span><span class="p">:</span> <span class="mf">0.</span><span class="p">,</span> <span class="s1">&#39;ice_mask&#39;</span><span class="p">:</span> <span class="mf">0.</span><span class="p">,</span>
<span class="s1">&#39;grounded_mask&#39;</span><span class="p">:</span> <span class="mf">0.</span><span class="p">,</span> <span class="s1">&#39;ocean_mask&#39;</span><span class="p">:</span> <span class="n">combined</span><span class="o">.</span><span class="n">bathymetry_mask</span><span class="p">}</span>

<span class="k">for</span> <span class="n">field</span><span class="p">,</span> <span class="n">fill_val</span> <span class="ow">in</span> <span class="n">fill</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">valid</span> <span class="o">=</span> <span class="n">bedmachine</span><span class="p">[</span><span class="n">field</span><span class="p">]</span><span class="o">.</span><span class="n">notnull</span><span class="p">()</span>
Expand Down

0 comments on commit d52d765

Please sign in to comment.