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

📄 matlab-netcdf.html

📁 读取Network Common Data Form (netCDF)数据
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD>   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">   <META NAME="description" CONTENT="The CSIRO matlab/netCDF is used in a matlabsession to retrieve data from, and information about, existing netCDF files. The interface has options for automatically handling missing values, scalefactors, and permutation of hyperslabs. It also has a simple syntax.">   <META NAME="keywords" CONTENT="CSIRO matlab netCDF interface">   <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; SunOS 4.1.3 sun4m) [Netscape]">   <TITLE>matlab-netCDF home page</TITLE><!$Id: matlab-netcdf.html,v 1.16 2003/04/29 03:08:02 man133 Exp $></HEAD><BODY BGCOLOR="#FFFFFF" LINK="#000089"><IMG SRC="http://www.marine.csiro.au/dmrimages/dmrlogo3.gif" ALT="CSIRO Marine Research" BORDER=0  ALIGN=TOP><BLOCKQUOTE>&nbsp;<CENTER><H1>CSIRO matlab/netCDF interface</H1></CENTER><HR ALIGN=LEFT width = 100%><H4>Index</H4><A HREF="#short_description">Short Description of the matlab/netCDF interface</A><BR><A HREF="#portability">Portability issues</A><BR><A HREF="#installation">Downloading and installation</A><BR><A HREF="#summary">Summary of functions</A><BR><A HREF="#doc_getnc">Detailed discussion of getnc</A><BR><A HREF="#further_documentation">Further documentation</A><BR><A HREF="#backwards_compatibility">Backwards compatibility issues</A><BR><A HREF="#latest_changes">Latest changes</A><BR><A HREF="#disclaimer">Disclaimer</A><BR><A HREF="#development_people">People involved in the development ofthe matlab/netCDF interface</A><BR><A HREF="#contact">Contact details</A><BR><A HREF="#links">Matlab links</A><P><HR ALIGN=LEFT width = 100%><A NAME="short_description"></A><H4>Short Description of the matlab/netCDF interface</H4>This page describes an interface between <A HREF="http://www.unidata.ucar.edu/packages/netcdf">NetCDF</A>and <A HREF="http://www.mathworks.com">MATLAB (versions 5 and 6).</A> The interfacehas been developed since 1991 by a <A HREF="#development_people">numberof people</A>.<P>The basis of the interface is a machine-dependent mex-file called mexcdf53(an older version running under matlab4 used mexcdf). Rather than callthe mex-file directly users are advised to employ either Chuck Denham's netCDFtoolbox or the CSIRO matlab/netCDF interface described here.<P>The CSIRO matlab/netCDF interface has a simple syntax. It has optionsfor automatically handling missing values, scale factors, and permutationof hyperslabs. It is however limited to retrieving data from, and informationabout, existing netCDF files.<P>By contrast, Chuck's netCDF toolbox allows users to create and manipulatenetCDF files as well as to read and examine them. It does this by makingfull use of matlab features that were new in version 5 - such as cells, structuresand operator overloading.The extra capabilities mean that there is a little more to learn and remember.<p>I suggest that you install them both and use the one most appropriate to your given problem.</p><P>The rest of this web page describes the interface between matlab andnetCDF files. There is an older, no longer supported, version of the CSIROinterface that runs under matlab4; this web document tells you how to getthat version but does not describe it.<P><HR ALIGN=LEFT width = 100%><A NAME="portability"></A><H4>Portability issues</H4>Almost all of the machine dependence of the system is in the mex-file whichis downloaded separately. The m-files that make up the CSIRO matlab/netCDFinterface have been tested on a number of unix machines as well as a windows-95box. No problems have been found with matlab versions 5.0 through to 6.1.<P>Earlier versions, however, did not work properly on pc operating systemsbecause they used file names with more than 8 characters. This has beenchanged for the latest version. The m-file 'whatnc' will produce prettieroutput on a unix machine (where it is able to make unix function calls)but it will still work on non-unix machines.<P><HR ALIGN=LEFT width = 100%><A NAME="installation"></A><H4>Downloading and installation</H4>What you should get depends on whether you are using matlab4 or later versions (5.0 through to 6.1)and also whether you want backwards compatibility to older versions ofthe matlab/netCDF interface that ran under matlab3 and 4.<DL><DT>matlab 5 and 6 users</DT><DD>First you should install Chuck Denham's <A HREF="http://crusty.er.usgs.gov/~cdenham/MexCDF/nc4ml5.html">netCDFtoolbox and the appropriate mex-file</A>. Note that although the latest version of Chuck's toolbox should work for allversions of matlab5 and 6 these may require different versions of the mex files due to incompatibilities betweendifferent matlab versions.</DD><P>Next get the CSIRO matlab/netCDF interface. There are 2 versions ofthis according to whether you are a new user or whether you already havecode requiring the previous version of the interface (in this case youwill get all of the code needed for the latest version of the interfaceas well as extra m-files to mimic the previous version). Each version ofthe interface is available in 2 forms - as a tar'ed and compressed fileor as a p-code file. The contents of these files are identical but thetar'ed and compressed file is very small (~56 kb) and is convenient forunix users while the p-code version is much larger(~256 kb) but will workfor everyone.<P>New users download one of the following<UL><LI>tar'ed and compressed file <A HREF="ftp://ftp.marine.csiro.au/pub/mansbrid/matlab_netcdf_5_0.tar.Z">matlab_netcdf_5_0.tar.Z</A></LI><LI>p-code file <A HREF="ftp://ftp.marine.csiro.au/pub/mansbrid/matlab_netcdf_5_0.p">matlab_netcdf_5_0.p</A></LI></UL>Users wanting backwards compatibility download one of the following<UL><LI>tar'ed and compressed file <A HREF="ftp://ftp.marine.csiro.au/pub/mansbrid/matlab_netcdf_4x5.tar.Z">matlab_netcdf_4x5.tar.Z</A></LI><LI>p-code file <A HREF="ftp://ftp.marine.csiro.au/software/mansbrid/matlab_netcdf_4x5.p">matlab_netcdf_4x5.p</A></LI></UL><DT>matlab 4 users</DT><DD>An older, no longer supported, version of the CSIRO interface is also availableas <A HREF="ftp://ftp.marine.csiro.au/pub/mansbrid/matlab-netcdf-4.0.tar.Z">matlab-netcdf-4.0.tar.Z</A>.This requires an older mex-file which can be obtained from Rich Signell's<A HREF="http://crusty.er.usgs.gov/mexcdf.html">"MEXCDF: The Matlab/NetCDFInterface"</A> home page.</DD></DL>The installation of the m-files is easy.<OL><LI>If you have a tar'ed and compressed file then just type</LI><BR>zcat matlab_netcdf_5_0.tar.Z | tar -xf -<BR>or<BR>zcat matlab_netcdf_4x5.tar.Z | tar -xf -<BR>as appropriate. This will put all of the m-files into a suitable directory(called something like matlab_netcdf_5_0).<P>If you have a p-code version then put this into a new directory (calledsomething like matlab_netcdf_5_0), start matlab, and type in the name ofthe p-code file (without the .p). This will automagically put the requiredm-files into the directory.<LI>Put the directory containing the matlab/netCDF interface into matlab'spath - perhaps by using the 'path' command. It is possible to store them-files in the directory containing Chuck's files (this would usually be$TOOLBOX/local/netcdf). The only trouble with this is that matlab willthen see a conflict between the Contents.m file is this distribution andchuck's netCDF help file.</LI><LI>Edit the m-file pos_cds.m; it returns the path to the common data set directory.pos_cds.m is called by whatnc, inqnc and getnc and so any netCDF file inthe common data set will be accessible to users without them needing tospecify path names.</LI><LI>You may edit the the function y_rescale.m although this is strongly advisedagainst. The function y_rescale determines whether getnc applies the attributesscale_factor and add_offset to relevant variables and attributes. The defaultis that any variable will be automatically rescaled; if a variable hasattributes valid_range, valid_min, valid_max or _FillValue then these willbe automatically rescaled also. This behaviour can be changed by editingy_rescale.m but you should be very cautious in doing so. In particular,if the variable is rescaled and its attributes not, or vice versa, thenthe options to replace 'invalid' data will not work in the way expectedin the netCDF standard.</LI></OL><HR ALIGN=LEFT width = 100%><A NAME="summary"></A><H4>Summary of functions</H4>The following commands are available (use help in matlab for further information)and will be supported in the future. There is also a <A HREF="#doc_getnc">detaileddiscussion of getnc</A>.<DL><DT>attnc</DT><DD>imports attributes of a netCDF file</DD><DT>getnc</DT><DD>imports variables from a netCDF file</DD><DT>inqnc</DT><DD>interactive inquiry of netCDF file</DD><DT>netcdf toolbox</DT><DD>direct calls to netCDF functions - use 'help netcdf' for a detailed description</DD><DT>timenc</DT><DD>finds the time vector and the corresponding base date for a netCDF filethat meets <A HREF="http://www-pcmdi.llnl.gov/drach/netCDF.html">COARDSstandards</A></DD><DT>whatnc</DT><DD>lists netCDF files in current directory</DD></DL><HR ALIGN=LEFT width = 100%><A NAME="doc_getnc"></A><H4>Detailed description of getnc</H4>getnc retrieves data from a NetCDF file. It is called from within matlab 5 or 6by:<P>values = getnc(file, varid, corner, end_point, stride, order, change_miss, new_miss, squeeze_it, rescale_opts)<P>DESCRIPTION:<BR><P>getnc retrieves data from a NetCDF file. The way getnc behaves dependson how many of the input arguments are passed to it. If no arguments arepassed then it returns a help message. If one argument is passed then theuser is asked questions to determine information necessary for the dataretrieval. If more than one argument is passed then getnc returns the datawithout needing to ask any questions. The input arguments are listed below.<P>INPUT:<DL><DT>file</DT><DD>is the name of a netCDF file but without the .cdf or .nc extent.</DD><DT>varid</DT><DD>may be an integer or a string. If it is an integer then it must be themenu number of the n dimensional variable as used by a call to inqnc orgetnc. If it is a string then it should be the name of the variable.</DD><DT>corner</DT><DD>is a vector of length n specifying the hyperslab corner with the lowestindex values (the bottom left-hand corner in a 2-space). The corners referto the dimensions in the same order that these dimensions are listed inthe relevant questions in getnc.m and in the inqnc.m description of thevariable. A negative element means that all values in that direction willbe returned. If a negative scalar is used this means that all of the elementsin the array will be returned.</DD><DT>end_point</DT><DD>is a vector of length n specifying the hyperslab corner with the highestindex values (the top right-hand corner in a 2-space). The corners referto the dimensions in the same order that these dimensions are listed inthe relevant questions in getnc.m and in the inqnc.m description of thevariable. An element in the end_point vector will be ignored if the correspondingelement in the corner vector is negative.</DD>

⌨️ 快捷键说明

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