Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 5, 2024
1 parent 9c7445e commit 629b8eb
Show file tree
Hide file tree
Showing 10 changed files with 3,265 additions and 3,217 deletions.
2 changes: 1 addition & 1 deletion _modules/pysurfex/cmd_parsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h1>Source code for pysurfex.cmd_parsing</h1><div class="highlight"><pre>
<span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="s2">&quot;Converter function to specific humidity&quot;</span><span class="p">,</span>
<span class="n">default</span><span class="o">=</span><span class="s2">&quot;none&quot;</span><span class="p">,</span>
<span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;none&quot;</span><span class="p">,</span> <span class="s2">&quot;rh2q&quot;</span><span class="p">,</span> <span class="s2">&quot;rh2q_mslp&quot;</span><span class="p">],</span>
<span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;none&quot;</span><span class="p">,</span> <span class="s2">&quot;rh2q&quot;</span><span class="p">,</span> <span class="s2">&quot;rh2q_mslp&quot;</span><span class="p">,</span> <span class="s2">&quot;rh2q_z&quot;</span><span class="p">],</span>
<span class="p">)</span>

<span class="n">group_ps</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">&quot;PS&quot;</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s2">&quot;Surface air pressure [Pa]&quot;</span><span class="p">)</span>
Expand Down
2 changes: 2 additions & 0 deletions _modules/pysurfex/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ <h1>Source code for pysurfex.configuration</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">update_setting</span><span class="p">(</span><span class="s2">&quot;SURFEX#ASSIM#SCHEMES#ISBA&quot;</span><span class="p">,</span> <span class="s2">&quot;EKF&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">anasurf</span> <span class="o">==</span> <span class="s2">&quot;ENKF&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_setting</span><span class="p">(</span><span class="s2">&quot;SURFEX#ASSIM#SCHEMES#ISBA&quot;</span><span class="p">,</span> <span class="s2">&quot;ENKF&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">anasurf</span> <span class="o">==</span> <span class="s2">&quot;ISBA_NONE&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">update_setting</span><span class="p">(</span><span class="s2">&quot;SURFEX#ASSIM#SCHEMES#ISBA&quot;</span><span class="p">,</span> <span class="s2">&quot;NONE&quot;</span><span class="p">)</span>

<span class="c1"># Active EKF control variables from CVAR_M</span>
<span class="k">if</span> <span class="s2">&quot;NNCV&quot;</span> <span class="ow">in</span> <span class="n">env</span><span class="p">:</span>
Expand Down
15 changes: 15 additions & 0 deletions _modules/pysurfex/geo.html
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,21 @@ <h1>Source code for pysurfex.geo</h1><div class="highlight"><pre>
<span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;nam_pgd_grid not set!&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="get_geo_object_from_json_file"><a class="viewcode-back" href="../../index.html#pysurfex.geo.get_geo_object_from_json_file">[docs]</a><span class="k">def</span> <span class="nf">get_geo_object_from_json_file</span><span class="p">(</span><span class="n">fname</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get a surfex geometry object from a dictionary.</span>

<span class="sd"> Args:</span>
<span class="sd"> fname (str): Domain definition file.</span>

<span class="sd"> Returns:</span>
<span class="sd"> surfex.Geo: Surfex geometry.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s2">&quot;r&quot;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">&quot;utf8&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fh</span><span class="p">:</span>
<span class="n">domain_dict</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">fh</span><span class="p">)</span>
<span class="k">return</span> <span class="n">get_geo_object</span><span class="p">(</span><span class="n">domain_dict</span><span class="p">)</span></div>


<div class="viewcode-block" id="set_domain"><a class="viewcode-back" href="../../index.html#pysurfex.geo.set_domain">[docs]</a><span class="k">def</span> <span class="nf">set_domain</span><span class="p">(</span><span class="n">settings</span><span class="p">,</span> <span class="n">domain</span><span class="p">,</span> <span class="n">hm_mode</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Set domain.</span>

Expand Down
16 changes: 13 additions & 3 deletions _modules/pysurfex/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ <h1>Source code for pysurfex.read</h1><div class="highlight"><pre>
<span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;altitude&quot;</span><span class="p">]</span>
<span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pres</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_variable</span><span class="p">(</span><span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;mslp&quot;</span><span class="p">])</span>
<span class="k">elif</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_z&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">r_h</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_variable</span><span class="p">(</span><span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;rh&quot;</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">temp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_variable</span><span class="p">(</span><span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;t&quot;</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">altitude</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_variable</span><span class="p">(</span>
<span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;altitude&quot;</span><span class="p">]</span>
<span class="p">)</span>
<span class="k">elif</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;windspeed&quot;</span> <span class="ow">or</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;winddir&quot;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">x_wind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_variable</span><span class="p">(</span><span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;x&quot;</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">y_wind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_variable</span><span class="p">(</span><span class="n">fileformat</span><span class="p">,</span> <span class="n">defs</span><span class="p">,</span> <span class="n">conf</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s2">&quot;y&quot;</span><span class="p">])</span>
Expand Down Expand Up @@ -372,7 +378,7 @@ <h1>Source code for pysurfex.read</h1><div class="highlight"><pre>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;winddir&quot;</span><span class="p">:</span>
<span class="n">field</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mod</span><span class="p">(</span><span class="mi">90</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">rad2deg</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arctan2</span><span class="p">(</span><span class="n">field_y</span><span class="p">,</span> <span class="n">field_x</span><span class="p">)),</span> <span class="mi">360</span><span class="p">)</span>

<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q&quot;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_mslp&quot;</span><span class="p">:</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q&quot;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_mslp&quot;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_z&quot;</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> ZES = 6.112 * exp((17.67 * (ZT - 273.15)) / ((ZT - 273.15) + 243.5))</span>
<span class="sd"> ZE = ZRH * ZES</span>
Expand All @@ -381,8 +387,12 @@ <h1>Source code for pysurfex.read</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">field_r_h</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">r_h</span><span class="o">.</span><span class="n">read_variable</span><span class="p">(</span><span class="n">geo</span><span class="p">,</span> <span class="n">validtime</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> <span class="c1"># %</span>
<span class="n">field_temp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">temp</span><span class="o">.</span><span class="n">read_variable</span><span class="p">(</span><span class="n">geo</span><span class="p">,</span> <span class="n">validtime</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> <span class="c1"># In K</span>
<span class="n">field_pres</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pres</span><span class="o">.</span><span class="n">read_variable</span><span class="p">(</span><span class="n">geo</span><span class="p">,</span> <span class="n">validtime</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> <span class="c1"># In Pa</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_mslp&quot;</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_z&quot;</span><span class="p">:</span>
<span class="n">field_pres</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">field_r_h</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="n">field_pres</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="mf">101325.0</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">field_pres</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pres</span><span class="o">.</span><span class="n">read_variable</span><span class="p">(</span><span class="n">geo</span><span class="p">,</span> <span class="n">validtime</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> <span class="c1"># In Pa</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_mslp&quot;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">&quot;rh2q_z&quot;</span><span class="p">:</span>
<span class="n">field_altitude</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">altitude</span><span class="o">.</span><span class="n">read_variable</span><span class="p">(</span>
<span class="n">geo</span><span class="p">,</span> <span class="n">validtime</span><span class="p">,</span> <span class="n">cache</span>
<span class="p">)</span> <span class="c1"># In m</span>
Expand Down
4 changes: 2 additions & 2 deletions _modules/pysurfex/variable.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h1>Source code for pysurfex.variable</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">.datetime_utils</span> <span class="kn">import</span> <span class="n">as_timedelta</span>
<span class="kn">from</span> <span class="nn">.fa</span> <span class="kn">import</span> <span class="n">Fa</span>
<span class="kn">from</span> <span class="nn">.file</span> <span class="kn">import</span> <span class="n">SurfexFileVariable</span><span class="p">,</span> <span class="n">get_surfex_io_object</span>
<span class="kn">from</span> <span class="nn">.geo</span> <span class="kn">import</span> <span class="n">get_geo_object</span>
<span class="kn">from</span> <span class="nn">.geo</span> <span class="kn">import</span> <span class="n">get_geo_object_from_json_file</span>
<span class="kn">from</span> <span class="nn">.grib</span> <span class="kn">import</span> <span class="n">Grib</span><span class="p">,</span> <span class="n">Grib1Variable</span><span class="p">,</span> <span class="n">Grib2Variable</span>
<span class="kn">from</span> <span class="nn">.input_methods</span> <span class="kn">import</span> <span class="n">get_datasources</span>
<span class="kn">from</span> <span class="nn">.netcdf</span> <span class="kn">import</span> <span class="n">Netcdf</span><span class="p">,</span> <span class="n">NetCDFReadVariable</span>
Expand Down Expand Up @@ -163,7 +163,7 @@ <h1>Source code for pysurfex.variable</h1><div class="highlight"><pre>
<span class="n">geo_in</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">var_dict</span><span class="p">[</span><span class="s2">&quot;geo_input&quot;</span><span class="p">]</span>
<span class="k">elif</span> <span class="s2">&quot;geo_input_file&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">var_dict</span><span class="p">:</span>
<span class="n">geo_in_file</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">var_dict</span><span class="p">[</span><span class="s2">&quot;geo_input_file&quot;</span><span class="p">]</span>
<span class="n">geo_in</span> <span class="o">=</span> <span class="n">get_geo_object</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">geo_in_file</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">&quot;utf-8&quot;</span><span class="p">))</span>
<span class="n">geo_in</span> <span class="o">=</span> <span class="n">get_geo_object_from_json_file</span><span class="p">(</span><span class="n">geo_in_file</span><span class="p">)</span>

<span class="n">file_handler</span> <span class="o">=</span> <span class="n">get_surfex_io_object</span><span class="p">(</span>
<span class="n">filename</span><span class="p">,</span> <span class="n">fileformat</span><span class="o">=</span><span class="n">fileformat</span><span class="p">,</span> <span class="n">filetype</span><span class="o">=</span><span class="n">filetype</span><span class="p">,</span> <span class="n">geo</span><span class="o">=</span><span class="n">geo_in</span>
Expand Down
Loading

0 comments on commit 629b8eb

Please sign in to comment.