⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matlab-netcdf.html

📁 读取Network Common Data Form (netCDF)数据
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<DT>stride</DT><DD>is a vector of length n specifying the interval between accessed valuesof the hyperslab (sub-sampling) in each of the n dimensions. A value of1 accesses adjacent values in the given dimension; a value of 2 accessesevery other value; and so on. If no sub-sampling is required in any directionthen it is allowable to just pass the scalar 1 (or -1 to be consistentwith the corner and end_point notation).</DD><DT>order</DT><DD>is a vector of length n specifying the order of the dimensions in the returnedarray. order = -1 or [1 2 3 .. n] for an n dimensional netCDF variablewill return an array with the dimensions in the same order as describedby a call to inqnc(file) from within matlab or 'ncdump -h' from the commandline. Putting order = -2 will reverse this order. More general permutationsare given re-arranging the numbers 1 to n in the vector.</DD><DT>change_miss</DT><DD>== 1 causes missing values to be returned unchanged.</DD><BR>== 2 causes missing values to be changed to NaN.<BR>== 3 causes missing values to be changed to new_miss (after rescalingif that is necessary).<BR>&lt; 0 produces the default (missing values to be changed to NaN).<DT>new_miss</DT><DD>is the value given to missing data if change_miss = 3.</DD><DT>squeeze_it</DT><DD>specifies whether the returned array should be squeezed. That is, whensqueeze_it is non-zero then the squeeze function will be applied to thereturned array to eliminate singleton array dimensions. This is the default.Note also that a 1-d array is returned as a column vector.</DD><dt>rescale_opts</dt><dd>is a 2 element vector specifying whether or not rescaling iscarried out on retrieved variables or attributes. Only use this optionif you are sure that you know what you are doing.If rescale_opts(1) == 1 then a variable read in by getnc.m will berescaled by 'scale_factor' and  'add_offset' if these are attributes ofthe variable; this is the default. If rescale_opts(1) == 0 then thisrescaling will not be done.If rescale_opts(2) == 1 then the attributes '_FillValue', 'valid_range','valid_min' and 'valid_max' read in by getnc.m (and used to find themissing values of the relevant variable) will be rescaled by'scale_factor' and 'add_offset'; this is the default. If rescale_opts(2)== 0 then this rescaling will not be done.</dd></DL>OUTPUT:<DL><DT>values</DT><DD>is a scalar, vector or array of values that is read in from the NetCDFfile</DD></DL>NOTES:<OL><LI>In order for getnc to work non-interactively it is only strictly necessaryto pass the first 2 input arguments to getnc - sensible defaults are availablefor the rest.</LI><BR>These are:<BR>corner, end_point = [-1 ... -1], => all elements retrieved<BR>stride = 1, => all elements retrieved<BR>order = [1 2 3 .. n] for an n dimensional netCDF variable<BR>change_miss = 2, => missing values replaced by NaNs<BR>new_miss = 0;<BR>squeeze_it = 1; => singleton dimensions will be removed<LI>It is not acceptable to pass only 3 input arguments since there is no defaultin the case of the corner points being specified but the end points not.</LI><LI>By default the order of the dimensions of a returned array will be thesame as they appear in the relevant call to 'inqnc' (from matlab) or 'ncdump-h' (from the command line). (This is the opposite to what happened inan earlier version of getnc.) This actually involves getnc re-arrangingthe returned array because the netCDF utilities follow the C conventionfor data storage and matlab follows the fortran convention.</LI><P>Since the netCDF file follows the C convention this means that in theactual storage of the data lon is the fastest changing index, followedby lat, and then month. However matlab (and fortran) use the opposite conventionand so month is the fastest changing index, followed by lat, and then lon.getnc actually used the permute function to reverse the storage order.If efficiency is a concern (because of using very large arrays or a largenumber of small arrays) then passing order == -2 to getnc will producethe fastest response by returning the data in its 'natural' order (a 180x90x12array in our example)<LI>If the values are returned in a one-dimensional array then this will bea column vector. This choice provides consistency if there is an unlimiteddimension. That is, if the length of the unlimited dimension is n thenan m x n array will be returned even for n = 1.)</LI><LI>A strange 'feature' of matlab 5 (and later versions) is that it will not tolerate a singletondimension as the final dimension. Thus, if you chose to have only one elementin the final dimension this dimension will be 'squeezed' whether you wantit to be or not - this seems to be unavoidable.</LI></OL>EXAMPLES:<P>To be more explicit, suppose that we use inqnc to examine a netCDF file.Then 2 lines in the output might read:<P>The 3 dimensions are 1) month = 12 2) lat = 90 3) lon = 180.<BR>--- Information about airtemp(month lat lon ) ---<P>Likewise using 'ncdump -h' from the command line would have the correspondingline:<P>short airtemp(month, lat, lon);<P>1) The simplest possible call to getnc will get all the elements ofthe variable (note the order of the dimensions):<P>>> airtemp = getnc('oberhuber', 'airtemp');<BR>>> size(airtemp) = 12 90 180<P>2) Get a subsample of the variable, note the stride:<P>&nbsp;>> airtemp = getnc('oberhuber', 'airtemp', [-1 1 3], [-1 46 6],[1 5 1]);<BR>>> size(airtemp)<BR>ans = 12 10 4<P>3) Get all the elements of the variable, but with dimensions permuted:<P>&nbsp;>> airtemp = getnc('oberhuber', 'airtemp', -1, -1, -1, [2 3 1]);<BR>>> size(airtemp)<BR>ans = 90 180 12<P>4) Get all the elements of the variable, but with missing values replacedwith 1000. Note that the corner, end_point, stride and order vectors havebeen replaced by -1 to indicate that the whole range is required in thedefault order:<BR>>> airtemp = getnc('oberhuber', 'airtemp', -1, -1, -1, -1, 3, 1000);<P>>> size(airtemp)<BR>ans = 12 90 180<P>5) Get a subsample of the variable, a singleton dimension is squeezed:<P>&nbsp;>> airtemp = getnc('oberhuber', 'airtemp', [-1 7 -1], [-1 7 -1]);<BR>>> size(airtemp)<BR>ans = 12 180<P>6) Get a subsample of the variable, a singleton dimension is not squeezed:<P>&nbsp;>> airtemp = getnc('oberhuber','airtemp',[-1 7 -1],[-1 7 -1],-1,-1,-1,-1,0);<BR>>> size(airtemp)<BR>ans = 12 1 180<P><HR ALIGN=LEFT width = 100%><A NAME="further_documentation"></A><H4>Further documentation</H4>There used to be a user manual in latex and postscript form. I have notyet updated the manual and so have not put it in this distribution. Infact it should not be necessary for an experienced matlab and netCDF userto read the manual at all. Simply do a help on the 5 m-files that wouldbe commonly used - attnc, getnc, inqnc, timenc and whatnc.<P><HR ALIGN=LEFT width = 100%><A NAME="backwards_compatibility"></A><H4>Backwards compatibility issues</H4>Earlier versions of these m-files had names like getcdf, whatcdf, etc andwere used for matlab versions 3.5 and 4.2. If you have a lot of legacycode that you don't wish to change then you should download and installmatlab-netcdf-4.2-5.0.tar.Z. This runs under matlab 5 and mimics the oldermatlab/netCDF interface.<P><HR ALIGN=LEFT width = 100%><A NAME="latest_changes"></A><H4>Latest changes</H4><UL><LI><I>July 3 2000: </I>timenc was generalised so that it could handledates before the introduction of the Gregorian calendar on October 15,1582; it now works back to the year -4712. The earlier version couldgive incorrect dates for files which used the pre-Gregorian calendar ineither the time vector values or in its 'units' attribute.<LI><I>April 22 1998: </I>timenc was generalised so that when requested itwill return only part of the time vector. It can also return the lengthof the time vector as a separate variable.</LI><LI><I>December 12 1997:</I> attnc was generalised so that when the user doesnot specify the name of the variable's attribute then all of the attributes(and their names) will be returned in cells.</LI></UL><P><HR ALIGN=LEFT width = 100%><A NAME="disclaimer"></A><H4>Disclaimer</H4>This software is provided "as is" without warranty of any kind. It is coveredby a general CSIRO <A HREF="http://www.csiro.au/legalnotices/disclaimer.html">LegalNotice and Disclaimer</A>.<P><HR ALIGN=LEFT width = 100%><A NAME="development_people"></A><H4>People involved in the development of the matlab/netCDF interface</H4>Julie Allen: <A HREF="mailto:jallen@whoi.edu">jallen@whoi.edu</A><BR>Chuck Denham: <A HREF="mailto:cdenham@usgs.gov">cdenham@usgs.gov</A><BR>Jim Mansbridge: <img SRC="jmaddress1.gif"><BR>Rich Signell: <A HREF="mailto:rsignell@usgs.gov">rsignell@usgs.gov</A><P><HR ALIGN=LEFT width = 100%><A NAME="contact"></A><H4>Contact details</H4><P>This web page is maintained by Jim Mansbridge, CSIRO Division of MarineResearch<P><B>Postal address:</B> GPO Box 1538, Hobart, Tasmania 7001, Australia&nbsp;<!--CHANGE NEXT LINE TO YOUR PHONE NUMBERS --><BR><B>Phone:</B> +61-3-62 32 5416<BR><B>Fax:</B> +61-3-62 32 5123&nbsp;<!--CHANGE NEXT LINES TO YOUR EMAIL ADDRESS --><BR><img SRC="jmaddress1.gif"><P><HR ALIGN=LEFT width = 100%><A NAME="links"></A><H4>Matlab links</H4><table width=180 border=0 cellpadding=0 cellspacing=0><tr><td align=center><font size=-1><a href="http://www.links2go.com/topic/MATLAB"><img alt="Key Resource" src=http://www.marine.csiro.au/~mansbrid/key.gif width=121 height=121 border=0><br><b><i>Links<sup><small>2</small></sup>Go</i> Key Resource</b><br>MATLAB Topic</a></font></td></tr></table><P><HR ALIGN=LEFT width = 100%>This page is <A HREF="http://www.marine.csiro.au/sw/matlab-netcdf.html">http://www.marine.csiro.au/sw/matlab-netcdf.html</A>.<BR>It was last revised $Date: 2003/04/29 03:08:02 $.&nbsp;<!--START OF FOOTER  PLEASE DON'T CHANGE--><BR><BR<FONT SIZE="2"><HR>Further details on the research of the CSIRO Division of Marine Researchare available through the Division's Home Page.<CENTER></CENTER><CENTER><IMG SRC="http://www.marine.csiro.au/dmrimages/home.gif" ALT="CSIRO Marine Home Page" ALIGN=BOTTOMBORDER="1"></A><P>For more information contact reception@marine.csiro.au or telephone+61-3-62325222. Unless otherwise indicated all contents in these web documentsare copyright &copy; 1997 CSIRO. Use of this web site and information availablefrom it is subject to our <A HREF="http://www.csiro.au/legalnotices/legalnotices/disclaimer.html">LegalNotice and Disclaimer</A></BLOCKQUOTE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -