-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d32c4dd
Showing
68 changed files
with
27,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: f6842527cfc61a1e96c64b34bdb43eca | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#GitHub Pages | ||
|
||
Last update of sphinx html documentation from [ba484b7](https://github.com/MarkusPic/intensity_duration_frequency_analysis/tree/ba484b70adc90198464ca0db8d4830b9fc8013e0) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" data-content_root="../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>idf_analysis.in_out — Intensity Duration Frequency Analyse 0.3.0 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=a746c00c" /> | ||
<link rel="stylesheet" type="text/css" href="../../_static/nature.css?v=7d325330" /> | ||
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-codeautolink.css?v=125d5c1c" /> | ||
<script src="../../_static/documentation_options.js?v=e259d695"></script> | ||
<script src="../../_static/doctools.js?v=9bcbadda"></script> | ||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> | ||
<link rel="index" title="Index" href="../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../search.html" /> | ||
</head><body> | ||
<div class="related" role="navigation" aria-label="Related"> | ||
<h3>Navigation</h3> | ||
<ul> | ||
<li class="right" style="margin-right: 10px"> | ||
<a href="../../genindex.html" title="General Index" | ||
accesskey="I">index</a></li> | ||
<li class="right" > | ||
<a href="../../py-modindex.html" title="Python Module Index" | ||
>modules</a> |</li> | ||
<li class="nav-item nav-item-0"><a href="../../index.html">Intensity Duration Frequency Analyse 0.3.0 documentation</a> »</li> | ||
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> »</li> | ||
<li class="nav-item nav-item-this"><a href="">idf_analysis.in_out</a></li> | ||
</ul> | ||
</div> | ||
|
||
<div class="document"> | ||
<div class="documentwrapper"> | ||
<div class="bodywrapper"> | ||
<div class="body" role="main"> | ||
|
||
<h1>Source code for idf_analysis.in_out</h1><div class="highlight"><pre> | ||
<span></span><span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">OrderedDict</span> | ||
|
||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span> | ||
<span class="kn">import</span> <span class="nn">yaml</span> | ||
|
||
|
||
<div class="viewcode-block" id="import_series"> | ||
<a class="viewcode-back" href="../../base_functions.html#idf_analysis.in_out.import_series">[docs]</a> | ||
<span class="k">def</span> <span class="nf">import_series</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">series_label</span><span class="o">=</span><span class="s1">'precipitation'</span><span class="p">,</span> <span class="n">index_label</span><span class="o">=</span><span class="s1">'datetime'</span><span class="p">,</span> <span class="n">csv_reader_args</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
|
||
<span class="sd"> Args:</span> | ||
<span class="sd"> filename:</span> | ||
<span class="sd"> series_label:</span> | ||
<span class="sd"> index_label:</span> | ||
<span class="sd"> csv_reader_args: for example: sep="," or "." and decimal=";" or ","</span> | ||
|
||
<span class="sd"> Returns:</span> | ||
<span class="sd"> pandas.Series: precipitation series</span> | ||
<span class="sd"> """</span> | ||
<span class="k">if</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">'csv'</span><span class="p">):</span> | ||
<span class="k">if</span> <span class="n">csv_reader_args</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="n">csv_reader_args</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">sep</span><span class="o">=</span><span class="s1">';'</span><span class="p">,</span> <span class="n">decimal</span><span class="o">=</span><span class="s1">','</span><span class="p">)</span> | ||
<span class="k">try</span><span class="p">:</span> | ||
<span class="n">ts</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">index_col</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="o">**</span><span class="n">csv_reader_args</span><span class="p">)</span><span class="o">.</span><span class="n">squeeze</span><span class="p">(</span><span class="s1">'columns'</span><span class="p">)</span> | ||
<span class="n">ts</span><span class="o">.</span><span class="n">index</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">ts</span><span class="o">.</span><span class="n">index</span><span class="p">)</span> | ||
<span class="n">ts</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">index_label</span> | ||
<span class="n">ts</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">series_label</span> | ||
<span class="k">except</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">UserWarning</span><span class="p">(</span><span class="s1">'ERROR | '</span> | ||
<span class="s1">'Something is wrong with your csv format. The file should only include two columns. '</span> | ||
<span class="s1">'First column is the date and time index (prefered format is "YYYY-MM-DD HH:MM:SS") '</span> | ||
<span class="s1">'and second column the precipitation values in mm. '</span> | ||
<span class="s1">'As a separator use "</span><span class="si">{sep}</span><span class="s1">" and as decimal sign use "</span><span class="si">{decimal}</span><span class="s1">".'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="o">**</span><span class="n">csv_reader_args</span><span class="p">))</span> | ||
|
||
<span class="k">return</span> <span class="n">ts</span> | ||
<span class="k">elif</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">'parquet'</span><span class="p">):</span> | ||
<span class="c1"># You need to install `pyarrow` or `fastparquet` to read and write parquet files.</span> | ||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_parquet</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="n">series_label</span><span class="p">])[</span><span class="n">series_label</span><span class="p">]</span><span class="o">.</span><span class="n">rename_axis</span><span class="p">(</span><span class="n">index_label</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">'index'</span><span class="p">)</span> | ||
<span class="k">elif</span> <span class="n">filename</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">'pkl'</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_pickle</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">series_label</span><span class="p">)</span><span class="o">.</span><span class="n">rename_axis</span><span class="p">(</span><span class="n">index_label</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">'index'</span><span class="p">)</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s1">'Sorry, but only csv, parquet and pickle files are implemented. '</span> | ||
<span class="s1">'Maybe there will be more options soon.'</span><span class="p">)</span></div> | ||
|
||
|
||
<span class="c1"># ------------------------------------------------------------------------------</span> | ||
<span class="n">_mapping_tag</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">resolver</span><span class="o">.</span><span class="n">BaseResolver</span><span class="o">.</span><span class="n">DEFAULT_MAPPING_TAG</span> | ||
|
||
|
||
<span class="k">def</span> <span class="nf">_dict_representer</span><span class="p">(</span><span class="n">dumper</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="n">dumper</span><span class="o">.</span><span class="n">represent_dict</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> | ||
|
||
|
||
<span class="k">def</span> <span class="nf">_dict_constructor</span><span class="p">(</span><span class="n">loader</span><span class="p">,</span> <span class="n">node</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="n">OrderedDict</span><span class="p">(</span><span class="n">loader</span><span class="o">.</span><span class="n">construct_pairs</span><span class="p">(</span><span class="n">node</span><span class="p">))</span> | ||
|
||
|
||
<span class="c1"># yaml.add_representer(OrderedDict, _dict_representer)</span> | ||
<span class="c1"># yaml.add_constructor(_mapping_tag, _dict_constructor)</span> | ||
|
||
|
||
<span class="k">def</span> <span class="nf">write_yaml</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fn</span><span class="p">):</span> | ||
<span class="n">yaml</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">open</span><span class="p">(</span><span class="n">fn</span><span class="p">,</span> <span class="s1">'w'</span><span class="p">),</span> <span class="n">default_flow_style</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">200</span><span class="p">)</span> | ||
|
||
|
||
<span class="k">def</span> <span class="nf">read_yaml</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="n">yaml</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">'r'</span><span class="p">),</span> <span class="n">Loader</span><span class="o">=</span><span class="n">yaml</span><span class="o">.</span><span class="n">FullLoader</span><span class="p">)</span> | ||
</pre></div> | ||
|
||
<div class="clearer"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="sphinxsidebar" role="navigation" aria-label="Main"> | ||
<div class="sphinxsidebarwrapper"> | ||
<search id="searchbox" style="display: none" role="search"> | ||
<h3 id="searchlabel">Quick search</h3> | ||
<div class="searchformwrapper"> | ||
<form class="search" action="../../search.html" method="get"> | ||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> | ||
<input type="submit" value="Go" /> | ||
</form> | ||
</div> | ||
</search> | ||
<script>document.getElementById('searchbox').style.display = "block"</script> | ||
</div> | ||
</div> | ||
<div class="clearer"></div> | ||
</div> | ||
<div class="related" role="navigation" aria-label="Related"> | ||
<h3>Navigation</h3> | ||
<ul> | ||
<li class="right" style="margin-right: 10px"> | ||
<a href="../../genindex.html" title="General Index" | ||
>index</a></li> | ||
<li class="right" > | ||
<a href="../../py-modindex.html" title="Python Module Index" | ||
>modules</a> |</li> | ||
<li class="nav-item nav-item-0"><a href="../../index.html">Intensity Duration Frequency Analyse 0.3.0 documentation</a> »</li> | ||
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> »</li> | ||
<li class="nav-item nav-item-this"><a href="">idf_analysis.in_out</a></li> | ||
</ul> | ||
</div> | ||
<div class="footer" role="contentinfo"> | ||
© Copyright 2024, Pichler. | ||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3. | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.