-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvar.get.html
218 lines (203 loc) · 14.5 KB
/
var.get.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Retrieving values from a variable — PyGeode 1.4.1-rc2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/pygtheme.css" />
<link rel="stylesheet" type="text/css" href="_static/plot_directive.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-binder.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-dataframe.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-rendered-html.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/pygeode_icon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Arithmetic Operations on Variables" href="var.arith.html" />
<link rel="prev" title="Variable Querying Routines" href="varquery.html" />
<link href="http://fonts.googleapis.com/css?family=Ubuntu:300,300italic,regular,italic,500,500italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700' rel='stylesheet' type='text/css'>
</head><body>
<div class="header" role="banner"><img class="logo" src="_static/pygeode_logo.png" width=79px alt="Logo"/>
<h1 class="heading"><a href="index.html">
<span>PyGeode 1.4.1-rc2 documentation</span></a></h1>
<h2 class="heading"><span>Retrieving values from a variable</span></h2>
</div>
<div class="topnav" role="navigation" aria-label="top navigation">
<p>
«  <a href="varquery.html">Variable Querying Routines</a>
  ::  
<a class="uplink" href="reference.html">Reference</a>
  ::  
<a class="uplink" href="tutorial.html">Tutorial</a>
  ::  
<a class="uplink" href="gallery/index.html">Gallery</a>
  ::  
<a href="var.arith.html">Arithmetic Operations on Variables</a>  »
</p>
</div>
<div class="content">
<div class="section" id="retrieving-values-from-a-variable">
<h1>Retrieving values from a variable<a class="headerlink" href="#retrieving-values-from-a-variable" title="Permalink to this headline">¶</a></h1>
<p>The framework of PyGeode is designed to work with data that is too large to fit
in memory. That is to say, you don’t normally <em>have</em> the numerical values at
hand. Instead, you work with a symbolic reference to the data, and build a
sequence of operations that will be performed <em>only when data is needed</em>.
Usually, this is when:</p>
<blockquote>
<div><ul class="simple">
<li><p>You are saving the variable to a file</p></li>
<li><p>You are generating a plot</p></li>
<li><p>You are calling an iterative routine such as <a class="reference internal" href="eof.html#pygeode.EOF" title="pygeode.EOF"><code class="xref py py-func docutils literal notranslate"><span class="pre">EOF()</span></code></a>, or some other
complicated operation for which there is no efficient symbolic wrapper.</p></li>
</ul>
</div></blockquote>
<p>In the above routines, the logistics of retrieving the data is handled
internally, so you only see the end result. There may be times, however, when
you <em>want</em> to work with raw values. Perhaps you are using PyGeode in
conjunction with some other packages which operate on numpy arrays. Or,
perhaps you just feel more comfortable working with an array instead of some
abstract data object. We won’t judge you. Just call <a class="reference internal" href="#pygeode.Var.get" title="pygeode.Var.get"><code class="xref py py-func docutils literal notranslate"><span class="pre">Var.get()</span></code></a> and you
can do whatever you want with the data.</p>
<dl class="py method">
<dt class="sig sig-object py" id="pygeode.Var.get">
<span class="sig-prename descclassname"><span class="pre">Var.</span></span><span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/var.html#Var.get"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pygeode.Var.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets a raw numpy array containing the values of the variable.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>pbar</strong><span class="classifier">boolean (optional)</span></dt><dd><p>If <code class="docutils literal notranslate"><span class="pre">True</span></code>, will display a progress bar while the data is being
retrieved. This requires the <em>python-progressbar</em> package (not included
with PyGeode).</p>
</dd>
<dt><strong>**kwargs</strong><span class="classifier">keyword arguments (optional)</span></dt><dd><p>One or more keyword arguments may be included to subset the variable
before grabbing the data. See <a class="reference internal" href="varops.html#pygeode.Var.__call__" title="pygeode.Var.__call__"><code class="xref py py-func docutils literal notranslate"><span class="pre">Var.__call__()</span></code></a> for a similar
method which uses this keyword subsetting.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>out</strong><span class="classifier">numpy.ndarray</span></dt><dd><p>The requested values, as a numpy array.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Once you grab the data as a numpy array, you can no longer use the PyGeode
functions to do further work on it directly. You can, however, use
<a class="reference internal" href="var.html#pygeode.Var.__init__" title="pygeode.Var.__init__"><code class="xref py py-func docutils literal notranslate"><span class="pre">Var.__init__()</span></code></a> to re-wrap your numpy array as a PyGeode Var. This
may be useful if you want to do some very complicated operations on the
data using the numpy interface as an intermediate step.</p>
<p>PyGeode variables can be huge! They can be larger than the available RAM
in your computer, or even larger than your hard disk. Numpy arrays, on
the other hand, need to fit in memory, so make sure you are only getting
a reasonable piece of data at a time.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygeode.tutorial</span> <span class="kn">import</span> <span class="n">t1</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">t1</span><span class="o">.</span><span class="n">Temp</span><span class="p">)</span>
<span class="go"><Var 'Temp'>:</span>
<span class="go"> Units: K Shape: (lat,lon) (31,60)</span>
<span class="go"> Axes:</span>
<span class="go"> lat <Lat> : 90 S to 90 N (31 values)</span>
<span class="go"> lon <Lon> : 0 E to 354 E (60 values)</span>
<span class="go"> Attributes:</span>
<span class="go"> {}</span>
<span class="go"> Type: Add_Var (dtype="float64")</span>
<span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">t1</span><span class="o">.</span><span class="n">Temp</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">[[260.73262556 258.08759192 256.45287123 ... 265.01237988 265.01237988</span>
<span class="go"> 263.37765919]</span>
<span class="go"> [261.22683172 258.75813366 257.23239435 ... 265.22126909 265.22126909</span>
<span class="go"> 263.69552978]</span>
<span class="go"> [261.98265134 259.69028886 258.27353093 ... 265.69177175 265.69177175</span>
<span class="go"> 264.27501382]</span>
<span class="go"> ...</span>
<span class="go"> [261.98265134 264.27501382 265.69177175 ... 258.27353093 258.27353093</span>
<span class="go"> 259.69028886]</span>
<span class="go"> [261.22683172 263.69552978 265.22126909 ... 257.23239435 257.23239435</span>
<span class="go"> 258.75813366]</span>
<span class="go"> [260.73262556 263.37765919 265.01237988 ... 256.45287123 256.45287123</span>
<span class="go"> 258.08759192]]</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="pygeode.Var.__getitem__">
<span class="sig-prename descclassname"><span class="pre">Var.</span></span><span class="sig-name descname"><span class="pre">__getitem__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">slices</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/var.html#Var.__getitem__"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pygeode.Var.__getitem__" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets a raw numpy array containing a subset of values of the variable.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>slices</strong><span class="classifier">list of slices</span></dt><dd></dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>out</strong><span class="classifier">numpy.ndarray</span></dt><dd><p>The requested values, as a numpy array.</p>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#pygeode.Var.get" title="pygeode.Var.get"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Var.get</span></code></a>, <a class="reference internal" href="varops.html#pygeode.Var.slice" title="pygeode.Var.slice"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Var.slice</span></code></a>, <a class="reference internal" href="varops.html#pygeode.Var.__call__" title="pygeode.Var.__call__"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Var.__call__</span></code></a></dt><dd></dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygeode.tutorial</span> <span class="kn">import</span> <span class="n">t1</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">t1</span><span class="o">.</span><span class="n">Temp</span><span class="p">[:]</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="go">(31, 60)</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">t1</span><span class="o">.</span><span class="n">Temp</span><span class="p">[</span><span class="mi">20</span><span class="p">:</span><span class="o">-</span><span class="mi">6</span><span class="p">,</span> <span class="p">::</span><span class="mi">12</span><span class="p">])</span>
<span class="go">[[285.64721554 287.07380031 286.52889342 284.76553766 284.22063076]</span>
<span class="go"> [281.09169696 282.80359869 282.14971042 280.03368351 279.37979523]</span>
<span class="go"> [276.73945224 278.73667093 277.97380127 275.50510321 274.74223356]</span>
<span class="go"> [272.82122084 275.10375648 274.23190545 271.41053624 270.5386852 ]</span>
<span class="go"> [269.47711035 272.04496294 271.06413053 267.89009017 266.90925775]]</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="pygeode.Var.load">
<span class="sig-prename descclassname"><span class="pre">Var.</span></span><span class="sig-name descname"><span class="pre">load</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/var.html#Var.load"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pygeode.Var.load" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a version of this variable with all data loaded into memory.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>pbar</strong><span class="classifier">boolean</span></dt><dd><p>If True, display a progress bar while loading data.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="simple">
<dt><strong>See Also:</strong></dt><dd><p><a class="reference internal" href="var.html"><span class="doc">Var class overview</span></a></p>
</dd>
</dl>
</div>
</div>
<div class="bottomnav" role="navigation" aria-label="bottom navigation">
<p>
«  <a href="varquery.html">Variable Querying Routines</a>
  ::  
<a class="uplink" href="reference.html">Reference</a>
  ::  
<a class="uplink" href="tutorial.html">Tutorial</a>
  ::  
<a class="uplink" href="gallery/index.html">Gallery</a>
  ::  
<a href="var.arith.html">Arithmetic Operations on Variables</a>  »
</p>
</div>
<div class="footer" role="contentinfo">
© Copyright 2020, Mike Neish, Peter Hitchcock.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
</div>
</body>
</html>