-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcf.curl_xy.html
More file actions
275 lines (236 loc) · 17.8 KB
/
cf.curl_xy.html
File metadata and controls
275 lines (236 loc) · 17.8 KB
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
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>cf.curl_xy — Documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=61cd365c" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=a5d0ad34" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css?v=fd3f3429" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../_static/customise-alabaster.css?v=5dec66a6" />
<script src="../_static/documentation_options.js?v=cf9ada82"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
<script src="../_static/copybutton.js?v=b578dfe4"></script>
<script src="../_static/toggleprompt.js?v=1b41717f"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="cf.div_xy" href="cf.div_xy.html" />
<link rel="prev" title="cf.default_netCDF_fillvals" href="cf.default_netCDF_fillvals.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/logo.svg" alt="Logo"/>
</a></p>
<h1 class="logo"><a href="../index.html">cf 3.20.0</a></h1>
<p class="blurb">A CF-compliant earth science data analysis library</p>
<p>
<iframe src="https://ghbtns.com/github-btn.html?user=NCAS-CMS&repo=cf-python&type=star&count=true&size=large&v=2"
allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>
</p>
<search 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" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../introduction.html"><strong>Introduction</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation.html"><strong>Installation</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../cheat_sheet.html"><strong>Cheat Sheet</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../recipes/index.html"><strong>Recipes using cf</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial.html"><strong>Tutorial</strong></a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../api_reference.html"><strong>API reference</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../aggregation_rules.html"><strong>Aggregation rules</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../performance.html"><strong>Performance</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../releases.html"><strong>Releases</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../Changelog.html"><strong>Change log</strong></a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html"><strong>Contributing</strong></a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="../api_reference.html"><strong>API reference</strong></a><ul>
<li><a href="../function.html"><strong>cf functions</strong></a><ul>
<li>Previous: <a href="cf.default_netCDF_fillvals.html" title="previous chapter">cf.default_netCDF_fillvals</a></li>
<li>Next: <a href="cf.div_xy.html" title="next chapter">cf.div_xy</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
<br>
cf development has been supported by
the <a href="https://erc.europa.eu/">ERC</a>
through <a href="https://cordis.europa.eu/project/id/247220">Seachange</a>
and
<a href="https://cordis.europa.eu/project/id/786427">Couplet</a>; by
the <a href="https://ec.europa.eu/programmes/horizon2020/">EC Horizon
2020 programme</a> through
<a href="https://cordis.europa.eu/project/id/824084">IS-ENES3</a>;
by <a href="https://nerc.ukri.org/">NERC</a> through
<a href="https://gtr.ukri.org/project/0D95A6DB-0B95-48F7-8A8B-7B9A47DEA117">UKFAFMIP</a>;
and by <a href="https://ncas.ac.uk/">NCAS</a>.
<br>
<br>
<img src="../_static/logo_EC.png" height="40">
<img src="../_static/logo_ERC.png" height="40">
<img src="../_static/logo_NERC.png" height="40">
<br>
<img src="../_static/logo_NCAS.png" height="40">
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="cf-curl-xy">
<h1>cf.curl_xy<a class="headerlink" href="#cf-curl-xy" title="Link to this heading">¶</a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="cf.curl_xy">
<span class="sig-prename descclassname"><span class="pre">cf.</span></span><span class="sig-name descname"><span class="pre">curl_xy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fx</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fy</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_wrap</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="n"><span class="pre">one_sided_at_boundary</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/NCAS-CMS/cf-python/blob/v3.20.0/cf/maths.py#L329-L559"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#cf.curl_xy" title="Link to this definition">¶</a></dt>
<dd><p>Calculate the horizontal curl of an (X, Y) vector.</p>
<p>The horizontal curl is calculated from orthogonal vector component
fields which have dimension coordinates of X and Y, in either
Cartesian (e.g. plane projection) or spherical polar coordinate
systems.</p>
<p>Note that the curl of the horizontal wind field is the relative
vorticity.</p>
<p>The horizontal curl of the <span class="math notranslate nohighlight">\((f_x, f_y)\)</span> vector in Cartesian
coordinates is given by:</p>
<div class="math notranslate nohighlight">
\[\nabla \times (f_{x}(x,y), f_{y}(x,y)) =
\frac{\partial f_y}{\partial x}
-
\frac{\partial f_x}{\partial y}\]</div>
<p>The horizontal curl of the <span class="math notranslate nohighlight">\((f_\theta, f_\phi)\)</span> vector in
spherical polar coordinates is given by:</p>
<div class="math notranslate nohighlight">
\[\nabla \times (f_\theta(\theta,\phi), f_\phi(\theta,\phi)) =
\frac{1}{r \sin\theta}
\left(
\frac{\partial (f_\phi \sin\theta)}{\partial \theta}
-
\frac{\partial f_\theta}{\partial \phi}
\right)\]</div>
<p>where <em>r</em> is radial distance to the origin, <span class="math notranslate nohighlight">\(\theta\)</span> is the
polar angle with respect to polar axis, and <span class="math notranslate nohighlight">\(\phi\)</span> is the
azimuthal angle.</p>
<p>The curl is calculated using centred finite differences apart from
at the boundaries (see the <em>x_wrap</em> and <em>one_sided_at_boundary</em>
parameters). If missing values are present then missing values
will be returned at all points where a centred finite difference
could not be calculated.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.12.0.</span></p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="cf.div_xy.html#cf.div_xy" title="cf.div_xy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cf.div_xy</span></code></a>, <a class="reference internal" href="../method/cf.Field.derivative.html#cf.Field.derivative" title="cf.Field.derivative"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cf.Field.derivative</span></code></a>,
<a class="reference internal" href="../method/cf.Field.grad_xy.html#cf.Field.grad_xy" title="cf.Field.grad_xy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cf.Field.grad_xy</span></code></a>, <a class="reference internal" href="../method/cf.Field.iscyclic.html#cf.Field.iscyclic" title="cf.Field.iscyclic"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cf.Field.iscyclic</span></code></a>,
<a class="reference internal" href="../method/cf.Field.laplacian_xy.html#cf.Field.laplacian_xy" title="cf.Field.laplacian_xy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cf.Field.laplacian_xy</span></code></a></p>
</div>
<dl class="field-list">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><dl>
<dt>fx, fy: <a class="reference internal" href="../class/cf.Field.html#cf.Field" title="cf.Field"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Field</span></code></a></dt><dd><p>The fields containing the X and Y vector components.</p>
</dd>
<dt>x_wrap: <a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bool</span></code></a>, optional</dt><dd><p>Whether the X axis is cyclic or not. By default <em>x_wrap</em>
is set to the result of this call to the <em>fx</em> field
construct’s <a class="reference internal" href="../method/cf.Field.iscyclic.html#cf.Field.iscyclic" title="cf.Field.iscyclic"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iscyclic</span></code></a>
method:<code class="docutils literal notranslate"><span class="pre">fy.iscyclic('X')</span></code>. If the X axis is cyclic then
centred differences at one X boundary will always use
values from the other, regardless of the setting of
<em>one_sided_at_boundary</em>.</p>
<p>The cyclicity of the Y axis is always set to the result of
<code class="docutils literal notranslate"><span class="pre">fx.iscyclic('Y')</span></code>.</p>
</dd>
<dt>one_sided_at_boundary: <a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.14)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bool</span></code></a>, optional</dt><dd><p>If True then one-sided finite differences are calculated
at the non-cyclic boundaries. By default missing values
are set at non-cyclic boundaries.</p>
</dd>
<dt>radius: optional</dt><dd><p>Specify the radius of the latitude-longitude plane defined
in spherical polar coordinates. The radius is that which
would be returned by this call of the <em>fx</em> field
construct’s <a class="reference internal" href="../method/cf.Field.radius.html#cf.Field.radius" title="cf.Field.radius"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cf.Field.radius</span></code></a> method:
<code class="docutils literal notranslate"><span class="pre">fx.radius(default=radius)</span></code>. The radius is defined by
the datum of a coordinate reference construct, and if and
only if no such radius is found then the default value
given by the <em>radius</em> parameter is used instead. A value
of <code class="docutils literal notranslate"><span class="pre">'earth'</span></code> is equivalent to a default value of 6371229
metres.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><dl class="simple">
<dt><a class="reference internal" href="../class/cf.Field.html#cf.Field" title="cf.Field"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Field</span></code></a></dt><dd><p>The horizontal curl of the (X, Y) fields.</p>
</dd>
</dl>
</dd>
</dl>
<p><strong>Examples</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">f</span> <span class="o">=</span> <span class="n">cf</span><span class="o">.</span><span class="n">example_field</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="go">Field: specific_humidity (ncvar%q)</span>
<span class="go">----------------------------------</span>
<span class="go">Data : specific_humidity(latitude(5), longitude(8)) 1</span>
<span class="go">Cell methods : area: mean</span>
<span class="go">Dimension coords: latitude(5) = [-75.0, ..., 75.0] degrees_north</span>
<span class="go"> : longitude(8) = [22.5, ..., 337.5] degrees_east</span>
<span class="go"> : time(1) = [2019-01-01 00:00:00]</span>
<span class="gp">>>> </span><span class="n">f</span><span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.1</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">array</span><span class="p">)</span>
<span class="go">[[0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]</span>
<span class="go"> [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]</span>
<span class="go"> [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]</span>
<span class="go"> [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]</span>
<span class="go"> [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]]</span>
<span class="gp">>>> </span><span class="n">fx</span><span class="p">,</span> <span class="n">fy</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">grad_xy</span><span class="p">(</span><span class="n">radius</span><span class="o">=</span><span class="s1">'earth'</span><span class="p">,</span> <span class="n">one_sided_at_boundary</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">fx</span><span class="p">,</span> <span class="n">fy</span>
<span class="go">(<CF Field: long_name=X gradient of specific_humidity(latitude(5), longitude(8)) m-1>,</span>
<span class="go"> <CF Field: long_name=Y gradient of specific_humidity(latitude(5), longitude(8)) m-1>)</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">cf</span><span class="o">.</span><span class="n">curl_xy</span><span class="p">(</span><span class="n">fx</span><span class="p">,</span> <span class="n">fy</span><span class="p">,</span> <span class="n">radius</span><span class="o">=</span><span class="s1">'earth'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span>
<span class="go"><CF Field: long_name=Horizontal curl of (long_name=X gradient of specific_humidity, long_name=Y gradient of specific_humidity)(latitude(5), longitude(8)) m-2></span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">array</span><span class="p">)</span>
<span class="go">[[-- -- -- -- -- -- -- --]</span>
<span class="go"> [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]</span>
<span class="go"> [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]</span>
<span class="go"> [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]</span>
<span class="go"> [-- -- -- -- -- -- -- --]]</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">cf</span><span class="o">.</span><span class="n">curl_xy</span><span class="p">(</span><span class="n">fx</span><span class="p">,</span> <span class="n">fy</span><span class="p">,</span> <span class="n">radius</span><span class="o">=</span><span class="s1">'earth'</span><span class="p">,</span> <span class="n">one_sided_at_boundary</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">array</span><span class="p">)</span>
<span class="go">[[0. 0. 0. 0. 0. 0. 0. 0.]</span>
<span class="go"> [0. 0. 0. 0. 0. 0. 0. 0.]</span>
<span class="go"> [0. 0. 0. 0. 0. 0. 0. 0.]</span>
<span class="go"> [0. 0. 0. 0. 0. 0. 0. 0.]</span>
<span class="go"> [0. 0. 0. 0. 0. 0. 0. 0.]]</span>
</pre></div>
</div>
</dd></dl>
</section>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2026, NCAS | Page built on 2026-04-10.
|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 7.3.7</a>
& <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
</div>
</body>
</html>