ipfml.utils.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>ipfml.utils &mdash; IPFML v0.3.5 documentation</title>
  8. <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  9. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  10. <link rel="index" title="Index" href="../genindex.html" />
  11. <link rel="search" title="Search" href="../search.html" />
  12. <link rel="next" title="ipfml.exceptions" href="ipfml.exceptions.html" />
  13. <link rel="prev" title="ipfml.processing" href="ipfml.processing.html" />
  14. <script src="../_static/js/modernizr.min.js"></script>
  15. </head>
  16. <body class="wy-body-for-nav">
  17. <div class="wy-grid-for-nav">
  18. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  19. <div class="wy-side-scroll">
  20. <div class="wy-side-nav-search">
  21. <a href="../index.html" class="icon icon-home"> IPFML
  22. </a>
  23. <div class="version">
  24. 0.3.5
  25. </div>
  26. <div role="search">
  27. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  28. <input type="text" name="q" placeholder="Search docs" />
  29. <input type="hidden" name="check_keywords" value="yes" />
  30. <input type="hidden" name="area" value="default" />
  31. </form>
  32. </div>
  33. </div>
  34. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  35. <p class="caption"><span class="caption-text">Contents:</span></p>
  36. <ul class="current">
  37. <li class="toctree-l1"><a class="reference internal" href="../description.html">Description</a></li>
  38. <li class="toctree-l1 current"><a class="reference internal" href="../ipfml.html">Documentation</a><ul class="current">
  39. <li class="toctree-l2"><a class="reference internal" href="ipfml.metrics.html">ipfml.metrics</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="ipfml.processing.html">ipfml.processing</a></li>
  41. <li class="toctree-l2 current"><a class="current reference internal" href="#">ipfml.utils</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="ipfml.exceptions.html">ipfml.exceptions</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-filters">ipfml.filters</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="../ipfml.html#ipfml-iqa">ipfml.iqa</a></li>
  45. </ul>
  46. </li>
  47. <li class="toctree-l1"><a class="reference internal" href="../examples.html">Examples</a></li>
  48. <li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributing</a></li>
  49. </ul>
  50. </div>
  51. </div>
  52. </nav>
  53. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  54. <nav class="wy-nav-top" aria-label="top navigation">
  55. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  56. <a href="../index.html">IPFML</a>
  57. </nav>
  58. <div class="wy-nav-content">
  59. <div class="rst-content">
  60. <div role="navigation" aria-label="breadcrumbs navigation">
  61. <ul class="wy-breadcrumbs">
  62. <li><a href="../index.html">Docs</a> &raquo;</li>
  63. <li><a href="../ipfml.html">Documentation</a> &raquo;</li>
  64. <li>ipfml.utils</li>
  65. <li class="wy-breadcrumbs-aside">
  66. <a href="https://github.com/jbuisine/IPFML/blob/master/docs/source/ipfml/ipfml.utils.rst" class="fa fa-github"> Edit on GitHub</a>
  67. </li>
  68. </ul>
  69. <hr/>
  70. </div>
  71. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  72. <div itemprop="articleBody">
  73. <div class="section" id="module-ipfml.utils">
  74. <span id="ipfml-utils"></span><h1>ipfml.utils<a class="headerlink" href="#module-ipfml.utils" title="Permalink to this headline">¶</a></h1>
  75. <p>Utils functions of ipfml package (array normalization)</p>
  76. <p class="rubric">Functions</p>
  77. <table border="1" class="longtable docutils">
  78. <colgroup>
  79. <col width="10%" />
  80. <col width="90%" />
  81. </colgroup>
  82. <tbody valign="top">
  83. <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_highest_values" title="ipfml.utils.get_indices_of_highest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_highest_values</span></code></a>(arr,&nbsp;n)</td>
  84. <td>Returns indices of n highest values from list or 1D numpy array</td>
  85. </tr>
  86. <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.get_indices_of_lowest_values" title="ipfml.utils.get_indices_of_lowest_values"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_indices_of_lowest_values</span></code></a>(arr,&nbsp;n)</td>
  87. <td>Returns indices of n highest values from list or 1D numpy array</td>
  88. </tr>
  89. <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.integral_area_simps" title="ipfml.utils.integral_area_simps"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_simps</span></code></a>(y_values,&nbsp;dx)</td>
  90. <td>Returns area under curves from provided data points using Simpsons rule</td>
  91. </tr>
  92. <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.integral_area_trapz" title="ipfml.utils.integral_area_trapz"><code class="xref py py-obj docutils literal notranslate"><span class="pre">integral_area_trapz</span></code></a>(y_values,&nbsp;dx)</td>
  93. <td>Returns area under curves from provided data points using Trapezium rule</td>
  94. </tr>
  95. <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.normalize_2D_arr" title="ipfml.utils.normalize_2D_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_2D_arr</span></code></a>(arr)</td>
  96. <td>Return array normalize from its min and max values</td>
  97. </tr>
  98. <tr class="row-even"><td><a class="reference internal" href="#ipfml.utils.normalize_arr" title="ipfml.utils.normalize_arr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr</span></code></a>(arr)</td>
  99. <td>Normalize data of 1D array shape</td>
  100. </tr>
  101. <tr class="row-odd"><td><a class="reference internal" href="#ipfml.utils.normalize_arr_with_range" title="ipfml.utils.normalize_arr_with_range"><code class="xref py py-obj docutils literal notranslate"><span class="pre">normalize_arr_with_range</span></code></a>(arr,&nbsp;min,&nbsp;max)</td>
  102. <td>Normalize data of 1D array shape</td>
  103. </tr>
  104. </tbody>
  105. </table>
  106. <dl class="function">
  107. <dt id="ipfml.utils.get_indices_of_highest_values">
  108. <code class="descclassname">ipfml.utils.</code><code class="descname">get_indices_of_highest_values</code><span class="sig-paren">(</span><em>arr</em>, <em>n</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_indices_of_highest_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_indices_of_highest_values" title="Permalink to this definition">¶</a></dt>
  109. <dd><p>Returns indices of n highest values from list or 1D numpy array</p>
  110. <table class="docutils field-list" frame="void" rules="none">
  111. <col class="field-name" />
  112. <col class="field-body" />
  113. <tbody valign="top">
  114. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  115. <li><strong>arr</strong> – List of numpy array</li>
  116. <li><strong>n</strong> – number of highest elements wanted</li>
  117. </ul>
  118. </td>
  119. </tr>
  120. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><cite>n</cite> indices of highest values</p>
  121. </td>
  122. </tr>
  123. </tbody>
  124. </table>
  125. <p>Example:</p>
  126. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  127. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  128. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  129. <span class="gp">&gt;&gt;&gt; </span><span class="n">indices</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_indices_of_highest_values</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
  130. <span class="gp">&gt;&gt;&gt; </span><span class="n">indices</span>
  131. <span class="go">array([9, 8])</span>
  132. </pre></div>
  133. </div>
  134. </dd></dl>
  135. <dl class="function">
  136. <dt id="ipfml.utils.get_indices_of_lowest_values">
  137. <code class="descclassname">ipfml.utils.</code><code class="descname">get_indices_of_lowest_values</code><span class="sig-paren">(</span><em>arr</em>, <em>n</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#get_indices_of_lowest_values"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.get_indices_of_lowest_values" title="Permalink to this definition">¶</a></dt>
  138. <dd><p>Returns indices of n highest values from list or 1D numpy array</p>
  139. <table class="docutils field-list" frame="void" rules="none">
  140. <col class="field-name" />
  141. <col class="field-body" />
  142. <tbody valign="top">
  143. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  144. <li><strong>arr</strong> – List of numpy array</li>
  145. <li><strong>n</strong> – number of highest elements wanted</li>
  146. </ul>
  147. </td>
  148. </tr>
  149. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><cite>n</cite> indices of highest values</p>
  150. </td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. <p>Example:</p>
  155. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  156. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  157. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
  158. <span class="gp">&gt;&gt;&gt; </span><span class="n">indices</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_indices_of_lowest_values</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
  159. <span class="gp">&gt;&gt;&gt; </span><span class="n">indices</span>
  160. <span class="go">array([0, 1])</span>
  161. </pre></div>
  162. </div>
  163. </dd></dl>
  164. <dl class="function">
  165. <dt id="ipfml.utils.integral_area_simps">
  166. <code class="descclassname">ipfml.utils.</code><code class="descname">integral_area_simps</code><span class="sig-paren">(</span><em>y_values</em>, <em>dx</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#integral_area_simps"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.integral_area_simps" title="Permalink to this definition">¶</a></dt>
  167. <dd><p>Returns area under curves from provided data points using Simpsons rule</p>
  168. <table class="docutils field-list" frame="void" rules="none">
  169. <col class="field-name" />
  170. <col class="field-body" />
  171. <tbody valign="top">
  172. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  173. <li><strong>y_values</strong> – y values of curve</li>
  174. <li><strong>dx</strong> – number of unit for x axis</li>
  175. </ul>
  176. </td>
  177. </tr>
  178. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Area under curves obtained from these points</p>
  179. </td>
  180. </tr>
  181. </tbody>
  182. </table>
  183. <p>Example:</p>
  184. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  185. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  186. <span class="gp">&gt;&gt;&gt; </span><span class="n">y_values</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="mi">5</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
  187. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">integral_area_simps</span><span class="p">(</span><span class="n">y_values</span><span class="p">,</span> <span class="n">dx</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  188. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span>
  189. <span class="go">460.0</span>
  190. </pre></div>
  191. </div>
  192. </dd></dl>
  193. <dl class="function">
  194. <dt id="ipfml.utils.integral_area_trapz">
  195. <code class="descclassname">ipfml.utils.</code><code class="descname">integral_area_trapz</code><span class="sig-paren">(</span><em>y_values</em>, <em>dx</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#integral_area_trapz"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.integral_area_trapz" title="Permalink to this definition">¶</a></dt>
  196. <dd><p>Returns area under curves from provided data points using Trapezium rule</p>
  197. <table class="docutils field-list" frame="void" rules="none">
  198. <col class="field-name" />
  199. <col class="field-body" />
  200. <tbody valign="top">
  201. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  202. <li><strong>y_values</strong> – y values of curve</li>
  203. <li><strong>dx</strong> – number of unit for x axis</li>
  204. </ul>
  205. </td>
  206. </tr>
  207. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Area under curves obtained from these points</p>
  208. </td>
  209. </tr>
  210. </tbody>
  211. </table>
  212. <p>Example:</p>
  213. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  214. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  215. <span class="gp">&gt;&gt;&gt; </span><span class="n">y_values</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="mi">5</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
  216. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">integral_area_trapz</span><span class="p">(</span><span class="n">y_values</span><span class="p">,</span> <span class="n">dx</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
  217. <span class="gp">&gt;&gt;&gt; </span><span class="n">area</span>
  218. <span class="go">452.5</span>
  219. </pre></div>
  220. </div>
  221. </dd></dl>
  222. <dl class="function">
  223. <dt id="ipfml.utils.normalize_2D_arr">
  224. <code class="descclassname">ipfml.utils.</code><code class="descname">normalize_2D_arr</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#normalize_2D_arr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.normalize_2D_arr" title="Permalink to this definition">¶</a></dt>
  225. <dd><p>Return array normalize from its min and max values</p>
  226. <table class="docutils field-list" frame="void" rules="none">
  227. <col class="field-name" />
  228. <col class="field-body" />
  229. <tbody valign="top">
  230. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – 2D Numpy array</td>
  231. </tr>
  232. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 2D Numpy array</td>
  233. </tr>
  234. </tbody>
  235. </table>
  236. <p>Example:</p>
  237. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">PIL</span> <span class="k">import</span> <span class="n">Image</span>
  238. <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span><span class="p">,</span> <span class="n">processing</span>
  239. <span class="gp">&gt;&gt;&gt; </span><span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;./images/test_img.png&#39;</span><span class="p">)</span>
  240. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_mscn</span> <span class="o">=</span> <span class="n">processing</span><span class="o">.</span><span class="n">rgb_to_mscn</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
  241. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_2D_arr</span><span class="p">(</span><span class="n">img_mscn</span><span class="p">)</span>
  242. <span class="gp">&gt;&gt;&gt; </span><span class="n">img_normalized</span><span class="o">.</span><span class="n">shape</span>
  243. <span class="go">(200, 200)</span>
  244. </pre></div>
  245. </div>
  246. </dd></dl>
  247. <dl class="function">
  248. <dt id="ipfml.utils.normalize_arr">
  249. <code class="descclassname">ipfml.utils.</code><code class="descname">normalize_arr</code><span class="sig-paren">(</span><em>arr</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#normalize_arr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.normalize_arr" title="Permalink to this definition">¶</a></dt>
  250. <dd><p>Normalize data of 1D array shape</p>
  251. <table class="docutils field-list" frame="void" rules="none">
  252. <col class="field-name" />
  253. <col class="field-body" />
  254. <tbody valign="top">
  255. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  256. </tr>
  257. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D array</td>
  258. </tr>
  259. </tbody>
  260. </table>
  261. <p>Example:</p>
  262. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  263. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  264. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span>
  265. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_arr</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span>
  266. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  267. <span class="go">0.1</span>
  268. </pre></div>
  269. </div>
  270. </dd></dl>
  271. <dl class="function">
  272. <dt id="ipfml.utils.normalize_arr_with_range">
  273. <code class="descclassname">ipfml.utils.</code><code class="descname">normalize_arr_with_range</code><span class="sig-paren">(</span><em>arr</em>, <em>min</em>, <em>max</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/ipfml/utils.html#normalize_arr_with_range"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ipfml.utils.normalize_arr_with_range" title="Permalink to this definition">¶</a></dt>
  274. <dd><p>Normalize data of 1D array shape</p>
  275. <table class="docutils field-list" frame="void" rules="none">
  276. <col class="field-name" />
  277. <col class="field-body" />
  278. <tbody valign="top">
  279. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arr</strong> – array data of 1D shape</td>
  280. </tr>
  281. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized 1D Numpy array</td>
  282. </tr>
  283. </tbody>
  284. </table>
  285. <p>Example:</p>
  286. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">ipfml</span> <span class="k">import</span> <span class="n">utils</span>
  287. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
  288. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span>
  289. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">normalize_arr_with_range</span><span class="p">(</span><span class="n">arr</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
  290. <span class="gp">&gt;&gt;&gt; </span><span class="n">arr_normalized</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
  291. <span class="go">0.05</span>
  292. </pre></div>
  293. </div>
  294. </dd></dl>
  295. </div>
  296. </div>
  297. </div>
  298. <footer>
  299. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  300. <a href="ipfml.exceptions.html" class="btn btn-neutral float-right" title="ipfml.exceptions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
  301. <a href="ipfml.processing.html" class="btn btn-neutral" title="ipfml.processing" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
  302. </div>
  303. <hr/>
  304. <div role="contentinfo">
  305. <p>
  306. &copy; Copyright 2019, Jérôme BUISINE
  307. </p>
  308. </div>
  309. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  310. </footer>
  311. </div>
  312. </div>
  313. </section>
  314. </div>
  315. <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
  316. <script type="text/javascript" src="../_static/jquery.js"></script>
  317. <script type="text/javascript" src="../_static/underscore.js"></script>
  318. <script type="text/javascript" src="../_static/doctools.js"></script>
  319. <script type="text/javascript" src="../_static/language_data.js"></script>
  320. <script type="text/javascript" src="../_static/js/theme.js"></script>
  321. <script type="text/javascript">
  322. jQuery(function () {
  323. SphinxRtdTheme.Navigation.enable(true);
  324. });
  325. </script>
  326. </body>
  327. </html>