This commit is contained in:
srcarter3 2020-09-09 20:02:35 +00:00
commit 389ed9229e
218 changed files with 53681 additions and 0 deletions

4
.buildinfo Normal file
View file

@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: e55bc64e0067ab6e7273e407b0228137
tags: 645f666f9bcd5a90fca523b33c5a78b7

0
.nojekyll Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View file

@ -0,0 +1,295 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.DateTimeConverter &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>awips.DateTimeConverter</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.DateTimeConverter</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Functions for converting between the various &quot;Java&quot; dynamic serialize types</span>
<span class="c1"># used by EDEX to the native python time datetime.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 06/24/15 #4480 dgilling Initial Creation.</span>
<span class="c1">#</span>
<span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.java.util</span> <span class="kn">import</span> <span class="n">Date</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.java.sql</span> <span class="kn">import</span> <span class="n">Timestamp</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.time</span> <span class="kn">import</span> <span class="n">TimeRange</span>
<span class="n">MAX_TIME</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">31</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span>
<span class="n">MICROS_IN_SECOND</span> <span class="o">=</span> <span class="mi">1000000</span>
<div class="viewcode-block" id="convertToDateTime"><a class="viewcode-back" href="../../api/DateTimeConverter.html#awips.DateTimeConverter.convertToDateTime">[docs]</a><span class="k">def</span> <span class="nf">convertToDateTime</span><span class="p">(</span><span class="n">timeArg</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Converts the given object to a python datetime object. Supports native</span>
<span class="sd"> python representations like datetime and struct_time, but also</span>
<span class="sd"> the dynamicserialize types like Date and Timestamp. Raises TypeError</span>
<span class="sd"> if no conversion can be performed.</span>
<span class="sd"> Args:</span>
<span class="sd"> timeArg: a python object representing a date and time. Supported</span>
<span class="sd"> types include datetime, struct_time, float, int, long and the</span>
<span class="sd"> dynamicserialize types Date and Timestamp.</span>
<span class="sd"> Returns:</span>
<span class="sd"> A datetime that represents the same date/time as the passed in object.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">timeArg</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span>
<span class="k">return</span> <span class="n">timeArg</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">timeArg</span><span class="p">,</span> <span class="n">time</span><span class="o">.</span><span class="n">struct_time</span><span class="p">):</span>
<span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="o">*</span><span class="n">timeArg</span><span class="p">[:</span><span class="mi">6</span><span class="p">])</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">timeArg</span><span class="p">,</span> <span class="nb">float</span><span class="p">):</span>
<span class="c1"># seconds as float, should be avoided due to floating point errors</span>
<span class="n">totalSecs</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">timeArg</span><span class="p">)</span>
<span class="n">micros</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">timeArg</span> <span class="o">-</span> <span class="n">totalSecs</span><span class="p">)</span> <span class="o">*</span> <span class="n">MICROS_IN_SECOND</span><span class="p">)</span>
<span class="k">return</span> <span class="n">_convertSecsAndMicros</span><span class="p">(</span><span class="n">totalSecs</span><span class="p">,</span> <span class="n">micros</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">timeArg</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
<span class="c1"># seconds as integer</span>
<span class="n">totalSecs</span> <span class="o">=</span> <span class="n">timeArg</span>
<span class="k">return</span> <span class="n">_convertSecsAndMicros</span><span class="p">(</span><span class="n">totalSecs</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">timeArg</span><span class="p">,</span> <span class="p">(</span><span class="n">Date</span><span class="p">,</span> <span class="n">Timestamp</span><span class="p">)):</span>
<span class="n">totalSecs</span> <span class="o">=</span> <span class="n">timeArg</span><span class="o">.</span><span class="n">getTime</span><span class="p">()</span>
<span class="k">return</span> <span class="n">_convertSecsAndMicros</span><span class="p">(</span><span class="n">totalSecs</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">objType</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">timeArg</span><span class="p">))</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Cannot convert object of type &quot;</span> <span class="o">+</span> <span class="n">objType</span> <span class="o">+</span> <span class="s2">&quot; to datetime.&quot;</span><span class="p">)</span></div>
<span class="k">def</span> <span class="nf">_convertSecsAndMicros</span><span class="p">(</span><span class="n">seconds</span><span class="p">,</span> <span class="n">micros</span><span class="p">):</span>
<span class="k">if</span> <span class="n">seconds</span> <span class="o">&lt;</span> <span class="n">MAX_TIME</span><span class="p">:</span>
<span class="n">rval</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcfromtimestamp</span><span class="p">(</span><span class="n">seconds</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">extraTime</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="p">(</span><span class="n">seconds</span> <span class="o">-</span> <span class="n">MAX_TIME</span><span class="p">))</span>
<span class="n">rval</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcfromtimestamp</span><span class="p">(</span><span class="n">MAX_TIME</span><span class="p">)</span> <span class="o">+</span> <span class="n">extraTime</span>
<span class="k">return</span> <span class="n">rval</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">microsecond</span><span class="o">=</span><span class="n">micros</span><span class="p">)</span>
<div class="viewcode-block" id="constructTimeRange"><a class="viewcode-back" href="../../api/DateTimeConverter.html#awips.DateTimeConverter.constructTimeRange">[docs]</a><span class="k">def</span> <span class="nf">constructTimeRange</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Builds a python dynamicserialize TimeRange object from the given</span>
<span class="sd"> arguments.</span>
<span class="sd"> Args:</span>
<span class="sd"> args*: must be a TimeRange or a pair of objects that can be</span>
<span class="sd"> converted to a datetime via convertToDateTime().</span>
<span class="sd"> Returns:</span>
<span class="sd"> A TimeRange.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">TimeRange</span><span class="p">):</span>
<span class="k">return</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">2</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;constructTimeRange takes exactly 2 arguments, &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">))</span> <span class="o">+</span> <span class="s2">&quot; provided.&quot;</span><span class="p">)</span>
<span class="n">startTime</span> <span class="o">=</span> <span class="n">convertToDateTime</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">endTime</span> <span class="o">=</span> <span class="n">convertToDateTime</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="k">return</span> <span class="n">TimeRange</span><span class="p">(</span><span class="n">startTime</span><span class="p">,</span> <span class="n">endTime</span><span class="p">)</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,348 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.RadarCommon &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>awips.RadarCommon</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.RadarCommon</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Common methods for the a2gtrad and a2advrad scripts.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 08/13/2014 3393 nabowle Initial creation to contain common</span>
<span class="c1"># code for a2*radStub scripts.</span>
<span class="c1"># 03/15/2015 mjames@ucar Edited/added to awips package as RadarCommon</span>
<span class="c1">#</span>
<span class="c1">#</span>
<div class="viewcode-block" id="get_datetime_str"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.get_datetime_str">[docs]</a><span class="k">def</span> <span class="nf">get_datetime_str</span><span class="p">(</span><span class="n">record</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get the datetime string for a record.</span>
<span class="sd"> Args:</span>
<span class="sd"> record: the record to get data for.</span>
<span class="sd"> Returns:</span>
<span class="sd"> datetime string.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getDataTime</span><span class="p">())[</span><span class="mi">0</span><span class="p">:</span><span class="mi">19</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="s2">&quot;_&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;.0&quot;</span></div>
<div class="viewcode-block" id="get_data_type"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.get_data_type">[docs]</a><span class="k">def</span> <span class="nf">get_data_type</span><span class="p">(</span><span class="n">azdat</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get the radar file type (radial or raster).</span>
<span class="sd"> Args:</span>
<span class="sd"> azdat: Boolean.</span>
<span class="sd"> Returns:</span>
<span class="sd"> Radial or raster.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">azdat</span><span class="p">:</span>
<span class="k">return</span> <span class="s2">&quot;radial&quot;</span>
<span class="k">return</span> <span class="s2">&quot;raster&quot;</span></div>
<div class="viewcode-block" id="get_hdf5_data"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.get_hdf5_data">[docs]</a><span class="k">def</span> <span class="nf">get_hdf5_data</span><span class="p">(</span><span class="n">idra</span><span class="p">):</span>
<span class="n">rdat</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">azdat</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">depVals</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">threshVals</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">idra</span><span class="p">:</span>
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">idra</span><span class="p">:</span>
<span class="k">if</span> <span class="n">item</span><span class="o">.</span><span class="n">getName</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;Data&quot;</span><span class="p">:</span>
<span class="n">rdat</span> <span class="o">=</span> <span class="n">item</span>
<span class="k">elif</span> <span class="n">item</span><span class="o">.</span><span class="n">getName</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;Angles&quot;</span><span class="p">:</span>
<span class="n">azdat</span> <span class="o">=</span> <span class="n">item</span>
<span class="c1"># dattyp = &quot;radial&quot;</span>
<span class="k">elif</span> <span class="n">item</span><span class="o">.</span><span class="n">getName</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;DependentValues&quot;</span><span class="p">:</span>
<span class="n">depVals</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getShortData</span><span class="p">()</span>
<span class="k">elif</span> <span class="n">item</span><span class="o">.</span><span class="n">getName</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;Thresholds&quot;</span><span class="p">:</span>
<span class="n">threshVals</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">getShortData</span><span class="p">()</span>
<span class="k">return</span> <span class="n">rdat</span><span class="p">,</span> <span class="n">azdat</span><span class="p">,</span> <span class="n">depVals</span><span class="p">,</span> <span class="n">threshVals</span></div>
<div class="viewcode-block" id="get_header"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.get_header">[docs]</a><span class="k">def</span> <span class="nf">get_header</span><span class="p">(</span><span class="n">record</span><span class="p">,</span> <span class="n">headerFormat</span><span class="p">,</span> <span class="n">xLen</span><span class="p">,</span> <span class="n">yLen</span><span class="p">,</span> <span class="n">azdat</span><span class="p">,</span> <span class="n">description</span><span class="p">):</span>
<span class="c1"># Encode dimensions, time, mapping, description, tilt, and VCP</span>
<span class="n">mytime</span> <span class="o">=</span> <span class="n">get_datetime_str</span><span class="p">(</span><span class="n">record</span><span class="p">)</span>
<span class="n">dattyp</span> <span class="o">=</span> <span class="n">get_data_type</span><span class="p">(</span><span class="n">azdat</span><span class="p">)</span>
<span class="k">if</span> <span class="n">headerFormat</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">xLen</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">yLen</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">mytime</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="n">dattyp</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getLatitude</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getLongitude</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getElevation</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getElevationNumber</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="n">description</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getTrueElevationAngle</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getVolumeCoveragePattern</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">xLen</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">yLen</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">mytime</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="n">dattyp</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">description</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getTrueElevationAngle</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> \
<span class="nb">str</span><span class="p">(</span><span class="n">record</span><span class="o">.</span><span class="n">getVolumeCoveragePattern</span><span class="p">())</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="n">msg</span></div>
<div class="viewcode-block" id="encode_thresh_vals"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.encode_thresh_vals">[docs]</a><span class="k">def</span> <span class="nf">encode_thresh_vals</span><span class="p">(</span><span class="n">threshVals</span><span class="p">):</span>
<span class="n">spec</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;.&quot;</span><span class="p">,</span> <span class="s2">&quot;TH&quot;</span><span class="p">,</span> <span class="s2">&quot;ND&quot;</span><span class="p">,</span> <span class="s2">&quot;RF&quot;</span><span class="p">,</span> <span class="s2">&quot;BI&quot;</span><span class="p">,</span> <span class="s2">&quot;GC&quot;</span><span class="p">,</span> <span class="s2">&quot;IC&quot;</span><span class="p">,</span> <span class="s2">&quot;GR&quot;</span><span class="p">,</span> <span class="s2">&quot;WS&quot;</span><span class="p">,</span> <span class="s2">&quot;DS&quot;</span><span class="p">,</span>
<span class="s2">&quot;RA&quot;</span><span class="p">,</span> <span class="s2">&quot;HR&quot;</span><span class="p">,</span> <span class="s2">&quot;BD&quot;</span><span class="p">,</span> <span class="s2">&quot;HA&quot;</span><span class="p">,</span> <span class="s2">&quot;UK&quot;</span><span class="p">]</span>
<span class="n">nnn</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">threshVals</span><span class="p">)</span>
<span class="n">j</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="k">while</span> <span class="n">j</span> <span class="o">&lt;</span> <span class="n">nnn</span><span class="p">:</span>
<span class="n">lo</span> <span class="o">=</span> <span class="n">threshVals</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">%</span> <span class="mi">256</span>
<span class="n">hi</span> <span class="o">=</span> <span class="n">threshVals</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">/</span> <span class="mi">256</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot; &quot;</span>
<span class="n">j</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">if</span> <span class="n">hi</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">if</span> <span class="n">lo</span> <span class="o">&gt;</span> <span class="mi">14</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;.&quot;</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="n">spec</span><span class="p">[</span><span class="n">lo</span><span class="p">]</span>
<span class="k">continue</span>
<span class="k">if</span> <span class="n">hi</span> <span class="o">%</span> <span class="mi">16</span> <span class="o">&gt;=</span> <span class="mi">8</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;&gt;&quot;</span>
<span class="k">elif</span> <span class="n">hi</span> <span class="o">%</span> <span class="mi">8</span> <span class="o">&gt;=</span> <span class="mi">4</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;&lt;&quot;</span>
<span class="k">if</span> <span class="n">hi</span> <span class="o">%</span> <span class="mi">4</span> <span class="o">&gt;=</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;+&quot;</span>
<span class="k">elif</span> <span class="n">hi</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;-&quot;</span>
<span class="k">if</span> <span class="n">hi</span> <span class="o">&gt;=</span> <span class="mi">64</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="si">%.2f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">lo</span><span class="o">*</span><span class="mf">0.01</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">hi</span> <span class="o">%</span> <span class="mi">64</span> <span class="o">&gt;=</span> <span class="mi">32</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="si">%.2f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">lo</span><span class="o">*</span><span class="mf">0.05</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">hi</span> <span class="o">%</span> <span class="mi">32</span> <span class="o">&gt;=</span> <span class="mi">16</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="si">%.1f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">lo</span><span class="o">*</span><span class="mf">0.1</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="n">lo</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="k">return</span> <span class="n">msg</span></div>
<div class="viewcode-block" id="encode_dep_vals"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.encode_dep_vals">[docs]</a><span class="k">def</span> <span class="nf">encode_dep_vals</span><span class="p">(</span><span class="n">depVals</span><span class="p">):</span>
<span class="n">nnn</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">depVals</span><span class="p">)</span>
<span class="n">j</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">while</span> <span class="n">j</span> <span class="o">&lt;</span> <span class="n">nnn</span><span class="p">:</span>
<span class="n">msg</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">depVals</span><span class="p">[</span><span class="n">j</span><span class="p">]))</span>
<span class="n">j</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">return</span> <span class="n">msg</span></div>
<div class="viewcode-block" id="encode_radial"><a class="viewcode-back" href="../../api/RadarCommon.html#awips.RadarCommon.encode_radial">[docs]</a><span class="k">def</span> <span class="nf">encode_radial</span><span class="p">(</span><span class="n">azVals</span><span class="p">):</span>
<span class="n">azValsLen</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">azVals</span><span class="p">)</span>
<span class="n">j</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">while</span> <span class="n">j</span> <span class="o">&lt;</span> <span class="n">azValsLen</span><span class="p">:</span>
<span class="n">msg</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">azVals</span><span class="p">[</span><span class="n">j</span><span class="p">])</span>
<span class="n">j</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">return</span> <span class="n">msg</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,287 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.ThriftClient &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>awips.ThriftClient</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.ThriftClient</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Provides a Python-based interface for executing Thrift requests.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 09/20/10 dgilling Initial Creation.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="k">try</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">http.client</span> <span class="k">as</span> <span class="nn">httpcl</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">httplib</span> <span class="k">as</span> <span class="nn">httpcl</span>
<span class="kn">from</span> <span class="nn">dynamicserialize</span> <span class="kn">import</span> <span class="n">DynamicSerializationManager</span>
<div class="viewcode-block" id="ThriftClient"><a class="viewcode-back" href="../../api/ThriftClient.html#awips.ThriftClient.ThriftClient">[docs]</a><span class="k">class</span> <span class="nc">ThriftClient</span><span class="p">:</span>
<span class="c1"># How to call this constructor:</span>
<span class="c1"># 1. Pass in all arguments separately (e.g.,</span>
<span class="c1"># ThriftClient.ThriftClient(&quot;localhost&quot;, 9581, &quot;/services&quot;))</span>
<span class="c1"># will return a Thrift client pointed at http://localhost:9581/services.</span>
<span class="c1"># 2. Pass in all arguments through the host string (e.g.,</span>
<span class="c1"># ThriftClient.ThriftClient(&quot;localhost:9581/services&quot;))</span>
<span class="c1"># will return a Thrift client pointed at http://localhost:9581/services.</span>
<span class="c1"># 3. Pass in host/port arguments through the host string (e.g.,</span>
<span class="c1"># ThriftClient.ThriftClient(&quot;localhost:9581&quot;, &quot;/services&quot;))</span>
<span class="c1"># will return a Thrift client pointed at http://localhost:9581/services.</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">9581</span><span class="p">,</span> <span class="n">uri</span><span class="o">=</span><span class="s2">&quot;/services&quot;</span><span class="p">):</span>
<span class="n">hostParts</span> <span class="o">=</span> <span class="n">host</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;/&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">hostParts</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">hostString</span> <span class="o">=</span> <span class="n">hostParts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__uri</span> <span class="o">=</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="n">hostParts</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span> <span class="o">=</span> <span class="n">httpcl</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">hostString</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">port</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span> <span class="o">=</span> <span class="n">httpcl</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span> <span class="o">=</span> <span class="n">httpcl</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__uri</span> <span class="o">=</span> <span class="n">uri</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__dsm</span> <span class="o">=</span> <span class="n">DynamicSerializationManager</span><span class="o">.</span><span class="n">DynamicSerializationManager</span><span class="p">()</span>
<div class="viewcode-block" id="ThriftClient.sendRequest"><a class="viewcode-back" href="../../api/ThriftClient.html#awips.ThriftClient.ThriftClient.sendRequest">[docs]</a> <span class="k">def</span> <span class="nf">sendRequest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">uri</span><span class="o">=</span><span class="s2">&quot;/thrift&quot;</span><span class="p">):</span>
<span class="n">message</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dsm</span><span class="o">.</span><span class="n">serializeObject</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s2">&quot;POST&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__uri</span> <span class="o">+</span> <span class="n">uri</span><span class="p">,</span> <span class="n">message</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span>
<span class="k">if</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o">!=</span> <span class="mi">200</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">ThriftRequestException</span><span class="p">(</span><span class="s2">&quot;Unable to post request to server&quot;</span><span class="p">)</span>
<span class="n">rval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dsm</span><span class="o">.</span><span class="n">deserializeBytes</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__httpConn</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="c1"># let&#39;s verify we have an instance of ServerErrorResponse</span>
<span class="c1"># IF we do, through an exception up to the caller along</span>
<span class="c1"># with the original Java stack trace</span>
<span class="c1"># ELSE: we have a valid response and pass it back</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">forceError</span> <span class="o">=</span> <span class="n">rval</span><span class="o">.</span><span class="n">getException</span><span class="p">()</span>
<span class="k">raise</span> <span class="n">ThriftRequestException</span><span class="p">(</span><span class="n">forceError</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="k">return</span> <span class="n">rval</span></div></div>
<div class="viewcode-block" id="ThriftRequestException"><a class="viewcode-back" href="../../api/ThriftClient.html#awips.ThriftClient.ThriftRequestException">[docs]</a><span class="k">class</span> <span class="nc">ThriftRequestException</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parameter</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">parameter</span><span class="p">)</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,294 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.TimeUtil &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>awips.TimeUtil</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.TimeUtil</h1><div class="highlight"><pre>
<span></span><span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># This software is in the public domain, furnished &quot;as is&quot;, without technical</span>
<span class="c1"># support, and with no warranty, express or implied, as to its usefulness for</span>
<span class="c1"># any purpose.</span>
<span class="c1">#</span>
<span class="c1"># offsetTime.py</span>
<span class="c1"># Handles Displaced Real Time for various applications</span>
<span class="c1">#</span>
<span class="c1"># Author: hansen/romberg</span>
<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="kn">import</span> <span class="nn">string</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="c1"># Given the timeStr, return the offset (in seconds)</span>
<span class="c1"># from the current time.</span>
<span class="c1"># Also return the launchStr i.e. Programs launched from this</span>
<span class="c1"># offset application will use the launchStr as the -z argument.</span>
<span class="c1"># The offset will be positive for time in the future,</span>
<span class="c1"># negative for time in the past.</span>
<span class="c1">#</span>
<span class="c1"># May still want it to be normalized to the most recent midnight.</span>
<span class="c1">#</span>
<span class="c1"># NOTES about synchronizing:</span>
<span class="c1"># --With synchronizing on, the &quot;current time&quot; for all processes started</span>
<span class="c1"># within a given hour will be the same.</span>
<span class="c1"># This guarantees that GFE&#39;s have the same current time and ISC grid</span>
<span class="c1"># time stamps are syncrhonized and can be exchanged.</span>
<span class="c1"># Formatters launched from the GFE in this mode will be synchronized as</span>
<span class="c1"># well by setting the launchStr to use the time difference format</span>
<span class="c1"># (YYYYMMDD_HHMM,YYYYMMDD_HHMM).</span>
<span class="c1"># --This does not solve the problem in the general case.</span>
<span class="c1"># For example, if someone starts the GFE at 12:59 and someone</span>
<span class="c1"># else starts it at 1:01, they will have different offsets and</span>
<span class="c1"># current times.</span>
<span class="c1"># --With synchronizing off, when the process starts, the current time</span>
<span class="c1"># matches the drtTime in the command line. However, with synchronizing</span>
<span class="c1"># on, the current time will be offset by the fraction of the hour at</span>
<span class="c1"># which the process was started. Examples:</span>
<span class="c1"># Actual Starting time: 20040617_1230</span>
<span class="c1"># drtTime 20040616_0000</span>
<span class="c1"># Synchronizing off:</span>
<span class="c1"># GFE Spatial Editor at StartUp: 20040616_0000</span>
<span class="c1"># Synchronizing on:</span>
<span class="c1"># GFE Spatial Editor at StartUp: 20040616_0030</span>
<span class="c1">#</span>
<div class="viewcode-block" id="determineDrtOffset"><a class="viewcode-back" href="../../api/TimeUtil.html#awips.TimeUtil.determineDrtOffset">[docs]</a><span class="k">def</span> <span class="nf">determineDrtOffset</span><span class="p">(</span><span class="n">timeStr</span><span class="p">):</span>
<span class="n">launchStr</span> <span class="o">=</span> <span class="n">timeStr</span>
<span class="c1"># Check for time difference</span>
<span class="k">if</span> <span class="n">timeStr</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="n">timeStr</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="p">)</span>
<span class="n">t1</span> <span class="o">=</span> <span class="n">makeTime</span><span class="p">(</span><span class="n">times</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">t2</span> <span class="o">=</span> <span class="n">makeTime</span><span class="p">(</span><span class="n">times</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="k">return</span> <span class="n">t1</span><span class="o">-</span><span class="n">t2</span><span class="p">,</span> <span class="n">launchStr</span>
<span class="c1"># Check for synchronized mode</span>
<span class="n">synch</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">if</span> <span class="n">timeStr</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;S&quot;</span><span class="p">:</span>
<span class="n">timeStr</span> <span class="o">=</span> <span class="n">timeStr</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
<span class="n">synch</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">drt_t</span> <span class="o">=</span> <span class="n">makeTime</span><span class="p">(</span><span class="n">timeStr</span><span class="p">)</span>
<span class="n">gm</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">gmtime</span><span class="p">()</span>
<span class="n">cur_t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">mktime</span><span class="p">(</span><span class="n">gm</span><span class="p">)</span>
<span class="c1"># Synchronize to most recent hour</span>
<span class="c1"># i.e. &quot;truncate&quot; cur_t to most recent hour.</span>
<span class="k">if</span> <span class="n">synch</span><span class="p">:</span>
<span class="n">cur_t</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">mktime</span><span class="p">((</span><span class="n">gm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">gm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">gm</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">gm</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="n">curStr</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%4s%2s%2s</span><span class="s1">_</span><span class="si">%2s</span><span class="s1">00</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">gm</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="nb">repr</span><span class="p">(</span><span class="n">gm</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span>
<span class="nb">repr</span><span class="p">(</span><span class="n">gm</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span> <span class="nb">repr</span><span class="p">(</span><span class="n">gm</span><span class="p">[</span><span class="mi">3</span><span class="p">]))</span>
<span class="n">curStr</span> <span class="o">=</span> <span class="n">curStr</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">,</span> <span class="s1">&#39;0&#39;</span><span class="p">)</span>
<span class="n">launchStr</span> <span class="o">=</span> <span class="n">timeStr</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span> <span class="o">+</span> <span class="n">curStr</span>
<span class="n">offset</span> <span class="o">=</span> <span class="n">drt_t</span> <span class="o">-</span> <span class="n">cur_t</span>
<span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">offset</span><span class="p">),</span> <span class="n">launchStr</span></div>
<div class="viewcode-block" id="makeTime"><a class="viewcode-back" href="../../api/TimeUtil.html#awips.TimeUtil.makeTime">[docs]</a><span class="k">def</span> <span class="nf">makeTime</span><span class="p">(</span><span class="n">timeStr</span><span class="p">):</span>
<span class="n">year</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">atoi</span><span class="p">(</span><span class="n">timeStr</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">4</span><span class="p">])</span>
<span class="n">month</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">atoi</span><span class="p">(</span><span class="n">timeStr</span><span class="p">[</span><span class="mi">4</span><span class="p">:</span><span class="mi">6</span><span class="p">])</span>
<span class="n">day</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">atoi</span><span class="p">(</span><span class="n">timeStr</span><span class="p">[</span><span class="mi">6</span><span class="p">:</span><span class="mi">8</span><span class="p">])</span>
<span class="n">hour</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">atoi</span><span class="p">(</span><span class="n">timeStr</span><span class="p">[</span><span class="mi">9</span><span class="p">:</span><span class="mi">11</span><span class="p">])</span>
<span class="n">minute</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">atoi</span><span class="p">(</span><span class="n">timeStr</span><span class="p">[</span><span class="mi">11</span><span class="p">:</span><span class="mi">13</span><span class="p">])</span>
<span class="c1"># Do not use daylight savings because gmtime is not in daylight</span>
<span class="c1"># savings time.</span>
<span class="k">return</span> <span class="n">time</span><span class="o">.</span><span class="n">mktime</span><span class="p">((</span><span class="n">year</span><span class="p">,</span> <span class="n">month</span><span class="p">,</span> <span class="n">day</span><span class="p">,</span> <span class="n">hour</span><span class="p">,</span> <span class="n">minute</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,577 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>awips.dataaccess</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># __init__.py for awips.dataaccess package</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 12/10/12 njensen Initial Creation.</span>
<span class="c1"># Feb 14, 2013 1614 bsteffen refactor data access framework</span>
<span class="c1"># to use single request.</span>
<span class="c1"># Apr 09, 2013 1871 njensen Add doc strings</span>
<span class="c1"># Jun 03, 2013 2023 dgilling Add getAttributes to IData, add</span>
<span class="c1"># getLatLonGrids() to IGridData.</span>
<span class="c1"># Aug 01, 2016 2416 tgurney Add INotificationSubscriber</span>
<span class="c1"># and INotificationFilter</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
<span class="s1">&#39;IData&#39;</span><span class="p">,</span>
<span class="s1">&#39;IDataRequest&#39;</span><span class="p">,</span>
<span class="s1">&#39;IGeometryData&#39;</span><span class="p">,</span>
<span class="s1">&#39;IGridData&#39;</span><span class="p">,</span>
<span class="s1">&#39;IGeometryData&#39;</span><span class="p">,</span>
<span class="s1">&#39;INotificationFilter&#39;</span><span class="p">,</span>
<span class="s1">&#39;INotificationSubscriber&#39;</span>
<span class="p">]</span>
<span class="kn">import</span> <span class="nn">abc</span>
<span class="kn">from</span> <span class="nn">six</span> <span class="kn">import</span> <span class="n">with_metaclass</span>
<div class="viewcode-block" id="IDataRequest"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest">[docs]</a><span class="k">class</span> <span class="nc">IDataRequest</span><span class="p">(</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">,</span> <span class="nb">object</span><span class="p">)):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> An IDataRequest to be submitted to the DataAccessLayer to retrieve data.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="IDataRequest.setDatatype"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.setDatatype">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">setDatatype</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">datatype</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Sets the datatype of the request.</span>
<span class="sd"> Args:</span>
<span class="sd"> datatype: A string of the datatype, such as &quot;grid&quot;, &quot;radar&quot;, &quot;gfe&quot;, &quot;obs&quot;</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.addIdentifier"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.addIdentifier">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">addIdentifier</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Adds an identifier to the request. Identifiers are specific to the</span>
<span class="sd"> datatype being requested.</span>
<span class="sd"> Args:</span>
<span class="sd"> key: the string key of the identifier</span>
<span class="sd"> value: the value of the identifier</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.setParameters"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.setParameters">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">setParameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Sets the parameters of data to request.</span>
<span class="sd"> Args:</span>
<span class="sd"> params: a list of strings of parameters to request</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.setLevels"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.setLevels">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">setLevels</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">levels</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Sets the levels of data to request. Not all datatypes support levels.</span>
<span class="sd"> Args:</span>
<span class="sd"> levels: a list of strings of level abbreviations to request</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.setEnvelope"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.setEnvelope">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">setEnvelope</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">env</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Sets the envelope of the request. If supported by the datatype factory,</span>
<span class="sd"> the data returned for the request will be constrained to only the data</span>
<span class="sd"> within the envelope.</span>
<span class="sd"> Args:</span>
<span class="sd"> env: a shapely geometry</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.setLocationNames"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.setLocationNames">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">setLocationNames</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">locationNames</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Sets the location names of the request.</span>
<span class="sd"> Args:</span>
<span class="sd"> locationNames: a list of strings of location names to request</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.getDatatype"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.getDatatype">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getDatatype</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the datatype of the request</span>
<span class="sd"> Returns:</span>
<span class="sd"> the datatype set on the request</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.getIdentifiers"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.getIdentifiers">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getIdentifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the identifiers on the request</span>
<span class="sd"> Returns:</span>
<span class="sd"> a dictionary of the identifiers</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.getLevels"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.getLevels">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getLevels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the levels on the request</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of the levels</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.getLocationNames"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.getLocationNames">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getLocationNames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the location names on the request</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of the location names</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div>
<div class="viewcode-block" id="IDataRequest.getEnvelope"><a class="viewcode-back" href="../../api/IDataRequest.html#awips.dataaccess.IDataRequest.getEnvelope">[docs]</a> <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getEnvelope</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the envelope on the request</span>
<span class="sd"> Returns:</span>
<span class="sd"> a rectangular shapely geometry</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span></div></div>
<span class="k">class</span> <span class="nc">IData</span><span class="p">(</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">,</span> <span class="nb">object</span><span class="p">)):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> An IData representing data returned from the DataAccessLayer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getAttribute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets an attribute of the data.</span>
<span class="sd"> Args:</span>
<span class="sd"> key: the key of the attribute</span>
<span class="sd"> Returns:</span>
<span class="sd"> the value of the attribute</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getAttributes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the valid attributes for the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of the attribute names</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getDataTime</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the data time of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> the data time of the data, or None if no time is associated</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getLevel</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the level of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> the level of the data, or None if no level is associated</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getLocationName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the location name of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> the location name of the data, or None if no location name is</span>
<span class="sd"> associated</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="k">class</span> <span class="nc">IGridData</span><span class="p">(</span><span class="n">IData</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> An IData representing grid data that is returned by the DataAccessLayer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getParameter</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the parameter of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> the parameter of the data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getUnit</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the unit of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> the string abbreviation of the unit, or None if no unit is associated</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getRawData</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the grid data as a numpy array.</span>
<span class="sd"> Returns:</span>
<span class="sd"> a numpy array of the data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getLatLonCoords</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the lat/lon coordinates of the grid data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> a tuple where the first element is a numpy array of lons, and the</span>
<span class="sd"> second element is a numpy array of lats</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="k">class</span> <span class="nc">IGeometryData</span><span class="p">(</span><span class="n">IData</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> An IData representing geometry data that is returned by the DataAccessLayer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getGeometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the geometry of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> a shapely geometry</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getParameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Gets the parameters of the data.</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of the parameter names</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getString</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the string value of the specified param.</span>
<span class="sd"> Args:</span>
<span class="sd"> param: the string name of the param</span>
<span class="sd"> Returns:</span>
<span class="sd"> the string value of the param</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getNumber</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the number value of the specified param.</span>
<span class="sd"> Args:</span>
<span class="sd"> param: the string name of the param</span>
<span class="sd"> Returns:</span>
<span class="sd"> the number value of the param</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getUnit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the unit of the specified param.</span>
<span class="sd"> Args:</span>
<span class="sd"> param: the string name of the param</span>
<span class="sd"> Returns:</span>
<span class="sd"> the string abbreviation of the unit of the param</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">getType</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the type of the param.</span>
<span class="sd"> Args:</span>
<span class="sd"> param: the string name of the param</span>
<span class="sd"> Returns:</span>
<span class="sd"> a string of the type of the parameter, such as</span>
<span class="sd"> &quot;STRING&quot;, &quot;INT&quot;, &quot;LONG&quot;, &quot;FLOAT&quot;, or &quot;DOUBLE&quot;</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span>
<span class="k">class</span> <span class="nc">INotificationSubscriber</span><span class="p">(</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">,</span> <span class="nb">object</span><span class="p">)):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> An INotificationSubscriber representing a notification filter returned from</span>
<span class="sd"> the DataNotificationLayer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">subscribe</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callback</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Subscribes to the requested data. Method will not return until close is</span>
<span class="sd"> called in a separate thread.</span>
<span class="sd"> Args:</span>
<span class="sd"> callback: the method to call with the IGridData/IGeometryData</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">pass</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Closes the notification subscriber&quot;&quot;&quot;</span>
<span class="k">pass</span>
<span class="k">class</span> <span class="nc">INotificationFilter</span><span class="p">(</span><span class="n">with_metaclass</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABCMeta</span><span class="p">,</span> <span class="nb">object</span><span class="p">)):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Represents data required to filter a set of URIs and</span>
<span class="sd"> return a corresponding list of IDataRequest to retrieve data for.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
<span class="k">def</span> <span class="nf">accept</span><span class="p">(</span><span class="n">dataUri</span><span class="p">):</span>
<span class="k">pass</span>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,293 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.CombinedTimeQuery &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.CombinedTimeQuery</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.CombinedTimeQuery</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Method for performing a DAF time query where all parameter/level/location</span>
<span class="c1"># combinations must be available at the same time.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 06/22/16 #5591 bsteffen Initial Creation.</span>
<span class="c1">#</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">DataAccessLayer</span>
<div class="viewcode-block" id="getAvailableTimes"><a class="viewcode-back" href="../../../api/CombinedTimeQuery.html#awips.dataaccess.CombinedTimeQuery.getAvailableTimes">[docs]</a><span class="k">def</span> <span class="nf">getAvailableTimes</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="k">return</span> <span class="n">__getAvailableTimesForEachParameter</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span></div>
<span class="k">def</span> <span class="nf">__getAvailableTimesForEachParameter</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="n">parameters</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getParameters</span><span class="p">()</span>
<span class="k">if</span> <span class="n">parameters</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">for</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="n">parameters</span><span class="p">:</span>
<span class="n">specificRequest</span> <span class="o">=</span> <span class="n">__cloneRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">specificRequest</span><span class="o">.</span><span class="n">setParameters</span><span class="p">(</span><span class="n">parameter</span><span class="p">)</span>
<span class="n">specificTimes</span> <span class="o">=</span> <span class="n">__getAvailableTimesForEachLevel</span><span class="p">(</span><span class="n">specificRequest</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span>
<span class="k">if</span> <span class="n">times</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="n">specificTimes</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">times</span><span class="o">.</span><span class="n">intersection_update</span><span class="p">(</span><span class="n">specificTimes</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">times</span><span class="p">:</span>
<span class="k">break</span>
<span class="k">return</span> <span class="n">times</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">__getAvailableTimesForEachLevel</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__getAvailableTimesForEachLevel</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="n">levels</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getLevels</span><span class="p">()</span>
<span class="k">if</span> <span class="n">levels</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">for</span> <span class="n">level</span> <span class="ow">in</span> <span class="n">levels</span><span class="p">:</span>
<span class="n">specificRequest</span> <span class="o">=</span> <span class="n">__cloneRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">specificRequest</span><span class="o">.</span><span class="n">setLevels</span><span class="p">(</span><span class="n">level</span><span class="p">)</span>
<span class="n">specificTimes</span> <span class="o">=</span> <span class="n">__getAvailableTimesForEachLocation</span><span class="p">(</span><span class="n">specificRequest</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span>
<span class="k">if</span> <span class="n">times</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="n">specificTimes</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">times</span><span class="o">.</span><span class="n">intersection_update</span><span class="p">(</span><span class="n">specificTimes</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">times</span><span class="p">:</span>
<span class="k">break</span>
<span class="k">return</span> <span class="n">times</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">__getAvailableTimesForEachLocation</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__getAvailableTimesForEachLocation</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="n">locations</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">getLocationNames</span><span class="p">()</span>
<span class="k">if</span> <span class="n">locations</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">for</span> <span class="n">location</span> <span class="ow">in</span> <span class="n">locations</span><span class="p">:</span>
<span class="n">specificRequest</span> <span class="o">=</span> <span class="n">__cloneRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">specificRequest</span><span class="o">.</span><span class="n">setLocationNames</span><span class="p">(</span><span class="n">location</span><span class="p">)</span>
<span class="n">specificTimes</span> <span class="o">=</span> <span class="n">DataAccessLayer</span><span class="o">.</span><span class="n">getAvailableTimes</span><span class="p">(</span><span class="n">specificRequest</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span>
<span class="k">if</span> <span class="n">times</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">times</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">specificTimes</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">times</span><span class="o">.</span><span class="n">intersection_update</span><span class="p">(</span><span class="n">specificTimes</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">times</span><span class="p">:</span>
<span class="k">break</span>
<span class="k">return</span> <span class="n">times</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">DataAccessLayer</span><span class="o">.</span><span class="n">getAvailableTimes</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__cloneRequest</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">return</span> <span class="n">DataAccessLayer</span><span class="o">.</span><span class="n">newDataRequest</span><span class="p">(</span><span class="n">datatype</span><span class="o">=</span><span class="n">request</span><span class="o">.</span><span class="n">getDatatype</span><span class="p">(),</span>
<span class="n">parameters</span><span class="o">=</span><span class="n">request</span><span class="o">.</span><span class="n">getParameters</span><span class="p">(),</span>
<span class="n">levels</span><span class="o">=</span><span class="n">request</span><span class="o">.</span><span class="n">getLevels</span><span class="p">(),</span>
<span class="n">locationNames</span><span class="o">=</span><span class="n">request</span><span class="o">.</span><span class="n">getLocationNames</span><span class="p">(),</span>
<span class="n">envelope</span><span class="o">=</span><span class="n">request</span><span class="o">.</span><span class="n">getEnvelope</span><span class="p">(),</span>
<span class="o">**</span><span class="n">request</span><span class="o">.</span><span class="n">getIdentifiers</span><span class="p">())</span>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,600 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.DataAccessLayer &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.DataAccessLayer</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.DataAccessLayer</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Published interface for awips.dataaccess package</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ------- ---------- -------------------------</span>
<span class="c1"># 12/10/12 njensen Initial Creation.</span>
<span class="c1"># Feb 14, 2013 1614 bsteffen refactor data access framework to use single request.</span>
<span class="c1"># 04/10/13 1871 mnash move getLatLonCoords to JGridData and add default args</span>
<span class="c1"># 05/29/13 2023 dgilling Hook up ThriftClientRouter.</span>
<span class="c1"># 03/03/14 2673 bsteffen Add ability to query only ref times.</span>
<span class="c1"># 07/22/14 3185 njensen Added optional/default args to newDataRequest</span>
<span class="c1"># 07/30/14 3185 njensen Renamed valid identifiers to optional</span>
<span class="c1"># Apr 26, 2015 4259 njensen Updated for new JEP API</span>
<span class="c1"># Apr 13, 2016 5379 tgurney Add getIdentifierValues(), getRequiredIdentifiers(),</span>
<span class="c1"># and getOptionalIdentifiers()</span>
<span class="c1"># Oct 07, 2016 ---- mjames@ucar Added getForecastRun</span>
<span class="c1"># Oct 18, 2016 5916 bsteffen Add setLazyLoadGridLatLon</span>
<span class="c1"># Oct 11, 2018 ---- mjames@ucar Added getMetarObs() getSynopticObs()</span>
<span class="c1">#</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="n">THRIFT_HOST</span> <span class="o">=</span> <span class="s2">&quot;edex&quot;</span>
<span class="n">USING_NATIVE_THRIFT</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">if</span> <span class="s1">&#39;jep&#39;</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">:</span>
<span class="c1"># intentionally do not catch if this fails to import, we want it to</span>
<span class="c1"># be obvious that something is configured wrong when running from within</span>
<span class="c1"># Java instead of allowing false confidence and fallback behavior</span>
<span class="kn">import</span> <span class="nn">JepRouter</span>
<span class="n">router</span> <span class="o">=</span> <span class="n">JepRouter</span>
<span class="k">else</span><span class="p">:</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">ThriftClientRouter</span>
<span class="n">router</span> <span class="o">=</span> <span class="n">ThriftClientRouter</span><span class="o">.</span><span class="n">ThriftClientRouter</span><span class="p">(</span><span class="n">THRIFT_HOST</span><span class="p">)</span>
<span class="n">USING_NATIVE_THRIFT</span> <span class="o">=</span> <span class="kc">True</span>
<div class="viewcode-block" id="getRadarProductIDs"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getRadarProductIDs">[docs]</a><span class="k">def</span> <span class="nf">getRadarProductIDs</span><span class="p">(</span><span class="n">availableParms</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get only the numeric idetifiers for NEXRAD3 products.</span>
<span class="sd"> Args:</span>
<span class="sd"> availableParms: Full list of radar parameters</span>
<span class="sd"> Returns:</span>
<span class="sd"> List of filtered parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">productIDs</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">availableParms</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">p</span><span class="p">),</span> <span class="nb">int</span><span class="p">):</span>
<span class="n">productIDs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="k">return</span> <span class="n">productIDs</span></div>
<div class="viewcode-block" id="getRadarProductNames"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getRadarProductNames">[docs]</a><span class="k">def</span> <span class="nf">getRadarProductNames</span><span class="p">(</span><span class="n">availableParms</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get only the named idetifiers for NEXRAD3 products.</span>
<span class="sd"> Args:</span>
<span class="sd"> availableParms: Full list of radar parameters</span>
<span class="sd"> Returns:</span>
<span class="sd"> List of filtered parameters</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">productNames</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">availableParms</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
<span class="n">productNames</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="k">return</span> <span class="n">productNames</span></div>
<div class="viewcode-block" id="getMetarObs"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getMetarObs">[docs]</a><span class="k">def</span> <span class="nf">getMetarObs</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Processes a DataAccessLayer &quot;obs&quot; response into a dictionary,</span>
<span class="sd"> with special consideration for multi-value parameters</span>
<span class="sd"> &quot;presWeather&quot;, &quot;skyCover&quot;, and &quot;skyLayerBase&quot;.</span>
<span class="sd"> Args:</span>
<span class="sd"> response: DAL getGeometry() list</span>
<span class="sd"> Returns:</span>
<span class="sd"> A dictionary of METAR obs</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
<span class="n">single_val_params</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;timeObs&quot;</span><span class="p">,</span> <span class="s2">&quot;stationName&quot;</span><span class="p">,</span> <span class="s2">&quot;longitude&quot;</span><span class="p">,</span> <span class="s2">&quot;latitude&quot;</span><span class="p">,</span>
<span class="s2">&quot;temperature&quot;</span><span class="p">,</span> <span class="s2">&quot;dewpoint&quot;</span><span class="p">,</span> <span class="s2">&quot;windDir&quot;</span><span class="p">,</span>
<span class="s2">&quot;windSpeed&quot;</span><span class="p">,</span> <span class="s2">&quot;seaLevelPress&quot;</span><span class="p">]</span>
<span class="n">multi_val_params</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;presWeather&quot;</span><span class="p">,</span> <span class="s2">&quot;skyCover&quot;</span><span class="p">,</span> <span class="s2">&quot;skyLayerBase&quot;</span><span class="p">]</span>
<span class="n">params</span> <span class="o">=</span> <span class="n">single_val_params</span> <span class="o">+</span> <span class="n">multi_val_params</span>
<span class="n">station_names</span><span class="p">,</span> <span class="n">pres_weather</span><span class="p">,</span> <span class="n">sky_cov</span><span class="p">,</span> <span class="n">sky_layer_base</span> <span class="o">=</span> <span class="p">[],</span> <span class="p">[],</span> <span class="p">[],</span> <span class="p">[]</span>
<span class="n">obs</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">({</span><span class="n">params</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">params</span> <span class="ow">in</span> <span class="n">params</span><span class="p">})</span>
<span class="k">for</span> <span class="n">ob</span> <span class="ow">in</span> <span class="n">response</span><span class="p">:</span>
<span class="n">avail_params</span> <span class="o">=</span> <span class="n">ob</span><span class="o">.</span><span class="n">getParameters</span><span class="p">()</span>
<span class="k">if</span> <span class="s2">&quot;presWeather&quot;</span> <span class="ow">in</span> <span class="n">avail_params</span><span class="p">:</span>
<span class="n">pres_weather</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="s2">&quot;presWeather&quot;</span><span class="p">))</span>
<span class="k">elif</span> <span class="s2">&quot;skyCover&quot;</span> <span class="ow">in</span> <span class="n">avail_params</span> <span class="ow">and</span> <span class="s2">&quot;skyLayerBase&quot;</span> <span class="ow">in</span> <span class="n">avail_params</span><span class="p">:</span>
<span class="n">sky_cov</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="s2">&quot;skyCover&quot;</span><span class="p">))</span>
<span class="n">sky_layer_base</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getNumber</span><span class="p">(</span><span class="s2">&quot;skyLayerBase&quot;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># If we already have a record for this stationName, skip</span>
<span class="k">if</span> <span class="n">ob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="s1">&#39;stationName&#39;</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">station_names</span><span class="p">:</span>
<span class="n">station_names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="s1">&#39;stationName&#39;</span><span class="p">))</span>
<span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">single_val_params</span><span class="p">:</span>
<span class="k">if</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">avail_params</span><span class="p">:</span>
<span class="k">if</span> <span class="n">param</span> <span class="o">==</span> <span class="s1">&#39;timeObs&#39;</span><span class="p">:</span>
<span class="n">obs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getNumber</span><span class="p">(</span><span class="n">param</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.0</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">obs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getNumber</span><span class="p">(</span><span class="n">param</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
<span class="n">obs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="n">param</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">obs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
<span class="n">obs</span><span class="p">[</span><span class="s1">&#39;presWeather&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pres_weather</span><span class="p">)</span>
<span class="n">obs</span><span class="p">[</span><span class="s1">&#39;skyCover&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sky_cov</span><span class="p">)</span>
<span class="n">obs</span><span class="p">[</span><span class="s1">&#39;skyLayerBase&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sky_layer_base</span><span class="p">)</span>
<span class="n">pres_weather</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">sky_cov</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">sky_layer_base</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">return</span> <span class="n">obs</span></div>
<div class="viewcode-block" id="getSynopticObs"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getSynopticObs">[docs]</a><span class="k">def</span> <span class="nf">getSynopticObs</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Processes a DataAccessLayer &quot;sfcobs&quot; response into a dictionary</span>
<span class="sd"> of available parameters.</span>
<span class="sd"> Args:</span>
<span class="sd"> response: DAL getGeometry() list</span>
<span class="sd"> Returns:</span>
<span class="sd"> A dictionary of synop obs</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
<span class="n">station_names</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">params</span> <span class="o">=</span> <span class="n">response</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">getParameters</span><span class="p">()</span>
<span class="n">sfcobs</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">({</span><span class="n">params</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">params</span> <span class="ow">in</span> <span class="n">params</span><span class="p">})</span>
<span class="k">for</span> <span class="n">sfcob</span> <span class="ow">in</span> <span class="n">response</span><span class="p">:</span>
<span class="c1"># If we already have a record for this stationId, skip</span>
<span class="k">if</span> <span class="n">sfcob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="s1">&#39;stationId&#39;</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">station_names</span><span class="p">:</span>
<span class="n">station_names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sfcob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="s1">&#39;stationId&#39;</span><span class="p">))</span>
<span class="k">for</span> <span class="n">param</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span>
<span class="k">if</span> <span class="n">param</span> <span class="o">==</span> <span class="s1">&#39;timeObs&#39;</span><span class="p">:</span>
<span class="n">sfcobs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">fromtimestamp</span><span class="p">(</span><span class="n">sfcob</span><span class="o">.</span><span class="n">getNumber</span><span class="p">(</span><span class="n">param</span><span class="p">)</span> <span class="o">/</span> <span class="mf">1000.0</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">sfcobs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sfcob</span><span class="o">.</span><span class="n">getNumber</span><span class="p">(</span><span class="n">param</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
<span class="n">sfcobs</span><span class="p">[</span><span class="n">param</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sfcob</span><span class="o">.</span><span class="n">getString</span><span class="p">(</span><span class="n">param</span><span class="p">))</span>
<span class="k">return</span> <span class="n">sfcobs</span></div>
<div class="viewcode-block" id="getForecastRun"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getForecastRun">[docs]</a><span class="k">def</span> <span class="nf">getForecastRun</span><span class="p">(</span><span class="n">cycle</span><span class="p">,</span> <span class="n">times</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get the latest forecast run (list of objects) from all</span>
<span class="sd"> all cycles and times returned from DataAccessLayer &quot;grid&quot;</span>
<span class="sd"> response.</span>
<span class="sd"> Args:</span>
<span class="sd"> cycle: Forecast cycle reference time</span>
<span class="sd"> times: All available times/cycles</span>
<span class="sd"> Returns:</span>
<span class="sd"> DataTime array for a single forecast run</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">fcstRun</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">times</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)[:</span><span class="mi">19</span><span class="p">]</span> <span class="o">==</span> <span class="nb">str</span><span class="p">(</span><span class="n">cycle</span><span class="p">):</span>
<span class="n">fcstRun</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
<span class="k">return</span> <span class="n">fcstRun</span></div>
<div class="viewcode-block" id="getAvailableTimes"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableTimes">[docs]</a><span class="k">def</span> <span class="nf">getAvailableTimes</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get the times of available data to the request.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the IDataRequest to get data for</span>
<span class="sd"> refTimeOnly: optional, use True if only unique refTimes should be</span>
<span class="sd"> returned (without a forecastHr)</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of DataTimes</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getAvailableTimes</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">)</span></div>
<div class="viewcode-block" id="getGridData"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getGridData">[docs]</a><span class="k">def</span> <span class="nf">getGridData</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">times</span><span class="o">=</span><span class="p">[]):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the grid data that matches the request at the specified times. Each</span>
<span class="sd"> combination of parameter, level, and dataTime will be returned as a</span>
<span class="sd"> separate IGridData.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the IDataRequest to get data for</span>
<span class="sd"> times: a list of DataTimes, a TimeRange, or None if the data is time</span>
<span class="sd"> agnostic</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of IGridData</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getGridData</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">times</span><span class="p">)</span></div>
<div class="viewcode-block" id="getGeometryData"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getGeometryData">[docs]</a><span class="k">def</span> <span class="nf">getGeometryData</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">times</span><span class="o">=</span><span class="p">[]):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the geometry data that matches the request at the specified times.</span>
<span class="sd"> Each combination of geometry, level, and dataTime will be returned as a</span>
<span class="sd"> separate IGeometryData.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the IDataRequest to get data for</span>
<span class="sd"> times: a list of DataTimes, a TimeRange, or None if the data is time</span>
<span class="sd"> agnostic</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of IGeometryData</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getGeometryData</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">times</span><span class="p">)</span></div>
<div class="viewcode-block" id="getAvailableLocationNames"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableLocationNames">[docs]</a><span class="k">def</span> <span class="nf">getAvailableLocationNames</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the available location names that match the request without actually</span>
<span class="sd"> requesting the data.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the request to find matching location names for</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of available location names.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getAvailableLocationNames</span><span class="p">(</span><span class="n">request</span><span class="p">)</span></div>
<div class="viewcode-block" id="getAvailableParameters"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableParameters">[docs]</a><span class="k">def</span> <span class="nf">getAvailableParameters</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the available parameters names that match the request without actually</span>
<span class="sd"> requesting the data.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the request to find matching parameter names for</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of available parameter names.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getAvailableParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span></div>
<div class="viewcode-block" id="getAvailableLevels"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableLevels">[docs]</a><span class="k">def</span> <span class="nf">getAvailableLevels</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the available levels that match the request without actually</span>
<span class="sd"> requesting the data.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the request to find matching levels for</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of available levels.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getAvailableLevels</span><span class="p">(</span><span class="n">request</span><span class="p">)</span></div>
<div class="viewcode-block" id="getRequiredIdentifiers"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getRequiredIdentifiers">[docs]</a><span class="k">def</span> <span class="nf">getRequiredIdentifiers</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the required identifiers for this request. These identifiers</span>
<span class="sd"> must be set on a request for the request of this datatype to succeed.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the request to find required identifiers for</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of required identifiers</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="o">==</span> <span class="n">request</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;Use getRequiredIdentifiers(IDataRequest) instead&quot;</span><span class="p">,</span>
<span class="ne">DeprecationWarning</span><span class="p">)</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getRequiredIdentifiers</span><span class="p">(</span><span class="n">request</span><span class="p">)</span></div>
<div class="viewcode-block" id="getOptionalIdentifiers"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getOptionalIdentifiers">[docs]</a><span class="k">def</span> <span class="nf">getOptionalIdentifiers</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the optional identifiers for this request.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the request to find optional identifiers for</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of optional identifiers</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="o">==</span> <span class="n">request</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;Use getOptionalIdentifiers(IDataRequest) instead&quot;</span><span class="p">,</span>
<span class="ne">DeprecationWarning</span><span class="p">)</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getOptionalIdentifiers</span><span class="p">(</span><span class="n">request</span><span class="p">)</span></div>
<div class="viewcode-block" id="getIdentifierValues"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getIdentifierValues">[docs]</a><span class="k">def</span> <span class="nf">getIdentifierValues</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">identifierKey</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the allowed values for a particular identifier on this datatype.</span>
<span class="sd"> Args:</span>
<span class="sd"> request: the request to find identifier values for</span>
<span class="sd"> identifierKey: the identifier to find values for</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of allowed values for the specified identifier</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getIdentifierValues</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">identifierKey</span><span class="p">)</span></div>
<div class="viewcode-block" id="newDataRequest"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.newDataRequest">[docs]</a><span class="k">def</span> <span class="nf">newDataRequest</span><span class="p">(</span><span class="n">datatype</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Creates a new instance of IDataRequest suitable for the runtime environment.</span>
<span class="sd"> All args are optional and exist solely for convenience.</span>
<span class="sd"> Args:</span>
<span class="sd"> datatype: the datatype to create a request for</span>
<span class="sd"> parameters: a list of parameters to set on the request</span>
<span class="sd"> levels: a list of levels to set on the request</span>
<span class="sd"> locationNames: a list of locationNames to set on the request</span>
<span class="sd"> envelope: an envelope to limit the request</span>
<span class="sd"> kwargs: any leftover kwargs will be set as identifiers</span>
<span class="sd"> Returns:</span>
<span class="sd"> a new IDataRequest</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">newDataRequest</span><span class="p">(</span><span class="n">datatype</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>
<div class="viewcode-block" id="getSupportedDatatypes"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getSupportedDatatypes">[docs]</a><span class="k">def</span> <span class="nf">getSupportedDatatypes</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the datatypes that are supported by the framework</span>
<span class="sd"> Returns:</span>
<span class="sd"> a list of strings of supported datatypes</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">router</span><span class="o">.</span><span class="n">getSupportedDatatypes</span><span class="p">()</span></div>
<div class="viewcode-block" id="changeEDEXHost"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.changeEDEXHost">[docs]</a><span class="k">def</span> <span class="nf">changeEDEXHost</span><span class="p">(</span><span class="n">newHostName</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Changes the EDEX host the Data Access Framework is communicating with. Only</span>
<span class="sd"> works if using the native Python client implementation, otherwise, this</span>
<span class="sd"> method will throw a TypeError.</span>
<span class="sd"> Args:</span>
<span class="sd"> newHostName: the EDEX host to connect to</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">USING_NATIVE_THRIFT</span><span class="p">:</span>
<span class="k">global</span> <span class="n">THRIFT_HOST</span>
<span class="n">THRIFT_HOST</span> <span class="o">=</span> <span class="n">newHostName</span>
<span class="k">global</span> <span class="n">router</span>
<span class="n">router</span> <span class="o">=</span> <span class="n">ThriftClientRouter</span><span class="o">.</span><span class="n">ThriftClientRouter</span><span class="p">(</span><span class="n">THRIFT_HOST</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Cannot call changeEDEXHost when using JepRouter.&quot;</span><span class="p">)</span></div>
<div class="viewcode-block" id="setLazyLoadGridLatLon"><a class="viewcode-back" href="../../../api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.setLazyLoadGridLatLon">[docs]</a><span class="k">def</span> <span class="nf">setLazyLoadGridLatLon</span><span class="p">(</span><span class="n">lazyLoadGridLatLon</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Provide a hint to the Data Access Framework indicating whether to load the</span>
<span class="sd"> lat/lon data for a grid immediately or wait until it is needed. This is</span>
<span class="sd"> provided as a performance tuning hint and should not affect the way the</span>
<span class="sd"> Data Access Framework is used. Depending on the internal implementation of</span>
<span class="sd"> the Data Access Framework this hint might be ignored. Examples of when this</span>
<span class="sd"> should be set to True are when the lat/lon information is not used or when</span>
<span class="sd"> it is used only if certain conditions within the data are met. It could be</span>
<span class="sd"> set to False if it is guaranteed that all lat/lon information is needed and</span>
<span class="sd"> it would be better to get any performance overhead for generating the</span>
<span class="sd"> lat/lon data out of the way during the initial request.</span>
<span class="sd"> Args:</span>
<span class="sd"> lazyLoadGridLatLon: Boolean value indicating whether to lazy load.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">router</span><span class="o">.</span><span class="n">setLazyLoadGridLatLon</span><span class="p">(</span><span class="n">lazyLoadGridLatLon</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="c1"># The router is not required to support this capability.</span>
<span class="k">pass</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,440 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.ModelSounding &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.ModelSounding</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.ModelSounding</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Classes for retrieving soundings based on gridded data from the Data Access</span>
<span class="c1"># Framework</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 06/24/15 #4480 dgilling Initial Creation.</span>
<span class="c1">#</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">DataAccessLayer</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level</span> <span class="kn">import</span> <span class="n">Level</span>
<span class="kn">from</span> <span class="nn">shapely.geometry</span> <span class="kn">import</span> <span class="n">Point</span>
<div class="viewcode-block" id="getSounding"><a class="viewcode-back" href="../../../api/ModelSounding.html#awips.dataaccess.ModelSounding.getSounding">[docs]</a><span class="k">def</span> <span class="nf">getSounding</span><span class="p">(</span><span class="n">modelName</span><span class="p">,</span> <span class="n">weatherElements</span><span class="p">,</span> <span class="n">levels</span><span class="p">,</span> <span class="n">samplePoint</span><span class="p">,</span> <span class="n">timeRange</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Performs a series of Data Access Framework requests to retrieve a sounding object</span>
<span class="sd"> based on the specified request parameters.</span>
<span class="sd"> Args:</span>
<span class="sd"> modelName: the grid model datasetid to use as the basis of the sounding.</span>
<span class="sd"> weatherElements: a list of parameters to return in the sounding.</span>
<span class="sd"> levels: a list of levels to sample the given weather elements at</span>
<span class="sd"> samplePoint: a lat/lon pair to perform the sampling of data at.</span>
<span class="sd"> timeRange: (optional) a list of times, or a TimeRange to specify</span>
<span class="sd"> which forecast hours to use. If not specified, will default to all forecast hours.</span>
<span class="sd"> Returns:</span>
<span class="sd"> A _SoundingCube instance, which acts a 3-tiered dictionary, keyed</span>
<span class="sd"> by DataTime, then by level and finally by weather element. If no</span>
<span class="sd"> data is available for the given request parameters, None is returned.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="p">(</span><span class="n">locationNames</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="n">levels</span><span class="p">,</span> <span class="n">envelope</span><span class="p">,</span> <span class="n">timeRange</span><span class="p">)</span> <span class="o">=</span> \
<span class="n">__sanitizeInputs</span><span class="p">(</span><span class="n">modelName</span><span class="p">,</span> <span class="n">weatherElements</span><span class="p">,</span> <span class="n">levels</span><span class="p">,</span> <span class="n">samplePoint</span><span class="p">,</span> <span class="n">timeRange</span><span class="p">)</span>
<span class="n">requestArgs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;datatype&#39;</span><span class="p">:</span> <span class="s1">&#39;grid&#39;</span><span class="p">,</span> <span class="s1">&#39;locationNames&#39;</span><span class="p">:</span> <span class="n">locationNames</span><span class="p">,</span>
<span class="s1">&#39;parameters&#39;</span><span class="p">:</span> <span class="n">parameters</span><span class="p">,</span> <span class="s1">&#39;levels&#39;</span><span class="p">:</span> <span class="n">levels</span><span class="p">,</span> <span class="s1">&#39;envelope&#39;</span><span class="p">:</span> <span class="n">envelope</span><span class="p">}</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">DataAccessLayer</span><span class="o">.</span><span class="n">newDataRequest</span><span class="p">(</span><span class="o">**</span><span class="n">requestArgs</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">DataAccessLayer</span><span class="o">.</span><span class="n">getGeometryData</span><span class="p">(</span><span class="n">req</span><span class="p">,</span> <span class="n">timeRange</span><span class="p">)</span>
<span class="n">soundingObject</span> <span class="o">=</span> <span class="n">_SoundingCube</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="k">return</span> <span class="n">soundingObject</span></div>
<div class="viewcode-block" id="changeEDEXHost"><a class="viewcode-back" href="../../../api/ModelSounding.html#awips.dataaccess.ModelSounding.changeEDEXHost">[docs]</a><span class="k">def</span> <span class="nf">changeEDEXHost</span><span class="p">(</span><span class="n">host</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Changes the EDEX host the Data Access Framework is communicating with.</span>
<span class="sd"> Args:</span>
<span class="sd"> host: the EDEX host to connect to</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">host</span><span class="p">:</span>
<span class="n">DataAccessLayer</span><span class="o">.</span><span class="n">changeEDEXHost</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">host</span><span class="p">))</span></div>
<span class="k">def</span> <span class="nf">__sanitizeInputs</span><span class="p">(</span><span class="n">modelName</span><span class="p">,</span> <span class="n">weatherElements</span><span class="p">,</span> <span class="n">levels</span><span class="p">,</span> <span class="n">samplePoint</span><span class="p">,</span> <span class="n">timeRange</span><span class="p">):</span>
<span class="n">locationNames</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">modelName</span><span class="p">)]</span>
<span class="n">parameters</span> <span class="o">=</span> <span class="n">__buildStringList</span><span class="p">(</span><span class="n">weatherElements</span><span class="p">)</span>
<span class="n">levels</span> <span class="o">=</span> <span class="n">__buildStringList</span><span class="p">(</span><span class="n">levels</span><span class="p">)</span>
<span class="n">envelope</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="n">samplePoint</span><span class="p">)</span>
<span class="k">return</span> <span class="n">locationNames</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="n">levels</span><span class="p">,</span> <span class="n">envelope</span><span class="p">,</span> <span class="n">timeRange</span>
<span class="k">def</span> <span class="nf">__buildStringList</span><span class="p">(</span><span class="n">param</span><span class="p">):</span>
<span class="k">if</span> <span class="n">__notStringIter</span><span class="p">(</span><span class="n">param</span><span class="p">):</span>
<span class="k">return</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">param</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">param</span><span class="p">)]</span>
<span class="k">def</span> <span class="nf">__notStringIter</span><span class="p">(</span><span class="n">iterable</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="n">iterable</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">iter</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>
<span class="k">class</span> <span class="nc">_SoundingCube</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The top-level sounding object returned when calling ModelSounding.getSounding.</span>
<span class="sd"> This object acts as a 3-tiered dict which is keyed by time then level</span>
<span class="sd"> then parameter name. Calling times() will return all valid keys into this</span>
<span class="sd"> object.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">geometryDataObjects</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sortedTimes</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">geometryDataObjects</span><span class="p">:</span>
<span class="k">for</span> <span class="n">geometryData</span> <span class="ow">in</span> <span class="n">geometryDataObjects</span><span class="p">:</span>
<span class="n">dataTime</span> <span class="o">=</span> <span class="n">geometryData</span><span class="o">.</span><span class="n">getDataTime</span><span class="p">()</span>
<span class="n">level</span> <span class="o">=</span> <span class="n">geometryData</span><span class="o">.</span><span class="n">getLevel</span><span class="p">()</span>
<span class="k">for</span> <span class="n">parameter</span> <span class="ow">in</span> <span class="n">geometryData</span><span class="o">.</span><span class="n">getParameters</span><span class="p">():</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__addItem</span><span class="p">(</span><span class="n">parameter</span><span class="p">,</span> <span class="n">dataTime</span><span class="p">,</span> <span class="n">level</span><span class="p">,</span> <span class="n">geometryData</span><span class="o">.</span><span class="n">getNumber</span><span class="p">(</span><span class="n">parameter</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">__addItem</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parameter</span><span class="p">,</span> <span class="n">dataTime</span><span class="p">,</span> <span class="n">level</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="n">timeLayer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dataTime</span><span class="p">,</span> <span class="n">_SoundingTimeLayer</span><span class="p">(</span><span class="n">dataTime</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">[</span><span class="n">dataTime</span><span class="p">]</span> <span class="o">=</span> <span class="n">timeLayer</span>
<span class="n">timeLayer</span><span class="o">.</span><span class="n">_addItem</span><span class="p">(</span><span class="n">parameter</span><span class="p">,</span> <span class="n">level</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="k">if</span> <span class="n">dataTime</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_sortedTimes</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sortedTimes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dataTime</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_sortedTimes</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">times</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the valid times for this sounding.</span>
<span class="sd"> Returns:</span>
<span class="sd"> A list containing the valid DataTimes for this sounding in order.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_sortedTimes</span>
<span class="k">class</span> <span class="nc">_SoundingTimeLayer</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The second-level sounding object returned when calling ModelSounding.getSounding.</span>
<span class="sd"> This object acts as a 2-tiered dict which is keyed by level then parameter</span>
<span class="sd"> name. Calling levels() will return all valid keys into this</span>
<span class="sd"> object. Calling time() will return the DataTime for this particular layer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataTime</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dataTime</span> <span class="o">=</span> <span class="n">dataTime</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">def</span> <span class="nf">_addItem</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parameter</span><span class="p">,</span> <span class="n">level</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="n">asString</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">level</span><span class="p">)</span>
<span class="n">levelLayer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">asString</span><span class="p">,</span> <span class="n">_SoundingTimeAndLevelLayer</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_dataTime</span><span class="p">,</span> <span class="n">asString</span><span class="p">))</span>
<span class="n">levelLayer</span><span class="o">.</span><span class="n">_addItem</span><span class="p">(</span><span class="n">parameter</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">[</span><span class="n">asString</span><span class="p">]</span> <span class="o">=</span> <span class="n">levelLayer</span>
<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="n">asString</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
<span class="k">if</span> <span class="n">asString</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">[</span><span class="n">asString</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;Level &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; is not a valid level for this sounding.&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">time</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the DataTime for this sounding cube layer.</span>
<span class="sd"> Returns:</span>
<span class="sd"> The DataTime for this sounding layer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_dataTime</span>
<span class="k">def</span> <span class="nf">levels</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the valid levels for this sounding.</span>
<span class="sd"> Returns:</span>
<span class="sd"> A list containing the valid levels for this sounding in order of</span>
<span class="sd"> closest to surface to highest from surface.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">sortedLevels</span> <span class="o">=</span> <span class="p">[</span><span class="n">Level</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> <span class="k">for</span> <span class="n">level</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_dataDict</span><span class="o">.</span><span class="n">keys</span><span class="p">())]</span>
<span class="n">sortedLevels</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
<span class="k">return</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">level</span><span class="p">)</span> <span class="k">for</span> <span class="n">level</span> <span class="ow">in</span> <span class="n">sortedLevels</span><span class="p">]</span>
<span class="k">class</span> <span class="nc">_SoundingTimeAndLevelLayer</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> The bottom-level sounding object returned when calling ModelSounding.getSounding.</span>
<span class="sd"> This object acts as a dict which is keyed by parameter name. Calling</span>
<span class="sd"> parameters() will return all valid keys into this object. Calling time()</span>
<span class="sd"> will return the DataTime for this particular layer. Calling level() will</span>
<span class="sd"> return the level for this layer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">time</span><span class="p">,</span> <span class="n">level</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_time</span> <span class="o">=</span> <span class="n">time</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_level</span> <span class="o">=</span> <span class="n">level</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">def</span> <span class="nf">_addItem</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parameter</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">[</span><span class="n">parameter</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">level</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the level for this sounding cube layer.</span>
<span class="sd"> Returns:</span>
<span class="sd"> The level for this sounding layer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_level</span>
<span class="k">def</span> <span class="nf">parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the valid parameters for this sounding.</span>
<span class="sd"> Returns:</span>
<span class="sd"> A list containing the valid parameter names.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parameters</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
<span class="k">def</span> <span class="nf">time</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns the DataTime for this sounding cube layer.</span>
<span class="sd"> Returns:</span>
<span class="sd"> The DataTime for this sounding layer.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_time</span>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,253 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.PyData &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.PyData</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.PyData</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Implements IData for use by native Python clients to the Data Access</span>
<span class="c1"># Framework.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 06/03/13 dgilling Initial Creation.</span>
<span class="c1"># 10/05/18 mjames@ucar Encode/decode attribute names.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">IData</span>
<span class="kn">import</span> <span class="nn">six</span>
<div class="viewcode-block" id="PyData"><a class="viewcode-back" href="../../../api/PyData.html#awips.dataaccess.PyData.PyData">[docs]</a><span class="k">class</span> <span class="nc">PyData</span><span class="p">(</span><span class="n">IData</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataRecord</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__time</span> <span class="o">=</span> <span class="n">dataRecord</span><span class="o">.</span><span class="n">getTime</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__level</span> <span class="o">=</span> <span class="n">dataRecord</span><span class="o">.</span><span class="n">getLevel</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__locationName</span> <span class="o">=</span> <span class="n">dataRecord</span><span class="o">.</span><span class="n">getLocationName</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__attributes</span> <span class="o">=</span> <span class="n">dataRecord</span><span class="o">.</span><span class="n">getAttributes</span><span class="p">()</span>
<div class="viewcode-block" id="PyData.getAttribute"><a class="viewcode-back" href="../../../api/PyData.html#awips.dataaccess.PyData.PyData.getAttribute">[docs]</a> <span class="k">def</span> <span class="nf">getAttribute</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attributes</span><span class="p">[</span><span class="n">key</span><span class="p">]</span></div>
<div class="viewcode-block" id="PyData.getAttributes"><a class="viewcode-back" href="../../../api/PyData.html#awips.dataaccess.PyData.PyData.getAttributes">[docs]</a> <span class="k">def</span> <span class="nf">getAttributes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attributes</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span></div>
<div class="viewcode-block" id="PyData.getDataTime"><a class="viewcode-back" href="../../../api/PyData.html#awips.dataaccess.PyData.PyData.getDataTime">[docs]</a> <span class="k">def</span> <span class="nf">getDataTime</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__time</span></div>
<div class="viewcode-block" id="PyData.getLevel"><a class="viewcode-back" href="../../../api/PyData.html#awips.dataaccess.PyData.PyData.getLevel">[docs]</a> <span class="k">def</span> <span class="nf">getLevel</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__level</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">__level</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__level</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__level</span></div>
<div class="viewcode-block" id="PyData.getLocationName"><a class="viewcode-back" href="../../../api/PyData.html#awips.dataaccess.PyData.PyData.getLocationName">[docs]</a> <span class="k">def</span> <span class="nf">getLocationName</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__locationName</span></div></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,290 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.PyGeometryData &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.PyGeometryData</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.PyGeometryData</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Implements IGeometryData for use by native Python clients to the Data Access</span>
<span class="c1"># Framework.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 06/03/13 dgilling Initial Creation.</span>
<span class="c1"># 01/06/14 2537 bsteffen Share geometry WKT.</span>
<span class="c1"># 03/19/14 2882 dgilling Raise an exception when getNumber()</span>
<span class="c1"># is called for data that is not a</span>
<span class="c1"># numeric Type.</span>
<span class="c1"># 06/09/16 5574 mapeters Handle &#39;SHORT&#39; type in getNumber().</span>
<span class="c1"># 10/05/18 mjames@ucar Encode/decode string, number val, and type</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">IGeometryData</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">PyData</span>
<span class="kn">import</span> <span class="nn">six</span>
<div class="viewcode-block" id="PyGeometryData"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData">[docs]</a><span class="k">class</span> <span class="nc">PyGeometryData</span><span class="p">(</span><span class="n">IGeometryData</span><span class="p">,</span> <span class="n">PyData</span><span class="o">.</span><span class="n">PyData</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">geoDataRecord</span><span class="p">,</span> <span class="n">geometry</span><span class="p">):</span>
<span class="n">PyData</span><span class="o">.</span><span class="n">PyData</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">geoDataRecord</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__geometry</span> <span class="o">=</span> <span class="n">geometry</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">tempDataMap</span> <span class="o">=</span> <span class="n">geoDataRecord</span><span class="o">.</span><span class="n">getDataMap</span><span class="p">()</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">tempDataMap</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">value</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
<div class="viewcode-block" id="PyGeometryData.getGeometry"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData.getGeometry">[docs]</a> <span class="k">def</span> <span class="nf">getGeometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__geometry</span></div>
<div class="viewcode-block" id="PyGeometryData.getParameters"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData.getParameters">[docs]</a> <span class="k">def</span> <span class="nf">getParameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="o">.</span><span class="n">keys</span><span class="p">())]</span></div>
<div class="viewcode-block" id="PyGeometryData.getString"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData.getString">[docs]</a> <span class="k">def</span> <span class="nf">getString</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
<span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)][</span><span class="mi">0</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">value</span><span class="p">)</span></div>
<div class="viewcode-block" id="PyGeometryData.getNumber"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData.getNumber">[docs]</a> <span class="k">def</span> <span class="nf">getNumber</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getType</span><span class="p">(</span><span class="n">param</span><span class="p">)</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</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">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)][</span><span class="mi">0</span><span class="p">]</span>
<span class="k">if</span> <span class="n">t</span> <span class="o">==</span> <span class="s1">&#39;INT&#39;</span> <span class="ow">or</span> <span class="n">t</span> <span class="o">==</span> <span class="s1">&#39;SHORT&#39;</span> <span class="ow">or</span> <span class="n">t</span> <span class="o">==</span> <span class="s1">&#39;LONG&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">t</span> <span class="o">==</span> <span class="s1">&#39;FLOAT&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">t</span> <span class="o">==</span> <span class="s1">&#39;DOUBLE&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Data for parameter &quot;</span> <span class="o">+</span> <span class="n">param</span> <span class="o">+</span> <span class="s2">&quot; is not a numeric type.&quot;</span><span class="p">)</span></div>
<div class="viewcode-block" id="PyGeometryData.getUnit"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData.getUnit">[docs]</a> <span class="k">def</span> <span class="nf">getUnit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span>
<span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)][</span><span class="mi">2</span><span class="p">]</span>
<span class="k">if</span> <span class="n">unit</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">unit</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">unit</span></div>
<div class="viewcode-block" id="PyGeometryData.getType"><a class="viewcode-back" href="../../../api/PyGeometryData.html#awips.dataaccess.PyGeometryData.PyGeometryData.getType">[docs]</a> <span class="k">def</span> <span class="nf">getType</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
<span class="n">datatype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dataMap</span><span class="p">[</span><span class="n">param</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)][</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="n">datatype</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">datatype</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">datatype</span></div></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,273 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.PyGridData &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.PyGridData</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.PyGridData</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Implements IGridData for use by native Python clients to the Data Access</span>
<span class="c1"># Framework.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 06/03/13 #2023 dgilling Initial Creation.</span>
<span class="c1"># 10/13/16 #5916 bsteffen Correct grid shape, allow lat/lon</span>
<span class="c1"># 11/10/16 #5900 bsteffen Correct grid shape</span>
<span class="c1"># to be requested by a delegate</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="kn">import</span> <span class="nn">numpy</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">import</span> <span class="nn">six</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">IGridData</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">PyData</span>
<span class="n">NO_UNIT_CONVERT_WARNING</span> <span class="o">=</span> <span class="s2">&quot;&quot;&quot;</span>
<span class="s2">The ability to unit convert grid data is not currently available in this version of the Data Access Framework.</span>
<span class="s2">&quot;&quot;&quot;</span>
<div class="viewcode-block" id="PyGridData"><a class="viewcode-back" href="../../../api/PyGridData.html#awips.dataaccess.PyGridData.PyGridData">[docs]</a><span class="k">class</span> <span class="nc">PyGridData</span><span class="p">(</span><span class="n">IGridData</span><span class="p">,</span> <span class="n">PyData</span><span class="o">.</span><span class="n">PyData</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">gridDataRecord</span><span class="p">,</span> <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="n">latLonGrid</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">latLonDelegate</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="n">PyData</span><span class="o">.</span><span class="n">PyData</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">gridDataRecord</span><span class="p">)</span>
<span class="n">nx</span> <span class="o">=</span> <span class="n">nx</span>
<span class="n">ny</span> <span class="o">=</span> <span class="n">ny</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__parameter</span> <span class="o">=</span> <span class="n">gridDataRecord</span><span class="o">.</span><span class="n">getParameter</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__unit</span> <span class="o">=</span> <span class="n">gridDataRecord</span><span class="o">.</span><span class="n">getUnit</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__gridData</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">gridDataRecord</span><span class="o">.</span><span class="n">getGridData</span><span class="p">()),</span> <span class="p">(</span><span class="n">ny</span><span class="p">,</span> <span class="n">nx</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__latLonGrid</span> <span class="o">=</span> <span class="n">latLonGrid</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__latLonDelegate</span> <span class="o">=</span> <span class="n">latLonDelegate</span>
<div class="viewcode-block" id="PyGridData.getParameter"><a class="viewcode-back" href="../../../api/PyGridData.html#awips.dataaccess.PyGridData.PyGridData.getParameter">[docs]</a> <span class="k">def</span> <span class="nf">getParameter</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__parameter</span></div>
<div class="viewcode-block" id="PyGridData.getUnit"><a class="viewcode-back" href="../../../api/PyGridData.html#awips.dataaccess.PyGridData.PyGridData.getUnit">[docs]</a> <span class="k">def</span> <span class="nf">getUnit</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__unit</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__unit</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</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">__unit</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__unit</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__unit</span></div>
<div class="viewcode-block" id="PyGridData.getRawData"><a class="viewcode-back" href="../../../api/PyGridData.html#awips.dataaccess.PyGridData.PyGridData.getRawData">[docs]</a> <span class="k">def</span> <span class="nf">getRawData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="c1"># TODO: Find a proper python library that deals will with numpy and</span>
<span class="c1"># javax.measure style unit strings and hook it in to this method to</span>
<span class="c1"># allow end-users to perform unit conversion for grid data.</span>
<span class="k">if</span> <span class="n">unit</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="n">NO_UNIT_CONVERT_WARNING</span><span class="p">,</span> <span class="n">stacklevel</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__gridData</span></div>
<div class="viewcode-block" id="PyGridData.getLatLonCoords"><a class="viewcode-back" href="../../../api/PyGridData.html#awips.dataaccess.PyGridData.PyGridData.getLatLonCoords">[docs]</a> <span class="k">def</span> <span class="nf">getLatLonCoords</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__latLonGrid</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__latLonGrid</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__latLonDelegate</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__latLonDelegate</span><span class="p">()</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__latLonGrid</span></div></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,466 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.dataaccess.ThriftClientRouter &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li><a href="../dataaccess.html">awips.dataaccess</a> &raquo;</li>
<li>awips.dataaccess.ThriftClientRouter</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.dataaccess.ThriftClientRouter</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Routes requests to the Data Access Framework through Python Thrift.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 05/21/13 2023 dgilling Initial Creation.</span>
<span class="c1"># 01/06/14 2537 bsteffen Share geometry WKT.</span>
<span class="c1"># 03/03/14 2673 bsteffen Add ability to query only ref times.</span>
<span class="c1"># 07/22/14 3185 njensen Added optional/default args to newDataRequest</span>
<span class="c1"># 07/23/14 3185 njensen Added new methods</span>
<span class="c1"># 07/30/14 3185 njensen Renamed valid identifiers to optional</span>
<span class="c1"># 06/30/15 4569 nabowle Use hex WKB for geometries.</span>
<span class="c1"># 04/13/15 5379 tgurney Add getIdentifierValues()</span>
<span class="c1"># 06/01/16 5587 tgurney Add new signatures for</span>
<span class="c1"># getRequiredIdentifiers() and</span>
<span class="c1"># getOptionalIdentifiers()</span>
<span class="c1"># 08/01/16 2416 tgurney Add getNotificationFilter()</span>
<span class="c1"># 10/13/16 5916 bsteffen Correct grid shape, allow lazy grid lat/lon</span>
<span class="c1"># 10/26/16 5919 njensen Speed up geometry creation in getGeometryData()</span>
<span class="c1">#</span>
<span class="kn">import</span> <span class="nn">numpy</span>
<span class="kn">import</span> <span class="nn">six</span>
<span class="kn">import</span> <span class="nn">shapely.wkb</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.impl</span> <span class="kn">import</span> <span class="n">DefaultDataRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetAvailableLocationNamesRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetAvailableTimesRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetGeometryDataRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetGridDataRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetGridLatLonRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetAvailableParametersRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetAvailableLevelsRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetRequiredIdentifiersRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetOptionalIdentifiersRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetIdentifierValuesRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetSupportedDatatypesRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request</span> <span class="kn">import</span> <span class="n">GetNotificationFilterRequest</span>
<span class="kn">from</span> <span class="nn">awips</span> <span class="kn">import</span> <span class="n">ThriftClient</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">PyGeometryData</span>
<span class="kn">from</span> <span class="nn">awips.dataaccess</span> <span class="kn">import</span> <span class="n">PyGridData</span>
<div class="viewcode-block" id="LazyGridLatLon"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.LazyGridLatLon">[docs]</a><span class="k">class</span> <span class="nc">LazyGridLatLon</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">client</span><span class="p">,</span> <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="n">envelope</span><span class="p">,</span> <span class="n">crsWkt</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_latLonGrid</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_client</span> <span class="o">=</span> <span class="n">client</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_request</span> <span class="o">=</span> <span class="n">GetGridLatLonRequest</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_request</span><span class="o">.</span><span class="n">setNx</span><span class="p">(</span><span class="n">nx</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_request</span><span class="o">.</span><span class="n">setNy</span><span class="p">(</span><span class="n">ny</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_request</span><span class="o">.</span><span class="n">setEnvelope</span><span class="p">(</span><span class="n">envelope</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_request</span><span class="o">.</span><span class="n">setCrsWkt</span><span class="p">(</span><span class="n">crsWkt</span><span class="p">)</span>
<span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># Its important that the data is cached internally so that if multiple</span>
<span class="c1"># GridData are sharing the same delegate then they can also share a</span>
<span class="c1"># single request for the LatLon information.</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_latLonGrid</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_request</span><span class="p">)</span>
<span class="n">nx</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">getNx</span><span class="p">()</span>
<span class="n">ny</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">getNy</span><span class="p">()</span>
<span class="n">latData</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">getLats</span><span class="p">()),</span> <span class="p">(</span><span class="n">ny</span><span class="p">,</span> <span class="n">nx</span><span class="p">))</span>
<span class="n">lonData</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">getLons</span><span class="p">()),</span> <span class="p">(</span><span class="n">ny</span><span class="p">,</span> <span class="n">nx</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_latLonGrid</span> <span class="o">=</span> <span class="p">(</span><span class="n">lonData</span><span class="p">,</span> <span class="n">latData</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_latLonGrid</span></div>
<div class="viewcode-block" id="ThriftClientRouter"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter">[docs]</a><span class="k">class</span> <span class="nc">ThriftClientRouter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="s1">&#39;localhost&#39;</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_client</span> <span class="o">=</span> <span class="n">ThriftClient</span><span class="o">.</span><span class="n">ThriftClient</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_lazyLoadGridLatLon</span> <span class="o">=</span> <span class="kc">False</span>
<div class="viewcode-block" id="ThriftClientRouter.setLazyLoadGridLatLon"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.setLazyLoadGridLatLon">[docs]</a> <span class="k">def</span> <span class="nf">setLazyLoadGridLatLon</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lazyLoadGridLatLon</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_lazyLoadGridLatLon</span> <span class="o">=</span> <span class="n">lazyLoadGridLatLon</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getAvailableTimes"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getAvailableTimes">[docs]</a> <span class="k">def</span> <span class="nf">getAvailableTimes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">refTimeOnly</span><span class="p">):</span>
<span class="n">timesRequest</span> <span class="o">=</span> <span class="n">GetAvailableTimesRequest</span><span class="p">()</span>
<span class="n">timesRequest</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">timesRequest</span><span class="o">.</span><span class="n">setRefTimeOnly</span><span class="p">(</span><span class="n">refTimeOnly</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">timesRequest</span><span class="p">)</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getGridData"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getGridData">[docs]</a> <span class="k">def</span> <span class="nf">getGridData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">times</span><span class="p">):</span>
<span class="n">gridDataRequest</span> <span class="o">=</span> <span class="n">GetGridDataRequest</span><span class="p">()</span>
<span class="n">gridDataRequest</span><span class="o">.</span><span class="n">setIncludeLatLonData</span><span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lazyLoadGridLatLon</span><span class="p">)</span>
<span class="n">gridDataRequest</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="c1"># if we have an iterable times instance, then the user must have asked</span>
<span class="c1"># for grid data with the List of DataTime objects</span>
<span class="c1"># else, we assume it was a single TimeRange that was meant for the</span>
<span class="c1"># request</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">iter</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="n">gridDataRequest</span><span class="o">.</span><span class="n">setRequestedTimes</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
<span class="n">gridDataRequest</span><span class="o">.</span><span class="n">setRequestedPeriod</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">gridDataRequest</span><span class="p">)</span>
<span class="n">locSpecificData</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">locNames</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">getSiteNxValues</span><span class="p">()</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
<span class="k">for</span> <span class="n">location</span> <span class="ow">in</span> <span class="n">locNames</span><span class="p">:</span>
<span class="n">nx</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">getSiteNxValues</span><span class="p">()[</span><span class="n">location</span><span class="p">]</span>
<span class="n">ny</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">getSiteNyValues</span><span class="p">()[</span><span class="n">location</span><span class="p">]</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lazyLoadGridLatLon</span><span class="p">:</span>
<span class="n">envelope</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">getSiteEnvelopes</span><span class="p">()[</span><span class="n">location</span><span class="p">]</span>
<span class="n">crsWkt</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">getSiteCrsWkt</span><span class="p">()[</span><span class="n">location</span><span class="p">]</span>
<span class="n">delegate</span> <span class="o">=</span> <span class="n">LazyGridLatLon</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="p">,</span> <span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="n">envelope</span><span class="p">,</span> <span class="n">crsWkt</span><span class="p">)</span>
<span class="n">locSpecificData</span><span class="p">[</span><span class="n">location</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="n">delegate</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">latData</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="n">response</span><span class="o">.</span><span class="n">getSiteLatGrids</span><span class="p">()[</span><span class="n">location</span><span class="p">]),</span> <span class="p">(</span><span class="n">ny</span><span class="p">,</span> <span class="n">nx</span><span class="p">))</span>
<span class="n">lonData</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="n">response</span><span class="o">.</span><span class="n">getSiteLonGrids</span><span class="p">()[</span><span class="n">location</span><span class="p">]),</span> <span class="p">(</span><span class="n">ny</span><span class="p">,</span> <span class="n">nx</span><span class="p">))</span>
<span class="n">locSpecificData</span><span class="p">[</span><span class="n">location</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">nx</span><span class="p">,</span> <span class="n">ny</span><span class="p">,</span> <span class="p">(</span><span class="n">lonData</span><span class="p">,</span> <span class="n">latData</span><span class="p">))</span>
<span class="n">retVal</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">gridDataRecord</span> <span class="ow">in</span> <span class="n">response</span><span class="o">.</span><span class="n">getGridData</span><span class="p">():</span>
<span class="n">locationName</span> <span class="o">=</span> <span class="n">gridDataRecord</span><span class="o">.</span><span class="n">getLocationName</span><span class="p">()</span>
<span class="k">if</span> <span class="n">locationName</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="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="n">locData</span> <span class="o">=</span> <span class="n">locSpecificData</span><span class="p">[</span><span class="n">locationName</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">locData</span> <span class="o">=</span> <span class="n">locSpecificData</span><span class="p">[</span><span class="n">locationName</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">locData</span> <span class="o">=</span> <span class="n">locSpecificData</span><span class="p">[</span><span class="n">locationName</span><span class="p">]</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lazyLoadGridLatLon</span><span class="p">:</span>
<span class="n">retVal</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">PyGridData</span><span class="o">.</span><span class="n">PyGridData</span><span class="p">(</span><span class="n">gridDataRecord</span><span class="p">,</span> <span class="n">locData</span><span class="p">[</span>
<span class="mi">0</span><span class="p">],</span> <span class="n">locData</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">latLonDelegate</span><span class="o">=</span><span class="n">locData</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">retVal</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">PyGridData</span><span class="o">.</span><span class="n">PyGridData</span><span class="p">(</span>
<span class="n">gridDataRecord</span><span class="p">,</span> <span class="n">locData</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">locData</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">locData</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span>
<span class="k">return</span> <span class="n">retVal</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getGeometryData"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getGeometryData">[docs]</a> <span class="k">def</span> <span class="nf">getGeometryData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">times</span><span class="p">):</span>
<span class="n">geoDataRequest</span> <span class="o">=</span> <span class="n">GetGeometryDataRequest</span><span class="p">()</span>
<span class="n">geoDataRequest</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="c1"># if we have an iterable times instance, then the user must have asked</span>
<span class="c1"># for geometry data with the List of DataTime objects</span>
<span class="c1"># else, we assume it was a single TimeRange that was meant for the</span>
<span class="c1"># request</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">iter</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="n">geoDataRequest</span><span class="o">.</span><span class="n">setRequestedTimes</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
<span class="n">geoDataRequest</span><span class="o">.</span><span class="n">setRequestedPeriod</span><span class="p">(</span><span class="n">times</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">geoDataRequest</span><span class="p">)</span>
<span class="n">geometries</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">wkb</span> <span class="ow">in</span> <span class="n">response</span><span class="o">.</span><span class="n">getGeometryWKBs</span><span class="p">():</span>
<span class="c1"># the wkb is a numpy.ndarray of dtype int8</span>
<span class="c1"># convert the bytearray to a byte string and load it</span>
<span class="n">geometries</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">shapely</span><span class="o">.</span><span class="n">wkb</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">wkb</span><span class="o">.</span><span class="n">tostring</span><span class="p">()))</span>
<span class="n">retVal</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">geoDataRecord</span> <span class="ow">in</span> <span class="n">response</span><span class="o">.</span><span class="n">getGeoData</span><span class="p">():</span>
<span class="n">geom</span> <span class="o">=</span> <span class="n">geometries</span><span class="p">[</span><span class="n">geoDataRecord</span><span class="o">.</span><span class="n">getGeometryWKBindex</span><span class="p">()]</span>
<span class="n">retVal</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">PyGeometryData</span><span class="o">.</span><span class="n">PyGeometryData</span><span class="p">(</span><span class="n">geoDataRecord</span><span class="p">,</span> <span class="n">geom</span><span class="p">))</span>
<span class="k">return</span> <span class="n">retVal</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getAvailableLocationNames"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getAvailableLocationNames">[docs]</a> <span class="k">def</span> <span class="nf">getAvailableLocationNames</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="n">locNamesRequest</span> <span class="o">=</span> <span class="n">GetAvailableLocationNamesRequest</span><span class="p">()</span>
<span class="n">locNamesRequest</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">locNamesRequest</span><span class="p">)</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">response</span>
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">response</span><span class="p">]</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getAvailableParameters"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getAvailableParameters">[docs]</a> <span class="k">def</span> <span class="nf">getAvailableParameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="n">paramReq</span> <span class="o">=</span> <span class="n">GetAvailableParametersRequest</span><span class="p">()</span>
<span class="n">paramReq</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">paramReq</span><span class="p">)</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">response</span>
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">response</span><span class="p">]</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getAvailableLevels"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getAvailableLevels">[docs]</a> <span class="k">def</span> <span class="nf">getAvailableLevels</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="n">levelReq</span> <span class="o">=</span> <span class="n">GetAvailableLevelsRequest</span><span class="p">()</span>
<span class="n">levelReq</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">levelReq</span><span class="p">)</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getRequiredIdentifiers"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getRequiredIdentifiers">[docs]</a> <span class="k">def</span> <span class="nf">getRequiredIdentifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="o">==</span> <span class="n">request</span><span class="p">:</span>
<span class="c1"># Handle old version getRequiredIdentifiers(str)</span>
<span class="n">request</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">newDataRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">idReq</span> <span class="o">=</span> <span class="n">GetRequiredIdentifiersRequest</span><span class="p">()</span>
<span class="n">idReq</span><span class="o">.</span><span class="n">setRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">idReq</span><span class="p">)</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">response</span>
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">response</span><span class="p">]</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getOptionalIdentifiers"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getOptionalIdentifiers">[docs]</a> <span class="k">def</span> <span class="nf">getOptionalIdentifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="o">==</span> <span class="n">request</span><span class="p">:</span>
<span class="c1"># Handle old version getOptionalIdentifiers(str)</span>
<span class="n">request</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">newDataRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">idReq</span> <span class="o">=</span> <span class="n">GetOptionalIdentifiersRequest</span><span class="p">()</span>
<span class="n">idReq</span><span class="o">.</span><span class="n">setRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">idReq</span><span class="p">)</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">response</span>
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">response</span><span class="p">]</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getIdentifierValues"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getIdentifierValues">[docs]</a> <span class="k">def</span> <span class="nf">getIdentifierValues</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">identifierKey</span><span class="p">):</span>
<span class="n">idValReq</span> <span class="o">=</span> <span class="n">GetIdentifierValuesRequest</span><span class="p">()</span>
<span class="n">idValReq</span><span class="o">.</span><span class="n">setIdentifierKey</span><span class="p">(</span><span class="n">identifierKey</span><span class="p">)</span>
<span class="n">idValReq</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">idValReq</span><span class="p">)</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">response</span>
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">response</span><span class="p">]</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.newDataRequest"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.newDataRequest">[docs]</a> <span class="k">def</span> <span class="nf">newDataRequest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">datatype</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="p">[],</span> <span class="n">levels</span><span class="o">=</span><span class="p">[],</span> <span class="n">locationNames</span><span class="o">=</span><span class="p">[],</span>
<span class="n">envelope</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">DefaultDataRequest</span><span class="p">()</span>
<span class="k">if</span> <span class="n">datatype</span><span class="p">:</span>
<span class="n">req</span><span class="o">.</span><span class="n">setDatatype</span><span class="p">(</span><span class="n">datatype</span><span class="p">)</span>
<span class="k">if</span> <span class="n">parameters</span><span class="p">:</span>
<span class="n">req</span><span class="o">.</span><span class="n">setParameters</span><span class="p">(</span><span class="o">*</span><span class="n">parameters</span><span class="p">)</span>
<span class="k">if</span> <span class="n">levels</span><span class="p">:</span>
<span class="n">req</span><span class="o">.</span><span class="n">setLevels</span><span class="p">(</span><span class="o">*</span><span class="n">levels</span><span class="p">)</span>
<span class="k">if</span> <span class="n">locationNames</span><span class="p">:</span>
<span class="n">req</span><span class="o">.</span><span class="n">setLocationNames</span><span class="p">(</span><span class="o">*</span><span class="n">locationNames</span><span class="p">)</span>
<span class="k">if</span> <span class="n">envelope</span><span class="p">:</span>
<span class="n">req</span><span class="o">.</span><span class="n">setEnvelope</span><span class="p">(</span><span class="n">envelope</span><span class="p">)</span>
<span class="k">if</span> <span class="n">kwargs</span><span class="p">:</span>
<span class="c1"># any args leftover are assumed to be identifiers</span>
<span class="n">req</span><span class="o">.</span><span class="n">identifiers</span> <span class="o">=</span> <span class="n">kwargs</span>
<span class="k">return</span> <span class="n">req</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getSupportedDatatypes"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getSupportedDatatypes">[docs]</a> <span class="k">def</span> <span class="nf">getSupportedDatatypes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">GetSupportedDatatypesRequest</span><span class="p">())</span>
<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">response</span>
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">response</span><span class="p">]</span>
<span class="k">return</span> <span class="n">response</span></div>
<div class="viewcode-block" id="ThriftClientRouter.getNotificationFilter"><a class="viewcode-back" href="../../../api/ThriftClientRouter.html#awips.dataaccess.ThriftClientRouter.ThriftClientRouter.getNotificationFilter">[docs]</a> <span class="k">def</span> <span class="nf">getNotificationFilter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="n">notifReq</span> <span class="o">=</span> <span class="n">GetNotificationFilterRequest</span><span class="p">()</span>
<span class="n">notifReq</span><span class="o">.</span><span class="n">setRequestParameters</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">notifReq</span><span class="p">)</span>
<span class="k">return</span> <span class="n">response</span></div></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,359 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>awips.gfe.IFPClient &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
<script src="../../../_static/jquery.js"></script>
<script src="../../../_static/underscore.js"></script>
<script src="../../../_static/doctools.js"></script>
<script src="../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../../../about.html" />
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../../index.html">Module code</a> &raquo;</li>
<li>awips.gfe.IFPClient</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for awips.gfe.IFPClient</h1><div class="highlight"><pre>
<span></span><span class="c1">#</span>
<span class="c1"># Provides a Python-based interface for executing GFE requests.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1"># SOFTWARE HISTORY</span>
<span class="c1">#</span>
<span class="c1"># Date Ticket# Engineer Description</span>
<span class="c1"># ------------ ---------- ----------- --------------------------</span>
<span class="c1"># 07/26/12 dgilling Initial Creation.</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="kn">from</span> <span class="nn">awips</span> <span class="kn">import</span> <span class="n">ThriftClient</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects</span> <span class="kn">import</span> <span class="n">DatabaseID</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.db.objects</span> <span class="kn">import</span> <span class="n">ParmID</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request</span> <span class="kn">import</span> <span class="n">CommitGridsRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request</span> <span class="kn">import</span> <span class="n">GetGridInventoryRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request</span> <span class="kn">import</span> <span class="n">GetParmListRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request</span> <span class="kn">import</span> <span class="n">GetSelectTimeRangeRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request</span> <span class="kn">import</span> <span class="n">CommitGridRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.message</span> <span class="kn">import</span> <span class="n">WsId</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.site.requests</span> <span class="kn">import</span> <span class="n">GetActiveSitesRequest</span>
<span class="kn">from</span> <span class="nn">dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.message</span> <span class="kn">import</span> <span class="n">ServerResponse</span>
<div class="viewcode-block" id="IFPClient"><a class="viewcode-back" href="../../../api/IFPClient.html#awips.gfe.IFPClient.IFPClient">[docs]</a><span class="k">class</span> <span class="nc">IFPClient</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">,</span> <span class="n">user</span><span class="p">,</span> <span class="n">site</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">progName</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__thrift</span> <span class="o">=</span> <span class="n">ThriftClient</span><span class="o">.</span><span class="n">ThriftClient</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__wsId</span> <span class="o">=</span> <span class="n">WsId</span><span class="p">(</span><span class="n">userName</span><span class="o">=</span><span class="n">user</span><span class="p">,</span> <span class="n">progName</span><span class="o">=</span><span class="n">progName</span><span class="p">)</span>
<span class="c1"># retrieve default site</span>
<span class="k">if</span> <span class="n">site</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getSiteID</span><span class="p">()</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">())</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">site</span> <span class="o">=</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__siteId</span> <span class="o">=</span> <span class="n">site</span>
<div class="viewcode-block" id="IFPClient.commitGrid"><a class="viewcode-back" href="../../../api/IFPClient.html#awips.gfe.IFPClient.IFPClient.commitGrid">[docs]</a> <span class="k">def</span> <span class="nf">commitGrid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">CommitGridRequest</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__commitGrid</span><span class="p">([</span><span class="n">request</span><span class="p">])</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__isHomogenousIterable</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">CommitGridRequest</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__commitGrid</span><span class="p">([</span><span class="n">cgr</span> <span class="k">for</span> <span class="n">cgr</span> <span class="ow">in</span> <span class="n">request</span><span class="p">])</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Invalid type: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">request</span><span class="p">))</span> <span class="o">+</span>
<span class="s2">&quot; for commitGrid(). Only accepts CommitGridRequest or lists of CommitGridRequest.&quot;</span><span class="p">)</span></div>
<span class="k">def</span> <span class="nf">__commitGrid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">requests</span><span class="p">):</span>
<span class="n">ssr</span> <span class="o">=</span> <span class="n">ServerResponse</span><span class="p">()</span>
<span class="n">request</span> <span class="o">=</span> <span class="n">CommitGridsRequest</span><span class="p">()</span>
<span class="n">request</span><span class="o">.</span><span class="n">setCommits</span><span class="p">(</span><span class="n">requests</span><span class="p">)</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__makeRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getMessages</span><span class="p">())</span>
<span class="k">return</span> <span class="n">ssr</span>
<div class="viewcode-block" id="IFPClient.getParmList"><a class="viewcode-back" href="../../../api/IFPClient.html#awips.gfe.IFPClient.IFPClient.getParmList">[docs]</a> <span class="k">def</span> <span class="nf">getParmList</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pid</span><span class="p">):</span>
<span class="n">argType</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">pid</span><span class="p">)</span>
<span class="k">if</span> <span class="n">argType</span> <span class="ow">is</span> <span class="n">DatabaseID</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getParmList</span><span class="p">([</span><span class="n">pid</span><span class="p">])</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__isHomogenousIterable</span><span class="p">(</span><span class="n">pid</span><span class="p">,</span> <span class="n">DatabaseID</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getParmList</span><span class="p">([</span><span class="n">dbid</span> <span class="k">for</span> <span class="n">dbid</span> <span class="ow">in</span> <span class="n">pid</span><span class="p">])</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Invalid type: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">argType</span><span class="p">)</span> <span class="o">+</span>
<span class="s2">&quot; for getParmList(). Only accepts DatabaseID or lists of DatabaseID.&quot;</span><span class="p">)</span></div>
<span class="k">def</span> <span class="nf">__getParmList</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ids</span><span class="p">):</span>
<span class="n">ssr</span> <span class="o">=</span> <span class="n">ServerResponse</span><span class="p">()</span>
<span class="n">request</span> <span class="o">=</span> <span class="n">GetParmListRequest</span><span class="p">()</span>
<span class="n">request</span><span class="o">.</span><span class="n">setDbIds</span><span class="p">(</span><span class="n">ids</span><span class="p">)</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__makeRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getMessages</span><span class="p">())</span>
<span class="n">parmlist</span> <span class="o">=</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()</span> <span class="k">if</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">parmlist</span><span class="p">)</span>
<span class="k">return</span> <span class="n">ssr</span>
<span class="k">def</span> <span class="nf">__isHomogenousIterable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">iterable</span><span class="p">,</span> <span class="n">classType</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">iterator</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">iterable</span><span class="p">)</span>
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">iterator</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="n">item</span><span class="p">,</span> <span class="n">classType</span><span class="p">):</span>
<span class="k">return</span> <span class="kc">False</span>
<span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span>
<span class="k">return</span> <span class="kc">True</span>
<div class="viewcode-block" id="IFPClient.getGridInventory"><a class="viewcode-back" href="../../../api/IFPClient.html#awips.gfe.IFPClient.IFPClient.getGridInventory">[docs]</a> <span class="k">def</span> <span class="nf">getGridInventory</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parmID</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parmID</span><span class="p">,</span> <span class="n">ParmID</span><span class="p">):</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getGridInventory</span><span class="p">([</span><span class="n">parmID</span><span class="p">])</span>
<span class="n">inventoryList</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">inventoryList</span> <span class="o">=</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()[</span><span class="n">parmID</span><span class="p">]</span>
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
<span class="c1"># no-op, we&#39;ve already default the TimeRange list to empty</span>
<span class="k">pass</span>
<span class="n">sr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">inventoryList</span><span class="p">)</span>
<span class="k">return</span> <span class="n">sr</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__isHomogenousIterable</span><span class="p">(</span><span class="n">parmID</span><span class="p">,</span> <span class="n">ParmID</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getGridInventory</span><span class="p">([</span><span class="n">pid</span> <span class="k">for</span> <span class="n">pid</span> <span class="ow">in</span> <span class="n">parmID</span><span class="p">])</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Invalid type: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">parmID</span><span class="p">))</span> <span class="o">+</span>
<span class="s2">&quot; specified to getGridInventory(). Accepts ParmID or lists of ParmID.&quot;</span><span class="p">)</span></div>
<span class="k">def</span> <span class="nf">__getGridInventory</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parmIDs</span><span class="p">):</span>
<span class="n">ssr</span> <span class="o">=</span> <span class="n">ServerResponse</span><span class="p">()</span>
<span class="n">request</span> <span class="o">=</span> <span class="n">GetGridInventoryRequest</span><span class="p">()</span>
<span class="n">request</span><span class="o">.</span><span class="n">setParmIds</span><span class="p">(</span><span class="n">parmIDs</span><span class="p">)</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__makeRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getMessages</span><span class="p">())</span>
<span class="n">trs</span> <span class="o">=</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()</span> <span class="k">if</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">{}</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">trs</span><span class="p">)</span>
<span class="k">return</span> <span class="n">ssr</span>
<div class="viewcode-block" id="IFPClient.getSelectTR"><a class="viewcode-back" href="../../../api/IFPClient.html#awips.gfe.IFPClient.IFPClient.getSelectTR">[docs]</a> <span class="k">def</span> <span class="nf">getSelectTR</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
<span class="n">request</span> <span class="o">=</span> <span class="n">GetSelectTimeRangeRequest</span><span class="p">()</span>
<span class="n">request</span><span class="o">.</span><span class="n">setName</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__makeRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">ssr</span> <span class="o">=</span> <span class="n">ServerResponse</span><span class="p">()</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getMessages</span><span class="p">())</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">())</span>
<span class="k">return</span> <span class="n">ssr</span></div>
<div class="viewcode-block" id="IFPClient.getSiteID"><a class="viewcode-back" href="../../../api/IFPClient.html#awips.gfe.IFPClient.IFPClient.getSiteID">[docs]</a> <span class="k">def</span> <span class="nf">getSiteID</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">ssr</span> <span class="o">=</span> <span class="n">ServerResponse</span><span class="p">()</span>
<span class="n">request</span> <span class="o">=</span> <span class="n">GetActiveSitesRequest</span><span class="p">()</span>
<span class="n">sr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__makeRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="n">ssr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">(</span><span class="n">sr</span><span class="o">.</span><span class="n">getMessages</span><span class="p">())</span>
<span class="n">ids</span> <span class="o">=</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()</span> <span class="k">if</span> <span class="n">sr</span><span class="o">.</span><span class="n">getPayload</span><span class="p">()</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span>
<span class="n">sr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">ids</span><span class="p">)</span>
<span class="k">return</span> <span class="n">sr</span></div>
<span class="k">def</span> <span class="nf">__makeRequest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">request</span><span class="o">.</span><span class="n">setSiteID</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__siteId</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">request</span><span class="o">.</span><span class="n">setWorkstationID</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__wsId</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="n">sr</span> <span class="o">=</span> <span class="n">ServerResponse</span><span class="p">()</span>
<span class="n">response</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__thrift</span><span class="o">.</span><span class="n">sendRequest</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ThriftClient</span><span class="o">.</span><span class="n">ThriftRequestException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">sr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)])</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">sr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">getPayload</span><span class="p">())</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="n">sr</span><span class="o">.</span><span class="n">setPayload</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">sr</span><span class="o">.</span><span class="n">setMessages</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">getMessages</span><span class="p">())</span>
<span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span>
<span class="c1"># not a server response, nothing else to do</span>
<span class="k">pass</span>
<span class="k">return</span> <span class="n">sr</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

218
_modules/index.html Normal file
View file

@ -0,0 +1,218 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Overview: module code &mdash; python-awips documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home" alt="Documentation Home"> python-awips
</a>
<div class="version">
18.1.7
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../api/index.html">API Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../datatypes.html">Available Data Types</a></li>
<li class="toctree-l1"><a class="reference internal" href="../examples/index.html">Data Plotting Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev.html">Development Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../gridparms.html">Grid Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="../about.html">About Unidata AWIPS</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">python-awips</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>Overview: module code</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>All modules for which code is available</h1>
<ul><li><a href="awips/DateTimeConverter.html">awips.DateTimeConverter</a></li>
<li><a href="awips/RadarCommon.html">awips.RadarCommon</a></li>
<li><a href="awips/ThriftClient.html">awips.ThriftClient</a></li>
<li><a href="awips/TimeUtil.html">awips.TimeUtil</a></li>
<li><a href="awips/dataaccess.html">awips.dataaccess</a></li>
<ul><li><a href="awips/dataaccess/CombinedTimeQuery.html">awips.dataaccess.CombinedTimeQuery</a></li>
<li><a href="awips/dataaccess/DataAccessLayer.html">awips.dataaccess.DataAccessLayer</a></li>
<li><a href="awips/dataaccess/ModelSounding.html">awips.dataaccess.ModelSounding</a></li>
<li><a href="awips/dataaccess/PyData.html">awips.dataaccess.PyData</a></li>
<li><a href="awips/dataaccess/PyGeometryData.html">awips.dataaccess.PyGeometryData</a></li>
<li><a href="awips/dataaccess/PyGridData.html">awips.dataaccess.PyGridData</a></li>
<li><a href="awips/dataaccess/ThriftClientRouter.html">awips.dataaccess.ThriftClientRouter</a></li>
</ul><li><a href="awips/gfe/IFPClient.html">awips.gfe.IFPClient</a></li>
</ul>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, Unidata
</p>
</div>
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>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>

181
_sources/about.rst.txt Normal file
View file

@ -0,0 +1,181 @@
===================
About Unidata AWIPS
===================
AWIPS is a weather forecasting display and analysis package
developed by the National Weather Service and Raytheon. AWIPS is a
Java application consisting of a data-rendering client (CAVE, which runs
on Red Hat/CentOS Linux and Mac OS X) and a backend data server (EDEX,
which runs only on Linux)
AWIPS takes a unified approach to data ingest, and most data types
follow a standard path through the system. At a high level, data flow
describes the path taken by a piece of data from its source to its
display by a client system. This path starts with data requested and
stored by an `LDM <#ldm>`_ client and includes the decoding of the data
and storing of decoded data in a form readable and displayable by the
end user.
The AWIPS ingest and request processes are a highly distributed
system, and the messaging broken `Qpid <#qpid>`_ is used for
inter-process communication.
.. figure:: http://www.unidata.ucar.edu/software/awips2/images/awips2_coms.png
:align: center
:alt: image
image
License
-------
The AWIPS software package released by the Unidata Program Center is considered to
be in the public domain since it is released without proprietary code. As such, export
controls do not apply.  Any person is free to download, modify, distribute, or share
Unidata AWIPS in any form. Entities who modify or re-distribute Unidata AWIPS
software are encouraged to conduct their own FOSS/COTS entitlement/license review
to ensure that they remain compatible with the associated terms (see
FOSS_COTS_License.pdf at `https://github.com/Unidata/awips2 <https://github.com/Unidata/awips2>`_).
About AWIPS
-----------
The primary AWIPS application for data ingest, processing, and
storage is the Environmental Data EXchange (**EDEX**) server; the
primary AWIPS application for visualization/data manipulation is the
Common AWIPS Visualization Environment (**CAVE**) client, which is
typically installed on a workstation separate from other AWIPS
components.
In addition to programs developed specifically for AWIPS, AWIPS uses
several commercial off-the-shelf (COTS) and Free or Open Source software
(FOSS) products to assist in its operation. The following components,
working together and communicating, compose the entire AWIPS system.
EDEX
----
The main server for AWIPS. Qpid sends alerts to EDEX when data stored
by the LDM is ready for processing. These Qpid messages include file
header information which allows EDEX to determine the appropriate data
decoder to use. The default ingest server (simply named ingest) handles
all data ingest other than grib messages, which are processed by a
separate ingestGrib server. After decoding, EDEX writes metadata to the
database via Postgres and saves the processed data in HDF5 via PyPIES. A
third EDEX server, request, feeds requested data to CAVE clients. EDEX
ingest and request servers are started and stopped with the commands
``edex start`` and ``edex stop``, which runs the system script
``/etc/rc.d/init.d/edex_camel``
CAVE
----
Common AWIPS Visualization Environment. The data rendering and
visualization tool for AWIPS. CAVE contains of a number of different
data display configurations called perspectives. Perspectives used in
operational forecasting environments include **D2D** (Display
Two-Dimensional), **GFE** (Graphical Forecast Editor), and **NCP**
(National Centers Perspective). CAVE is started with the command
``/awips2/cave/cave.sh`` or ``cave.sh``
.. figure:: http://www.unidata.ucar.edu/software/awips2/images/Unidata_AWIPS2_CAVE.png
:align: center
:alt: CAVE
CAVE
Alertviz
--------
**Alertviz** is a modernized version of an AWIPS I application, designed
to present various notifications, error messages, and alarms to the user
(forecaster). AlertViz can be executed either independently or from CAVE
itself. In the Unidata CAVE client, Alertviz is run within CAVE and is
not required to be run separately. The toolbar is also **hidden from
view** and is accessed by right-click on the desktop taskbar icon.
LDM
---
`http://www.unidata.ucar.edu/software/ldm/ <http://www.unidata.ucar.edu/software/ldm/>`_
The **LDM** (Local Data Manager), developed and supported by Unidata, is
a suite of client and server programs designed for data distribution,
and is the fundamental component comprising the Unidata Internet Data
Distribution (IDD) system. In AWIPS, the LDM provides data feeds for
grids, surface observations, upper-air profiles, satellite and radar
imagery and various other meteorological datasets. The LDM writes data
directly to file and alerts EDEX via Qpid when a file is available for
processing. The LDM is started and stopped with the commands
``edex start`` and ``edex stop``, which runs the commands
``service edex_ldm start`` and ``service edex_ldm stop``
edexBridge
----------
edexBridge, invoked in the LDM configuration file
``/awips2/ldm/etc/ldmd.conf``, is used by the LDM to post "data
available" messaged to Qpid, which alerts the EDEX Ingest server that a
file is ready for processing.
Qpid
----
`http://qpid.apache.org <http://qpid.apache.org>`_
**Apache Qpid**, the Queue Processor Interface Daemon, is the messaging
system used by AWIPS to facilitate communication between services.
When the LDM receives a data file to be processed, it employs
**edexBridge** to send EDEX ingest servers a message via Qpid. When EDEX
has finished decoding the file, it sends CAVE a message via Qpid that
data are available for display or further processing. Qpid is started
and stopped by ``edex start`` and ``edex stop``, and is controlled by
the system script ``/etc/rc.d/init.d/qpidd``
PostgreSQL
----------
`http://www.postgresql.org <http://www.postgresql.org>`_
**PostgreSQL**, known simply as Postgres, is a relational database
management system (DBMS) which handles the storage and retrieval of
metadata, database tables and some decoded data. The storage and reading
of EDEX metadata is handled by the Postgres DBMS. Users may query the
metadata tables by using the termainal-based front-end for Postgres
called **psql**. Postgres is started and stopped by ``edex start`` and
``edex stop``, and is controlled by the system script
``/etc/rc.d/init.d/edex_postgres``
HDF5
----
`http://www.hdfgroup.org/HDF5/ <http://www.hdfgroup.org/HDF5/>`_
**Hierarchical Data Format (v.5)** is
the primary data storage format used by AWIPS for processed grids,
satellite and radar imagery and other products. Similar to netCDF,
developed and supported by Unidata, HDF5 supports multiple types of data
within a single file. For example, a single HDF5 file of radar data may
contain multiple volume scans of base reflectivity and base velocity as
well as derived products such as composite reflectivity. The file may
also contain data from multiple radars. HDF5 is stored in
``/awips2/edex/data/hdf5/``
PyPIES (httpd-pypies)
---------------------
**PyPIES**, Python Process Isolated Enhanced Storage, was created for
AWIPS to isolate the management of HDF5 Processed Data Storage from
the EDEX processes. PyPIES manages access, i.e., reads and writes, of
data in the HDF5 files. In a sense, PyPIES provides functionality
similar to a DBMS (i.e PostgreSQL for metadata); all data being written
to an HDF5 file is sent to PyPIES, and requests for data stored in HDF5
are processed by PyPIES.
PyPIES is implemented in two parts: 1. The PyPIES manager is a Python
application that runs as part of an Apache HTTP server, and handles
requests to store and retrieve data. 2. The PyPIES logger is a Python
process that coordinates logging. PyPIES is started and stopped by
``edex start`` and ``edex stop``, and is controlled by the system script
``/etc/rc.d/init.d/https-pypies``

View file

@ -0,0 +1,7 @@
=================
CombinedTimeQuery
=================
.. automodule:: awips.dataaccess.CombinedTimeQuery
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
===============
DataAccessLayer
===============
.. automodule:: awips.dataaccess.DataAccessLayer
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
=================
DateTimeConverter
=================
.. automodule:: awips.DateTimeConverter
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
===============================
IDataRequest (newDataRequest())
===============================
.. autoclass:: awips.dataaccess.IDataRequest
:members:
:special-members:

View file

@ -0,0 +1,7 @@
=========
IFPClient
=========
.. automodule:: awips.gfe.IFPClient
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
=============
ModelSounding
=============
.. automodule:: awips.dataaccess.ModelSounding
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
PyData
======================
.. automodule:: awips.dataaccess.PyData
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
PyGeometryData
======================
.. automodule:: awips.dataaccess.PyGeometryData
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
PyGridData
======================
.. automodule:: awips.dataaccess.PyGridData
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
RadarCommon
======================
.. automodule:: awips.RadarCommon
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
ThriftClient
======================
.. automodule:: awips.ThriftClient
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
ThriftClientRouter
======================
.. automodule:: awips.dataaccess.ThriftClientRouter
:members:
:undoc-members:

View file

@ -0,0 +1,7 @@
======================
TimeUtil
======================
.. automodule:: awips.TimeUtil
:members:
:undoc-members:

View file

@ -0,0 +1,22 @@
#################
API Documentation
#################
.. toctree::
:maxdepth: 2
DataAccessLayer
IDataRequest
PyData
PyGridData
PyGeometryData
ModelSounding
ThriftClientRouter
ThriftClient
TimeUtil
RadarCommon
IFPClient
DateTimeConverter
CombinedTimeQuery
* :ref:`genindex`

129
_sources/datatypes.rst.txt Normal file
View file

@ -0,0 +1,129 @@
====================
Available Data Types
====================
.. _awips.dataaccess.DataAccessLayer.getGeometryData(request, times=[]): api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getGeometryData
.. _awips.dataaccess.DataAccessLayer.getGridData(request, times=[]): api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getGridData
.. _RadarCommon.get_hdf5_data(idra): api/RadarCommon.html
satellite
---------
- 2-D NumPy Array
- returned by: `awips.dataaccess.DataAccessLayer.getGridData(request, times=[])`_
- example::
# Contrust a full satellite product tree
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu)
request = DataAccessLayer.newDataRequest("satellite")
creatingEntities = DataAccessLayer.getIdentifierValues(request, "creatingEntity")
for entity in creatingEntities:
print(entity)
request = DataAccessLayer.newDataRequest("satellite")
request.addIdentifier("creatingEntity", entity)
availableSectors = DataAccessLayer.getAvailableLocationNames(request)
availableSectors.sort()
for sector in availableSectors:
print(" - " + sector)
request.setLocationNames(sector)
availableProducts = DataAccessLayer.getAvailableParameters(request)
availableProducts.sort()
for product in availableProducts:
print(" - " + product)
---
binlightning
------------
- Shapely Point::
POINT (-65.65293884277344 -16.94915580749512)
- returned by: `awips.dataaccess.DataAccessLayer.getGeometryData(request, times=[])`_
- example (GLM)::
request = DataAccessLayer.newDataRequest("binlightning")
request.addIdentifier("source", "GLMgr")
request.setParameters("intensity")
times = DataAccessLayer.getAvailableTimes(request)
response = DataAccessLayer.getGeometryData(request, times[-10:-1])
for ob in response:
geom = ob.getGeometry()
---
grid
----
- 2-D NumPy Array
- returned by: `awips.dataaccess.DataAccessLayer.getGridData(request, times=[])`_
- example::
request = DataAccessLayer.newDataRequest()
request.setDatatype("grid")
request.setLocationNames("RAP13")
request.setParameters("T")
request.setLevels("2.0FHAG")
cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)
response = DataAccessLayer.getGridData(request, [fcstRun[-1]])
for grid in response:
data = grid.getRawData()
lons, lats = grid.getLatLonCoords()
---
warning
-------
- Shapely MultiPolygon, Polygon::
MULTIPOLYGON ((-92.092348410 46.782322971, ..., -92.092348410 46.782322971),
(-90.948581075 46.992865960, ..., -90.948581075 46.992865960),
...
(-92.274543999 46.652773000, ..., -92.280511999 46.656933000),
(-92.285491999 46.660741000, ..., -92.285491999 46.660741000))
- returned by: `awips.dataaccess.DataAccessLayer.getGeometryData(request, times=[])`_
- example::
request = DataAccessLayer.newDataRequest()
request.setDatatype("warning")
request.setParameters('phensig')
times = DataAccessLayer.getAvailableTimes(request)
response = DataAccessLayer.getGeometryData(request, times[-50:-1])
for ob in response:
poly = ob.getGeometry()
site = ob.getLocationName()
pd = ob.getDataTime().getValidPeriod()
ref = ob.getDataTime().getRefTime()
---
radar
-----
- 2-D NumPy Array
- returned by: `awips.dataaccess.DataAccessLayer.getGridData(request, times=[])`_
- also returned by: `RadarCommon.get_hdf5_data(idra)`_
- example::
request = DataAccessLayer.newDataRequest("radar")
request.setLocationNames("kmhx")
request.setParameters("Digital Hybrid Scan Refl")
availableLevels = DataAccessLayer.getAvailableLevels(request)
times = DataAccessLayer.getAvailableTimes(request)
response = DataAccessLayer.getGridData(request, [times[-1]])
for image in response:
data = image.getRawData()
lons, lats = image.getLatLonCoords()

654
_sources/dev.rst.txt Normal file
View file

@ -0,0 +1,654 @@
Development Guide
=================
The Data Access Framework allows developers to retrieve different types
of data without having dependencies on those types of data. It provides
a single, unified data type that can be customized by individual
implementing plug-ins to provide full functionality pertinent to each
data type.
Writing a New Factory
---------------------
Factories will most often be written in a dataplugin, but should always
be written in a common plug-in. This will allow for clean dependencies
from both CAVE and EDEX.
A new plug-ins data access class must implement IDataFactory. For ease
of use, abstract classes have been created to combine similar methods.
Data factories do not have to implement both types of data (grid and
geometry). They can if they choose, but if they choose not to, they
should do the following:
::
throw new UnsupportedOutputTypeException(request.getDatatype(), "grid");
This lets the code know that grid type is not supported for this data
factory. Depending on where the data is coming from, helpers have been
written to make writing a new data type factory easier. For example,
PluginDataObjects can use AbstractDataPluginFactory as a start and not
have to create everything from scratch.
Each data type is allowed to implement retrieval in any manner that is
felt necessary. The power of the framework means that the code
retrieving data does not have to know anything of the underlying
retrieval methods, only that it is getting data in a certain manner. To
see some examples of ways to retrieve data, reference
**SatelliteGridFactory** and **RadarGridFactory**.
Methods required for implementation:
**public DataTime[] getAvailableTimes(IDataRequest request)**
- This method returns an array of DataTime objects corresponding to
what times are available for the data being retrieved, based on the
parameters and identifiers being passed in.
**public DataTime[] getAvailableTimes(IDataRequest request, BinOffset
binOffset)**
- This method returns available times as above, only with a bin offset
applied.
Note: Both of the preceding methods can throw TimeAgnosticDataException
exceptions if times do not apply to the data type.
**public IGridData[] getGridData(IDataRequest request,
DataTime...times)**
- This method returns IGridData objects (an array) based on the request
and times to request for. There can be multiple times or a single
time.
**public IGridData[] getGridData(IDataRequest request, TimeRange
range)**
- Similar to the preceding method, this returns IGridData objects based
on a range of times.
**public IGeometryData[] getGeometryData(IDataRequest request, DataTime
times)**
- This method returns IGeometryData objects based on a request and
times.
**public IGeometryData[] getGeometryData(IDataRequest request, TimeRange
range)**
- Like the preceding method, this method returns IGeometryData objects
based on a range of times.
**public String[] getAvailableLocationNames(IDataRequest request)**
- This method returns location names that match the request. If this
does not apply to the data type, an IncompatibleRequestException
should be thrown.
Registering the Factory with the Framework
------------------------------------------
The following needs to be added in a spring file in the plug-in that
contains the new factory:
::
<bean id="radarGridFactory"
class="com.raytheon.uf.common.dataplugin.radar.dataaccess.RadarGridFactory" />
<bean factory-bean="dataAccessRegistry" factorymethod="register">
<constructor-arg value="radar"/>
<constructor-arg ref="radarGridFactory"/>
</bean>
This takes the RadarGridFactory and registers it with the registry and
allows it to be used any time the code makes a request for the data type
“radar.”
Retrieving Data Using the Factory
---------------------------------
For ease of use and more diverse use, there are multiple interfaces into
the Data Access Layer. Currently, there is a Python implementation and a
Java implementation, which have very similar method calls and work in a
similar manner. Plug-ins that want to use the data access framework to
retrieve data should include **com.raytheon.uf.common.dataaccess** as a
Required Bundle in their MANIFEST.MF.
To retrieve data using the Python interface :
::
from awips.dataaccess import DataAccessLayer
req = DataAccessLayer.newDataRequest()
req.setDatatype("grid")
req.setParameters("T")
req.setLevels("2FHAG")
req.addIdentifier("info.datasetId", "GFS40")
times = DataAccessLayer.getAvailableTimes(req)
data = DataAccessLayer.getGridData(req, times)
To retrieve data using the Java interface :
::
IDataRequest req = DataAccessLayer.newDataRequest();
req.setDatatype("grid");
req.setParameters("T");
req.setLevels("2FHAG");
req.addIdentifier("info.datasetId", "GFS40");
DataTime[] times = DataAccessLayer.getAvailableTimes(req)
IData data = DataAccessLayer.getGridData(req, times);
**newDataRequest()**
- This creates a new data request. Most often this is a
DefaultDataRequest, but saves for future implentations as well.
**setDatatype(String)**
- This is the data type being retrieved. This can be found as the value
that is registered when creating the new factory (See section above
**Registering the Factory with the Framework** [radar in that case]).
**setParameters(String...)**
- This can differ depending on data type. It is most often used as a
main difference between products.
**setLevels(String...)**
- This is often used to identify the same products on different
mathematical angles, heights, levels, etc.
**addIdentifier(String, String)**
- This differs based on data type, but is often used for more
fine-tuned querying.
Both methods return a similar set of data and can be manipulated by
their respective languages. See DataAccessLayer.py and
DataAccessLayer.java for more methods that can be called to retrieve
data and different parts of the data. Because each data type has
different parameters, levels, and identifiers, it is best to see the
actual data type for the available options. If it is undocumented, then
the best way to identify what parameters are to be used is to reference
the code.
Development Background
----------------------
In support of Hazard Services Raytheon Technical Services is building a
generic data access framework that can be called via JAVA or Python. The
data access framework code can be found within the AWIPS Baseline in
::
com.raytheon.uf.common.dataaccess
As of 2016, plugins have been written for grid, radar, satellite, Hydro
(SHEF), point data (METAR, SYNOP, Profiler, ACARS, AIREP, PIREP), maps
data, and other data types. The Factories for each can be found in the
following packages (you may need to look at the development baseline to
see these):
::
com.raytheon.uf.common.dataplugin.grid.dataaccess
com.raytheon.uf.common.dataplugin.radar.dataaccess
com.raytheon.uf.common.dataplugin.satellite.dataaccess
com.raytheon.uf.common.dataplugin.binlightning.dataaccess
com.raytheon.uf.common.dataplugin.sfc.dataaccess
com.raytheon.uf.common.dataplugin.sfcobs.dataaccess
com.raytheon.uf.common.dataplugin.acars.dataaccess
com.raytheon.uf.common.dataplugin.ffmp.dataaccess
com.raytheon.uf.common.dataplugin.bufrua.dataaccess
com.raytheon.uf.common.dataplugin.profiler.dataaccess
com.raytheon.uf.common.dataplugin.moddelsounding.dataaccess
com.raytheon.uf.common.dataplugin.ldadmesonet.dataaccess
com.raytheon.uf.common.dataplugin.binlightning.dataaccess
com.raytheon.uf.common.dataplugin.gfe.dataaccess
com.raytheon.uf.common.hydro.dataaccess
com.raytheon.uf.common.pointdata.dataaccess
com.raytheon.uf.common.dataplugin.maps.dataaccess
Additional data types may be added in the future. To determine what
datatypes are supported display the "type hierarchy" associated with the
classes
**AbstractGridDataPluginFactory**,
**AbstractGeometryDatabaseFactory**, and
**AbstractGeometryTimeAgnosticDatabaseFactory**.
The following content was taken from the design review document which is
attached and modified slightly.
Design/Implementation
---------------------
The Data Access Framework is designed to provide a consistent interface
for requesting and using geospatial data within CAVE or EDEX. Examples
of geospatial data are grids, satellite, radar, metars, maps, river gage
heights, FFMP basin data, airmets, etc. To allow for convenient use of
geospatial data, the framework will support two types of requests: grids
and geometries (points, polygons, etc). The framework will also hide
implementation details of specific data types from users, making it
easier to use data without worrying about how the data objects are
structured or retrieved.
A suggested mapping of some current data types to one of the two
supported data requests is listed below. This list is not definitive and
can be expanded. If a developer can dream up an interpretation of the
data in the other supported request type, that support can be added.
Grids
- Grib
- Satellite
- Radar
- GFE
Geometries
- Map (states, counties, zones, etc)
- Hydro DB (IHFS)
- Obs (metar)
- FFMP
- Hazard
- Warning
- CCFP
- Airmet
The framework is designed around the concept of each data type plugin
contributing the necessary code for the framework to support its data.
For example, the satellite plugin provides a factory class for
interacting with the framework and registers itself as being compatible
with the Data Access Framework. This concept is similar to how EDEX in
AWIPS expects a plugin developer to provide a decoder class and
record class and register them, but then automatically manages the rest
of the ingest process including routing, storing, and alerting on new
data. This style of plugin architecture effectively enables the
framework to expand its capabilities to more data types without having
to alter the framework code itself. This will enable software developers
to incrementally add support for more data types as time allows, and
allow the framework to expand to new data types as they become
available.
The Data Access Framework will not break any existing functionality or
APIs, and there are no plans to retrofit existing cosde to use the new
API at this time. Ideally code will be retrofitted in the future to
improve ease of maintainability. The plugin pecific code that hooks into
the framework will make use of existing APIs such as **IDataStore** and
**IServerRequest** to complete the requests.
The Data Access Framework can be understood as three parts:
- How users of the framework retrieve and use the data
- How plugin developers contribute support for new data types
- How the framework works when it receives a request
How users of the framework retrieve and use the data
----------------------------------------------------
When a user of the framework wishes to request data, they must
instantiate a request object and set some of the values on that request.
Two request interfaces will be supported, for detailed methods see
section "Detailed Code" below.
**IDataRequest**
**IGridRequest** extends **IDataRequest**
**IGeometryRequest** extends **IDataRequest**
For the request interfaces, default implementations of
**DefaultGridRequest** and **DefaultGeometryRequest** will be provided
to handle most cases. However, the use of interfaces allows for custom
special cases in the future. If necessary, the developer of a plugin can
write their own custom request implementation to handle a special case.
After the request object has been prepared, the user will pass it to the
Data Access Layer to receive a data object in return. See the "Detailed
Code" section below for detailed methods of the Data Access Layer. The
Data Access Layer will return one of two data interfaces.
**IData**
**IGridData** extends **IData**
**IGeometryData** extends **IData**
For the data interfaces, the use of interfaces effectively hides the
implementation details of specific data types from the user of the
framework. For example, the user receives an **IGridData** and knows the
data time, grid geometry, parameter, and level, but does not know that
the data is actually a **GFEGridData** vs **D2DGridData** vs
**SatelliteGridData**. This enables users of the framework to write
generic code that can support multiple data types.
For python users of the framework, the interfaces will be very similar
with a few key distinctions. Geometries will be represented by python
geometries from the open source Shapely project. For grids, the python
**IGridData** will have a method for requesting the raw data as a numpy
array, and the Data Access Layer will have methods for requesting the
latitude coordinates and the longitude coordinates of grids as numpy
arrays. The python requests and data objects will be pure python and not
JEP PyJObjects that wrap Java objects. A future goal of the Data Access
Framework is to provide support to python local apps and therefore
enable requests of data outside of CAVE and EDEX to go through the same
familiar interfaces. This goal is out of scope for this project but by
making the request and returned data objects pure python it will not be
a huge undertaking to add this support in the future.
How plugin developers contribute support for new datatypes
----------------------------------------------------------
When a developer wishes to add support for another data type to the
framework, they must implement one or both of the factory interfaces
within a common plugin. Two factory interfaces will be supported, for
detailed methods see below.
**IDataFactory**
**IGridFactory** extends **IDataFactory**
**IGeometryFactory** extends **IDataFactory**
For some data types, it may be desired to add support for both types of
requests. For example, the developer of grid data may want to provide
support for both grid requests and geometry requests. In this case the
developer would write two separate classes where one implements
**IGridFactory** and the other implements **IGeometryFactory**.
Furthermore, factories could be stacked on top of one another by having
factory implementations call into the Data Access Layer.
For example, a custom factory keyed to "derived" could be written for
derived parameters, and the implementation of that factory may then call
into the Data Access Layer to retrieve “grid” data. In this example the
raw data would be retrieved through the **GridDataFactory** while the
derived factory then applies the calculations before returning the data.
Implementations do not need to support all methods on the interfaces or
all values on the request objects. For example, a developer writing the
**MapGeometryFactory** does not need to support **getAvailableTimes()**
because map data such as US counties is time agnostic. In this case the
method should throw **UnsupportedOperationException** and the javadoc
will indicate this.
Another example would be the developer writing **ObsGeometryFactory**
can ignore the Level field of the **IDataRequest** as there are not
different levels of metar data, it is all at the surface. It is up to
the factory writer to determine which methods and fields to support and
which to ignore, but the factory writer should always code the factory
with the user requesting data in mind. If a user of the framework could
reasonably expect certain behavior from the framework based on the
request, the factory writer should implement support for that behavior.
Abstract factories will be provided and can be extended to reduce the
amount of code a factory developer has to write to complete some common
actions that will be used by multiple factories. The factory should be
capable of working within either CAVE or EDEX, therefore all of its
server specific actions (e.g. database queries) should go through the
Request/Handler API by using **IServerRequests**. CAVE can then send the
**IServerRequests** to EDEX with **ThriftClient** while EDEX can use the
**ServerRequestRouter** to process the **IServerRequests**, making the
code compatible regardless of which JVM it is running inside.
Once the factory code is written, it must be registered with the
framework as an available factory. This will be done through spring xml
in a common plugin, with the xml file inside the res/spring folder of
the plugin. Registering the factory will identify the datatype name that
must match what users would use as the datatype on the **IDataRequest**,
e.g. the word "satellite". Registering the factory also indicates to the
framework what request types are supported, i.e. grid vs geometry or
both.
An example of the spring xml for a satellite factory is provided below:
::
<bean id="satelliteFactory"
class="com.raytheon.uf.common.dataplugin.satellite.SatelliteFactory" />
<bean id="satelliteFactoryRegistered" factory-bean="dataFactoryRegistry" factory-method="register">
<constructor-arg value="satellite" />
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest" />
<constructor-arg value="satelliteFactory" />
</bean>
How the framework works when it receives a request
--------------------------------------------------
**IDataRequest** requires a datatype to be set on every request. The
framework will have a registry of existing factories for each data type
(grid and geometry). When the Data Access Layer methods are called, it
will first lookup in the registry for the factory that corresponds to
the datatype on the **IDataRequest**. If no corresponding factory is
found, it will throw an exception with a useful error message that
indicates there is no current support for that datatype request. If a
factory is found, it will delegate the processing of the request to the
factory. The factory will receive the request and process it, returning
the result back to the Data Access Layer which then returns it to the
caller.
By going through the Data Access Layer, the user is able to retrieve the
data and use it without understanding which factory was used, how the
factory retrieved the data, or what implementation of data was returned.
This effectively frees the framework and users of the framework from any
dependencies on any particular data types. Since these dependencies are
avoided, the specific **IDataFactory** and **IData** implementations can
be altered in the future if necessary and the code making use of the
framework will not need to be changed as long as the interfaces continue
to be met.
Essentially, the Data Access Framework is a service that provides data
in a consistent way, with the service capabilities being expanded by
plugin developers who write support for more data types. Note that the
framework itself is useless without plugins contributing and registering
**IDataFactories**. Once the framework is coded, developers will need to
be tasked to add the factories necessary to support the needed data
types.
Request interfaces
------------------
Requests and returned data interfaces will exist in both Java and
Python. The Java interfaces are listed below and the Python interfaces
will match the Java interfaces except where noted. Factories will only
be written in Java.
**IDataRequest**
- **void setDatatype(String datatype)** - the datatype name and
also the key to which factory will be used. Frequently pluginName
such as radar, satellite, gfe, ffmp, etc
- **void addIdentifier(String key, Object value)** - an identifier the
factory can use to determine which data to return, e.g. for grib data
key "modelName" and value “GFS40”
- **void setParameters(String... params)**
- **void setLevels(Level... levels)**
- **String getDatatype()**
- **Map getIdentifiers()**
- **String[] getParameters()**
- **Level[] getLevels()**
- Python Differences
- **Levels** will be represented as **Strings**
**IGridRequest extends IDataRequest**
- **void setStorageRequest(Request request)** - a datastorage request
that allows for slab, line, and point requests for faster performance
and less data retrieval
- **Request getStorageRequest()**
- Python Differences
- No support for storage requests
**IGeometryRequest extends IDataRequest**
- **void setEnvelope(Envelope env)** - a bounding box envelope to limit
the data that is searched through and returned. Not all factories may
support this.
- **setLocationNames(String... locationNames)** - a convenience of
requesting data by names such as ICAOs, airports, stationIDs, etc
- **Envelope getEnvelope()**
- **String[] getLocationNames()**
- Python Differences
- Envelope methods will use a **shapely.geometry.Polygon** instead of
**Envelopes** (shapely has no concept of envelopes and considers them
as rectangular polygons)
Data Interfaces
~~~~~~~~~~~~~~~
**IData**
- **Object getAttribute(String key)** - **getAttribute** provides a way
to get at attributes of the data that the interface does not provide,
allowing the user to get more info about the data without adding
dependencies on the specific data type plugin
- **DataTime getDataTime()** - some data may return null (e.g. maps)
- **Level getLevel()** - some data may return null
- Python Differences
- **Levels** will be represented by **Strings**
**IGridData extends IData**
- **String getParameter()**
- **GridGeometry2D getGridGeometry()**
- **Unit getUnit()** - some data may return null
- **DataDestination populateData(DataDestination destination)** - How
the user gets the raw data by passing in a **DataDestination** such
as **FloatArrayWrapper** or **ByteBufferWrapper**. This allows the
user to specify the way the raw data of the grid should be structured
in memory.
- **DataDestination populateData(DataDestination destination, Unit
unit)** - Same as the above method but also attempts to convert the
raw data to the specified unit when populating the
**DataDestination**.
- Python Differences
- **Units** will be represented by **Strings**
- **populateData()** methods will not exist, instead there will be
a **getRawData()** method that returns a numpy array in the native
type of the data
**IGeometryData extends IData**
- **Geometry getGeometry()**
- **Set getParameters()** - Gets the list of parameters included in
this data
- **String getString(String param)** - Gets the value of the parameter
as a String
- **Number getNumber(String param)** - Gets the value of the parameter
as a Number
- **Unit getUnit(String param)** - Gets the unit of the parameter,
may be null
- **Type getType(String param)** - Returns an enum of the raw type of
the parameter, such as Float, Int, or String
- **String getLocationName()** - Returns the location name of the piece
of data, typically to correlate if the request was made with
locationNames. May be null.
- Python Differences
- **Geometry** will be **shapely.geometry.Geometry**
- **getNumber()** will return the python native number of the data
- **Units** will be represented by **Strings**
- **getType()** will return the python type object
**DataAccessLayer** (in implementation, these methods delegate
processing to factories)
- **DataTime[] getAvailableTimes(IDataRequest request)**
- **DataTime[] getAvailableTimes(IDataRequest request, BinOffset
binOffset)**
- **IData[] getData(IDataRequest request, DataTime... times)**
- **IData[] getData(IDataRequest request, TimeRange timeRange)**
- **GridGeometry2D getGridGeometry(IGridRequest request)**
- **String[] getAvailableLocationNames(IGeometryRequest request)**
- Python Differences
- No support for **BinOffset**
- **getGridGeometry(IGridRequest)** will be replaced by
**getLatCoords(IGridRequest)** and **getLonCoords(IGridRequest)**
that will return numpy arrays of the lat or lon of every grid
cell
Factory Interfaces (Java only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- **IDataFactory**
- **DataTime[] getAvailableTimes(R request)** - queries the
database and returns the times that match the request. Some factories
may not support this (e.g. maps).
- **DataTime[] getAvailableTimes(R request, BinOffset binOffset)** -
queries the database with a bin offset and returns the times that
match the request. Some factories may not support this.
- **D[] getData(R request, DataTime... times)** - Gets the data that
matches the request at the specified times.
- **D[] getData(R request, TimeRange timeRange)** - Gets the data that
matches the request and is within the time range.
**IGridDataFactory extends IDataFactory**
- **GridGeometry2D** **getGeometry(IGridRequest request)** - Returns
the grid geometry of the data that matches the request BEFORE making
the request. Useful for then making slab or line requests for subsets
of the data. Does not support moving grids, but moving grids dont
make subset requests either.
**IGeometryDataFactory extends IDataFactory**
- **getAvailableLocationNames(IGeometryRequest request)** - Convenience
method to retrieve available location names that match a request. Not
all factories may support this.

View file

@ -0,0 +1,76 @@
=======================
AWIPS Grids and Cartopy
=======================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/AWIPS_Grids_and_Cartopy.ipynb>`_
A simple example of requesting and plotting AWIPS grids with Matplotlib
and Cartopy.
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
%matplotlib inline
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest()
request.setDatatype("grid")
request.setLocationNames("RAP13")
request.setParameters("T")
request.setLevels("2.0FHAG")
cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)
response = DataAccessLayer.getGridData(request, [fcstRun[0]])
grid = response[0]
data = grid.getRawData()
lons, lats = grid.getLatLonCoords()
bbox = [lons.min(), lons.max(), lats.min(), lats.max()]
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(16, 9),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
gl = ax.gridlines(draw_labels=True)
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
with pcolormesh
~~~~~~~~~~~~~~~
.. code:: ipython3
cmap = plt.get_cmap('rainbow')
fig, ax = make_map(bbox=bbox)
cs = ax.pcolormesh(lons, lats, data, cmap=cmap)
cbar = fig.colorbar(cs, shrink=0.7, orientation='horizontal')
cbar.set_label(grid.getLocationName() +" "+ grid.getLevel() + " " \
+ grid.getParameter() + " (" + grid.getUnit() + ") " \
+ "valid " + str(grid.getDataTime().getRefTime()))
.. image:: AWIPS_Grids_and_Cartopy_files/AWIPS_Grids_and_Cartopy_3_0.png
with contourf
~~~~~~~~~~~~~
.. code:: ipython3
fig2, ax2 = make_map(bbox=bbox)
cs2 = ax2.contourf(lons, lats, data, 80, cmap=cmap,
vmin=data.min(), vmax=data.max())
cbar2 = fig2.colorbar(cs2, shrink=0.7, orientation='horizontal')
cbar2.set_label(grid.getLocationName() +" "+ grid.getLevel() + " " \
+ grid.getParameter() + " (" + grid.getUnit()+ ") " \
+ "valid " + str(grid.getDataTime().getRefTime()))
.. image:: AWIPS_Grids_and_Cartopy_files/AWIPS_Grids_and_Cartopy_5_0.png

View file

@ -0,0 +1,104 @@
================================
Colored Surface Temperature Plot
================================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Colored_Surface_Temperature_Plot.ipynb>`_
This exercise creates a colored temperature plot for North America using
AWIPS METAR observations (datatype *obs*), similar to existing products
in GEMPAK and CAVE.
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
from datetime import datetime, timedelta
import numpy as np
import cartopy.crs as ccrs
import warnings
import matplotlib.pyplot as plt
from cartopy.feature import ShapelyFeature
from shapely.geometry import Polygon
from metpy.plots import StationPlot
%matplotlib inline
# CONUS bounding box and envelope geometry
bbox=[-120, -70, 15, 55]
envelope = Polygon([(bbox[0],bbox[2]),(bbox[0],bbox[3]),
(bbox[1], bbox[3]),(bbox[1],bbox[2]),
(bbox[0],bbox[2])])
# New obs request
edexServer = "edex-cloud.unidata.ucar.edu"
DataAccessLayer.changeEDEXHost(edexServer)
request = DataAccessLayer.newDataRequest("obs", envelope=envelope)
single_value_params = ["timeObs", "stationName", "longitude", "latitude",
"temperature", "dewpoint", "windDir",
"windSpeed", "seaLevelPress"]
multi_value_params = ["presWeather", "skyCover", "skyLayerBase"]
params = single_value_params + multi_value_params
request.setParameters(*(params))
# Get records from the last 15 minutes
lastHourDateTime = datetime.utcnow() - timedelta(minutes = 15)
start = lastHourDateTime.strftime('%Y-%m-%d %H:%M:%S')
end = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
beginRange = datetime.strptime( start , "%Y-%m-%d %H:%M:%S")
endRange = datetime.strptime( end , "%Y-%m-%d %H:%M:%S")
timerange = TimeRange(beginRange, endRange)
# Get response
response = DataAccessLayer.getGeometryData(request,timerange)
obs = DataAccessLayer.getMetarObs(response)
print("Found " + str(len(response)) + " total records")
print("Using " + str(len(obs['temperature'])) + " temperature records")
# Create a station plot pointing to an Axes to draw on as well as the location of points
lats = obs['latitude']
lons = obs['longitude']
thresholds = {
'15': 'purple',
'25': 'c',
'35': 'royalblue',
'45': 'darkgreen',
'55': 'green',
'65': 'y',
'75': 'orange',
'85': 'red'
}
fig, ax = plt.subplots(figsize=(16,12),subplot_kw=dict(projection=ccrs.LambertConformal()))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
ax.set_title(str(response[-1].getDataTime()) + " | Surface Temps (degF) | " + edexServer)
# Suppress nan masking warnings
warnings.filterwarnings("ignore",category =RuntimeWarning)
for x, value in thresholds.items():
tair = np.array(obs['temperature'], dtype=float)
tair[tair == -9999.0] = 'nan'
tair = (tair*1.8)+32
if x==max(thresholds):
tair[(tair < int(x))] = 'nan'
elif x==min(thresholds):
tair[(tair >= int(x)+10)] = 'nan'
else:
tair[(tair < int(x))] = 'nan'
tair[(tair >= int(x)+10)] = 'nan'
stationplot = StationPlot(ax, lons, lats, transform=ccrs.PlateCarree(),
fontsize=14)
stationplot.plot_parameter('C', tair, color=thresholds[str(x)])
.. parsed-literal::
Found 10692 total records
Using 872 temperature records
.. image:: Colored_Surface_Temperature_Plot_files/Colored_Surface_Temperature_Plot_1_1.png

View file

@ -0,0 +1,326 @@
================================
Forecast Model Vertical Sounding
================================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Forecast_Model_Vertical_Sounding.ipynb>`_
The ModelSounding class allows us to create a vertical sounding through
any available AWIPS model with isobaric levels.
- A Shapely Point geometry is used to select longitude and latitude:
from shapely.geometry import Point point = Point(-104.67,39.87)
- Parameters ``['T','DpT','uW','vW']`` are requested for all isobaric
levels available for the selected model.
- There is a single-record query performed for ``level = "0.0FHAG"`` to
determine the surface pressure level.
- Pay attention to units when switching models. This notebook was
written for the NAM 40km AWIPS model where temperature and dewpoint
are returned as Kelvin and wind components as m/s.
.. code:: ipython3
%matplotlib inline
from awips.dataaccess import DataAccessLayer, ModelSounding
from awips import ThriftClient
import matplotlib.pyplot as plt
import numpy as np
from metpy.plots import SkewT, Hodograph
from metpy.units import units
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from math import sqrt
from datetime import datetime, timedelta
from shapely.geometry import Point, Polygon
import shapely.wkb
import timeit
model="NAM40"
parms = ['T','DpT','uW','vW']
server = 'edex-cloud.unidata.ucar.edu'
DataAccessLayer.changeEDEXHost(server)
# note the order is LON,lat and not lat,LON
point = Point(-104.67,39.87)
inc = 0.005
bbox=[point.y-inc, point.y+inc, point.x-inc, point.x+inc]
polygon = Polygon([(bbox[0],bbox[2]),(bbox[0],bbox[3]),
(bbox[1],bbox[3]),(bbox[1],bbox[2]),
(bbox[0],bbox[2])])
# Get latest forecast cycle run
timeReq = DataAccessLayer.newDataRequest("grid")
timeReq.setLocationNames(model)
cycles = DataAccessLayer.getAvailableTimes(timeReq, True)
times = DataAccessLayer.getAvailableTimes(timeReq)
fcstRun = DataAccessLayer.getForecastRun(cycles[-2], times)
print("Using " + model + " forecast time " + str(fcstRun[0]))
.. parsed-literal::
Using NAM40 forecast time 2018-10-15 12:00:00
.. code:: ipython3
p,t,d,u,v = [],[],[],[],[]
use_parms = ['T','DpT','uW','vW','P']
use_level = "0.0FHAG"
sndObject = ModelSounding.getSounding(model, use_parms,
["0.0FHAG"], point, timeRange=[fcstRun[0]])
if len(sndObject) > 0:
for time in sndObject._dataDict:
p.append(float(sndObject._dataDict[time][use_level]['P']))
t.append(float(sndObject._dataDict[time][use_level]['T']))
d.append(float(sndObject._dataDict[time][use_level]['DpT']))
u.append(float(sndObject._dataDict[time][use_level]['uW']))
v.append(float(sndObject._dataDict[time][use_level]['vW']))
print("Found surface record at " + "%.1f" % p[0] + "MB")
else:
raise ValueError("sndObject returned empty for query ["
+ ', '.join(str(x) for x in (model, use_parms, point, use_level)) +"]")
.. parsed-literal::
Found surface record at 836.4MB
.. code:: ipython3
# Get isobaric levels with our requested parameters
levelReq = DataAccessLayer.newDataRequest("grid", envelope=point)
levelReq.setLocationNames(model)
levelReq.setParameters('T','DpT','uW','vW')
availableLevels = DataAccessLayer.getAvailableLevels(levelReq)
# Clean levels list of unit string (MB, FHAG, etc.)
levels = []
for lvl in availableLevels:
name=str(lvl)
if 'MB' in name and '_' not in name:
# If this level is above (less than in mb) our 0.0FHAG record
if float(name.replace('MB','')) < p[0]:
levels.append(lvl)
# Get Sounding
sndObject = ModelSounding.getSounding(model, parms, levels, point,
timeRange=[fcstRun[0]])
if not len(sndObject) > 0:
raise ValueError("sndObject returned empty for query ["
+ ', '.join(str(x) for x in (model, parms, point, levels)) +"]")
for time in sndObject._dataDict:
for lvl in sndObject._dataDict[time].levels():
for parm in sndObject._dataDict[time][lvl].parameters():
if parm == "T":
t.append(float(sndObject._dataDict[time][lvl][parm]))
elif parm == "DpT":
d.append(float(sndObject._dataDict[time][lvl][parm]))
elif parm == 'uW':
u.append(float(sndObject._dataDict[time][lvl][parm]))
elif parm == 'vW':
v.append(float(sndObject._dataDict[time][lvl][parm]))
else:
print("WHAT IS THIS")
print(sndObject._dataDict[time][lvl][parm])
# Pressure is our requested level rather than a returned parameter
p.append(float(lvl.replace('MB','')))
# convert to numpy.array()
p = np.array(p, dtype=float)
t = (np.array(t, dtype=float) - 273.15) * units.degC
d = (np.array(d, dtype=float) - 273.15) * units.degC
u = (np.array(u, dtype=float) * units('m/s')).to('knots')
v = (np.array(v, dtype=float) * units('m/s')).to('knots')
w = np.sqrt(u**2 + v**2)
print("Using " + str(len(levels)) + " levels between " +
str("%.1f" % max(p)) + " and " + str("%.1f" % min(p)) + "MB")
.. parsed-literal::
Using 32 levels between 836.4 and 50.0MB
--------------
Skew-T/Log-P
------------
.. code:: ipython3
plt.rcParams['figure.figsize'] = (12, 14)
# Skew-T
skew = SkewT(rotation=45)
skew.plot(p, t, 'r', linewidth=2)
skew.plot(p, d, 'g', linewidth=2)
skew.plot_barbs(p, u, v)
skew.plot_dry_adiabats()
skew.plot_moist_adiabats()
skew.plot_mixing_lines(linestyle=':')
skew.ax.set_ylim(1000, np.min(p))
skew.ax.set_xlim(-50, 40)
# Title
plt.title( model + " (" + str(point) + ") " + str(time.getRefTime()))
# Hodograph
ax_hod = inset_axes(skew.ax, '40%', '40%', loc=2)
h = Hodograph(ax_hod, component_range=max(w.magnitude))
h.add_grid(increment=20)
h.plot_colormapped(u, v, w)
# Dotted line at 0C isotherm
l = skew.ax.axvline(0, color='c', linestyle='-', linewidth=1)
plt.show()
.. image:: Forecast_Model_Vertical_Sounding_files/Forecast_Model_Vertical_Sounding_5_0.png
Model Sounding Comparison
-------------------------
.. code:: ipython3
models = ["CMC", "GFS20", "NAM40"]
parms = ['T','DpT','uW','vW']
for modelName in models:
timeReq = DataAccessLayer.newDataRequest("grid")
timeReq.setLocationNames(modelName)
cycles = DataAccessLayer.getAvailableTimes(timeReq, True)
times = DataAccessLayer.getAvailableTimes(timeReq)
fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)
print("Using " + modelName + " forecast time " + str(fcstRun[0]))
p,t,d,u,v = [],[],[],[],[]
use_parms = ['T','DpT','uW','vW','P']
use_level = "0.0FHAG"
sndObject = ModelSounding.getSounding(modelName, use_parms,
[use_level], point, timeRange=[fcstRun[0]])
if len(sndObject) > 0:
for time in sndObject._dataDict:
p.append(float(sndObject._dataDict[time][use_level]['P']))
t.append(float(sndObject._dataDict[time][use_level]['T']))
d.append(float(sndObject._dataDict[time][use_level]['DpT']))
u.append(float(sndObject._dataDict[time][use_level]['uW']))
v.append(float(sndObject._dataDict[time][use_level]['vW']))
print("Found surface record at " + "%.1f" % p[0] + "MB")
else:
raise ValueError("sndObject returned empty for query ["
+ ', '.join(str(x) for x in (modelName, use_parms, point, use_level)) +"]")
# Get isobaric levels with our requested parameters
levelReq = DataAccessLayer.newDataRequest("grid", envelope=point)
levelReq.setLocationNames(modelName)
levelReq.setParameters('T','DpT','uW','vW')
availableLevels = DataAccessLayer.getAvailableLevels(levelReq)
# Clean levels list of unit string (MB, FHAG, etc.)
levels = []
for lvl in availableLevels:
name=str(lvl)
if 'MB' in name and '_' not in name:
# If this level is above (less than in mb) our 0.0FHAG record
if float(name.replace('MB','')) < p[0]:
levels.append(lvl)
# Get Sounding
sndObject = ModelSounding.getSounding(modelName, parms, levels, point,
timeRange=[fcstRun[0]])
if not len(sndObject) > 0:
raise ValueError("sndObject returned empty for query ["
+ ', '.join(str(x) for x in (modelName, parms, point, levels)) +"]")
for time in sndObject._dataDict:
for lvl in sndObject._dataDict[time].levels():
for parm in sndObject._dataDict[time][lvl].parameters():
if parm == "T":
t.append(float(sndObject._dataDict[time][lvl][parm]))
elif parm == "DpT":
d.append(float(sndObject._dataDict[time][lvl][parm]))
elif parm == 'uW':
u.append(float(sndObject._dataDict[time][lvl][parm]))
elif parm == 'vW':
v.append(float(sndObject._dataDict[time][lvl][parm]))
else:
print("WHAT IS THIS")
print(sndObject._dataDict[time][lvl][parm])
# Pressure is our requested level rather than a returned parameter
p.append(float(lvl.replace('MB','')))
# convert to numpy.array()
p = np.array(p, dtype=float)
t = (np.array(t, dtype=float) - 273.15) * units.degC
d = (np.array(d, dtype=float) - 273.15) * units.degC
u = (np.array(u, dtype=float) * units('m/s')).to('knots')
v = (np.array(v, dtype=float) * units('m/s')).to('knots')
w = np.sqrt(u**2 + v**2)
print("Using " + str(len(levels)) + " levels between " +
str("%.1f" % max(p)) + " and " + str("%.1f" % min(p)) + "MB")
# Skew-T
plt.rcParams['figure.figsize'] = (12, 14)
skew = SkewT(rotation=45)
skew.plot(p, t, 'r', linewidth=2)
skew.plot(p, d, 'g', linewidth=2)
skew.plot_barbs(p, u, v)
skew.plot_dry_adiabats()
skew.plot_moist_adiabats()
skew.plot_mixing_lines(linestyle=':')
skew.ax.set_ylim(1000, 100)
skew.ax.set_xlim(-50, 40)
# Title
plt.title( modelName + " (" + str(point) + ") " + str(time.getRefTime()))
# Hodograph
ax_hod = inset_axes(skew.ax, '40%', '40%', loc=2)
h = Hodograph(ax_hod, component_range=max(w.magnitude))
h.add_grid(increment=20)
h.plot_colormapped(u, v, w)
# Dotted line at 0C isotherm
l = skew.ax.axvline(0, color='c', linestyle='-', linewidth=1)
plt.show()
.. parsed-literal::
Using CMC forecast time 2018-10-15 12:00:00
Found surface record at 848.6MB
Using 19 levels between 848.6 and 50.0MB
.. image:: Forecast_Model_Vertical_Sounding_files/Forecast_Model_Vertical_Sounding_7_1.png
.. parsed-literal::
Using GFS20 forecast time 2018-10-15 18:00:00
Found surface record at 848.1MB
Using 22 levels between 848.1 and 100.0MB
.. image:: Forecast_Model_Vertical_Sounding_files/Forecast_Model_Vertical_Sounding_7_3.png
.. parsed-literal::
Using NAM40 forecast time 2018-10-15 18:00:00
Found surface record at 837.7MB
Using 32 levels between 837.7 and 50.0MB
.. image:: Forecast_Model_Vertical_Sounding_files/Forecast_Model_Vertical_Sounding_7_5.png

View file

@ -0,0 +1,106 @@
===================================
GOES Geostationary Lightning Mapper
===================================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/GOES_Geostationary_Lightning_Mapper.ipynb>`_
The Geostationary Lightning Mapper, or GLM, on board GOES-R Series
spacecraft, is the first operational lightning mapper flown in
geostationary orbit. GLM detects the light emitted by lightning at the
tops of clouds day and night and collects information such as the
frequency, location and extent of lightning discharges. The instrument
measures total lightning, both in-cloud and cloud-to-ground, to aid in
forecasting developing severe storms and a wide range of high-impact
environmental phenomena including hailstorms, microburst winds,
tornadoes, hurricanes, flash floods, snowstorms and fires.
AWIPS GLM point data are available in three formats
- ``GLMev`` Events
- ``GLMfl`` Flashes
- ``GLMgr`` Groups
and with seven attributes:
- height
- intensity
- msgType
- pulseCount
- pulseIndex
- sensorCount
- strikeType
GLM Sources and Parameters
--------------------------
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
import cartopy.crs as ccrs
import cartopy.feature as cfeat
import matplotlib.pyplot as plt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import numpy as np
import datetime
%matplotlib inline
# Create an EDEX data request
edexServer = "edex-cloud.unidata.ucar.edu"
datatype = "binlightning"
DataAccessLayer.changeEDEXHost(edexServer)
request = DataAccessLayer.newDataRequest(datatype)
# Show available sources
sources = DataAccessLayer.getIdentifierValues(request, "source")
print("available sources:")
print(list(sources))
print("")
availableParms = DataAccessLayer.getAvailableParameters(request)
availableParms.sort()
print("available parameters:")
print(list(availableParms))
.. parsed-literal::
available sources:
['GLMgr', 'GLMfl', 'GLMev']
available parameters:
['height', 'intensity', 'msgType', 'pulseCount', 'pulseIndex', 'sensorCount', 'strikeType']
.. code:: ipython3
request.addIdentifier("source", "GLMgr")
request.setParameters("intensity")
times = DataAccessLayer.getAvailableTimes(request)
response = DataAccessLayer.getGeometryData(request, [times[-1]])
glm_points = []
for data in response:
glm_points.append(data.getGeometry())
ob = response[0]
.. code:: ipython3
# Plot markers
fig, ax = plt.subplots(figsize=(16,16),subplot_kw=dict(projection=ccrs.Orthographic(central_longitude=-90.0)))
ax.coastlines(resolution='50m')
ax.gridlines()
ax.scatter([point.x for point in glm_points],
[point.y for point in glm_points],
transform=ccrs.PlateCarree(),marker="+",facecolor='red')
ax.set_title(str(response[-1].getDataTime().getRefTime()) + " | " + ob.getAttribute('source') + " | " + edexServer)
.. parsed-literal::
Text(0.5,1,'Oct 15 18 22:15:07 GMT | GLMgr | edex-cloud.unidata.ucar.edu')
.. image:: GOES_Geostationary_Lightning_Mapper_files/GOES_Geostationary_Lightning_Mapper_3_1.png

View file

@ -0,0 +1,859 @@
==========================
Grid Levels and Parameters
==========================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Grid_Levels_and_Parameters.ipynb>`_
This example covers the callable methods of the Python AWIPS DAF when
working with gridded data. We start with a connection to an EDEX server,
then query data types, then grid names, parameters, levels, and other
information. Finally the gridded data is plotted for its domain using
Matplotlib and Cartopy.
DataAccessLayer.getSupportedDatatypes()
---------------------------------------
getSupportedDatatypes() returns a list of available data types offered
by the EDEX server defined above.
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
import unittest
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
dataTypes = DataAccessLayer.getSupportedDatatypes()
dataTypes.sort()
list(dataTypes)
.. parsed-literal::
['acars',
'airep',
'binlightning',
'bufrmosAVN',
'bufrmosETA',
'bufrmosGFS',
'bufrmosHPC',
'bufrmosLAMP',
'bufrmosMRF',
'bufrua',
'climate',
'common_obs_spatial',
'gfe',
'gfeEditArea',
'grid',
'maps',
'modelsounding',
'obs',
'pirep',
'practicewarning',
'profiler',
'radar',
'radar_spatial',
'satellite',
'sfcobs',
'topo',
'warning']
DataAccessLayer.getAvailableLocationNames()
-------------------------------------------
Now create a new data request, and set the data type to **grid** to
request all available grids with **getAvailableLocationNames()**
.. code:: ipython3
request = DataAccessLayer.newDataRequest()
request.setDatatype("grid")
available_grids = DataAccessLayer.getAvailableLocationNames(request)
available_grids.sort()
list(available_grids)
.. parsed-literal::
['AUTOSPE',
'CMC',
'ESTOFS',
'ETSS',
'FFG-ALR',
'FFG-FWR',
'FFG-KRF',
'FFG-MSR',
'FFG-ORN',
'FFG-PTR',
'FFG-RHA',
'FFG-RSA',
'FFG-STR',
'FFG-TAR',
'FFG-TIR',
'FFG-TUA',
'GEFS',
'GFS',
'GFS20',
'HFR-EAST_6KM',
'HFR-EAST_PR_6KM',
'HFR-US_EAST_DELAWARE_1KM',
'HFR-US_EAST_FLORIDA_2KM',
'HFR-US_EAST_NORTH_2KM',
'HFR-US_EAST_SOUTH_2KM',
'HFR-US_EAST_VIRGINIA_1KM',
'HFR-US_HAWAII_1KM',
'HFR-US_HAWAII_2KM',
'HFR-US_HAWAII_6KM',
'HFR-US_WEST_500M',
'HFR-US_WEST_CENCAL_2KM',
'HFR-US_WEST_LOSANGELES_1KM',
'HFR-US_WEST_LOSOSOS_1KM',
'HFR-US_WEST_NORTH_2KM',
'HFR-US_WEST_SANFRAN_1KM',
'HFR-US_WEST_SOCAL_2KM',
'HFR-US_WEST_WASHINGTON_1KM',
'HFR-WEST_6KM',
'HPCGuide',
'HPCqpfNDFD',
'HRRR',
'LAMP2p5',
'MRMS_0500',
'MRMS_1000',
'NAM12',
'NAM40',
'NOHRSC-SNOW',
'NationalBlend',
'RAP13',
'RTMA',
'RTOFS-Now-WestAtl',
'RTOFS-Now-WestConus',
'RTOFS-WestAtl',
'RTOFS-WestConus',
'SPCGuide',
'SeaIce',
'TPCWindProb',
'URMA25',
'WaveWatch']
DataAccessLayer.getAvailableParameters()
----------------------------------------
After datatype and model name (locationName) are set, you can query all
available parameters with **getAvailableParameters()**
.. code:: ipython3
request.setLocationNames("RAP13")
availableParms = DataAccessLayer.getAvailableParameters(request)
availableParms.sort()
list(availableParms)
.. parsed-literal::
['36SHRMi',
'50dbzZ',
'AV',
'Along',
'AppT',
'BLI',
'BRN',
'BRNEHIi',
'BRNSHR',
'BRNmag',
'BRNvec',
'BdEPT06',
'BlkMag',
'BlkShr',
'CAPE',
'CFRZR',
'CICEP',
'CIn',
'CP',
'CP1hr',
'CPr',
'CPrD',
'CRAIN',
'CSNOW',
'CURU',
'CXR',
'CapeStk',
'Corf',
'CorfF',
'CorfFM',
'CorfM',
'CritT1',
'CumNrm',
'CumShr',
'DivF',
'DivFn',
'DivFs',
'DpD',
'DpT',
'EHI',
'EHI01',
'EHIi',
'EPT',
'EPTA',
'EPTC',
'EPTGrd',
'EPTGrdM',
'EPTs',
'EPVg',
'EPVs',
'EPVt1',
'EPVt2',
'ESP',
'ESP2',
'FVecs',
'FeatMot',
'FnVecs',
'FsVecs',
'Fzra1',
'Fzra2',
'GH',
'GHxSM',
'GHxSM2',
'Gust',
'HI',
'HI1',
'HI3',
'HI4',
'HIdx',
'HPBL',
'Heli',
'HeliC',
'INV',
'IPLayer',
'Into',
'KI',
'L-I',
'LIsfc2x',
'LM5',
'LM6',
'MAdv',
'MCon',
'MCon2',
'MLLCL',
'MMP',
'MMSP',
'MSFDi',
'MSFi',
'MSFmi',
'MSG',
'MTV',
'Mix1',
'Mix2',
'Mmag',
'MpV',
'NBE',
'NST',
'NST1',
'NST2',
'OmDiff',
'P',
'PAdv',
'PBE',
'PEC',
'PFrnt',
'PGrd',
'PGrd1',
'PGrdM',
'PIVA',
'PR',
'PTvA',
'PTyp',
'PVV',
'PW',
'PW2',
'PoT',
'PoTA',
'QPV1',
'QPV2',
'QPV3',
'QPV4',
'REFC',
'RH',
'RH_001_bin',
'RH_002_bin',
'RM5',
'RM6',
'RMprop',
'RMprop2',
'RRtype',
'RV',
'Rain1',
'Rain2',
'Rain3',
'Ro',
'SH',
'SHx',
'SLI',
'SNSQ',
'SNW',
'SNWA',
'SRMl',
'SRMlM',
'SRMm',
'SRMmM',
'SRMr',
'SRMrM',
'SSP',
'SSi',
'STP',
'STP1',
'Shear',
'ShrMag',
'SnD',
'Snow1',
'Snow2',
'Snow3',
'SnowT',
'St-Pr',
'StrTP',
'StrmMot',
'SuCP',
'T',
'TAdv',
'TGrd',
'TGrdM',
'TORi',
'TORi2',
'TP',
'TP1hr',
'TQIND',
'TShrMi',
'TV',
'TW',
'T_001_bin',
'Tdef',
'Tdend',
'ThGrd',
'Thom5',
'Thom5a',
'Thom6',
'TmDpD',
'Tmax',
'Tmin',
'Topo',
'TotQi',
'Tstk',
'TwMax',
'TwMin',
'Twstk',
'TxSM',
'USTM',
'VAdv',
'VAdvAdvection',
'VGP',
'VSTM',
'Vis',
'WCD',
'WD',
'WEASD',
'WEASD1hr',
'WGS',
'Wind',
'WndChl',
'ageoVC',
'ageoW',
'ageoWM',
'cCape',
'cCin',
'cTOT',
'capeToLvl',
'dCape',
'dP',
'dT',
'dVAdv',
'dZ',
'defV',
'del2gH',
'df',
'fGen',
'fnD',
'fsD',
'gamma',
'gammaE',
'geoVort',
'geoW',
'geoWM',
'loCape',
'maxEPT',
'minEPT',
'mixRat',
'msl-P',
'muCape',
'pV',
'pVeq',
'qDiv',
'qVec',
'qnVec',
'qsVec',
'shWlt',
'snoRat',
'snoRatCrocus',
'snoRatEMCSREF',
'snoRatOv2',
'snoRatSPC',
'snoRatSPCdeep',
'snoRatSPCsurface',
'staticCoriolis',
'staticSpacing',
'staticTopo',
'swtIdx',
'tTOT',
'tWind',
'tWindU',
'tWindV',
'uFX',
'uW',
'uWStk',
'ulSnoRat',
'vSmthW',
'vTOT',
'vW',
'vWStk',
'vertCirc',
'wDiv',
'wSp',
'wSp_001_bin',
'wSp_002_bin',
'wSp_003_bin',
'wSp_004_bin',
'zAGL']
DataAccessLayer.getAvailableLevels()
------------------------------------
Selecting **"T"** for temperature.
.. code:: ipython3
request.setParameters("T")
availableLevels = DataAccessLayer.getAvailableLevels(request)
for lvl in availableLevels:
print(lvl)
.. parsed-literal::
0.0SFC
350.0MB
475.0MB
610.0_40000.0FHAG
225.0MB
120.0_150.0BL
900.0MB
125.0MB
0.0_610.0FHAG
450.0MB
575.0MB
325.0MB
100.0MB
1000.0MB
60.0_90.0BL
275.0MB
1.0PV
950.0MB
150.0MB
1.5PV
700.0MB
825.0MB
150.0_180.0BL
250.0MB
375.0MB
1000.0_500.0MB
800.0MB
4000.0FHAG
925.0MB
2.0PV
0.5PV
0.0TROP
750.0MB
500.0MB
625.0MB
400.0MB
0.0FHAG
2.0FHAG
875.0MB
175.0MB
0.0_1000.0FHAG
850.0MB
600.0MB
725.0MB
0.0_6000.0FHAG
975.0MB
550.0MB
0.0_3000.0FHAG
675.0MB
425.0MB
200.0MB
0.0_30.0BL
30.0_60.0BL
650.0MB
525.0MB
300.0MB
90.0_120.0BL
1000.0FHAG
775.0MB
340.0_350.0K
290.0_300.0K
700.0_600.0MB
700.0_300.0MB
320.0Ke
800.0_750.0MB
60.0TILT
5.3TILT
1000.0_900.0MB
340.0K
5500.0_6000.0FHAG
255.0K
255.0_265.0K
3000.0_6000.0FHAG
25.0TILT
2000.0FHAG
0.0_500.0FHAG
1000.0_850.0MB
850.0_250.0MB
280.0_290.0Ke
1524.0FHAG
320.0_330.0K
0.0TILT
310.0_320.0Ke
310.0Ke
330.0K
900.0_800.0MB
550.0_500.0MB
2.4TILT
50.0TILT
3500.0FHAG
35.0TILT
12.0TILT
300.0_310.0K
3000.0_12000.0FHAG
0.9TILT
320.0K
400.0_350.0MB
500.0FHAG
750.0_700.0MB
1000.0_400.0MB
345.0K
250.0_260.0K
300.0Ke
290.0Ke
950.0_900.0MB
4572.0FHAG
275.0_285.0Ke
335.0Ke
295.0_305.0Ke
275.0_285.0K
600.0_550.0MB
310.0K
9000.0FHAG
335.0K
1000.0_7000.0FHAG
700.0_500.0MB
9144.0FHAG
325.0_335.0K
2000.0_8000.0FHAG
0.0_609.6FHAG
300.0K
0.0MAXOMEGA
315.0_325.0K
325.0K
340.0Ke
0.0_4000.0FHAG
5000.0_5500.0FHAG
300.0_250.0MB
1.5TILT
335.0_345.0K
315.0K
3.4TILT
2500.0FHAG
10000.0FHAG
0.0_2000.0FHAG
7000.0FHAG
5000.0FHAG
330.0Ke
500.0_400.0MB
1000.0_1500.0FHAG
305.0K
285.0_295.0Ke
14.0TILT
3000.0_3500.0FHAG
325.0_335.0Ke
2000.0_5000.0FHAG
7620.0FHAG
850.0_800.0MB
6096.0FHAG
6000.0_7000.0FHAG
2000.0_7000.0FHAG
9000.0_10000.0FHAG
295.0Ke
305.0Ke
265.0_275.0K
7000.0_8000.0FHAG
3000.0_8000.0FHAG
700.0_650.0MB
1000.0_6000.0FHAG
0.5TILT
450.0_400.0MB
1.8TILT
330.0_340.0K
800.0_700.0MB
850.0_300.0MB
6.0TILT
900.0_850.0MB
3657.6FHAG
0.0_5000.0FHAG
320.0_330.0Ke
8.7TILT
650.0_600.0MB
600.0_400.0MB
55.0TILT
270.0_280.0Ke
30.0TILT
310.0_320.0K
1500.0FHAG
1000.0_950.0MB
5500.0FHAG
250.0_200.0MB
500.0_1000.0FHAG
400.0_300.0MB
500.0_100.0MB
1000.0_3000.0FHAG
8000.0FHAG
285.0Ke
290.0K
305.0_315.0K
285.0_295.0K
0.0_2500.0FHAG
925.0_850.0MB
275.0Ke
1500.0_2000.0FHAG
300.0_200.0MB
260.0_270.0K
2743.2FHAG
3000.0FHAG
315.0_325.0Ke
600.0_500.0MB
16.7TILT
280.0K
500.0_250.0MB
40.0TILT
3048.0FHAG
400.0_200.0MB
300.0_310.0Ke
270.0_280.0K
1000.0_700.0MB
45.0TILT
850.0_500.0MB
2500.0_3000.0FHAG
609.6FHAG
0.0_8000.0FHAG
295.0K
4.3TILT
295.0_305.0K
330.0_340.0Ke
270.0K
4000.0_4500.0FHAG
280.0_290.0K
925.0_700.0MB
0.0_1500.0FHAG
260.0K
10.0TILT
3500.0_4000.0FHAG
325.0Ke
285.0K
290.0_300.0Ke
7.5TILT
1828.8FHAG
280.0Ke
500.0_450.0MB
305.0_315.0Ke
250.0K
4500.0FHAG
1250.0FHAG
0.0_10000.0FHAG
4500.0_5000.0FHAG
250.0_350.0K
270.0Ke
275.0K
315.0Ke
500.0_300.0MB
350.0_300.0MB
750.0FHAG
19.5TILT
2000.0_2500.0FHAG
850.0_700.0MB
350.0K
265.0K
6000.0FHAG
8000.0_9000.0FHAG
700.0_300.0LYRMB
850.0_700.0LYRMB
- **0.0SFC** is the Surface level
- **FHAG** stands for Fixed Height Above Ground (in meters)
- **NTAT** stands for Nominal Top of the ATmosphere
- **BL** stands for Boundary Layer, where **0.0\_30.0BL** reads as
*0-30 mb above ground level*
- **TROP** is the Tropopause level
**request.setLevels()**
For this example we will use Surface Temperature
.. code:: ipython3
request.setLevels("2.0FHAG")
DataAccessLayer.getAvailableTimes()
-----------------------------------
- **getAvailableTimes(request, True)** will return an object of *run
times* - formatted as ``YYYY-MM-DD HH:MM:SS``
- **getAvailableTimes(request)** will return an object of all times -
formatted as ``YYYY-MM-DD HH:MM:SS (F:ff)``
- **getForecastRun(cycle, times)** will return a DataTime array for a
single forecast cycle.
.. code:: ipython3
cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)
list(fcstRun)
.. parsed-literal::
[<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >,
<DataTime instance: 2020-09-04 18:00:00 >]
DataAccessLayer.getGridData()
-----------------------------
Now that we have our ``request`` and DataTime ``fcstRun`` arrays ready,
it's time to request the data array from EDEX.
.. code:: ipython3
response = DataAccessLayer.getGridData(request, [fcstRun[-1]])
for grid in response:
data = grid.getRawData()
lons, lats = grid.getLatLonCoords()
print('Time :', str(grid.getDataTime()))
print('Model:', str(grid.getLocationName()))
print('Parm :', str(grid.getParameter()))
print('Unit :', str(grid.getUnit()))
print(data.shape)
.. parsed-literal::
Time : 2020-09-04 18:00:00
Model: RAP13
Parm : T
Unit : K
(337, 451)
Plotting with Matplotlib and Cartopy
------------------------------------
**1. pcolormesh**
.. code:: ipython3
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import numpy as np
import numpy.ma as ma
from scipy.io import loadmat
from scipy.constants import convert_temperature
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(16, 9),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
gl = ax.gridlines(draw_labels=True)
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
#convert temp from K to F
dataf = convert_temperature(data, 'K', 'F')
cmap = plt.get_cmap('rainbow')
bbox = [lons.min(), lons.max(), lats.min(), lats.max()]
fig, ax = make_map(bbox=bbox)
cs = ax.pcolormesh(lons, lats, dataf, cmap=cmap)
cbar = fig.colorbar(cs, extend='both', shrink=0.5, orientation='horizontal')
cbar.set_label(grid.getLocationName() +" " + grid.getLevel() + " " \
+ grid.getParameter() + " (F) " \
+ "valid " + str(grid.getDataTime().getRefTime()))
.. image:: Grid_Levels_and_Parameters_files/Grid_Levels_and_Parameters_16_0.png
**2. contourf**
.. code:: ipython3
fig2, ax2 = make_map(bbox=bbox)
cs2 = ax2.contourf(lons, lats, dataf, 80, cmap=cmap,
vmin=dataf.min(), vmax=dataf.max(), extend='both')
cbar2 = fig2.colorbar(cs2, shrink=0.5, orientation='horizontal')
cbar2.set_label(grid.getLocationName() +" " + grid.getLevel() + " " \
+ grid.getParameter() + " (F) " \
+ "valid " + str(grid.getDataTime().getRefTime()))
.. image:: Grid_Levels_and_Parameters_files/Grid_Levels_and_Parameters_18_0.png

View file

@ -0,0 +1,195 @@
=============================
METAR Station Plot with MetPy
=============================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/METAR_Station_Plot_with_MetPy.ipynb>`_
This exercise creates a METAR plot for North America using AWIPS METAR
observations (datatype *obs*) and MetPy.
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
from datetime import datetime, timedelta
import numpy as np
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
from metpy.calc import wind_components
from metpy.plots import StationPlot, StationPlotLayout
from metpy.units import units
import warnings
%matplotlib inline
warnings.filterwarnings("ignore",category =RuntimeWarning)
def get_cloud_cover(code):
if 'OVC' in code:
return 1.0
elif 'BKN' in code:
return 6.0/8.0
elif 'SCT' in code:
return 4.0/8.0
elif 'FEW' in code:
return 2.0/8.0
else:
return 0
# Pull out these specific stations (prepend K for AWIPS identifiers)
selected = ['PDX', 'OKC', 'ICT', 'GLD', 'MEM', 'BOS', 'MIA', 'MOB', 'ABQ', 'PHX', 'TTF',
'ORD', 'BIL', 'BIS', 'CPR', 'LAX', 'ATL', 'MSP', 'SLC', 'DFW', 'NYC', 'PHL',
'PIT', 'IND', 'OLY', 'SYR', 'LEX', 'CHS', 'TLH', 'HOU', 'GJT', 'LBB', 'LSV',
'GRB', 'CLT', 'LNK', 'DSM', 'BOI', 'FSD', 'RAP', 'RIC', 'JAN', 'HSV', 'CRW',
'SAT', 'BUY', '0CO', 'ZPC', 'VIH', 'BDG', 'MLF', 'ELY', 'WMC', 'OTH', 'CAR',
'LMT', 'RDM', 'PDT', 'SEA', 'UIL', 'EPH', 'PUW', 'COE', 'MLP', 'PIH', 'IDA',
'MSO', 'ACV', 'HLN', 'BIL', 'OLF', 'RUT', 'PSM', 'JAX', 'TPA', 'SHV', 'MSY',
'ELP', 'RNO', 'FAT', 'SFO', 'NYL', 'BRO', 'MRF', 'DRT', 'FAR', 'BDE', 'DLH',
'HOT', 'LBF', 'FLG', 'CLE', 'UNV']
selected = ['K{0}'.format(id) for id in selected]
data_arr = []
.. code:: ipython3
# EDEX Request
edexServer = "edex-cloud.unidata.ucar.edu"
DataAccessLayer.changeEDEXHost(edexServer)
request = DataAccessLayer.newDataRequest("obs")
availableProducts = DataAccessLayer.getAvailableParameters(request)
single_value_params = ["timeObs", "stationName", "longitude", "latitude",
"temperature", "dewpoint", "windDir",
"windSpeed", "seaLevelPress"]
multi_value_params = ["presWeather", "skyCover", "skyLayerBase"]
pres_weather, sky_cov, sky_layer_base = [],[],[]
params = single_value_params + multi_value_params
obs = dict({params: [] for params in params})
request.setParameters(*(params))
request.setLocationNames(*(selected))
Here we use the Python-AWIPS class **TimeRange** to prepare a beginning
and end time span for requesting observations (the last hour):
.. code:: ipython3
# Time range
lastHourDateTime = datetime.utcnow() - timedelta(hours = 1)
start = lastHourDateTime.strftime('%Y-%m-%d %H')
beginRange = datetime.strptime( start + ":00:00", "%Y-%m-%d %H:%M:%S")
endRange = datetime.strptime( start + ":59:59", "%Y-%m-%d %H:%M:%S")
timerange = TimeRange(beginRange, endRange)
response = DataAccessLayer.getGeometryData(request,timerange)
.. code:: ipython3
station_names = []
for ob in response:
avail_params = ob.getParameters()
if "presWeather" in avail_params:
pres_weather.append(ob.getString("presWeather"))
elif "skyCover" in avail_params and "skyLayerBase" in avail_params:
sky_cov.append(ob.getString("skyCover"))
sky_layer_base.append(ob.getNumber("skyLayerBase"))
else:
# If we already have a record for this stationName, skip
if ob.getString('stationName') not in station_names:
station_names.append(ob.getString('stationName'))
for param in single_value_params:
if param in avail_params:
if param == 'timeObs':
obs[param].append(datetime.fromtimestamp(ob.getNumber(param)/1000.0))
else:
try:
obs[param].append(ob.getNumber(param))
except TypeError:
obs[param].append(ob.getString(param))
else:
obs[param].append(None)
obs['presWeather'].append(pres_weather);
obs['skyCover'].append(sky_cov);
obs['skyLayerBase'].append(sky_layer_base);
pres_weather = []
sky_cov = []
sky_layer_base = []
Next grab the simple variables out of the data we have (attaching
correct units), and put them into a dictionary that we will hand the
plotting function later:
- Get wind components from speed and direction
- Convert cloud fraction values to integer codes [0 - 8]
- Map METAR weather codes to WMO codes for weather symbols
.. code:: ipython3
data = dict()
data['stid'] = np.array(obs['stationName'])
data['latitude'] = np.array(obs['latitude'])
data['longitude'] = np.array(obs['longitude'])
data['air_temperature'] = np.array(obs['temperature'], dtype=float)* units.degC
data['dew_point_temperature'] = np.array(obs['dewpoint'], dtype=float)* units.degC
data['air_pressure_at_sea_level'] = np.array(obs['seaLevelPress'])* units('mbar')
direction = np.array(obs['windDir'])
direction[direction == -9999.0] = 'nan'
u, v = wind_components(np.array(obs['windSpeed']) * units('knots'),
direction * units.degree)
data['eastward_wind'], data['northward_wind'] = u, v
data['cloud_coverage'] = [int(get_cloud_cover(x)*8) for x in obs['skyCover']]
data['present_weather'] = obs['presWeather']
.. code:: ipython3
print(obs['stationName'])
.. parsed-literal::
['K0CO', 'KHOT', 'KSHV', 'KIND', 'KBDE', 'KPSM', 'KORD', 'KDFW', 'KPHL', 'KTTF', 'KBDG', 'KOLY', 'KNYC', 'KABQ', 'KLEX', 'KDRT', 'KELP', 'KRUT', 'KRIC', 'KPIT', 'KMSP', 'KHSV', 'KUNV', 'KSAT', 'KCLE', 'KPHX', 'KMIA', 'KBOI', 'KBRO', 'KLAX', 'KLBB', 'KMSO', 'KPDX', 'KTLH', 'KUIL', 'KTPA', 'KVIH', 'KBIL', 'KMLF', 'KCPR', 'KATL', 'KBIS', 'KCLT', 'KOKC', 'KRAP', 'KACV', 'KEPH', 'KELY', 'KFAR', 'KFAT', 'KMSY', 'KOLF', 'KPDT', 'KLMT', 'KHLN', 'KHOU', 'KICT', 'KIDA', 'KPIH', 'KPUW', 'KGJT', 'KGLD', 'KGRB', 'KLBF', 'KMLP', 'KBOS', 'KSYR', 'KDLH', 'KCOE', 'KOTH', 'KCRW', 'KSEA', 'KCAR', 'KDSM', 'KJAN', 'KSLC', 'KBUY', 'KLNK', 'KMEM', 'KNYL', 'KRDM', 'KCHS', 'KFSD', 'KJAX', 'KMOB', 'KRNO', 'KSFO', 'KWMC', 'KFLG', 'KLSV']
MetPy Surface Obs Plot
----------------------
.. code:: ipython3
proj = ccrs.LambertConformal(central_longitude=-95, central_latitude=35,
standard_parallels=[35])
# Change the DPI of the figure
plt.rcParams['savefig.dpi'] = 255
# Winds, temps, dewpoint, station id
custom_layout = StationPlotLayout()
custom_layout.add_barb('eastward_wind', 'northward_wind', units='knots')
custom_layout.add_value('NW', 'air_temperature', fmt='.0f', units='degF', color='darkred')
custom_layout.add_value('SW', 'dew_point_temperature', fmt='.0f', units='degF', color='darkgreen')
custom_layout.add_value('E', 'precipitation', fmt='0.1f', units='inch', color='blue')
# Create the figure
fig = plt.figure(figsize=(20, 10))
ax = fig.add_subplot(1, 1, 1, projection=proj)
# Add various map elements
ax.add_feature(cfeature.LAND)
ax.add_feature(cfeature.OCEAN)
ax.add_feature(cfeature.LAKES)
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.STATES)
ax.add_feature(cfeature.BORDERS, linewidth=2)
# Set plot bounds
ax.set_extent((-118, -73, 23, 50))
ax.set_title(str(ob.getDataTime()) + " | METAR | " + edexServer)
stationplot = StationPlot(ax, data['longitude'], data['latitude'], clip_on=True,
transform=ccrs.PlateCarree(), fontsize=10)
stationplot.plot_text((2, 0), data['stid'])
custom_layout.plot(stationplot, data)
plt.show()
.. image:: METAR_Station_Plot_with_MetPy_files/METAR_Station_Plot_with_MetPy_10_0.png

View file

@ -0,0 +1,398 @@
============================
Map Resources and Topography
============================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Map_Resources_and_Topography.ipynb>`_
The python-awips package provides access to the entire AWIPS Maps
Database for use in Python GIS applications. Map objects are returned as
Shapely geometries (*Polygon*, *Point*, *MultiLineString*, etc.) and can
be easily plotted by Matplotlib, Cartopy, MetPy, and other packages.
Each map database table has a geometry field called ``the_geom``, which
can be used to spatially select map resources for any column of type
geometry,
Notes
-----
- This notebook requires: **python-awips, numpy, matplotplib, cartopy,
shapely**
- Use datatype **maps** and **addIdentifier('table', <postgres maps
schema>)** to define the map table:
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu") request
= DataAccessLayer.newDataRequest('maps')
request.addIdentifier('table', 'mapdata.county')
- Use **request.setLocationNames()** and **request.addIdentifier()** to
spatially filter a map resource. In the example below, WFO ID **BOU**
(Boulder, Colorado) is used to query counties within the BOU county
watch area (CWA)
::
request.addIdentifier('geomField', 'the_geom')
request.addIdentifier('inLocation', 'true')
request.addIdentifier('locationField', 'cwa')
request.setLocationNames('BOU')
request.addIdentifier('cwa', 'BOU')
See the Maps Database Reference Page for available database tables,
column names, and types.
Note the geometry definition of ``the_geom`` for each data type,
which can be **Point**, **MultiPolygon**, or **MultiLineString**.
Setup
-----
.. code:: ipython3
from __future__ import print_function
from awips.dataaccess import DataAccessLayer
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import numpy as np
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
from cartopy.feature import ShapelyFeature,NaturalEarthFeature
from shapely.geometry import Polygon
from shapely.ops import cascaded_union
# Standard map plot
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(12,12),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
gl = ax.gridlines(draw_labels=True)
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
# Server, Data Request Type, and Database Table
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest('maps')
request.addIdentifier('table', 'mapdata.county')
Request County Boundaries for a WFO
-----------------------------------
- Use **request.setParameters()** to define fields to be returned by
the request.
.. code:: ipython3
# Define a WFO ID for location
# tie this ID to the mapdata.county column "cwa" for filtering
request.setLocationNames('BOU')
request.addIdentifier('cwa', 'BOU')
# enable location filtering (inLocation)
# locationField is tied to the above cwa definition (BOU)
request.addIdentifier('geomField', 'the_geom')
request.addIdentifier('inLocation', 'true')
request.addIdentifier('locationField', 'cwa')
# This is essentially the same as "'"select count(*) from mapdata.cwa where cwa='BOU';" (=1)
# Get response and create dict of county geometries
response = DataAccessLayer.getGeometryData(request, [])
counties = np.array([])
for ob in response:
counties = np.append(counties,ob.getGeometry())
print("Using " + str(len(counties)) + " county MultiPolygons")
%matplotlib inline
# All WFO counties merged to a single Polygon
merged_counties = cascaded_union(counties)
envelope = merged_counties.buffer(2)
boundaries=[merged_counties]
# Get bounds of this merged Polygon to use as buffered map extent
bounds = merged_counties.bounds
bbox=[bounds[0]-1,bounds[2]+1,bounds[1]-1.5,bounds[3]+1.5]
fig, ax = make_map(bbox=bbox)
# Plot political/state boundaries handled by Cartopy
political_boundaries = NaturalEarthFeature(category='cultural',
name='admin_0_boundary_lines_land',
scale='50m', facecolor='none')
states = NaturalEarthFeature(category='cultural',
name='admin_1_states_provinces_lines',
scale='50m', facecolor='none')
ax.add_feature(political_boundaries, linestyle='-', edgecolor='black')
ax.add_feature(states, linestyle='-', edgecolor='black',linewidth=2)
# Plot CWA counties
for i, geom in enumerate(counties):
cbounds = Polygon(geom)
intersection = cbounds.intersection
geoms = (intersection(geom)
for geom in counties
if cbounds.intersects(geom))
shape_feature = ShapelyFeature(geoms,ccrs.PlateCarree(),
facecolor='none', linestyle="-",edgecolor='#86989B')
ax.add_feature(shape_feature)
.. parsed-literal::
Using 23 county MultiPolygons
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_4_1.png
Create a merged CWA with cascaded\_union
----------------------------------------
.. code:: ipython3
# Plot CWA envelope
for i, geom in enumerate(boundaries):
gbounds = Polygon(geom)
intersection = gbounds.intersection
geoms = (intersection(geom)
for geom in boundaries
if gbounds.intersects(geom))
shape_feature = ShapelyFeature(geoms,ccrs.PlateCarree(),
facecolor='none', linestyle="-",linewidth=3.,edgecolor='#cc5000')
ax.add_feature(shape_feature)
fig
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_6_0.png
WFO boundary spatial filter for interstates
-------------------------------------------
Using the previously-defined **envelope=merged\_counties.buffer(2)** in
**newDataRequest()** to request geometries which fall inside the
buffered boundary.
.. code:: ipython3
request = DataAccessLayer.newDataRequest('maps', envelope=envelope)
request.addIdentifier('table', 'mapdata.interstate')
request.addIdentifier('geomField', 'the_geom')
request.setParameters('name')
interstates = DataAccessLayer.getGeometryData(request, [])
print("Using " + str(len(interstates)) + " interstate MultiLineStrings")
# Plot interstates
for ob in interstates:
shape_feature = ShapelyFeature(ob.getGeometry(),ccrs.PlateCarree(),
facecolor='none', linestyle="-",edgecolor='orange')
ax.add_feature(shape_feature)
fig
.. parsed-literal::
Using 225 interstate MultiLineStrings
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_8_1.png
Nearby cities
-------------
Request the city table and filter by population and progressive
disclosure level:
**Warning**: the ``prog_disc`` field is not entirely understood and
values appear to change significantly depending on WFO site.
.. code:: ipython3
request = DataAccessLayer.newDataRequest('maps', envelope=envelope)
request.addIdentifier('table', 'mapdata.city')
request.addIdentifier('geomField', 'the_geom')
request.setParameters('name','population','prog_disc')
cities = DataAccessLayer.getGeometryData(request, [])
print("Queried " + str(len(cities)) + " total cities")
citylist = []
cityname = []
# For BOU, progressive disclosure values above 50 and pop above 5000 looks good
for ob in cities:
if ob.getString("population"):
if ob.getNumber("prog_disc") > 50:
if int(ob.getString("population")) > 5000:
citylist.append(ob.getGeometry())
cityname.append(ob.getString("name"))
print("Plotting " + str(len(cityname)) + " cities")
# Plot city markers
ax.scatter([point.x for point in citylist],
[point.y for point in citylist],
transform=ccrs.PlateCarree(),marker="+",facecolor='black')
# Plot city names
for i, txt in enumerate(cityname):
ax.annotate(txt, (citylist[i].x,citylist[i].y),
xytext=(3,3), textcoords="offset points")
fig
.. parsed-literal::
Queried 1203 total cities
Plotting 57 cities
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_10_1.png
Lakes
-----
.. code:: ipython3
request = DataAccessLayer.newDataRequest('maps', envelope=envelope)
request.addIdentifier('table', 'mapdata.lake')
request.addIdentifier('geomField', 'the_geom')
request.setParameters('name')
# Get lake geometries
response = DataAccessLayer.getGeometryData(request, [])
lakes = np.array([])
for ob in response:
lakes = np.append(lakes,ob.getGeometry())
print("Using " + str(len(lakes)) + " lake MultiPolygons")
# Plot lakes
for i, geom in enumerate(lakes):
cbounds = Polygon(geom)
intersection = cbounds.intersection
geoms = (intersection(geom)
for geom in lakes
if cbounds.intersects(geom))
shape_feature = ShapelyFeature(geoms,ccrs.PlateCarree(),
facecolor='blue', linestyle="-",edgecolor='#20B2AA')
ax.add_feature(shape_feature)
fig
.. parsed-literal::
Using 208 lake MultiPolygons
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_12_1.png
Major Rivers
------------
.. code:: ipython3
request = DataAccessLayer.newDataRequest('maps', envelope=envelope)
request.addIdentifier('table', 'mapdata.majorrivers')
request.addIdentifier('geomField', 'the_geom')
request.setParameters('pname')
rivers = DataAccessLayer.getGeometryData(request, [])
print("Using " + str(len(rivers)) + " river MultiLineStrings")
# Plot rivers
for ob in rivers:
shape_feature = ShapelyFeature(ob.getGeometry(),ccrs.PlateCarree(),
facecolor='none', linestyle=":",edgecolor='#20B2AA')
ax.add_feature(shape_feature)
fig
.. parsed-literal::
Using 1400 river MultiLineStrings
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_14_1.png
Topography
----------
Spatial envelopes are required for topo requests, which can become slow
to download and render for large (CONUS) maps.
.. code:: ipython3
import numpy.ma as ma
request = DataAccessLayer.newDataRequest("topo")
request.addIdentifier("group", "/")
request.addIdentifier("dataset", "full")
request.setEnvelope(envelope)
gridData = DataAccessLayer.getGridData(request)
print(gridData)
print("Number of grid records: " + str(len(gridData)))
print("Sample grid data shape:\n" + str(gridData[0].getRawData().shape) + "\n")
print("Sample grid data:\n" + str(gridData[0].getRawData()) + "\n")
.. parsed-literal::
[<awips.dataaccess.PyGridData.PyGridData object at 0x7ffd0f33c040>]
Number of grid records: 1
Sample grid data shape:
(778, 1058)
Sample grid data:
[[1694. 1693. 1688. ... 757. 761. 762.]
[1701. 1701. 1701. ... 758. 760. 762.]
[1703. 1703. 1703. ... 760. 761. 762.]
...
[1767. 1741. 1706. ... 769. 762. 768.]
[1767. 1746. 1716. ... 775. 765. 761.]
[1781. 1753. 1730. ... 766. 762. 759.]]
.. code:: ipython3
grid=gridData[0]
topo=ma.masked_invalid(grid.getRawData())
lons, lats = grid.getLatLonCoords()
print(topo.min()) # minimum elevation in our domain (meters)
print(topo.max()) # maximum elevation in our domain (meters)
# Plot topography
cs = ax.contourf(lons, lats, topo, 80, cmap=plt.get_cmap('terrain'),alpha=0.1, extend='both')
cbar = fig.colorbar(cs, shrink=0.5, orientation='horizontal')
cbar.set_label("topography height in meters")
fig
.. parsed-literal::
623.0
4328.0
.. image:: Map_Resources_and_Topography_files/Map_Resources_and_Topography_17_1.png

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,386 @@
===================
NEXRAD Level3 Radar
===================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/NEXRAD_Level3_Radar.ipynb>`_
.. code:: ipython3
This example plots NEXRAD 3 algorithm, precipitation, and derived products (not base data).
.. code:: ipython3
import warnings
from awips.dataaccess import DataAccessLayer
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import numpy as np
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
%matplotlib inline
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest("radar")
available_locs = DataAccessLayer.getAvailableLocationNames(request)
available_locs.sort()
list(available_locs)
request.setLocationNames("kmhx")
availableParms = DataAccessLayer.getAvailableParameters(request)
availableParms.sort()
#list(availableParms)
productIDs = DataAccessLayer.getRadarProductIDs(availableParms)
productNames = DataAccessLayer.getRadarProductNames(availableParms)
print(productIDs)
print(productNames)
.. parsed-literal::
['134', '135', '138', '141', '159', '161', '163', '165', '166', '169', '170', '171', '172', '173', '174', '175', '176', '177', '19', '20', '27', '32', '37', '41', '56', '57', '58', '78', '80', '81', '94', '99']
['Composite Refl', 'Correlation Coeff', 'Diff Reflectivity', 'Digital Hybrid Scan Refl', 'Digital Inst Precip Rate', 'Digital Precip Array', 'Digital Vert Integ Liq', 'Echo Tops', 'Enhanced Echo Tops', 'Hybrid Hydrometeor Class', 'Hydrometeor Class', 'Melting Layer', 'Mesocyclone', 'One Hour Accum', 'One Hour Diff', 'One Hour Precip', 'One Hour Unbiased Accum', 'Reflectivity', 'Specific Diff Phase', 'Storm Rel Velocity', 'Storm Total Accum', 'Storm Total Diff', 'Storm Total Precip', 'Storm Track', 'User Select Accum', 'Velocity', 'Vert Integ Liq']
.. code:: ipython3
warnings.filterwarnings("ignore",category =RuntimeWarning)
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(16, 16),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
gl = ax.gridlines(draw_labels=True)
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
nexrad_data = {}
for prod in productNames:
request.setParameters(prod)
availableLevels = DataAccessLayer.getAvailableLevels(request)
if availableLevels:
request.setLevels(availableLevels[0])
else:
print("No levels found for " + prod)
continue
cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
if times:
print()
response = DataAccessLayer.getGridData(request, [times[-1]])
print("Recs : ", len(response))
if response:
grid = response[0]
else:
continue
data = grid.getRawData()
lons, lats = grid.getLatLonCoords()
nexrad_data[prod] = data
print('Time :', str(grid.getDataTime()))
flat = np.ndarray.flatten(data)
print('Name :', str(grid.getLocationName()))
print('Prod :', str(grid.getParameter()))
print('Range:' , np.nanmin(flat), " to ", np.nanmax(flat), " (Unit :", grid.getUnit(), ")")
print('Size :', str(data.shape))
print()
cmap = plt.get_cmap('rainbow')
bbox = [lons.min()-0.5, lons.max()+0.5, lats.min()-0.5, lats.max()+0.5]
fig, ax = make_map(bbox=bbox)
cs = ax.pcolormesh(lons, lats, data, cmap=cmap)
cbar = fig.colorbar(cs, extend='both', shrink=0.5, orientation='horizontal')
cbar.set_label(grid.getParameter() +" " + grid.getLevel() + " " \
+ grid.getLocationName() + " (" + prod + "), (" + grid.getUnit() + ") " \
+ "valid " + str(grid.getDataTime().getRefTime()))
plt.show()
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:37:23
Name : kmhx_0.0_464_464
Prod : Composite Refl
Range: 5.0 to 50.0 (Unit : dBZ )
Size : (464, 464)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_1.png
.. parsed-literal::
No levels found for Correlation Coeff
No levels found for Diff Reflectivity
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_230_360_0.0_359.0
Prod : Digital Hybrid Scan Refl
Range: -27.5 to 51.5 (Unit : dBZ )
Size : (230, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_3.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_920_360_0.0_359.0
Prod : Digital Inst Precip Rate
Range: 7.0555557e-09 to 2.3071667e-05 (Unit : m*sec^-1 )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_5.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_13_13
Prod : Digital Precip Array
Range: 190.0 to 690.0 (Unit : count )
Size : (13, 13)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_7.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:37:23
Name : kmhx_0.0_460_360_0.0_359.0
Prod : Digital Vert Integ Liq
Range: 0.0 to 18.834518 (Unit : kg*m^-2 )
Size : (460, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_9.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:37:23
Name : kmhx_0.0_116_116
Prod : Echo Tops
Range: 0.0 to 12192.0 (Unit : m )
Size : (116, 116)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_11.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:37:23
Name : kmhx_0.0_346_360_0.0_359.0
Prod : Enhanced Echo Tops
Range: nan to nan (Unit : m )
Size : (346, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_13.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_920_360_0.0_359.0
Prod : Hybrid Hydrometeor Class
Range: 1.0 to 14.0 (Unit : count )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_15.png
.. parsed-literal::
No levels found for Hydrometeor Class
No levels found for Melting Layer
Recs : 0
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_115_360_359.0_359.0
Prod : One Hour Accum
Range: 0.0 to 0.0127 (Unit : m )
Size : (115, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_17.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_920_360_0.0_359.0
Prod : One Hour Diff
Range: -0.008382 to 0.0027720002 (Unit : m )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_19.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_115_360_359.0_359.0
Prod : One Hour Precip
Range: 0.0 to 0.0127 (Unit : m )
Size : (115, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_21.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_920_360_0.0_359.0
Prod : One Hour Unbiased Accum
Range: 2.5775646e-05 to 0.017472787 (Unit : m )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_23.png
.. parsed-literal::
No levels found for Reflectivity
No levels found for Specific Diff Phase
No levels found for Storm Rel Velocity
Recs : 2
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_920_360_0.0_359.0
Prod : Storm Total Accum
Range: 0.000508 to 0.082804 (Unit : m )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_25.png
.. parsed-literal::
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_920_360_0.0_359.0
Prod : Storm Total Diff
Range: -0.08255 to 0.019499999 (Unit : m )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_27.png
.. parsed-literal::
Recs : 2
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_116_360_0.0_359.0
Prod : Storm Total Precip
Range: 0.0 to 0.088392 (Unit : m )
Size : (116, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_29.png
.. parsed-literal::
Recs : 0
Recs : 1
Time : 2018-10-17 16:11:08
Name : kmhx_0.0_920_360_0.0_359.0
Prod : User Select Accum
Range: 2.5399999e-05 to 0.033959802 (Unit : m )
Size : (920, 360)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_31.png
.. parsed-literal::
No levels found for Velocity
Recs : 1
Time : 2018-10-17 16:42:31
Name : kmhx_0.0_116_116
Prod : Vert Integ Liq
Range: 1.0 to 20.0 (Unit : kg*m^-2 )
Size : (116, 116)
.. image:: NEXRAD_Level3_Radar_files/NEXRAD_Level3_Radar_2_33.png

View file

@ -0,0 +1,215 @@
======================================
Precip Accumulation-Region Of Interest
======================================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Precip_Accumulation-Region_Of_Interest.ipynb>`_
A way to determine areas of greatest precipitation and generate imagery
for that sector.
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
from metpy.units import units
import numpy as np
from shapely.geometry import Point, Polygon
%matplotlib inline
conus=[-120, -65, 28, 50]
conus_envelope = Polygon([(conus[0],conus[2]),(conus[0],conus[3]),
(conus[1],conus[3]),(conus[1],conus[2]),
(conus[0],conus[2])])
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest("grid", envelope=conus_envelope)
request.setLocationNames("NAM40")
request.setLevels("0.0SFC")
request.setParameters("TP")
cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
fcstRun = DataAccessLayer.getForecastRun(cycles[-2], times)
Calculate accumulated precipitation
.. code:: ipython3
for i, tt in enumerate(fcstRun):
response = DataAccessLayer.getGridData(request, [tt])
grid = response[0]
if i>0:
data += grid.getRawData()
else:
data = grid.getRawData()
data[data <= -9999] = 0
print(data.min(), data.max(), grid.getDataTime().getFcstTime()/3600)
lons, lats = grid.getLatLonCoords()
bbox = [lons.min(), lons.max(), lats.min(), lats.max()]
fcstHr = int(grid.getDataTime().getFcstTime()/3600)
tp_inch = data * (0.0393701)
print(tp_inch.min(), tp_inch.max())
.. parsed-literal::
0.0 0.0 0.0
0.0 32.1875 3.0
0.0 52.125 6.0
0.0 74.375 9.0
0.0 77.125 12.0
0.0 78.625 15.0
0.0 78.75 18.0
0.0 78.75 21.0
0.0 79.375 24.0
0.0 82.25 27.0
0.0 84.0 30.0
0.0 84.6875 33.0
0.0 85.625 36.0
0.0 87.3125 39.0
0.0 87.75 42.0
0.0 87.75 45.0
0.0 89.375 48.0
0.0 127.875 51.0
0.0 139.5625 54.0
0.0 139.6875 57.0
0.0 140.5625 60.0
0.0 140.625 63.0
0.0 140.625 66.0
0.0 140.625 69.0
0.0 140.625 72.0
0.0 140.625 75.0
0.0 140.625 78.0
0.0 140.625 81.0
0.0 140.625 84.0
0.0 5.5364203
Determine lat/lon of maximum rainfall value:
.. code:: ipython3
ii,jj = np.where(tp_inch==tp_inch.max())
i=ii[0]
j=jj[0]
point = Point(lons[i][j], lats[i][j])
Draw CONUS map
.. code:: ipython3
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(20, 14),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
return fig, ax
cmap = plt.get_cmap('rainbow')
fig, ax = make_map(bbox=bbox)
cs = ax.pcolormesh(lons, lats, tp_inch, cmap=cmap)
cbar = fig.colorbar(cs, shrink=0.7, orientation='horizontal')
cbar.set_label(grid.getLocationName() + " Total precipitation in inches, " \
+ str(fcstHr) + "-hr fcst valid " + str(grid.getDataTime().getRefTime()))
ax.scatter(point.x, point.y, s=300,
transform=ccrs.PlateCarree(),marker="+",facecolor='black')
inc = 3.5
box=[point.x-inc, point.x+inc, point.y-inc, point.y+inc]
polygon = Polygon([(box[0],box[2]),(box[0],box[3]),
(box[1],box[3]),(box[1],box[2]),
(box[0],box[2])])
ax.add_geometries([polygon], ccrs.PlateCarree(), facecolor='none', edgecolor='white', linewidth=2)
.. parsed-literal::
<cartopy.mpl.feature_artist.FeatureArtist at 0x11b971da0>
.. image:: Precip_Accumulation-Region_Of_Interest_files/Precip_Accumulation-Region_Of_Interest_7_1.png
Now create a new gridded data request with a geometry envelope for our
Region of Interest
.. code:: ipython3
request = DataAccessLayer.newDataRequest("grid", envelope=polygon)
request.setLocationNames("HRRR")
request.setLevels("0.0SFC")
request.setParameters("TP")
cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
fcstRun = DataAccessLayer.getForecastRun(cycles[-2], times)
for i, tt in enumerate(fcstRun):
response = DataAccessLayer.getGridData(request, [tt])
grid = response[0]
if i>0:
data += grid.getRawData()
else:
data = grid.getRawData()
data[data <= -9999] = 0
print(data.min(), data.max(), grid.getDataTime().getFcstTime()/3600)
lons, lats = grid.getLatLonCoords()
bbox = [lons.min(), lons.max(), lats.min(), lats.max()]
fcstHr = int(grid.getDataTime().getFcstTime()/3600)
tp_inch = data * (0.0393701)
print(tp_inch.min(), tp_inch.max())
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(20, 14),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
return fig, ax
cmap = plt.get_cmap('rainbow')
fig, ax = make_map(bbox=box)
cs = ax.pcolormesh(lons, lats, tp_inch, cmap=cmap)
cbar = fig.colorbar(cs, shrink=0.7, orientation='horizontal')
cbar.set_label(grid.getLocationName() + " Total precipitation in inches, " \
+ str(fcstHr) + "-hr fcst valid " + str(grid.getDataTime().getRefTime()))
.. parsed-literal::
0.0 1.853 1.0
0.0 3.5290003 2.0
0.0 5.0290003 3.0
0.0 5.051 4.0
0.0 5.2960005 5.0
0.0 5.2960005 6.0
0.0 5.8269997 7.0
0.0 6.1790004 8.0
0.0 6.1890006 9.0
0.0 9.071 10.0
0.0 10.812 11.0
0.0 14.718 12.0
0.0 18.295 13.0
0.0 21.339 14.0
0.0 22.626 15.0
0.0 28.670002 16.0
0.0 32.334 17.0
0.0 36.628002 18.0
0.0 1.4420482
.. image:: Precip_Accumulation-Region_Of_Interest_files/Precip_Accumulation-Region_Of_Interest_9_1.png

View file

@ -0,0 +1,344 @@
=========================
Regional Surface Obs Plot
=========================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Regional_Surface_Obs_Plot.ipynb>`_
This exercise creates a surface observsation station plot for the state
of Florida, using both METAR (datatype *obs*) and Synoptic (datatype
*sfcobs*). Because we are using the AWIPS Map Database for state and
county boundaries, there is no use of Cartopy ``cfeature`` in this
exercise.
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
from datetime import datetime, timedelta
import numpy as np
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
from cartopy.feature import ShapelyFeature
from shapely.geometry import Polygon
import matplotlib.pyplot as plt
from metpy.units import units
from metpy.calc import wind_components
from metpy.plots import simple_layout, StationPlot, StationPlotLayout
import warnings
%matplotlib inline
def get_cloud_cover(code):
if 'OVC' in code:
return 1.0
elif 'BKN' in code:
return 6.0/8.0
elif 'SCT' in code:
return 4.0/8.0
elif 'FEW' in code:
return 2.0/8.0
else:
return 0
.. code:: ipython3
# EDEX request for a single state
edexServer = "edex-cloud.unidata.ucar.edu"
DataAccessLayer.changeEDEXHost(edexServer)
request = DataAccessLayer.newDataRequest('maps')
request.addIdentifier('table', 'mapdata.states')
request.addIdentifier('state', 'FL')
request.addIdentifier('geomField', 'the_geom')
request.setParameters('state','name','lat','lon')
response = DataAccessLayer.getGeometryData(request)
record = response[0]
print("Found " + str(len(response)) + " MultiPolygon")
state={}
state['name'] = record.getString('name')
state['state'] = record.getString('state')
state['lat'] = record.getNumber('lat')
state['lon'] = record.getNumber('lon')
#state['geom'] = record.getGeometry()
state['bounds'] = record.getGeometry().bounds
print(state['name'], state['state'], state['lat'], state['lon'], state['bounds'])
print()
# EDEX request for multiple states
request = DataAccessLayer.newDataRequest('maps')
request.addIdentifier('table', 'mapdata.states')
request.addIdentifier('geomField', 'the_geom')
request.addIdentifier('inLocation', 'true')
request.addIdentifier('locationField', 'state')
request.setParameters('state','name','lat','lon')
request.setLocationNames('FL','GA','MS','AL','SC','LA')
response = DataAccessLayer.getGeometryData(request)
print("Found " + str(len(response)) + " MultiPolygons")
# Append each geometry to a numpy array
states = np.array([])
for ob in response:
print(ob.getString('name'), ob.getString('state'), ob.getNumber('lat'), ob.getNumber('lon'))
states = np.append(states,ob.getGeometry())
.. parsed-literal::
Found 1 MultiPolygon
Florida FL 28.67402 -82.50934 (-87.63429260299995, 24.521051616000022, -80.03199876199994, 31.001012802000048)
Found 6 MultiPolygons
Florida FL 28.67402 -82.50934
Georgia GA 32.65155 -83.44848
Louisiana LA 31.0891 -92.02905
Alabama AL 32.79354 -86.82676
Mississippi MS 32.75201 -89.66553
South Carolina SC 33.93574 -80.89899
Now make sure we can plot the states with a lat/lon grid.
.. code:: ipython3
def make_map(bbox, proj=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(16,12),subplot_kw=dict(projection=proj))
ax.set_extent(bbox)
gl = ax.gridlines(draw_labels=True, color='#e7e7e7')
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
# buffer our bounds by +/i degrees lat/lon
bounds = state['bounds']
bbox=[bounds[0]-3,bounds[2]+3,bounds[1]-1.5,bounds[3]+1.5]
fig, ax = make_map(bbox=bbox)
shape_feature = ShapelyFeature(states,ccrs.PlateCarree(),
facecolor='none', linestyle="-",edgecolor='#000000',linewidth=2)
ax.add_feature(shape_feature)
.. parsed-literal::
<cartopy.mpl.feature_artist.FeatureArtist at 0x11dcfedd8>
.. image:: Regional_Surface_Obs_Plot_files/Regional_Surface_Obs_Plot_4_1.png
--------------
Plot METAR (obs)
----------------
Here we use a spatial envelope to limit the request to the boundary or
our plot. Without such a filter you may be requesting many tens of
thousands of records.
.. code:: ipython3
# Create envelope geometry
envelope = Polygon([(bbox[0],bbox[2]),(bbox[0],bbox[3]),
(bbox[1], bbox[3]),(bbox[1],bbox[2]),
(bbox[0],bbox[2])])
# New obs request
DataAccessLayer.changeEDEXHost(edexServer)
request = DataAccessLayer.newDataRequest("obs", envelope=envelope)
availableProducts = DataAccessLayer.getAvailableParameters(request)
single_value_params = ["timeObs", "stationName", "longitude", "latitude",
"temperature", "dewpoint", "windDir",
"windSpeed", "seaLevelPress"]
multi_value_params = ["presWeather", "skyCover", "skyLayerBase"]
params = single_value_params + multi_value_params
request.setParameters(*(params))
# Time range
lastHourDateTime = datetime.utcnow() - timedelta(minutes = 60)
start = lastHourDateTime.strftime('%Y-%m-%d %H:%M:%S')
end = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
beginRange = datetime.strptime( start , "%Y-%m-%d %H:%M:%S")
endRange = datetime.strptime( end , "%Y-%m-%d %H:%M:%S")
timerange = TimeRange(beginRange, endRange)
# Get response
response = DataAccessLayer.getGeometryData(request,timerange)
# function getMetarObs was added in python-awips 18.1.4
obs = DataAccessLayer.getMetarObs(response)
print("Found " + str(len(response)) + " records")
print("Using " + str(len(obs['temperature'])) + " temperature records")
.. parsed-literal::
Found 3468 records
Using 152 temperature records
Next grab the simple variables out of the data we have (attaching
correct units), and put them into a dictionary that we will hand the
plotting function later:
- Get wind components from speed and direction
- Convert cloud fraction values to integer codes [0 - 8]
- Map METAR weather codes to WMO codes for weather symbols
.. code:: ipython3
data = dict()
data['stid'] = np.array(obs['stationName'])
data['latitude'] = np.array(obs['latitude'])
data['longitude'] = np.array(obs['longitude'])
tmp = np.array(obs['temperature'], dtype=float)
dpt = np.array(obs['dewpoint'], dtype=float)
# Suppress nan masking warnings
warnings.filterwarnings("ignore",category =RuntimeWarning)
tmp[tmp == -9999.0] = 'nan'
dpt[dpt == -9999.] = 'nan'
data['air_temperature'] = tmp * units.degC
data['dew_point_temperature'] = dpt * units.degC
data['air_pressure_at_sea_level'] = np.array(obs['seaLevelPress'])* units('mbar')
direction = np.array(obs['windDir'])
direction[direction == -9999.0] = 'nan'
u, v = wind_components(np.array(obs['windSpeed']) * units('knots'),
direction * units.degree)
data['eastward_wind'], data['northward_wind'] = u, v
data['cloud_coverage'] = [int(get_cloud_cover(x)*8) for x in obs['skyCover']]
data['present_weather'] = obs['presWeather']
proj = ccrs.LambertConformal(central_longitude=state['lon'], central_latitude=state['lat'],
standard_parallels=[35])
custom_layout = StationPlotLayout()
custom_layout.add_barb('eastward_wind', 'northward_wind', units='knots')
custom_layout.add_value('NW', 'air_temperature', fmt='.0f', units='degF', color='darkred')
custom_layout.add_value('SW', 'dew_point_temperature', fmt='.0f', units='degF', color='darkgreen')
custom_layout.add_value('E', 'precipitation', fmt='0.1f', units='inch', color='blue')
ax.set_title(str(response[-1].getDataTime()) + " | METAR Surface Obs | " + edexServer)
stationplot = StationPlot(ax, data['longitude'], data['latitude'], clip_on=True,
transform=ccrs.PlateCarree(), fontsize=10)
custom_layout.plot(stationplot, data)
fig
.. image:: Regional_Surface_Obs_Plot_files/Regional_Surface_Obs_Plot_8_0.png
--------------
Plot Synoptic (sfcobs)
----------------------
.. code:: ipython3
# New sfcobs/SYNOP request
DataAccessLayer.changeEDEXHost(edexServer)
request = DataAccessLayer.newDataRequest("sfcobs", envelope=envelope)
availableProducts = DataAccessLayer.getAvailableParameters(request)
# (sfcobs) uses stationId, while (obs) uses stationName,
# the rest of these parameters are the same.
single_value_params = ["timeObs", "stationId", "longitude", "latitude",
"temperature", "dewpoint", "windDir",
"windSpeed", "seaLevelPress"]
multi_value_params = ["presWeather", "skyCover", "skyLayerBase"]
pres_weather, sky_cov, sky_layer_base = [],[],[]
params = single_value_params + multi_value_params
request.setParameters(*(params))
# Time range
lastHourDateTime = datetime.utcnow() - timedelta(minutes = 60)
start = lastHourDateTime.strftime('%Y-%m-%d %H:%M:%S')
end = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
beginRange = datetime.strptime( start , "%Y-%m-%d %H:%M:%S")
endRange = datetime.strptime( end , "%Y-%m-%d %H:%M:%S")
timerange = TimeRange(beginRange, endRange)
# Get response
response = DataAccessLayer.getGeometryData(request,timerange)
# function getSynopticObs was added in python-awips 18.1.4
sfcobs = DataAccessLayer.getSynopticObs(response)
print("Found " + str(len(response)) + " records")
print("Using " + str(len(sfcobs['temperature'])) + " temperature records")
.. parsed-literal::
Found 260 records
Using 78 temperature records
.. code:: ipython3
data = dict()
data['stid'] = np.array(sfcobs['stationId'])
data['lat'] = np.array(sfcobs['latitude'])
data['lon'] = np.array(sfcobs['longitude'])
# Synop/sfcobs temps are stored in kelvin (degC for METAR/obs)
tmp = np.array(sfcobs['temperature'], dtype=float)
dpt = np.array(sfcobs['dewpoint'], dtype=float)
direction = np.array(sfcobs['windDir'])
# Account for missing values
tmp[tmp == -9999.0] = 'nan'
dpt[dpt == -9999.] = 'nan'
direction[direction == -9999.0] = 'nan'
data['air_temperature'] = tmp * units.kelvin
data['dew_point_temperature'] = dpt * units.kelvin
data['air_pressure_at_sea_level'] = np.array(sfcobs['seaLevelPress'])* units('mbar')
try:
data['eastward_wind'], data['northward_wind'] = wind_components(
np.array(sfcobs['windSpeed']) * units('knots'),direction * units.degree)
data['present_weather'] = sfcobs['presWeather']
except ValueError:
pass
fig_synop, ax_synop = make_map(bbox=bbox)
shape_feature = ShapelyFeature(states,ccrs.PlateCarree(),
facecolor='none', linestyle="-",edgecolor='#000000',linewidth=2)
ax_synop.add_feature(shape_feature)
custom_layout = StationPlotLayout()
custom_layout.add_barb('eastward_wind', 'northward_wind', units='knots')
custom_layout.add_value('NW', 'air_temperature', fmt='.0f', units='degF', color='darkred')
custom_layout.add_value('SW', 'dew_point_temperature', fmt='.0f', units='degF', color='darkgreen')
custom_layout.add_value('E', 'precipitation', fmt='0.1f', units='inch', color='blue')
ax_synop.set_title(str(response[-1].getDataTime()) + " | SYNOP Surface Obs | " + edexServer)
stationplot = StationPlot(ax_synop, data['lon'], data['lat'], clip_on=True,
transform=ccrs.PlateCarree(), fontsize=10)
custom_layout.plot(stationplot, data)
.. image:: Regional_Surface_Obs_Plot_files/Regional_Surface_Obs_Plot_11_0.png
--------------
Plot both METAR and SYNOP
-------------------------
.. code:: ipython3
custom_layout = StationPlotLayout()
custom_layout.add_barb('eastward_wind', 'northward_wind', units='knots')
custom_layout.add_value('NW', 'air_temperature', fmt='.0f', units='degF', color='darkred')
custom_layout.add_value('SW', 'dew_point_temperature', fmt='.0f', units='degF', color='darkgreen')
custom_layout.add_value('E', 'precipitation', fmt='0.1f', units='inch', color='blue')
ax.set_title(str(response[-1].getDataTime()) + " | METAR/SYNOP Surface Obs | " + edexServer)
stationplot = StationPlot(ax, data['lon'], data['lat'], clip_on=True,
transform=ccrs.PlateCarree(), fontsize=10)
custom_layout.plot(stationplot, data)
fig
.. image:: Regional_Surface_Obs_Plot_files/Regional_Surface_Obs_Plot_13_0.png

View file

@ -0,0 +1,664 @@
=================
Satellite Imagery
=================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Satellite_Imagery.ipynb>`_
Satellite images are returned by Python AWIPS as grids, and can be
rendered with Cartopy pcolormesh the same as gridded forecast models in
other python-awips examples.
Available Sources, Creating Entities, Sectors, and Products
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
import cartopy.crs as ccrs
import cartopy.feature as cfeat
import matplotlib.pyplot as plt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import numpy as np
import datetime
# Create an EDEX data request
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest()
request.setDatatype("satellite")
# get optional identifiers for satellite datatype
identifiers = set(DataAccessLayer.getOptionalIdentifiers(request))
print("Available Identifiers:")
for id in identifiers:
if id.lower() == 'datauri':
continue
print(" - " + id)
.. parsed-literal::
Available Identifiers:
- physicalElement
- creatingEntity
- source
- sectorID
.. code:: ipython3
# Show available sources
identifier = "source"
sources = DataAccessLayer.getIdentifierValues(request, identifier)
print(identifier + ":")
print(list(sources))
.. parsed-literal::
source:
['NESDIS', 'WCDAS', 'NSOF', 'UCAR', 'McIDAS']
.. code:: ipython3
# Show available creatingEntities
identifier = "creatingEntity"
creatingEntities = DataAccessLayer.getIdentifierValues(request, identifier)
print(identifier + ":")
print(list(creatingEntities))
.. parsed-literal::
creatingEntity:
['GOES-16', 'Composite', 'GOES-15(P)', 'POES-NPOESS', 'UNIWISC', 'GOES-11(L)', 'Miscellaneous', 'GOES-17', 'NEXRCOMP']
.. code:: ipython3
# Show available sectorIDs
identifier = "sectorID"
sectorIDs = DataAccessLayer.getIdentifierValues(request, identifier)
print(identifier + ":")
print(list(sectorIDs))
.. parsed-literal::
sectorID:
['EMESO-2', 'Northern Hemisphere Composite', 'EFD', 'TCONUS', 'Arctic', 'TFD', 'PRREGI', 'GOES-Sounder', 'EMESO-1', 'NEXRCOMP', 'ECONUS', 'GOES-West', 'Antarctic', 'GOES-East', 'Supernational', 'West CONUS', 'NH Composite - Meteosat-GOES E-GOES W-GMS']
.. code:: ipython3
# Contrust a full satellite product tree
for entity in creatingEntities:
print(entity)
request = DataAccessLayer.newDataRequest("satellite")
request.addIdentifier("creatingEntity", entity)
availableSectors = DataAccessLayer.getAvailableLocationNames(request)
availableSectors.sort()
for sector in availableSectors:
print(" - " + sector)
request.setLocationNames(sector)
availableProducts = DataAccessLayer.getAvailableParameters(request)
availableProducts.sort()
for product in availableProducts:
print(" - " + product)
.. parsed-literal::
GOES-16
- ECONUS
- ACTP
- ADP
- AOD
- CAPE
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
- CSM
- CTH
- FDC Area
- FDC Power
- FDC Temp
- KI
- LI
- LST
- SI
- TPW
- TT
- VMP-0.00hPa
- VMP-0.02hPa
- VMP-0.04hPa
- VMP-0.08hPa
- VMP-0.14hPa
- VMP-0.22hPa
- VMP-0.35hPa
- VMP-0.51hPa
- VMP-0.71hPa
- VMP-0.98hPa
- VMP-1.30hPa
- VMP-1.69hPa
- VMP-1013.95hPa
- VMP-103.02hPa
- VMP-1042.23hPa
- VMP-1070.92hPa
- VMP-11.00hPa
- VMP-110.24hPa
- VMP-1100.00hPa
- VMP-117.78hPa
- VMP-12.65hPa
- VMP-125.65hPa
- VMP-133.85hPa
- VMP-14.46hPa
- VMP-142.38hPa
- VMP-151.27hPa
- VMP-16.43hPa
- VMP-160.50hPa
- VMP-170.08hPa
- VMP-18.58hPa
- VMP-180.02hPa
- VMP-190.32hPa
- VMP-2.15hPa
- VMP-2.70hPa
- VMP-20.92hPa
- VMP-200.99hPa
- VMP-212.03hPa
- VMP-223.44hPa
- VMP-23.45hPa
- VMP-235.23hPa
- VMP-247.41hPa
- VMP-259.97hPa
- VMP-26.18hPa
- VMP-272.92hPa
- VMP-286.26hPa
- VMP-29.12hPa
- VMP-3.34hPa
- VMP-300.00hPa
- VMP-314.14hPa
- VMP-32.27hPa
- VMP-328.68hPa
- VMP-343.62hPa
- VMP-35.65hPa
- VMP-358.97hPa
- VMP-374.72hPa
- VMP-39.26hPa
- VMP-390.89hPa
- VMP-4.08hPa
- VMP-4.92hPa
- VMP-407.47hPa
- VMP-424.47hPa
- VMP-43.10hPa
- VMP-441.88hPa
- VMP-459.71hPa
- VMP-47.19hPa
- VMP-477.96hPa
- VMP-496.63hPa
- VMP-5.88hPa
- VMP-51.53hPa
- VMP-515.72hPa
- VMP-535.23hPa
- VMP-555.17hPa
- VMP-56.13hPa
- VMP-575.52hPa
- VMP-596.31hPa
- VMP-6.96hPa
- VMP-60.99hPa
- VMP-617.51hPa
- VMP-639.14hPa
- VMP-66.13hPa
- VMP-661.19hPa
- VMP-683.67hPa
- VMP-706.57hPa
- VMP-71.54hPa
- VMP-729.89hPa
- VMP-753.63hPa
- VMP-77.24hPa
- VMP-777.79hPa
- VMP-8.17hPa
- VMP-802.37hPa
- VMP-827.37hPa
- VMP-83.23hPa
- VMP-852.79hPa
- VMP-878.62hPa
- VMP-89.52hPa
- VMP-9.51hPa
- VMP-904.87hPa
- VMP-931.52hPa
- VMP-958.59hPa
- VMP-96.11hPa
- VMP-986.07hPa
- VTP-0.00hPa
- VTP-0.02hPa
- VTP-0.04hPa
- VTP-0.08hPa
- VTP-0.14hPa
- VTP-0.22hPa
- VTP-0.35hPa
- VTP-0.51hPa
- VTP-0.71hPa
- VTP-0.98hPa
- VTP-1.30hPa
- VTP-1.69hPa
- VTP-1013.95hPa
- VTP-103.02hPa
- VTP-1042.23hPa
- VTP-1070.92hPa
- VTP-11.00hPa
- VTP-110.24hPa
- VTP-1100.00hPa
- VTP-117.78hPa
- VTP-12.65hPa
- VTP-125.65hPa
- VTP-133.85hPa
- VTP-14.46hPa
- VTP-142.38hPa
- VTP-151.27hPa
- VTP-16.43hPa
- VTP-160.50hPa
- VTP-170.08hPa
- VTP-18.58hPa
- VTP-180.02hPa
- VTP-190.32hPa
- VTP-2.15hPa
- VTP-2.70hPa
- VTP-20.92hPa
- VTP-200.99hPa
- VTP-212.03hPa
- VTP-223.44hPa
- VTP-23.45hPa
- VTP-235.23hPa
- VTP-247.41hPa
- VTP-259.97hPa
- VTP-26.18hPa
- VTP-272.92hPa
- VTP-286.26hPa
- VTP-29.12hPa
- VTP-3.34hPa
- VTP-300.00hPa
- VTP-314.14hPa
- VTP-32.27hPa
- VTP-328.68hPa
- VTP-343.62hPa
- VTP-35.65hPa
- VTP-358.97hPa
- VTP-374.72hPa
- VTP-39.26hPa
- VTP-390.89hPa
- VTP-4.08hPa
- VTP-4.92hPa
- VTP-407.47hPa
- VTP-424.47hPa
- VTP-43.10hPa
- VTP-441.88hPa
- VTP-459.71hPa
- VTP-47.19hPa
- VTP-477.96hPa
- VTP-496.63hPa
- VTP-5.88hPa
- VTP-51.53hPa
- VTP-515.72hPa
- VTP-535.23hPa
- VTP-555.17hPa
- VTP-56.13hPa
- VTP-575.52hPa
- VTP-596.31hPa
- VTP-6.96hPa
- VTP-60.99hPa
- VTP-617.51hPa
- VTP-639.14hPa
- VTP-66.13hPa
- VTP-661.19hPa
- VTP-683.67hPa
- VTP-706.57hPa
- VTP-71.54hPa
- VTP-729.89hPa
- VTP-753.63hPa
- VTP-77.24hPa
- VTP-777.79hPa
- VTP-8.17hPa
- VTP-802.37hPa
- VTP-827.37hPa
- VTP-83.23hPa
- VTP-852.79hPa
- VTP-878.62hPa
- VTP-89.52hPa
- VTP-9.51hPa
- VTP-904.87hPa
- VTP-931.52hPa
- VTP-958.59hPa
- VTP-96.11hPa
- VTP-986.07hPa
- EFD
- ACTP
- ADP
- AOD
- CAPE
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
- CSM
- CTH
- CTT
- FDC Area
- FDC Power
- FDC Temp
- KI
- LI
- LST
- RRQPE
- SI
- SST
- TPW
- TT
- VAH
- VAML
- EMESO-1
- ACTP
- ADP
- CAPE
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
- CSM
- CTH
- CTT
- KI
- LI
- LST
- SI
- TPW
- TT
- EMESO-2
- ACTP
- ADP
- CAPE
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
- CSM
- CTH
- CTT
- KI
- LI
- LST
- SI
- TPW
- TT
- PRREGI
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
Composite
- NH Composite - Meteosat-GOES E-GOES W-GMS
- Imager 11 micron IR
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- Supernational
- Gridded Cloud Amount
- Gridded Cloud Top Pressure or Height
- Sounder Based Derived Lifted Index (LI)
- Sounder Based Derived Precipitable Water (PW)
- Sounder Based Derived Surface Skin Temp (SFC Skin)
GOES-15(P)
- Northern Hemisphere Composite
- Imager 11 micron IR
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- Supernational
- Imager 11 micron IR
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- West CONUS
- Imager 11 micron IR
- Imager 13 micron IR
- Imager 3.9 micron IR
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- Sounder 11.03 micron imagery
- Sounder 14.06 micron imagery
- Sounder 3.98 micron imagery
- Sounder 4.45 micron imagery
- Sounder 6.51 micron imagery
- Sounder 7.02 micron imagery
- Sounder 7.43 micron imagery
- Sounder Visible imagery
POES-NPOESS
- Supernational
- Rain fall rate
UNIWISC
- Antarctic
- Imager 11 micron IR
- Imager 12 micron IR
- Imager 3.5-4.0 micron IR (Fog)
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- Arctic
- Imager 11 micron IR
- Imager 12 micron IR
- Imager 3.5-4.0 micron IR (Fog)
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- GOES-East
- Imager 11 micron IR
- Imager 13 micron IR
- Imager 3.5-4.0 micron IR (Fog)
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
- GOES-Sounder
- CAPE
- Sounder Based Derived Lifted Index (LI)
- Sounder Based Derived Precipitable Water (PW)
- Sounder Based Total Column Ozone
- GOES-West
- Imager 11 micron IR
- Imager 13 micron IR
- Imager 3.5-4.0 micron IR (Fog)
- Imager 6.7-6.5 micron IR (WV)
- Imager Visible
GOES-11(L)
- West CONUS
- Low cloud base imagery
Miscellaneous
- Supernational
- Percent of Normal TPW
- Sounder Based Derived Precipitable Water (PW)
GOES-17
- TCONUS
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
- TFD
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
- CH-05-1.61um
- CH-06-2.25um
- CH-07-3.90um
- CH-08-6.19um
- CH-09-6.95um
- CH-10-7.34um
- CH-11-8.50um
- CH-12-9.61um
- CH-13-10.35um
- CH-14-11.20um
- CH-15-12.30um
- CH-16-13.30um
NEXRCOMP
- NEXRCOMP
- DHR
- DVL
- EET
- HHC
- N0R
- N1P
- NTP
GOES 16 Mesoscale Sectors
-------------------------
Define our imports, and define our map properties first.
.. code:: ipython3
%matplotlib inline
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(10,12),
subplot_kw=dict(projection=projection))
if bbox[0] is not np.nan:
ax.set_extent(bbox)
ax.coastlines(resolution='50m')
gl = ax.gridlines(draw_labels=True)
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
sectors = ["EMESO-1","EMESO-2"]
fig = plt.figure(figsize=(16,7*len(sectors)))
for i, sector in enumerate(sectors):
request = DataAccessLayer.newDataRequest()
request.setDatatype("satellite")
request.setLocationNames(sector)
request.setParameters("CH-13-10.35um")
utc = datetime.datetime.utcnow()
times = DataAccessLayer.getAvailableTimes(request)
hourdiff = utc - datetime.datetime.strptime(str(times[-1]),'%Y-%m-%d %H:%M:%S')
hours,days = hourdiff.seconds/3600,hourdiff.days
minute = str((hourdiff.seconds - (3600 * hours)) / 60)
offsetStr = ''
if hours > 0:
offsetStr += str(hours) + "hr "
offsetStr += str(minute) + "m ago"
if days > 1:
offsetStr = str(days) + " days ago"
response = DataAccessLayer.getGridData(request, [times[-1]])
grid = response[0]
data = grid.getRawData()
lons,lats = grid.getLatLonCoords()
bbox = [lons.min(), lons.max(), lats.min(), lats.max()]
print("Latest image available: "+str(times[-1]) + " ("+offsetStr+")")
print("Image grid size: " + str(data.shape))
print("Image grid extent: " + str(list(bbox)))
fig, ax = make_map(bbox=bbox)
states = cfeat.NaturalEarthFeature(category='cultural',
name='admin_1_states_provinces_lines',
scale='50m', facecolor='none')
ax.add_feature(states, linestyle=':')
cs = ax.pcolormesh(lons, lats, data, cmap='coolwarm')
cbar = fig.colorbar(cs, shrink=0.6, orientation='horizontal')
cbar.set_label(sector + " " + grid.getParameter() + " " \
+ str(grid.getDataTime().getRefTime()))
.. parsed-literal::
Latest image available: 2018-10-09 19:17:28 (0.021388888888888888hr 0.0m ago)
Image grid size: (500, 500)
Image grid extent: [-92.47462, -80.657455, 20.24799, 31.116167]
Latest image available: 2018-10-09 14:30:58 (4.797777777777778hr 0.0m ago)
Image grid size: (500, 500)
Image grid extent: [-104.61595, -87.45227, 29.422266, 42.70851]
.. parsed-literal::
<Figure size 1152x1008 with 0 Axes>
.. image:: Satellite_Imagery_files/Satellite_Imagery_7_2.png
.. image:: Satellite_Imagery_files/Satellite_Imagery_7_3.png

View file

@ -0,0 +1,148 @@
========================
Upper Air BUFR Soundings
========================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Upper_Air_BUFR_Soundings.ipynb>`_
The following script takes you through the steps of retrieving an Upper
Air vertical profile from an AWIPS EDEX server and plotting a
Skew-T/Log-P chart with Matplotlib and MetPy.
The **bufrua** plugin returns separate objects for parameters at
**mandatory levels** and at **significant temperature levels**. For the
Skew-T/Log-P plot, significant temperature levels are used to plot the
pressure, temperature, and dewpoint lines, while mandatory levels are
used to plot the wind profile.
.. code:: ipython3
%matplotlib inline
from awips.dataaccess import DataAccessLayer
import matplotlib.tri as mtri
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
import math
from metpy.calc import wind_speed, wind_components, lcl, dry_lapse, parcel_profile
from metpy.plots import SkewT, Hodograph
from metpy.units import units, concatenate
# Set host
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest()
# Set data type
request.setDatatype("bufrua")
availableLocs = DataAccessLayer.getAvailableLocationNames(request)
availableLocs.sort()
MAN_PARAMS = set(['prMan', 'htMan', 'tpMan', 'tdMan', 'wdMan', 'wsMan'])
SIGT_PARAMS = set(['prSigT', 'tpSigT', 'tdSigT'])
request.setParameters("wmoStaNum", "validTime", "rptType", "staElev", "numMand",
"numSigT", "numSigW", "numTrop", "numMwnd", "staName")
request.getParameters().extend(MAN_PARAMS)
request.getParameters().extend(SIGT_PARAMS)
locations = DataAccessLayer.getAvailableLocationNames(request)
locations.sort()
# Set station ID (not name)
request.setLocationNames("72562") #KLBF
# Get all times
datatimes = DataAccessLayer.getAvailableTimes(request)
# Get most recent record
response = DataAccessLayer.getGeometryData(request,times=datatimes[-1].validPeriod)
# Initialize data arrays
tdMan,tpMan,prMan,wdMan,wsMan = np.array([]),np.array([]),np.array([]),np.array([]),np.array([])
prSig,tpSig,tdSig = np.array([]),np.array([]),np.array([])
manGeos = []
sigtGeos = []
# Build arrays
for ob in response:
parm_array = ob.getParameters()
if set(parm_array) & MAN_PARAMS:
manGeos.append(ob)
prMan = np.append(prMan,ob.getNumber("prMan"))
tpMan, tpUnit = np.append(tpMan,ob.getNumber("tpMan")), ob.getUnit("tpMan")
tdMan, tdUnit = np.append(tdMan,ob.getNumber("tdMan")), ob.getUnit("tdMan")
wdMan = np.append(wdMan,ob.getNumber("wdMan"))
wsMan, wsUnit = np.append(wsMan,ob.getNumber("wsMan")), ob.getUnit("wsMan")
continue
if set(parm_array) & SIGT_PARAMS:
sigtGeos.append(ob)
prSig = np.append(prSig,ob.getNumber("prSigT"))
tpSig = np.append(tpSig,ob.getNumber("tpSigT"))
tdSig = np.append(tdSig,ob.getNumber("tdSigT"))
continue
# Sort mandatory levels (but not sigT levels) because of the 1000.MB interpolation inclusion
ps = prMan.argsort()[::-1]
wpres = prMan[ps]
direc = wdMan[ps]
spd = wsMan[ps]
tman = tpMan[ps]
dman = tdMan[ps]
# Flag missing data
prSig[prSig <= -9999] = np.nan
tpSig[tpSig <= -9999] = np.nan
tdSig[tdSig <= -9999] = np.nan
wpres[wpres <= -9999] = np.nan
tman[tman <= -9999] = np.nan
dman[dman <= -9999] = np.nan
direc[direc <= -9999] = np.nan
spd[spd <= -9999] = np.nan
# assign units
p = (prSig/100) * units.mbar
wpres = (wpres/100) * units.mbar
u,v = wind_components(spd * units.knots, np.deg2rad(direc))
if tpUnit == 'K':
T = (tpSig-273.15) * units.degC
Td = (tdSig-273.15) * units.degC
tman = tman * units.degC
dman = dman * units.degC
# Create SkewT/LogP
plt.rcParams['figure.figsize'] = (10, 12)
skew = SkewT()
skew.plot(p, T, 'r', linewidth=2)
skew.plot(p, Td, 'g', linewidth=2)
skew.plot_barbs(wpres, u, v)
skew.ax.set_ylim(1000, 100)
skew.ax.set_xlim(-60, 30)
title_string = " T(F) Td "
title_string += " " + str(ob.getString("staName"))
title_string += " " + str(ob.getDataTime().getRefTime())
title_string += " (" + str(ob.getNumber("staElev")) + "m elev)"
title_string += "\n" + str(round(T[0].to('degF').item(),1))
title_string += " " + str(round(Td[0].to('degF').item(),1))
plt.title(title_string, loc='left')
# Calculate LCL height and plot as black dot
lcl_pressure, lcl_temperature = lcl(p[0], T[0], Td[0])
skew.plot(lcl_pressure, lcl_temperature, 'ko', markerfacecolor='black')
# Calculate full parcel profile and add to plot as black line
prof = parcel_profile(p, T[0], Td[0]).to('degC')
skew.plot(p, prof, 'k', linewidth=2)
# An example of a slanted line at constant T -- in this case the 0 isotherm
l = skew.ax.axvline(0, color='c', linestyle='--', linewidth=2)
# Draw hodograph
ax_hod = inset_axes(skew.ax, '30%', '30%', loc=3)
h = Hodograph(ax_hod, component_range=max(wsMan))
h.add_grid(increment=20)
h.plot_colormapped(u, v, spd)
# Show the plot
plt.show()
.. image:: Upper_Air_BUFR_Soundings_files/Upper_Air_BUFR_Soundings_1_0.png

View file

@ -0,0 +1,139 @@
==========================
Watch and Warning Polygons
==========================
`Notebook <http://nbviewer.ipython.org/github/Unidata/python-awips/blob/master/examples/notebooks/Watch_and_Warning_Polygons.ipynb>`_
This example uses matplotlib, cartopy, shapely, and python-awips to plot
watch and warning polygons requested from a real-time AWIPS EDEX server.
First, set up our imports and define functions to be used later:
.. code:: ipython3
from awips.dataaccess import DataAccessLayer
from awips.tables import vtec
from datetime import datetime
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
from cartopy.feature import ShapelyFeature,NaturalEarthFeature
from shapely.geometry import MultiPolygon,Polygon
def warning_color(phensig):
return vtec[phensig]['color']
def make_map(bbox, projection=ccrs.PlateCarree()):
fig, ax = plt.subplots(figsize=(20,12),
subplot_kw=dict(projection=projection))
ax.set_extent(bbox)
gl = ax.gridlines(draw_labels=True)
gl.top_labels = gl.right_labels = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
return fig, ax
Next, we create a request for the "warning" data type:
.. code:: ipython3
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
request = DataAccessLayer.newDataRequest()
request.setDatatype("warning")
request.setParameters('phensig')
times = DataAccessLayer.getAvailableTimes(request)
# Get records for last 50 available times
response = DataAccessLayer.getGeometryData(request, times[-50:-1])
print("Using " + str(len(response)) + " records")
# Each record will have a numpy array the length of the number of "parameters"
# Default is 1 (request.setParameters('phensig'))
parameters = {}
for x in request.getParameters():
parameters[x] = np.array([])
print(parameters)
.. parsed-literal::
Using 109 records
{'phensig': array([], dtype=float64)}
Now loop through each record and plot it as either Polygon or
MultiPolygon, with appropriate colors
.. code:: ipython3
%matplotlib inline
bbox=[-127,-64,24,49]
fig, ax = make_map(bbox=bbox)
siteids=np.array([])
periods=np.array([])
reftimes=np.array([])
for ob in response:
poly = ob.getGeometry()
site = ob.getLocationName()
pd = ob.getDataTime().getValidPeriod()
ref = ob.getDataTime().getRefTime()
# do not plot if phensig is blank (SPS)
if ob.getString('phensig'):
phensigString = ob.getString('phensig')
siteids = np.append(siteids,site)
periods = np.append(periods,pd)
reftimes = np.append(reftimes,ref)
for parm in parameters:
parameters[parm] = np.append(parameters[parm],ob.getString(parm))
if poly.geom_type == 'MultiPolygon':
geometries = np.array([])
geometries = np.append(geometries,MultiPolygon(poly))
geom_count = ", " + str(len(geometries)) +" geometries"
else:
geometries = np.array([])
geometries = np.append(geometries,Polygon(poly))
geom_count=""
for geom in geometries:
bounds = Polygon(geom)
intersection = bounds.intersection
geoms = (intersection(geom)
for geom in geometries
if bounds.intersects(geom))
#print(vtec[phensigString]['hdln']
# + " (" + phensigString + ") issued at " + str(ref)
# + " ("+str(poly.geom_type) + geom_count + ")")
color = warning_color(phensigString)
shape_feature = ShapelyFeature(geoms,ccrs.PlateCarree(),
facecolor=color, edgecolor=color)
ax.add_feature(shape_feature)
states_provinces = cfeature.NaturalEarthFeature(
category='cultural',
name='admin_1_states_provinces_lines',
scale='50m',
facecolor='none')
political_boundaries = cfeature.NaturalEarthFeature(category='cultural',
name='admin_0_boundary_lines_land',
scale='50m', facecolor='none')
ax.add_feature(cfeature.LAND)
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(states_provinces, edgecolor='black')
ax.add_feature(political_boundaries, edgecolor='black')
plt.show()
.. image:: Watch_and_Warning_Polygons_files/Watch_and_Warning_Polygons_5_0.png

View file

@ -0,0 +1,11 @@
.. _examples-index:
######################
Data Plotting Examples
######################
.. toctree::
:maxdepth: 1
:glob:
generated/*

1456
_sources/gridparms.rst.txt Normal file

File diff suppressed because it is too large Load diff

128
_sources/index.rst.txt Normal file
View file

@ -0,0 +1,128 @@
==================================
Python AWIPS Data Access Framework
==================================
The python-awips package provides a data access framework for requesting grid and geometry datasets from an `EDEX <http://unidata.github.io/awips2/#edex>`_ server.
`AWIPS <http://unidata.github.io/awips2>`_ is a weather display and analysis package developed by the National Weather Service for operational forecasting. UCAR's `Unidata Program Center <http://www.unidata.ucar.edu/software/awips2/>`_ supports a non-operational open-source release of the AWIPS software (`EDEX <http://unidata.github.io/awips2/#edex>`_, `CAVE <http://unidata.github.io/awips2/#cave>`_, and `python-awips <https://github.com/Unidata/python-awips>`_).
.. _Jupyter Notebook: http://nbviewer.jupyter.org/github/Unidata/python-awips/tree/master/examples/notebooks
Pip Install
-----------
::
pip install python-awips
Conda Environment Install
-------------------------
To install the latest version of python-awips, with all required and optional packages:
::
git clone https://github.com/Unidata/python-awips.git
cd python-awips
conda env create -f environment.yml
conda activate python3-awips
python setup.py install --force
jupyter notebook examples
Requirements
------------
- python 2.7+
- numpy
- shapely
- six
Quick Example
~~~~~~~~~~~~~
::
from awips.dataaccess import DataAccessLayer
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")
dataTypes = DataAccessLayer.getSupportedDatatypes()
list(dataTypes)
['acars',
'binlightning',
'bufrmosavn',
'bufrmoseta',
'bufrmosgfs',
'bufrmoshpc',
'bufrmoslamp',
'bufrmosmrf',
'bufrua',
'climate',
'common_obs_spatial',
'gfe',
'gfeeditarea',
'grid',
'maps',
'modelsounding',
'obs',
'practicewarning',
'profiler',
'radar',
'radar_spatial',
'satellite',
'sfcobs',
'topo',
'warning']
request = DataAccessLayer.newDataRequest()
request.setDatatype("satellite")
availableSectors = DataAccessLayer.getAvailableLocationNames(request)
availableSectors.sort()
for sector in availableSectors:
print sector
request.setLocationNames(sector)
availableProducts = DataAccessLayer.getAvailableParameters(request)
availableProducts.sort()
for product in availableProducts:
print " - " + product
ECONUS
- ACTP
- ADP
- AOD
- CAPE
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
...
EFD
- ACTP
- ADP
- AOD
- CAPE
- CH-01-0.47um
- CH-02-0.64um
- CH-03-0.87um
- CH-04-1.38um
...
See the `API Documentation <api/DataAccessLayer.html>`_ for more information.
----------------------
Read The Docs Contents
----------------------
.. toctree::
:maxdepth: 2
api/index
datatypes
examples/index
dev
gridparms
about

855
_static/basic.css Normal file
View file

@ -0,0 +1,855 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
div.section::after {
display: block;
content: '';
clear: left;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
word-wrap: break-word;
overflow-wrap : break-word;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar #searchbox form.search {
overflow: hidden;
}
div.sphinxsidebar #searchbox input[type="text"] {
float: left;
width: 80%;
padding: 0.25em;
box-sizing: border-box;
}
div.sphinxsidebar #searchbox input[type="submit"] {
float: left;
width: 20%;
border-left: none;
padding: 0.25em;
box-sizing: border-box;
}
img {
border: 0;
max-width: 100%;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
margin-left: auto;
margin-right: auto;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable ul {
margin-top: 0;
margin-bottom: 0;
list-style-type: none;
}
table.indextable > tbody > tr > td > ul {
padding-left: 0em;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- domain module index --------------------------------------------------- */
table.modindextable td {
padding: 2px;
border-collapse: collapse;
}
/* -- general body styles --------------------------------------------------- */
div.body {
min-width: 450px;
max-width: 800px;
}
div.body p, div.body dd, div.body li, div.body blockquote {
-moz-hyphens: auto;
-ms-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
a.headerlink {
visibility: hidden;
}
a.brackets:before,
span.brackets > a:before{
content: "[";
}
a.brackets:after,
span.brackets > a:after {
content: "]";
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink,
caption:hover > a.headerlink,
p.caption:hover > a.headerlink,
div.code-block-caption:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
img.align-default, .figure.align-default {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-default {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px;
background-color: #ffe;
width: 40%;
float: right;
clear: right;
overflow-x: auto;
}
p.sidebar-title {
font-weight: bold;
}
div.admonition, div.topic, blockquote {
clear: left;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- content of sidebars/topics/admonitions -------------------------------- */
div.sidebar > :last-child,
div.topic > :last-child,
div.admonition > :last-child {
margin-bottom: 0;
}
div.sidebar::after,
div.topic::after,
div.admonition::after,
blockquote::after {
display: block;
content: '';
clear: both;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
margin-top: 10px;
margin-bottom: 10px;
border: 0;
border-collapse: collapse;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
table.align-default {
margin-left: auto;
margin-right: auto;
}
table caption span.caption-number {
font-style: italic;
}
table caption span.caption-text {
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
th > :first-child,
td > :first-child {
margin-top: 0px;
}
th > :last-child,
td > :last-child {
margin-bottom: 0px;
}
/* -- figures --------------------------------------------------------------- */
div.figure {
margin: 0.5em;
padding: 0.5em;
}
div.figure p.caption {
padding: 0.3em;
}
div.figure p.caption span.caption-number {
font-style: italic;
}
div.figure p.caption span.caption-text {
}
/* -- field list styles ----------------------------------------------------- */
table.field-list td, table.field-list th {
border: 0 !important;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.field-name {
-moz-hyphens: manual;
-ms-hyphens: manual;
-webkit-hyphens: manual;
hyphens: manual;
}
/* -- hlist styles ---------------------------------------------------------- */
table.hlist {
margin: 1em 0;
}
table.hlist td {
vertical-align: top;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
:not(li) > ol > li:first-child > :first-child,
:not(li) > ul > li:first-child > :first-child {
margin-top: 0px;
}
:not(li) > ol > li:last-child > :last-child,
:not(li) > ul > li:last-child > :last-child {
margin-bottom: 0px;
}
ol.simple ol p,
ol.simple ul p,
ul.simple ol p,
ul.simple ul p {
margin-top: 0;
}
ol.simple > li:not(:first-child) > p,
ul.simple > li:not(:first-child) > p {
margin-top: 0;
}
ol.simple p,
ul.simple p {
margin-bottom: 0;
}
dl.footnote > dt,
dl.citation > dt {
float: left;
margin-right: 0.5em;
}
dl.footnote > dd,
dl.citation > dd {
margin-bottom: 0em;
}
dl.footnote > dd:after,
dl.citation > dd:after {
content: "";
clear: both;
}
dl.field-list {
display: grid;
grid-template-columns: fit-content(30%) auto;
}
dl.field-list > dt {
font-weight: bold;
word-break: break-word;
padding-left: 0.5em;
padding-right: 5px;
}
dl.field-list > dt:after {
content: ":";
}
dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
margin-left: 0em;
margin-bottom: 0em;
}
dl {
margin-bottom: 15px;
}
dd > :first-child {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
}
dt:target, span.highlighted {
background-color: #fbe54e;
}
rect.highlighted {
fill: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.optional {
font-size: 1.3em;
}
.sig-paren {
font-size: larger;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
.classifier:before {
font-style: normal;
margin: 0.5em;
content: ":";
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
pre, div[class*="highlight-"] {
clear: both;
}
span.pre {
-moz-hyphens: none;
-ms-hyphens: none;
-webkit-hyphens: none;
hyphens: none;
}
div[class*="highlight-"] {
margin: 1em 0;
}
td.linenos pre {
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
display: block;
}
table.highlighttable tbody {
display: block;
}
table.highlighttable tr {
display: flex;
}
table.highlighttable td {
margin: 0;
padding: 0;
}
table.highlighttable td.linenos {
padding-right: 0.5em;
}
table.highlighttable td.code {
flex: 1;
overflow: hidden;
}
.highlight .hll {
display: block;
}
div.highlight pre,
table.highlighttable pre {
margin: 0;
}
div.code-block-caption + div {
margin-top: 0;
}
div.code-block-caption {
margin-top: 1em;
padding: 2px 5px;
font-size: small;
}
div.code-block-caption code {
background-color: transparent;
}
table.highlighttable td.linenos,
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
}
div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;
}
div.code-block-caption span.caption-text {
}
div.literal-block-wrapper {
margin: 1em 0;
}
code.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
code.descclassname {
background-color: transparent;
}
code.xref, a code {
background-color: transparent;
font-weight: bold;
}
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
span.eqno a.headerlink {
position: absolute;
z-index: 1;
}
div.math:hover a.headerlink {
visibility: visible;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}

View file

@ -0,0 +1 @@
.fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more