-
Notifications
You must be signed in to change notification settings - Fork 58
/
strategy.html
181 lines (174 loc) · 9.9 KB
/
strategy.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Strategy — UTide 0.2.4 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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="_static/language_data.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Usage" href="usage.html" />
<link rel="prev" title="Unified Tidal Analysis and Prediction in Python" href="index.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="usage.html" title="Usage"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Unified Tidal Analysis and Prediction in Python"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">UTide 0.2.4 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="strategy">
<h1>Strategy<a class="headerlink" href="#strategy" title="Permalink to this headline">¶</a></h1>
<p>In translating the algorithms from Matlab to Python, the
first step is generating a set of Python functions that
mimic their Matlab counterparts. Gradually, however, the
code evolves to become closer to what might have been done
if the original implementation had been in Python. This
evolution will include extensive renaming of variables and
functions to improve readability.</p>
<div class="section" id="array-dimension-ordering">
<h2>Array dimension ordering<a class="headerlink" href="#array-dimension-ordering" title="Permalink to this headline">¶</a></h2>
<p>One of the basic differences between Matlab and Python
(including numpy) is that the former is built around
matrices and linear algebra operations, while the core array
data structure in numpy is the ndarray–an n-dimensional
array, not a matrix. Arithmetic operations are
element-by-element. A feature of ndarray operations is
their ability to act as if dimensions were added to the left
as needed to make the dimensions of two operands match.
This is called ‘broadcasting’, and happens automatically.
Dimensions can also be added to the right by explicit
indexing. The default broadcasting to the left matches
another feature of numpy: by default, array storage is in C
order, with the right-most index (the column index for a 2-D
array) varying fastest. This is
in contrast to Matlab’s Fortran order, with the left index
(the row index) varying fastest.</p>
<p>To take full advantage of numpy broadcasting, we will need to
assume that the time index is on the right for arrays with
more than one dimension. This is the opposite of the Matlab
UTide case.</p>
</div>
<div class="section" id="public-interface">
<h2>Public interface<a class="headerlink" href="#public-interface" title="Permalink to this headline">¶</a></h2>
<p>The package is called <code class="xref py py-obj docutils literal notranslate"><span class="pre">utide</span></code>, and presently has a very
simple interface, with two function: <code class="xref py py-obj docutils literal notranslate"><span class="pre">solve</span></code> and
<code class="xref py py-obj docutils literal notranslate"><span class="pre">reconstruct</span></code>. These are simply English spellings of their
Matlab counterparts. Everything else
should be considered to be private, regardless of whether it
has a leading underscore.</p>
<p>There is an overwhelming number of options, and many of the
Matlab names are rather cryptic. We have made some changes
in the way options are specified, but the process is not
complete.</p>
<p>Options are being held internally in a <code class="xref py py-obj docutils literal notranslate"><span class="pre">Bunch</span></code> so as to
provide both dictionary and attribute access syntax.</p>
</div>
<div class="section" id="time">
<h2>Time<a class="headerlink" href="#time" title="Permalink to this headline">¶</a></h2>
<p>Time inputs are arrays of time in days relative to the epoch
given in the <code class="xref py py-obj docutils literal notranslate"><span class="pre">epoch</span></code> keyword argument. In the Matlab version
of utide these would be Matlab datenums; in the python version,
using Matlab datenums requires <code class="xref py py-obj docutils literal notranslate"><span class="pre">epoch</span> <span class="pre">=</span> <span class="pre">'matlab'</span></code>. The default is
<code class="xref py py-obj docutils literal notranslate"><span class="pre">epoch</span> <span class="pre">=</span> <span class="pre">'python'</span></code>, corresponding to the <code class="xref py py-obj docutils literal notranslate"><span class="pre">matplotlib</span></code> date
numbers. Any other epoch can be specified using either a
string, like <code class="xref py py-obj docutils literal notranslate"><span class="pre">'2015-01-01'</span></code>, or a Python standard library
<a class="reference external" href="https://docs.python.org/3/library/datetime.html#datetime.datetime" title="(in Python v3.7)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">datetime.datetime</span></code></a> or <a class="reference external" href="https://docs.python.org/3/library/datetime.html#datetime.date" title="(in Python v3.7)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">datetime.date</span></code></a> instance. The numpy
<code class="xref py py-obj docutils literal notranslate"><span class="pre">datetime64</span></code> dtype is not yet supported, nor are any Pandas
constructs.</p>
</div>
<div class="section" id="missing-values">
<h2>Missing values<a class="headerlink" href="#missing-values" title="Permalink to this headline">¶</a></h2>
<p>The <code class="xref py py-obj docutils literal notranslate"><span class="pre">t</span></code>, <code class="xref py py-obj docutils literal notranslate"><span class="pre">u</span></code>, <code class="xref py py-obj docutils literal notranslate"><span class="pre">v</span></code> inputs to <code class="xref py py-obj docutils literal notranslate"><span class="pre">solve</span></code> and the <code class="xref py py-obj docutils literal notranslate"><span class="pre">t</span></code> input to `
reconstruct` now support any combination
of nans and masked array inputs to indicate missing values.</p>
<p>The degree to which masked arrays will be used internally is
unclear, but most likely their use will be highly localized.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Strategy</a><ul>
<li><a class="reference internal" href="#array-dimension-ordering">Array dimension ordering</a></li>
<li><a class="reference internal" href="#public-interface">Public interface</a></li>
<li><a class="reference internal" href="#time">Time</a></li>
<li><a class="reference internal" href="#missing-values">Missing values</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Unified Tidal Analysis and Prediction in Python</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="usage.html"
title="next chapter">Usage</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/strategy.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="usage.html" title="Usage"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="Unified Tidal Analysis and Prediction in Python"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">UTide 0.2.4 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2015, Dan Codiga, Wesley Bowman, and contributors.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.0.
</div>
</body>
</html>