Skip to content

Commit

Permalink
Update 'docs' folder with 24-downloading-weather-data-fails-for-some-…
Browse files Browse the repository at this point in the history
…stations-picking-the-most-accurate-station-id-list and delete old branches.
  • Loading branch information
FWuellhorst committed Nov 6, 2023
1 parent 42ceba6 commit 4245f68
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 39 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ <h1>Source code for aixweather.imports.DWD</h1><div class="highlight"><pre>
<span class="k">try</span><span class="p">:</span>
<span class="n">values</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="n">stations</span><span class="o">.</span><span class="n">values</span><span class="o">.</span><span class="n">query</span><span class="p">())</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">excep</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;There is no loadable forecast for station </span><span class="si">{</span><span class="n">station</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">excep</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;There is no loadable forecast for station </span><span class="si">{</span><span class="n">station</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="p">)</span> <span class="kn">from</span> <span class="nn">excep</span>

<span class="n">imported_df</span> <span class="o">=</span> <span class="n">values</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">to_pandas</span><span class="p">()</span>

Expand All @@ -292,7 +294,7 @@ <h1>Source code for aixweather.imports.DWD</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">imported_df</span></div>


<div class="viewcode-block" id="import_meta_DWD_historical"><a class="viewcode-back" href="../../../code/aixweather.imports.html#aixweather.imports.DWD.import_meta_DWD_historical">[docs]</a><span class="k">def</span> <span class="nf">import_meta_DWD_historical</span><span class="p">(</span><span class="n">station</span><span class="p">:</span><span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">utils_import</span><span class="o">.</span><span class="n">MetaData</span><span class="p">:</span>
<div class="viewcode-block" id="import_meta_DWD_historical"><a class="viewcode-back" href="../../../code/aixweather.imports.html#aixweather.imports.DWD.import_meta_DWD_historical">[docs]</a><span class="k">def</span> <span class="nf">import_meta_DWD_historical</span><span class="p">(</span><span class="n">station</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">utils_import</span><span class="o">.</span><span class="n">MetaData</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Downloads and extracts metadata related to the specified station from</span>
<span class="sd"> the DWD (Deutscher Wetterdienst) Open Data Interface.</span>
Expand All @@ -305,9 +307,11 @@ <h1>Source code for aixweather.imports.DWD</h1><div class="highlight"><pre>
<span class="sd"> populated attributes related to the station.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://www.dwd.de/DE/leistungen/klimadatendeutschland/&quot;</span> \
<span class="s2">&quot;statliste/statlex_rich.txt;jsessionid&quot;</span> \
<span class="s2">&quot;=68E14BA255FE50BDC4AD9FF4F835895F.live31092?view=nasPublication&amp;nn=16102&quot;</span>
<span class="n">url</span> <span class="o">=</span> <span class="p">(</span>
<span class="s2">&quot;https://www.dwd.de/DE/leistungen/klimadatendeutschland/&quot;</span>
<span class="s2">&quot;statliste/statlex_rich.txt;jsessionid&quot;</span>
<span class="s2">&quot;=68E14BA255FE50BDC4AD9FF4F835895F.live31092?view=nasPublication&amp;nn=16102&quot;</span>
<span class="p">)</span>

<span class="c1"># load station overview</span>
<span class="n">data_str</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">&quot;latin-1&quot;</span><span class="p">)</span>
Expand Down Expand Up @@ -348,8 +352,10 @@ <h1>Source code for aixweather.imports.DWD</h1><div class="highlight"><pre>
<span class="k">break</span>

<span class="k">if</span> <span class="n">station_data</span> <span class="o">==</span> <span class="p">{}:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Station for historical weatherdata with ID </span><span class="si">{</span><span class="n">station</span><span class="si">}</span><span class="s2"> could not be&quot;</span>
<span class="sa">f</span><span class="s2">&quot;found in station list </span><span class="si">{</span><span class="n">url</span><span class="si">}</span><span class="s2">.&quot;</span><span class="p">)</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Station for historical weatherdata with ID </span><span class="si">{</span><span class="n">station</span><span class="si">}</span><span class="s2"> could not be&quot;</span>
<span class="sa">f</span><span class="s2">&quot;found in station list </span><span class="si">{</span><span class="n">url</span><span class="si">}</span><span class="s2">.&quot;</span>
<span class="p">)</span>

<span class="c1">### convert to meta class</span>
<span class="n">meta</span> <span class="o">=</span> <span class="n">utils_import</span><span class="o">.</span><span class="n">MetaData</span><span class="p">()</span>
Expand Down Expand Up @@ -377,9 +383,11 @@ <h1>Source code for aixweather.imports.DWD</h1><div class="highlight"><pre>
<span class="sd"> meta (meta_data object): An object of the meta_data class with</span>
<span class="sd"> populated attributes related to the station.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://www.dwd.de/DE/leistungen/met_verfahren_mosmix/&quot;</span> \
<span class="s2">&quot;mosmix_stationskatalog.cfg?view=nasPublication&amp;nn&quot;</span> \
<span class="s2">&quot;=16102&quot;</span>
<span class="n">url</span> <span class="o">=</span> <span class="p">(</span>
<span class="s2">&quot;https://www.dwd.de/DE/leistungen/met_verfahren_mosmix/&quot;</span>
<span class="s2">&quot;mosmix_stationskatalog.cfg?view=nasPublication&amp;nn&quot;</span>
<span class="s2">&quot;=16102&quot;</span>
<span class="p">)</span>

<span class="c1"># load station overview</span>
<span class="n">data_str</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">&quot;latin-1&quot;</span><span class="p">)</span>
Expand Down Expand Up @@ -440,9 +448,15 @@ <h1>Source code for aixweather.imports.DWD</h1><div class="highlight"><pre>
<span class="c1"># First, load all available filenames</span>
<span class="n">http_obj</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">()</span>

<span class="c1"># DWD data contains the stations with leading zeros, the meta-data and station lists without</span>
<span class="c1"># leading zeros. Apply leading zeros for pulling DWD data.</span>
<span class="n">station_with_leading_zeros</span> <span class="o">=</span> <span class="n">station</span><span class="o">.</span><span class="n">zfill</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>

<span class="c1"># select only those file names that belong to the station</span>
<span class="n">zip_names</span> <span class="o">=</span> <span class="p">[</span>
<span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">http_obj</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;&quot;&#39;</span><span class="p">)</span> <span class="k">if</span> <span class="sa">f</span><span class="s2">&quot;_</span><span class="si">{</span><span class="n">station</span><span class="si">}</span><span class="s2">_&quot;</span> <span class="ow">in</span> <span class="n">i</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">i</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;&gt;&quot;</span><span class="p">)</span>
<span class="n">i</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">http_obj</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;&quot;&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="sa">f</span><span class="s2">&quot;_</span><span class="si">{</span><span class="n">station_with_leading_zeros</span><span class="si">}</span><span class="s2">_&quot;</span> <span class="ow">in</span> <span class="n">i</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">i</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;&gt;&quot;</span><span class="p">)</span>
<span class="p">]</span>

<span class="n">data_total</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">()</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ <h1>Source code for aixweather.project_class</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">output_data_df</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">meta_data</span> <span class="o">=</span> <span class="kc">None</span>

<span class="c1"># checks too wordy with getter and setters</span>
<span class="bp">self</span><span class="o">.</span><span class="n">start_end_checks</span><span class="p">()</span>

<div class="viewcode-block" id="ProjectClassGeneral.start_end_checks"><a class="viewcode-back" href="../../code/aixweather.html#aixweather.project_class.ProjectClassGeneral.start_end_checks">[docs]</a> <span class="k">def</span> <span class="nf">start_end_checks</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># make sure start and end are of type datetime</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">end</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="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">end</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Time period for pulling data: start and end must be of &quot;</span>
<span class="s2">&quot;type datetime&quot;</span><span class="p">)</span>
<span class="c1"># make sure end is after start</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Time period for pulling data: end must be after start&quot;</span><span class="p">)</span></div>

<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">imported_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get imported data&quot;&quot;&quot;</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this
<dd><p>Get imported data</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="aixweather.project_class.ProjectClassGeneral.start_end_checks">
<span class="sig-name descname"><span class="pre">start_end_checks</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/aixweather/project_class.html#ProjectClassGeneral.start_end_checks"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#aixweather.project_class.ProjectClassGeneral.start_end_checks" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="py class">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ <h1>aixweather<a class="headerlink" href="#aixweather" title="Permalink to this
<li class="toctree-l4"><a class="reference internal" href="aixweather.html#aixweather.project_class.ProjectClassGeneral.data_2_core_data"><code class="docutils literal notranslate"><span class="pre">ProjectClassGeneral.data_2_core_data()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="aixweather.html#aixweather.project_class.ProjectClassGeneral.import_data"><code class="docutils literal notranslate"><span class="pre">ProjectClassGeneral.import_data()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="aixweather.html#aixweather.project_class.ProjectClassGeneral.imported_data"><code class="docutils literal notranslate"><span class="pre">ProjectClassGeneral.imported_data</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="aixweather.html#aixweather.project_class.ProjectClassGeneral.start_end_checks"><code class="docutils literal notranslate"><span class="pre">ProjectClassGeneral.start_end_checks()</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="aixweather.html#aixweather.project_class.ProjectClassTRY"><code class="docutils literal notranslate"><span class="pre">ProjectClassTRY</span></code></a><ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,12 @@ <h2 id="S">S</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="code/aixweather.transformation_functions.html#aixweather.transformation_functions.auxiliary.select_entry_by_core_name">select_entry_by_core_name() (in module aixweather.transformation_functions.auxiliary)</a>
</li>
<li><a href="code/aixweather.transformation_functions.html#aixweather.transformation_functions.time_observation_transformations.shift_time_by_dict">shift_time_by_dict() (in module aixweather.transformation_functions.time_observation_transformations)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="code/aixweather.transformation_functions.html#aixweather.transformation_functions.time_observation_transformations.shift_time_by_dict">shift_time_by_dict() (in module aixweather.transformation_functions.time_observation_transformations)</a>
<li><a href="code/aixweather.html#aixweather.project_class.ProjectClassGeneral.start_end_checks">start_end_checks() (aixweather.project_class.ProjectClassGeneral method)</a>
</li>
<li><a href="code/aixweather.imports.html#aixweather.imports.utils_import.MetaData.station_name">station_name (aixweather.imports.utils_import.MetaData property)</a>
</li>
Expand Down
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,38 @@ <h1>Pylint report from report.jinja2</h1>


<h2>Score</h2>
10.00 / 10
9.94 / 10

(previous score: 10.00 / 10)
(previous score: 9.94 / 10)



<h2>Messages</h2>

<h3>Module <code>aixweather.project_class</code> (<code>aixweather/project_class.py</code>)</h3>
<table>
<tr>
<th>Line</th>
<th>Col.</th>
<th>Type</th>
<th>Symbol</th>
<th>ID</th>
<th>Obj</th>
<th>Message</th>
</tr>

<tr>
<td>91</td>
<td>4</td>
<td>convention</td>
<td><code>missing-function-docstring</code></td>
<td>C0116</td>
<td>ProjectClassGeneral.start_end_checks</td>
<td><pre>Missing function or method docstring</pre></td>
</tr>

</table>


<h2>Metrics</h2>

Expand All @@ -47,6 +71,11 @@ <h3>Count per types</h3>
<th>Count</th>
</tr>

<tr>
<td>convention</td>
<td>1</td>
</tr>

</table>


Expand All @@ -57,6 +86,11 @@ <h3>Count per messages</h3>
<th>Count</th>
</tr>

<tr>
<td>missing-function-docstring</td>
<td>1</td>
</tr>

</table>


Expand All @@ -67,6 +101,11 @@ <h3>Count per modules</h3>
<th>Count</th>
</tr>

<tr>
<td>aixweather.project_class</td>
<td>1</td>
</tr>

</table>


Expand All @@ -77,6 +116,11 @@ <h3>Count per path</h3>
<th>Count</th>
</tr>

<tr>
<td>aixweather/project_class.py</td>
<td>1</td>
</tr>

</table>


Expand Down
Loading

0 comments on commit 4245f68

Please sign in to comment.