?? matlab-netcdf.html~
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1"> <TITLE>netCDF/OPeNDAP interface to matlab</TITLE> <meta name="generator" content="Bluefish 1.0.7"> <META NAME="CREATED" CONTENT="20050922;13333800"> <META NAME="CHANGED" CONTENT="20070827;15404300"> <META NAME="DESCRIPTION" CONTENT="The CSIRO netCDF/OPeNDAP interface to matlab is used in a matlab session to retrieve data from local netCDF files or OPeNDAP servers. 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 OPeNDAP interface"> <STYLE TYPE="text/css"> <!-- H1 { color: #000000 } P { color: #000000 } PRE { color: #000000 } H3 { color: #000000 } --> </STYLE></HEAD><BODY LANG="en-AU" TEXT="#000000" DIR="LTR"><H1 ALIGN=CENTER>The CSIRO netCDF/OPeNDAP interface to matlab</H1><P ALIGN=CENTER><FONT SIZE=6><B>Version 4.01</B></FONT></P><P ALIGN=CENTER><FONT SIZE=6><B>3 September 2007</B></FONT></P><P><A HREF="#Introduction"><FONT SIZE=4 STYLE="font-size: 16pt">Introduction</FONT></A></P><P><A HREF="#Summary"><FONT SIZE=4 STYLE="font-size: 16pt">Summary offunctions</FONT></A></P><UL> <LI><P><A HREF="#inqnc"><FONT SIZE=4 STYLE="font-size: 16pt">inqnc</FONT></A></P> <LI><P><A HREF="#getnc"><FONT SIZE=4 STYLE="font-size: 16pt">getnc</FONT></A></P> <LI><P><A HREF="#timenc"><FONT SIZE=4 STYLE="font-size: 16pt">timenc</FONT></A></P> <LI><P><A HREF="#attnc"><FONT SIZE=4 STYLE="font-size: 16pt">attnc</FONT></A></P> <LI><P><A HREF="#ddsnc"><FONT SIZE=4 STYLE="font-size: 16pt">ddsnc</FONT></A></P> <LI><P><A HREF="#whatnc"><FONT SIZE=4 STYLE="font-size: 16pt">whatnc</FONT></A></P></UL><P><A HREF="#Installation"><FONT SIZE=4 STYLE="font-size: 16pt">Installation</FONT></A></P><P><A HREF="#Drivers"><FONT SIZE=4 STYLE="font-size: 16pt">Drivers</FONT></A></P><P><A HREF="#Portability"><FONT SIZE=4 STYLE="font-size: 16pt">Portabilityand known problems</FONT></A></P><P><A HREF="#Revision"><FONT SIZE=4 STYLE="font-size: 16pt">Revisionhistory</FONT></A></P><P><A HREF="#Alternative"><FONT SIZE=4 STYLE="font-size: 16pt">Alternativeways of accessing netCDF and OPeNDAP data</FONT></A></P><P><A HREF="#Disclaimer"><FONT SIZE=4 STYLE="font-size: 16pt">Disclaimer</FONT></A></P><P><A HREF="#People"><FONT SIZE=4 STYLE="font-size: 16pt">Peopleinvolved in the development of the interface</FONT></A></P><P><A HREF="#Contact"><FONT SIZE=4 STYLE="font-size: 16pt">Contactdetails</FONT></A></P><HR><H1><A NAME="Introduction"></A>Introduction</H1><P>The CSIRO interface is used in a <A HREF="http://www.mathworks.com/">matlab</A>session to retrieve data from either a local <A HREF="http://www.unidata.ucar.edu/software/netcdf/">netCDF</A>file or via an <A HREF="http://opendap.org/">OPeNDAP/DODS</A> server.The same commands are used for either type of access in almost everycase (some small differences are discussed <A HREF="#Portability">here</A>).</P><P><FONT SIZE=3>The interface has options for automatically handlingmissing values, scalefactors, and the permutation of hyperslabs. Italso has a simple syntax.</FONT></P><P>The method of installing the software is described <A HREF="#Installation">here</A>.</P><P>There are other ways of accessing netCDF files and OPeNDAP/DODSdata and some of them are discussed briefly <A HREF="#Alternative">here</A>.</P><HR><H1><A NAME="Summary"></A>Summary of functions</H1><P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>Basicfunctions</FONT></FONT></P><P>There are six basic functions which are used to access datasetseither from locally held netCDF files or via an OPeNDAP/DODS server.</P><P>If dealing with a netCDF file then the first argument to eachfunction will be a file name. For example,'/home/netcdf-data/sst_cac_recon_ltm.nc' is a full file name(including a path) to a certain netCDF file at the CSIRO Marine Labs.The same file is available via an OPeNDAP/DODS server with the url'<A HREF="http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/sst_cac_recon_ltm.nc.html">http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/sst_cac_recon_ltm.nc</A>'.In the examples that follow we will use this file.</P><P>The six basic functions are:</P><UL> <LI><P ALIGN=LEFT STYLE="background: transparent"><A HREF="#inqnc"><FONT SIZE=4 STYLE="font-size: 16pt">inqnc</FONT></A> : interactive inquiry of the dataset</P></UL><UL> <LI><P ALIGN=LEFT STYLE="background: transparent"><A HREF="#getnc"><FONT SIZE=4 STYLE="font-size: 16pt">getnc</FONT></A> : imports variables from the dataset</P></UL><UL> <LI><P ALIGN=LEFT STYLE="background: transparent"><A HREF="#timenc"><FONT SIZE=4 STYLE="font-size: 16pt">timenc</FONT></A> : imports the time vector of the dataset</P></UL><UL> <LI><P ALIGN=LEFT STYLE="background: transparent"><A HREF="#attnc"><FONT SIZE=4 STYLE="font-size: 16pt">attnc</FONT></A> : imports attributes from the dataset</P> <LI><P ALIGN=LEFT STYLE="background: transparent"><A HREF="#ddsnc"><FONT SIZE=4 STYLE="font-size: 16pt">ddsnc</FONT></A> : returns information about the dataset</P> <LI><P ALIGN=LEFT STYLE="background: transparent"><A HREF="#whatnc"><FONT SIZE=4 STYLE="font-size: 16pt">whatnc</FONT></A> : lists netCDF files in current directory</P></UL><P>For a more detailed description of the functions and some examplesjust follow the links. For an introduction it is suggested that youlook at the functions in the order that they are listed above. Ofcourse documentation is also available using the matlab helpfacility.</P><P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>Auxiliaryfunctions</FONT></FONT></P><P STYLE="background: transparent">There are also some auxiliaryfunctions which are listed below. Use the matlab help facility for amore detailed description of them. You will not usually want to callthese directly although some of the time related functions may beuseful on occasion.</P><UL> <LI><P STYLE="background: transparent">check_nc : checks whether a netcdf or OPeNDAP file is accessible</P> <LI><P STYLE="background: transparent">check_st : checks if a string is stored in a cell or character array</P> <LI><P STYLE="background: transparent">fill_att : returns the names of the attributes of a variable</P> <LI><P STYLE="background: transparent">fill_var : fills a row of an array with the name of a variable</P> <LI><P STYLE="background: transparent">get_calendar_date : converts Julian day numbers to calendar dates</P> <LI><P STYLE="background: transparent">get_day_of_week : gets the day of the week given the Julian day number</P> <LI><P STYLE="background: transparent">get_dods_dds : finds the Dataset Descriptor Structure (DDS) for a DODS/OPeNDAP data set</P> <LI><P STYLE="background: transparent">get_julian_day : converts calendar dates to Julian day numbers</P> <LI><P STYLE="background: transparent">getnc_s : command line version of getnc</P> <LI><P STYLE="background: transparent">get_serial_time : find the absolute time value given a relative time</P> <LI><P STYLE="background: transparent">gregorian : converts Julian day numbers to Gregorian calendar date</P> <LI><P STYLE="background: transparent">hms2h: converts hours, minutes, and seconds to hours</P> <LI><P STYLE="background: transparent">julian : converts Gregorian calendar dates to Julian day numbers</P> <LI><P STYLE="background: transparent">loaddap : direct calls to get DODS/OPeNDAP data and metadata</P> <LI><P STYLE="background: transparent">menu_old : generate a menu of choices for user input</P> <LI><P STYLE="background: transparent">mexnc : direct calls to netcdf functions</P> <LI><P STYLE="background: transparent">parsetnc : parses the COARDS string that specifies time units</P> <LI><P STYLE="background: transparent">pos_cds : returns the path to the common data set directory</P> <LI><P STYLE="background: transparent">return_v : prints out a string to prompt the user for keyboard input</P> <LI><P STYLE="background: transparent">s2hms : converts seconds to integer hour,minute,seconds</P> <LI><P STYLE="background: transparent">tmexnc : test of mexnc Mex-file interface to NetCDF</P> <LI><P STYLE="background: transparent">uncmp_nc : offers to uncompress a netCDF file</P> <LI><P STYLE="background: transparent">y_rescal : returns the scalars rescale_var and rescale_att</P></UL><UL> <LI><P STYLE="background: transparent">whatnc : lists netCDF files in current directory</P></UL><HR><H1><A NAME="inqnc"></A>inqnc</H1><P>inqnc is an interactive function that is used to find out aboutthe structure of a netCDF file or OPeNDAP dataset. In the latter caseyou could use a web browser for the same purpose. Try clicking on theurl'<A HREF="http://www.marine.csiro.au/dods/nph-dods/dods-data/test_data/test_1.nc.html">http://www.marine.csiro.au/dods/nph-dods/dods-data/test_data/test_1.nc</A>' to see this structure. The same information is found in the matlabexample below. Of course, the output from inqnc will be almostidentical if we look at the netCDF file on a local disk.</P><P STYLE="margin-top: 0.17in; page-break-after: avoid"><FONT FACE="Albany, sans-serif"><FONT SIZE=4>Example</FONT></FONT></P><PRE>>> file = 'http://www.marine.csiro.au/dods/nph-dods/dods-data/test_data/test_1.nc';>> inqnc(file) --- Global attributes ---source: Test program The 5 dimensions are 1) dim_unlmited = 3 2) depth1 = 12 3) depth2 = 11 4) dim3 = 3 5) dim4 = 4.dim_unlmited is unlimited in length ----- Get further information about the following variables ----- -1) None of them (no further information) 0) All of the variables 1) time 2) u 3) ureverse 4) uchar1 5) uchar2 6) uchar3 7) ushort 8) ulong 9) udouble 10) no_atts 11) big_var 12) depth1 13) depth2 14) dim3 Select a menu number: 1 --- Information about time(dim_unlmited ) --- *units: days since 1990-1-1 00:00:0.0 *long_name: Time ----- Get further information about the following variables ----- -1) None of them (no further information) 0) All of the variables 1) time 2) u 3) ureverse 4) uchar1 5) uchar2 6) uchar3 7) ushort 8) ulong 9) udouble 10) no_atts 11) big_var 12) depth1 13) depth2 14) dim3 Select a menu number: 2 --- Information about u(depth1 depth2 ) --- *long_name: u,5_januarys *units: cm/sec*ml__FillValue: 10000000270000000 *missing_value: 10000000270000000 *valid_range: -10000000270000000 10000000270000000 *test_double: 100 2000 *test_short: 25 -3 19 *test_long: -4 333 -17 *scale_factor: 3 *add_offset: 0.5 ----- Get further information about the following variables ----- -1) None of them (no further information) 0) All of the variables 1) time 2) u 3) ureverse 4) uchar1 5) uchar2 6) uchar3 7) ushort 8) ulong 9) udouble 10) no_atts 11) big_var 12) depth1 13) depth2 14) dim3 Select a menu number: -1</PRE><HR><H1><A NAME="getnc"></A>getnc</H1><H3><A NAME="Introduction_getnc"></A><B>Introduction</B></H3><P>getnc retrieves data in two ways. It can be used <A HREF="#getnc_interactive">usedinteractively</A> to retrieve data from a netCDF file.<BR><BR>getncis more commonly used as a function call - it can then retrieve datafrom both netCDF and OPeNDAP files. Because many options areavailable getnc can take up to 11 <A HREF="#getnc_meanings_defaults">inputarguments</A> (although most have default values). To make thingseasier for the user there are <A HREF="#getnc_specifying_arguments">variousways of specifying</A> these arguments. Finally, a number of <A HREF="#getnc_examples">examples</A>are given.</P><H3><A NAME="getnc_interactive"></A><B>Interactive use</B></H3><P>To retrieve data interactively the user simply types in </P><PRE STYLE="margin-bottom: 0.2in">>> val = getnc(file);</PRE><P>where file is a string containing the name of the netCDF file. Fromthere the user is prompted for more information.</P><H3><A NAME="getnc_meanings_defaults"></A><B>Arguments - meanings anddefaults</B></H3><P>There are 11 variables that getnc must know. Don't be frightenedhowever as there are some easy ways to specify them and all but twohave defaults. The variables are:</P><OL> <LI><P STYLE="margin-bottom: 0in"><B>file</B>: This is a string containing the name of the netCDF file or the URL to the OPeNDAP dataset. It does not have a default. If describing a netCDF file it is permissible to drop the ".nc" prefix but this is not recommended. </P> <LI><P STYLE="margin-bottom: 0in"><B>varid: </B>This may be a
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -