forked from pygeode/pygeode.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaxes.html
309 lines (297 loc) · 19.5 KB
/
axes.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Axis class overview — PyGeode 1.0 alpha documentation</title>
<link rel="stylesheet" href="_static/pygtheme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0 alpha',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="PyGeode 1.0 alpha documentation" href="index.html" />
<link rel="up" title="Reference" href="reference.html" />
<link rel="next" title="Axis class reference" href="axis.html" />
<link rel="prev" title="Other operations" href="var.other.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="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="axis.html" title="Axis class reference"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="var.other.html" title="Other operations"
accesskey="P">previous</a> |</li>
<li><a href="index.html">PyGeode 1.0 alpha documentation</a> »</li>
<li><a href="reference.html" accesskey="U">Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="axis-class-overview">
<h1>Axis class overview<a class="headerlink" href="#axis-class-overview" title="Permalink to this headline">¶</a></h1>
<p>An Axis is a one-dimensional array of values, representing some kind of
coordinate. For example, a <tt class="docutils literal"><span class="pre">Lat</span></tt> axis represents a set of latitudes over the
globe. Axes are a subclass of <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a>, and can be treated as such for many purposes
(such as arithmetic operations), though they have some specific behaviour, including
the fact that their values are always explicitly loaded into memory.</p>
<p>In practice the <a class="reference internal" href="#pygeode.Axis" title="pygeode.Axis"><tt class="xref py py-class docutils literal"><span class="pre">Axis</span></tt></a> class is rarely instantiated directly; one of its subclasses
are typically used to represent a dimension of a particular type.</p>
<div class="section" id="types-of-axes">
<h2>Types of axes<a class="headerlink" href="#types-of-axes" title="Permalink to this headline">¶</a></h2>
<p>The following is a (non-exhaustive) list of more commonly used axes built into PyGeode:</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="namedaxis.html#pygeode.NamedAxis" title="pygeode.NamedAxis"><tt class="xref py py-obj docutils literal"><span class="pre">NamedAxis</span></tt></a></td>
<td>Generic axis object identified by its name.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="horizontalaxes.html#pygeode.Lon" title="pygeode.Lon"><tt class="xref py py-obj docutils literal"><span class="pre">Lon</span></tt></a></td>
<td>Longitude axis.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="horizontalaxes.html#pygeode.Lat" title="pygeode.Lat"><tt class="xref py py-obj docutils literal"><span class="pre">Lat</span></tt></a></td>
<td>Latitude axis.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="verticalaxes.html#pygeode.Height" title="pygeode.Height"><tt class="xref py py-obj docutils literal"><span class="pre">Height</span></tt></a></td>
<td>Geometric height axis.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="verticalaxes.html#pygeode.Pres" title="pygeode.Pres"><tt class="xref py py-obj docutils literal"><span class="pre">Pres</span></tt></a></td>
<td>Pressure height axis.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="verticalaxes.html#pygeode.Hybrid" title="pygeode.Hybrid"><tt class="xref py py-obj docutils literal"><span class="pre">Hybrid</span></tt></a></td>
<td>Hybridized vertical coordinate axis.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="timeaxes.html#pygeode.StandardTime" title="pygeode.StandardTime"><tt class="xref py py-obj docutils literal"><span class="pre">StandardTime</span></tt></a></td>
<td>Time axis describing the standard Gregorian calendar.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="timeaxes.html#pygeode.ModelTime365" title="pygeode.ModelTime365"><tt class="xref py py-obj docutils literal"><span class="pre">ModelTime365</span></tt></a></td>
<td>Time axis describing a model 365-day calendar.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="timeaxes.html#pygeode.ModelTime360" title="pygeode.ModelTime360"><tt class="xref py py-obj docutils literal"><span class="pre">ModelTime360</span></tt></a></td>
<td>Time axis describing a model 360-day calendar.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="timeaxes.html#pygeode.Yearless" title="pygeode.Yearless"><tt class="xref py py-obj docutils literal"><span class="pre">Yearless</span></tt></a></td>
<td>Time axis describing a calendar with no months or years.</td>
</tr>
</tbody>
</table>
<p>If PyGeode doesn’t have a built-in representation of an axis that your input
data uses, it will default to a generic <a class="reference internal" href="namedaxis.html#pygeode.NamedAxis" title="pygeode.NamedAxis"><tt class="xref py py-class docutils literal"><span class="pre">NamedAxis</span></tt></a> object, with no additional
context on what that axis represents. To get around this, you can always
define your own <a class="reference internal" href="#axis-custom"><em>custom</em></a> axis, and force your Var to use it
through <a class="reference internal" href="varops.html#pygeode.Var.replace_axes" title="pygeode.Var.replace_axes"><tt class="xref py py-meth docutils literal"><span class="pre">Var.replace_axes()</span></tt></a> or when importing from a data file.</p>
<p>In addition to the members listed below, <a class="reference internal" href="#pygeode.Axis" title="pygeode.Axis"><tt class="xref py py-class docutils literal"><span class="pre">Axis</span></tt></a> objects inherit methods from
the <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> class; see <a class="reference internal" href="var.html"><em>Var class overview</em></a> for this functionality.</p>
<dl class="class">
<dt id="pygeode.Axis">
<em class="property">class </em><tt class="descclassname">pygeode.</tt><tt class="descname">Axis</tt><a class="headerlink" href="#pygeode.Axis" title="Permalink to this definition">¶</a></dt>
<dd><p>Inherits from <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<p class="rubric">Useful attributes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.rtol" title="pygeode.Axis.rtol"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.rtol</span></tt></a></td>
<td>Floating point tolerance for axis values</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.formatstr" title="pygeode.Axis.formatstr"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.formatstr</span></tt></a></td>
<td>Formatting specification for printing values</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.auxatts" title="pygeode.Axis.auxatts"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.auxatts</span></tt></a></td>
<td></td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.auxarrays" title="pygeode.Axis.auxarrays"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.auxarrays</span></tt></a></td>
<td></td>
</tr>
<tr class="row-odd"><td><tt class="xref py py-obj docutils literal"><span class="pre">Axis.plotatts</span></tt></td>
<td></td>
</tr>
</tbody>
</table>
<p class="rubric">Generic Axis Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.__init__" title="pygeode.Axis.__init__"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.__init__</span></tt></a>(values[, name, atts, ...])</td>
<td>Create a new Axis object with the given values.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.argsort" title="pygeode.Axis.argsort"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.argsort</span></tt></a>([reverse])</td>
<td>Generates a list of indices that would sort the Axis.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.auxasvar" title="pygeode.Axis.auxasvar"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.auxasvar</span></tt></a>(name)</td>
<td>Returns auxiliary array as a new <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> object.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.formatter" title="pygeode.Axis.formatter"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.formatter</span></tt></a>()</td>
<td>Returns a matplotlib formatter (pygeode.AxisFormatter) for use in plotting.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.locator" title="pygeode.Axis.locator"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.locator</span></tt></a>()</td>
<td>Returns a matplotlib locator object for use in plotting.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.rename" title="pygeode.Axis.rename"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.rename</span></tt></a>(name)</td>
<td></td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.sorted" title="pygeode.Axis.sorted"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.sorted</span></tt></a>([reverse])</td>
<td>Sorts the points of the Axis.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.str_as_val" title="pygeode.Axis.str_as_val"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.str_as_val</span></tt></a>(key, s)</td>
<td>str_as_val(self, key, s) - converts string s to a value corresponding to this axis. Default</td>
</tr>
</tbody>
</table>
<p class="rubric">Internal calls</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.__call__" title="pygeode.Axis.__call__"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.__call__</span></tt></a>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis._getitem_asvar" title="pygeode.Axis._getitem_asvar"><tt class="xref py py-obj docutils literal"><span class="pre">Axis._getitem_asvar</span></tt></a>(slices)</td>
<td></td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.class_has_alias" title="pygeode.Axis.class_has_alias"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.class_has_alias</span></tt></a>(name)</td>
<td></td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="axis.html#pygeode.Axis.isparentof" title="pygeode.Axis.isparentof"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.isparentof</span></tt></a>(other)</td>
<td>Determines if an axis object is an instance of a base class (or the same class) of another axis.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="axis.html#pygeode.Axis.map_to" title="pygeode.Axis.map_to"><tt class="xref py py-obj docutils literal"><span class="pre">Axis.map_to</span></tt></a>(other)</td>
<td>Returns indices of this axis which correspond to the axis <tt class="docutils literal"><span class="pre">other</span></tt>.</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="defining-a-new-type-of-axis">
<span id="axis-custom"></span><h2>Defining a new type of axis<a class="headerlink" href="#defining-a-new-type-of-axis" title="Permalink to this headline">¶</a></h2>
<p>It’s impossible (or at least improbable) for the standard PyGeode package to include every possible type of axis that people may want. However, it’s fairly straight-forward to define your own custom axis. Simply define a new class, as a subclass of <a class="reference internal" href="#pygeode.Axis" title="pygeode.Axis"><tt class="xref py py-class docutils literal"><span class="pre">Axis</span></tt></a>.</p>
<p>For example, suppose one of the dimensions of your data is solar zenith angle (SZA). You can make a simple Axis representation as follows:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygeode</span> <span class="kn">import</span> <span class="n">Axis</span>
<span class="gp">>>> </span><span class="k">class</span> <span class="nc">SZA_Axis</span> <span class="p">(</span><span class="n">Axis</span><span class="p">):</span> <span class="k">pass</span>
<span class="gp">...</span>
</pre></div>
</div>
<p>You can now use it like any other axis:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">sza</span> <span class="o">=</span> <span class="n">SZA_Axis</span> <span class="p">([</span><span class="mf">20.1</span><span class="p">,</span> <span class="mf">20.2</span><span class="p">,</span> <span class="mf">20.3</span><span class="p">,</span> <span class="mf">20.4</span><span class="p">,</span> <span class="mf">20.5</span><span class="p">])</span>
<span class="gp">>>> </span><span class="k">print</span> <span class="n">sza</span>
<span class="go">sza_axis <SZA_Axis>: 20.1 to 20.5 (5 values)</span>
</pre></div>
</div>
<p>A more customized version:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">class</span> <span class="nc">SZA_Axis</span> <span class="p">(</span><span class="n">Axis</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">name</span> <span class="o">=</span> <span class="s">"sza"</span>
<span class="gp">... </span> <span class="n">units</span> <span class="o">=</span> <span class="s">"degrees"</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">sza</span> <span class="o">=</span> <span class="n">SZA_Axis</span> <span class="p">([</span><span class="mf">20.1</span><span class="p">,</span> <span class="mf">20.2</span><span class="p">,</span> <span class="mf">20.3</span><span class="p">,</span> <span class="mf">20.4</span><span class="p">,</span> <span class="mf">20.5</span><span class="p">])</span>
<span class="gp">>>> </span><span class="k">print</span> <span class="n">sza</span>
<span class="go">sza <SZA_Axis> : 20.1 degrees to 20.5 degrees (5 values)</span>
</pre></div>
</div>
<p>If you think your axis will be useful to others, please let us know, and we may include it in future versions.</p>
<p>Aspects of customizing an axis:</p>
<blockquote>
<div><ul class="simple">
<li>Defining its name</li>
<li>Customize how values are formatted as strings</li>
<li>Customize how strings are parsed into values</li>
<li>Customize matplotlib formatting and tick positioning</li>
<li>Customize CF-metadata encoding and decoding</li>
</ul>
</div></blockquote>
<div class="toctree-wrapper compound">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Axis class overview</a><ul>
<li><a class="reference internal" href="#types-of-axes">Types of axes</a></li>
<li><a class="reference internal" href="#defining-a-new-type-of-axis">Defining a new type of axis</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="var.other.html"
title="previous chapter">Other operations</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="axis.html"
title="next chapter">Axis class reference</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/axes.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="axis.html" title="Axis class reference"
>next</a> |</li>
<li class="right" >
<a href="var.other.html" title="Other operations"
>previous</a> |</li>
<li><a href="index.html">PyGeode 1.0 alpha documentation</a> »</li>
<li><a href="reference.html" >Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2013, Mike Neish, Peter Hitchcock.
Last updated on Sep 13, 2015.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>