/docs/0.9.2/build/write.html
HTML | 220 lines | 211 code | 9 blank | 0 comment | 0 complexity | 351452f8d78b693e5f77c5e7211fb48a MD5 | raw file
- <!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>cf.write — Python cf module v0.9.2 documentation</title>
- <link rel="stylesheet" href="_static/default.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <script type="text/javascript">
- var DOCUMENTATION_OPTIONS = {
- URL_ROOT: '',
- VERSION: '0.9.2',
- 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>
- <link rel="top" title="Python cf module v0.9.2 documentation" href="index.html" />
- <link rel="up" title="cf functions" href="function.html" />
- <link rel="next" title="cf classes" href="class.html" />
- <link rel="prev" title="cf.read1" href="read1.html" />
- </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="py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="class.html" title="cf classes"
- accesskey="N">next</a> |</li>
- <li class="right" >
- <a href="read1.html" title="cf.read1"
- accesskey="P">previous</a> |</li>
- <li><a href="index.html">Python cf module v0.9.2 documentation</a> »</li>
- <li><a href="function.html" accesskey="U">cf functions</a> »</li>
- </ul>
- </div>
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body">
-
- <div class="toctree-wrapper compound">
- <ul class="simple">
- </ul>
- </div>
- <div class="section" id="cf-write">
- <span id="write"></span><h1>cf.write<a class="headerlink" href="#cf-write" title="Permalink to this headline">¶</a></h1>
- <dl class="function">
- <dt id="cf.write">
- <tt class="descclassname">cf.</tt><tt class="descname">write</tt><big>(</big><em>spaces</em>, <em>file</em>, <em>format='NETCDF3_CLASSIC'</em>, <em>data=False</em>, <em>verbose=False</em>, <em>exact=False</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#cf.write" title="Permalink to this definition">¶</a></dt>
- <dd><p>Write a space, or sequence of spaces, to a CF compliant netCDF
- file.</p>
- <p>NetCDF dimension and variable names will be taken from the
- attributes <tt class="xref py py-attr docutils literal"><span class="pre">ncvar</span></tt> and <tt class="xref py py-attr docutils literal"><span class="pre">nc_dimensions</span></tt> if present,
- otherwise they are inferred from standard_name attributes or set
- to defaults. NetCDF names may be automatically given a numerical
- suffix to avoid duplication.</p>
- <p>Output netCDF file global attributes are those which occur in the
- set of CF global attributes and non-standard data variable
- attributes and which have equal values across all input spaces.</p>
- <p>It is possible to write only a subset of the input spaces by
- providing phenomena conditions with <tt class="xref py py-obj docutils literal"><span class="pre">**kwargs</span></tt> parameters.</p>
- <p>It does not matter if an input space’s data has not yet been read
- into memory. The write operation will automatically read the data
- array from disk if required, but the default is for it not to be
- saved in the input space if it had to be read during the write
- operation. However, if the <tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt> argument equals True then any
- input spaces which didn’t contain their full data arrays in memory
- will be changed in place so that they do. For example, for a
- space, s:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">type</span>
- <span class="go"> <type 'netCDF4.Variable'></span>
- <span class="gp">>>> </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">'filename'</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">type</span>
- <span class="go"> <type 'netCDF4.Variable'></span>
- <span class="gp">>>> </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">'filename'</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">s</span><span class="o">.</span><span class="n">type</span>
- <span class="go"> <type 'numpy.ndarray'></span>
- </pre></div>
- </div>
- <p>Identical grid components (as determined by their numerically
- tolerant <tt class="xref py py-meth docutils literal"><span class="pre">equals()</span></tt> methods) are only written to the file
- once, apart from when they need to fulfil both dimension
- coordinate and auxiliary coordinate roles for different data
- variables.</p>
- <p>If a coordinate with a <tt class="xref py py-attr docutils literal"><span class="pre">transform</span></tt> attribute is fully specified by
- another coordinate’s transformation then it will be not written to
- the file.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>spaces</strong> (<em>Space or sequence of spaces</em>) – The space or spaces to write to the file. If
- <tt class="xref py py-obj docutils literal"><span class="pre">**kwargs</span></tt> are set for selection by
- phenomena then some spaces may not be written.</li>
- <li><strong>file</strong> (<em>str</em>) – The netCDF file to write spaces to.</li>
- <li><strong>data</strong> (<em>bool</em>) – <em>Optional</em>. If True then ensure that spaces which
- have been written to disk retain their data
- in-place as numpy arrays.</li>
- <li><strong>exact</strong> (<em>bool</em>) – <em>Optional</em>. If True then interpret the keywords
- from <tt class="xref py py-obj docutils literal"><span class="pre">**kwargs</span></tt> as exact phenomenon
- names. Refer to <a class="reference internal" href="Space.html#cf.Space.extract" title="cf.Space.extract"><tt class="xref py py-meth docutils literal"><span class="pre">cf.Space.extract()</span></tt></a> for
- details.</li>
- <li><strong>format</strong> (<em>str</em>) – <em>Optional</em>. The format of the output netCDF
- file. Valid formats are those supported by the
- netCDF4 module: “NETCDF3_CLASSIC”,
- “NETCDF3_64BIT”, “NETCDF4_CLASSIC” and
- “NETCDF4”. The default is
- “NETCDF3_CLASSIC”. Certain write operations may
- be considerably faster using “NETCDF4_CLASSIC”.</li>
- <li><strong>verbose</strong> (<em>bool</em>) – <em>Optional</em>. If True then print information to
- stdout.</li>
- <li><strong>**kwargs</strong> – <p><em>Optional</em>. Other keyword arguments defining
- space selection based on phenomena
- criteria. Only selected spaces will be
- written to disk. If none are set then all
- spaces are selected. Keywords and their
- arguments are set as for
- <a class="reference internal" href="Space.html#cf.Space.extract" title="cf.Space.extract"><tt class="xref py py-meth docutils literal"><span class="pre">cf.Space.extract()</span></tt></a>. This behaviour is
- modified by the <tt class="xref py py-obj docutils literal"><span class="pre">exact</span></tt> keyword.</p>
- </li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <p><strong>Examples</strong></p>
- <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">s</span>
- <span class="go">[<CF Space: air_pressure(30, 24)>,</span>
- <span class="go"> <CF Space: u_compnt_of_wind(19, 29, 24)>,</span>
- <span class="go"> <CF Space: v_compnt_of_wind(19, 29, 24)>,</span>
- <span class="go"> <CF Space: potential_temperature(19, 30, 24)>]</span>
- <span class="gp">>>> </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">'file'</span><span class="p">)</span>
- <span class="gp">>>> </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">'file'</span><span class="p">,</span> <span class="n">standard_name</span> <span class="o">=</span> <span class="s">'air_pressure'</span><span class="p">)</span>
- </pre></div>
- </div>
- <div class="admonition-see-also admonition seealso">
- <p class="first admonition-title">See also</p>
- <p class="last"><a class="reference internal" href="Space.html#cf.Space.extract" title="cf.Space.extract"><tt class="xref py py-meth docutils literal"><span class="pre">cf.Space.extract()</span></tt></a> for more examples of space
- selection by phenomena criteria.</p>
- </div>
- </dd></dl>
- </div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar">
- <div class="sphinxsidebarwrapper">
- <h4>Previous topic</h4>
- <p class="topless"><a href="read1.html"
- title="previous chapter">cf.read1</a></p>
- <h4>Next topic</h4>
- <p class="topless"><a href="class.html"
- title="next chapter">cf classes</a></p>
- <h3>This Page</h3>
- <ul class="this-page-menu">
- <li><a href="_sources/write.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" size="18" />
- <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="py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="class.html" title="cf classes"
- >next</a> |</li>
- <li class="right" >
- <a href="read1.html" title="cf.read1"
- >previous</a> |</li>
- <li><a href="index.html">Python cf module v0.9.2 documentation</a> »</li>
- <li><a href="function.html" >cf functions</a> »</li>
- </ul>
- </div>
- <div class="footer">
- © Copyright 2011, David Hassell.
- Last updated on Aug 26, 2011.
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
- </div>
- </body>
- </html>