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 3e6a593 commit ce292a7
Show file tree
Hide file tree
Showing 30 changed files with 1,061 additions and 94 deletions.
2 changes: 1 addition & 1 deletion latest/_modules/compass/ocean/iceshelf.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ <h1>Source code for compass.ocean.iceshelf</h1><div class="highlight"><pre>
<span class="n">on_a_sphere</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">attrs</span><span class="p">[</span><span class="s1">&#39;on_a_sphere&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;yes&#39;</span>

<span class="n">modify_mask</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">logical_and</span><span class="p">(</span><span class="n">ds</span><span class="o">.</span><span class="n">maxLevelCell</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">,</span>
<span class="n">ds</span><span class="o">.</span><span class="n">modifyLandIcePressureMask</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">ds</span><span class="o">.</span><span class="n">sshAdjustmentMask</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span>

<span class="k">for</span> <span class="n">iter_index</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">iteration_count</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="s2">&quot; * Iteration </span><span class="si">{</span><span class="n">iter_index</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="si">}</span><span class="s2">/</span><span class="si">{</span><span class="n">iteration_count</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
Expand Down
6 changes: 2 additions & 4 deletions latest/_modules/compass/ocean/mesh/cull.html
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,7 @@ <h1>Source code for compass.ocean.mesh.cull</h1><div class="highlight"><pre>
<span class="c1"># we want the mask to be 1 where there&#39;s not ocean</span>
<span class="n">cull_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">ocean_frac</span> <span class="o">&lt;</span> <span class="mf">0.5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">land_ice_frac</span> <span class="o">=</span> <span class="n">ds_topo</span><span class="o">.</span><span class="n">landIceFracObserved</span>
<span class="n">grounded_ice_frac</span> <span class="o">=</span> <span class="n">ds_topo</span><span class="o">.</span><span class="n">landIceGroundedFracObserved</span>
<span class="n">floating_ice_frac</span> <span class="o">=</span> <span class="n">land_ice_frac</span> <span class="o">-</span> <span class="n">grounded_ice_frac</span>
<span class="n">floating_ice_frac</span> <span class="o">=</span> <span class="n">ds_topo</span><span class="o">.</span><span class="n">landIceFloatingFracObserved</span>
<span class="n">no_cavities_ocean_frac</span> <span class="o">=</span> <span class="n">ocean_frac</span> <span class="o">-</span> <span class="n">floating_ice_frac</span>

<span class="c1"># we want the mask to be 1 where there&#39;s not open ocean</span>
Expand Down Expand Up @@ -686,7 +684,7 @@ <h1>Source code for compass.ocean.mesh.cull</h1><div class="highlight"><pre>
<span class="n">land_ice_draft_mask</span> <span class="o">=</span> <span class="n">ds_mask</span><span class="o">.</span><span class="n">cellSeedMask</span>
<span class="n">ds_topo</span><span class="p">[</span><span class="s1">&#39;landIceDraftMask&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">land_ice_draft_mask</span>
<span class="n">ds_topo</span><span class="p">[</span><span class="s1">&#39;landIceDraftObserved&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">land_ice_mask</span> <span class="o">*</span> <span class="n">ds_topo</span><span class="o">.</span><span class="n">landIceDraftObserved</span><span class="p">)</span>
<span class="n">land_ice_draft_mask</span> <span class="o">*</span> <span class="n">ds_topo</span><span class="o">.</span><span class="n">landIceDraftObserved</span><span class="p">)</span>


<span class="k">def</span> <span class="nf">_land_mask_from_geojson</span><span class="p">(</span><span class="n">with_cavities</span><span class="p">,</span> <span class="n">process_count</span><span class="p">,</span> <span class="n">logger</span><span class="p">,</span>
Expand Down
41 changes: 31 additions & 10 deletions latest/_modules/compass/ocean/mesh/remap_topography.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h1>Source code for compass.ocean.mesh.remap_topography</h1><div class="highligh

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">xarray</span> <span class="k">as</span> <span class="nn">xr</span>
<span class="kn">from</span> <span class="nn">mpas_tools.cime.constants</span> <span class="kn">import</span> <span class="n">constants</span>
<span class="kn">from</span> <span class="nn">mpas_tools.io</span> <span class="kn">import</span> <span class="n">write_netcdf</span>
<span class="kn">from</span> <span class="nn">pyremap</span> <span class="kn">import</span> <span class="n">LatLonGridDescriptor</span><span class="p">,</span> <span class="n">MpasCellMeshDescriptor</span><span class="p">,</span> <span class="n">Remapper</span>

Expand Down Expand Up @@ -177,7 +178,8 @@ <h1>Source code for compass.ocean.mesh.remap_topography</h1><div class="highligh
<span class="sd"> dependencies.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">setup</span><span class="p">()</span>
<span class="n">topo_filename</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="s1">&#39;topo_filename&#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">topo_filename</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="s1">&#39;topo_filename&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_input_file</span><span class="p">(</span>
<span class="n">filename</span><span class="o">=</span><span class="s1">&#39;topography.nc&#39;</span><span class="p">,</span>
<span class="n">target</span><span class="o">=</span><span class="n">topo_filename</span><span class="p">,</span>
Expand All @@ -189,7 +191,6 @@ <h1>Source code for compass.ocean.mesh.remap_topography</h1><div class="highligh
<span class="n">target</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">base_path</span><span class="p">,</span> <span class="n">base_filename</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_input_file</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="s1">&#39;base_mesh.nc&#39;</span><span class="p">,</span> <span class="n">work_dir_target</span><span class="o">=</span><span class="n">target</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="bp">self</span><span class="o">.</span><span class="n">ntasks</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">getint</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="s1">&#39;ntasks&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">min_tasks</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">getint</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="s1">&#39;min_tasks&#39;</span><span class="p">)</span></div>

Expand Down Expand Up @@ -227,6 +228,9 @@ <h1>Source code for compass.ocean.mesh.remap_topography</h1><div class="highligh
<span class="n">method</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="s1">&#39;method&#39;</span><span class="p">)</span>
<span class="n">renorm_threshold</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">getfloat</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span>
<span class="s1">&#39;renorm_threshold&#39;</span><span class="p">)</span>
<span class="n">ice_density</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">getfloat</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="s1">&#39;ice_density&#39;</span><span class="p">)</span>
<span class="n">ocean_density</span> <span class="o">=</span> <span class="n">constants</span><span class="p">[</span><span class="s1">&#39;SHR_CONST_RHOSW&#39;</span><span class="p">]</span>
<span class="n">g</span> <span class="o">=</span> <span class="n">constants</span><span class="p">[</span><span class="s1">&#39;SHR_CONST_G&#39;</span><span class="p">]</span>

<span class="n">in_descriptor</span> <span class="o">=</span> <span class="n">LatLonGridDescriptor</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">fileName</span><span class="o">=</span><span class="s1">&#39;topography.nc&#39;</span><span class="p">,</span>
<span class="n">lonVarName</span><span class="o">=</span><span class="n">lon_var</span><span class="p">,</span>
Expand Down Expand Up @@ -254,29 +258,46 @@ <h1>Source code for compass.ocean.mesh.remap_topography</h1><div class="highligh
<span class="n">ds_in</span> <span class="o">=</span> <span class="n">ds_in</span><span class="o">.</span><span class="n">rename</span><span class="p">({</span><span class="s1">&#39;ncol&#39;</span><span class="p">:</span> <span class="s1">&#39;nCells&#39;</span><span class="p">})</span>
<span class="n">ds_out</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">Dataset</span><span class="p">()</span>
<span class="n">rename</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;bathymetry_var&#39;</span><span class="p">:</span> <span class="s1">&#39;bed_elevation&#39;</span><span class="p">,</span>
<span class="s1">&#39;ice_draft_var&#39;</span><span class="p">:</span> <span class="s1">&#39;landIceDraftObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;ice_thickness_var&#39;</span><span class="p">:</span> <span class="s1">&#39;landIceThkObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;ice_frac_var&#39;</span><span class="p">:</span> <span class="s1">&#39;landIceFracObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;grounded_ice_frac_var&#39;</span><span class="p">:</span> <span class="s1">&#39;landIceGroundedFracObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;ocean_frac_var&#39;</span><span class="p">:</span> <span class="s1">&#39;oceanFracObserved&#39;</span><span class="p">}</span>
<span class="s1">&#39;ocean_frac_var&#39;</span><span class="p">:</span> <span class="s1">&#39;oceanFracObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;bathy_frac_var&#39;</span><span class="p">:</span> <span class="s1">&#39;bathyFracObserved&#39;</span><span class="p">}</span>

<span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">rename</span><span class="p">:</span>
<span class="k">for</span> <span class="n">option</span><span class="p">,</span> <span class="n">out_var</span> <span class="ow">in</span> <span class="n">rename</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">in_var</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;remap_topography&#39;</span><span class="p">,</span> <span class="n">option</span><span class="p">)</span>
<span class="n">out_var</span> <span class="o">=</span> <span class="n">rename</span><span class="p">[</span><span class="n">option</span><span class="p">]</span>
<span class="n">ds_out</span><span class="p">[</span><span class="n">out_var</span><span class="p">]</span> <span class="o">=</span> <span class="n">ds_in</span><span class="p">[</span><span class="n">in_var</span><span class="p">]</span>

<span class="n">ds_out</span><span class="p">[</span><span class="s1">&#39;landIceFloatingFracObserved&#39;</span><span class="p">]</span> <span class="o">=</span> \
<span class="n">ds_out</span><span class="o">.</span><span class="n">landIceFracObserved</span> <span class="o">-</span> <span class="n">ds_out</span><span class="o">.</span><span class="n">landIceGroundedFracObserved</span>

<span class="c1"># make sure fractions don&#39;t exceed 1</span>
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;landIceFracObserved&#39;</span><span class="p">,</span> <span class="s1">&#39;landIceGroundedFracObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;oceanFracObserved&#39;</span><span class="p">]:</span>
<span class="s1">&#39;landIceFloatingFracObserved&#39;</span><span class="p">,</span> <span class="s1">&#39;oceanFracObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;bathyFracObserved&#39;</span><span class="p">]:</span>
<span class="n">ds_out</span><span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">minimum</span><span class="p">(</span><span class="n">ds_out</span><span class="p">[</span><span class="n">var</span><span class="p">],</span> <span class="mf">1.</span><span class="p">)</span>

<span class="c1"># renormalize elevation variables</span>
<span class="n">norm</span> <span class="o">=</span> <span class="n">ds_out</span><span class="o">.</span><span class="n">oceanFracObserved</span>
<span class="n">norm</span> <span class="o">=</span> <span class="n">ds_out</span><span class="o">.</span><span class="n">bathyFracObserved</span>
<span class="n">valid</span> <span class="o">=</span> <span class="n">norm</span> <span class="o">&gt;</span> <span class="n">renorm_threshold</span>
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;bed_elevation&#39;</span><span class="p">,</span> <span class="s1">&#39;landIceDraftObserved&#39;</span><span class="p">,</span>
<span class="s1">&#39;landIceThkObserved&#39;</span><span class="p">]:</span>
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;bed_elevation&#39;</span><span class="p">,</span> <span class="s1">&#39;landIceThkObserved&#39;</span><span class="p">]:</span>
<span class="n">ds_out</span><span class="p">[</span><span class="n">var</span><span class="p">]</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">valid</span><span class="p">,</span> <span class="n">ds_out</span><span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="o">/</span> <span class="n">norm</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>

<span class="n">thickness</span> <span class="o">=</span> <span class="n">ds_out</span><span class="o">.</span><span class="n">landIceThkObserved</span>
<span class="n">ds_out</span><span class="p">[</span><span class="s1">&#39;landIcePressureObserved&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ice_density</span> <span class="o">*</span> <span class="n">g</span> <span class="o">*</span> <span class="n">thickness</span>

<span class="c1"># compute the ice draft to be consistent with the land ice pressure</span>
<span class="c1"># and using E3SM&#39;s density of seawater</span>
<span class="n">draft</span> <span class="o">=</span> <span class="o">-</span> <span class="p">(</span><span class="n">ice_density</span> <span class="o">/</span> <span class="n">ocean_density</span><span class="p">)</span> <span class="o">*</span> <span class="n">thickness</span>
<span class="n">bed</span> <span class="o">=</span> <span class="n">ds_out</span><span class="o">.</span><span class="n">bed_elevation</span>

<span class="c1"># can&#39;t be deeper than the bed</span>
<span class="n">draft</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">draft</span> <span class="o">&gt;=</span> <span class="n">bed</span><span class="p">,</span> <span class="n">draft</span><span class="p">,</span> <span class="n">bed</span><span class="p">)</span>

<span class="n">ds_out</span><span class="p">[</span><span class="s1">&#39;landIceDraftObserved&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">draft</span>

<span class="n">ds_out</span><span class="p">[</span><span class="s1">&#39;ssh&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">draft</span>

<span class="n">write_netcdf</span><span class="p">(</span><span class="n">ds_out</span><span class="p">,</span> <span class="s1">&#39;topography_remapped.nc&#39;</span><span class="p">)</span></div>
</div>

Expand Down
Loading

0 comments on commit ce292a7

Please sign in to comment.