PageRenderTime 27ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/0.9.2/build/write.html

https://bitbucket.org/cfpython/cfpython.bitbucket.org
HTML | 220 lines | 211 code | 9 blank | 0 comment | 0 complexity | 351452f8d78b693e5f77c5e7211fb48a MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>cf.write &mdash; Python cf module v0.9.2 documentation</title>
  7. <link rel="stylesheet" href="_static/default.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '0.9.2',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/underscore.js"></script>
  20. <script type="text/javascript" src="_static/doctools.js"></script>
  21. <link rel="top" title="Python cf module v0.9.2 documentation" href="index.html" />
  22. <link rel="up" title="cf functions" href="function.html" />
  23. <link rel="next" title="cf classes" href="class.html" />
  24. <link rel="prev" title="cf.read1" href="read1.html" />
  25. </head>
  26. <body>
  27. <div class="related">
  28. <h3>Navigation</h3>
  29. <ul>
  30. <li class="right" style="margin-right: 10px">
  31. <a href="genindex.html" title="General Index"
  32. accesskey="I">index</a></li>
  33. <li class="right" >
  34. <a href="py-modindex.html" title="Python Module Index"
  35. >modules</a> |</li>
  36. <li class="right" >
  37. <a href="class.html" title="cf classes"
  38. accesskey="N">next</a> |</li>
  39. <li class="right" >
  40. <a href="read1.html" title="cf.read1"
  41. accesskey="P">previous</a> |</li>
  42. <li><a href="index.html">Python cf module v0.9.2 documentation</a> &raquo;</li>
  43. <li><a href="function.html" accesskey="U">cf functions</a> &raquo;</li>
  44. </ul>
  45. </div>
  46. <div class="document">
  47. <div class="documentwrapper">
  48. <div class="bodywrapper">
  49. <div class="body">
  50. <div class="toctree-wrapper compound">
  51. <ul class="simple">
  52. </ul>
  53. </div>
  54. <div class="section" id="cf-write">
  55. <span id="write"></span><h1>cf.write<a class="headerlink" href="#cf-write" title="Permalink to this headline"></a></h1>
  56. <dl class="function">
  57. <dt id="cf.write">
  58. <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>
  59. <dd><p>Write a space, or sequence of spaces, to a CF compliant netCDF
  60. file.</p>
  61. <p>NetCDF dimension and variable names will be taken from the
  62. 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,
  63. otherwise they are inferred from standard_name attributes or set
  64. to defaults. NetCDF names may be automatically given a numerical
  65. suffix to avoid duplication.</p>
  66. <p>Output netCDF file global attributes are those which occur in the
  67. set of CF global attributes and non-standard data variable
  68. attributes and which have equal values across all input spaces.</p>
  69. <p>It is possible to write only a subset of the input spaces by
  70. providing phenomena conditions with <tt class="xref py py-obj docutils literal"><span class="pre">**kwargs</span></tt> parameters.</p>
  71. <p>It does not matter if an input space&#8217;s data has not yet been read
  72. into memory. The write operation will automatically read the data
  73. array from disk if required, but the default is for it not to be
  74. saved in the input space if it had to be read during the write
  75. operation. However, if the <tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt> argument equals True then any
  76. input spaces which didn&#8217;t contain their full data arrays in memory
  77. will be changed in place so that they do. For example, for a
  78. space, s:</p>
  79. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">type</span>
  80. <span class="go"> &lt;type &#39;netCDF4.Variable&#39;&gt;</span>
  81. <span class="gp">&gt;&gt;&gt; </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">&#39;filename&#39;</span><span class="p">)</span>
  82. <span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">type</span>
  83. <span class="go"> &lt;type &#39;netCDF4.Variable&#39;&gt;</span>
  84. <span class="gp">&gt;&gt;&gt; </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">&#39;filename&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
  85. <span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">type</span>
  86. <span class="go"> &lt;type &#39;numpy.ndarray&#39;&gt;</span>
  87. </pre></div>
  88. </div>
  89. <p>Identical grid components (as determined by their numerically
  90. tolerant <tt class="xref py py-meth docutils literal"><span class="pre">equals()</span></tt> methods) are only written to the file
  91. once, apart from when they need to fulfil both dimension
  92. coordinate and auxiliary coordinate roles for different data
  93. variables.</p>
  94. <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
  95. another coordinate&#8217;s transformation then it will be not written to
  96. the file.</p>
  97. <table class="docutils field-list" frame="void" rules="none">
  98. <col class="field-name" />
  99. <col class="field-body" />
  100. <tbody valign="top">
  101. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  102. <li><strong>spaces</strong> (<em>Space or sequence of spaces</em>) &#8211; The space or spaces to write to the file. If
  103. <tt class="xref py py-obj docutils literal"><span class="pre">**kwargs</span></tt> are set for selection by
  104. phenomena then some spaces may not be written.</li>
  105. <li><strong>file</strong> (<em>str</em>) &#8211; The netCDF file to write spaces to.</li>
  106. <li><strong>data</strong> (<em>bool</em>) &#8211; <em>Optional</em>. If True then ensure that spaces which
  107. have been written to disk retain their data
  108. in-place as numpy arrays.</li>
  109. <li><strong>exact</strong> (<em>bool</em>) &#8211; <em>Optional</em>. If True then interpret the keywords
  110. from <tt class="xref py py-obj docutils literal"><span class="pre">**kwargs</span></tt> as exact phenomenon
  111. 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
  112. details.</li>
  113. <li><strong>format</strong> (<em>str</em>) &#8211; <em>Optional</em>. The format of the output netCDF
  114. file. Valid formats are those supported by the
  115. netCDF4 module: &#8220;NETCDF3_CLASSIC&#8221;,
  116. &#8220;NETCDF3_64BIT&#8221;, &#8220;NETCDF4_CLASSIC&#8221; and
  117. &#8220;NETCDF4&#8221;. The default is
  118. &#8220;NETCDF3_CLASSIC&#8221;. Certain write operations may
  119. be considerably faster using &#8220;NETCDF4_CLASSIC&#8221;.</li>
  120. <li><strong>verbose</strong> (<em>bool</em>) &#8211; <em>Optional</em>. If True then print information to
  121. stdout.</li>
  122. <li><strong>**kwargs</strong> &#8211; <p><em>Optional</em>. Other keyword arguments defining
  123. space selection based on phenomena
  124. criteria. Only selected spaces will be
  125. written to disk. If none are set then all
  126. spaces are selected. Keywords and their
  127. arguments are set as for
  128. <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
  129. modified by the <tt class="xref py py-obj docutils literal"><span class="pre">exact</span></tt> keyword.</p>
  130. </li>
  131. </ul>
  132. </td>
  133. </tr>
  134. </tbody>
  135. </table>
  136. <p><strong>Examples</strong></p>
  137. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span>
  138. <span class="go">[&lt;CF Space: air_pressure(30, 24)&gt;,</span>
  139. <span class="go"> &lt;CF Space: u_compnt_of_wind(19, 29, 24)&gt;,</span>
  140. <span class="go"> &lt;CF Space: v_compnt_of_wind(19, 29, 24)&gt;,</span>
  141. <span class="go"> &lt;CF Space: potential_temperature(19, 30, 24)&gt;]</span>
  142. <span class="gp">&gt;&gt;&gt; </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">&#39;file&#39;</span><span class="p">)</span>
  143. <span class="gp">&gt;&gt;&gt; </span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s">&#39;file&#39;</span><span class="p">,</span> <span class="n">standard_name</span> <span class="o">=</span> <span class="s">&#39;air_pressure&#39;</span><span class="p">)</span>
  144. </pre></div>
  145. </div>
  146. <div class="admonition-see-also admonition seealso">
  147. <p class="first admonition-title">See also</p>
  148. <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
  149. selection by phenomena criteria.</p>
  150. </div>
  151. </dd></dl>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="sphinxsidebar">
  157. <div class="sphinxsidebarwrapper">
  158. <h4>Previous topic</h4>
  159. <p class="topless"><a href="read1.html"
  160. title="previous chapter">cf.read1</a></p>
  161. <h4>Next topic</h4>
  162. <p class="topless"><a href="class.html"
  163. title="next chapter">cf classes</a></p>
  164. <h3>This Page</h3>
  165. <ul class="this-page-menu">
  166. <li><a href="_sources/write.txt"
  167. rel="nofollow">Show Source</a></li>
  168. </ul>
  169. <div id="searchbox" style="display: none">
  170. <h3>Quick search</h3>
  171. <form class="search" action="search.html" method="get">
  172. <input type="text" name="q" size="18" />
  173. <input type="submit" value="Go" />
  174. <input type="hidden" name="check_keywords" value="yes" />
  175. <input type="hidden" name="area" value="default" />
  176. </form>
  177. <p class="searchtip" style="font-size: 90%">
  178. Enter search terms or a module, class or function name.
  179. </p>
  180. </div>
  181. <script type="text/javascript">$('#searchbox').show(0);</script>
  182. </div>
  183. </div>
  184. <div class="clearer"></div>
  185. </div>
  186. <div class="related">
  187. <h3>Navigation</h3>
  188. <ul>
  189. <li class="right" style="margin-right: 10px">
  190. <a href="genindex.html" title="General Index"
  191. >index</a></li>
  192. <li class="right" >
  193. <a href="py-modindex.html" title="Python Module Index"
  194. >modules</a> |</li>
  195. <li class="right" >
  196. <a href="class.html" title="cf classes"
  197. >next</a> |</li>
  198. <li class="right" >
  199. <a href="read1.html" title="cf.read1"
  200. >previous</a> |</li>
  201. <li><a href="index.html">Python cf module v0.9.2 documentation</a> &raquo;</li>
  202. <li><a href="function.html" >cf functions</a> &raquo;</li>
  203. </ul>
  204. </div>
  205. <div class="footer">
  206. &copy; Copyright 2011, David Hassell.
  207. Last updated on Aug 26, 2011.
  208. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
  209. </div>
  210. </body>
  211. </html>