Navigation : Top/netcdf
*netcdf -> mexncと改名 [#d8a431c1]

* Linuxの場合 [#q520e6ed]

**ダウンロード [#z99791e5]
http://mexcdf.sourceforge.net
+mexcdf.tar.gz 
をダウンロード 

**インストール [#i32a18b9]

mexcdf.tar.gzを解凍し、mexncの下にあるmakefileをコンパイルする.
matlab/bin/mexopt.shをコピ−し.
 make -f makefile
とし,mexncを生成.
注意) 環境に合わせて[[mexopt.sh]](サンプル)の編集が必要

startup.mに以下を記述する。 
 addpath /usr/local/matlab6/toolbox/netcdf/netcdf/ncutility 
 addpath /usr/local/matlab6/toolbox/netcdf/netcdf/nctype 
 addpath /usr/local/matlab6/toolbox/netcdf/netcdf 
 addpath /usr/local/matlab6/toolbox/netcdf 
matlabを起動し、mexnc/test/test_mexnxを実行するとテストプログラムが起動する。 
ちゃんと起動したら、正しくインストールされたことになる(はず)。 

[[USGS作成のマニュアル:http://woodshole.er.usgs.gov/staffpages/cdenham/public_html/MexCDF/nc4ml5_guide.html]]

* Windowsの場合 [#r85897e1]

**ダウンロード [#k32b487d]
http://mexcdf.sourceforge.net
+ mexcdf.zip, mexnc-R14-win.zip, snctools.zip, netcdf_toolbox.zip
をダウンロード 

**インストール [#r6a07402]

mexnc-R14-win.zipを解凍し、mexnc.dllを$(matlab)/binおよび$(matlab)/bin/w32の下におく.

startup.mに以下を記述する。 
 addpath /usr/local/matlab7/toolbox/mexnc
 addpath /usr/local/matlab7/toolbox/netcdf_toolbox/netcdf/ncutility 
 addpath /usr/local/matlab7/toolbox/netcdf_toolbox/netcdf/nctype 
 addpath /usr/local/matlab7/toolbox/netcdf_toolbox/netcdf/source
 addpath /usr/local/matlab7/toolbox/snctools
matlabを起動し、mexnc/test/test_mexnxを実行するとテストプログラムが起動する。 
ちゃんと起動したら、正しくインストールされたことになる(はず)。 


* 使い方 [#y289845d]
***  netCDFデータを読む [#i44ca6e7]
- 文法
-- nc = netcdf('path', 'mode')
-- nc -- The output "netcdf" object, or [] if error.
-- path -- The path (filename) as a string.
-- mode -- The string 'nowrite' or 'write'.
- 例
-- nc = netcdf('foo.nc', 'nowrite')

*** ファイルを閉じる [#y1832081]
- 文法
-- result = close(nc)

*** ファイルの情報を得る [#ae1d44d1]
- 文法
-- theDims = dim(nc)
-- theVars = var(nc)
-- theGAtts = att(nc)
-- theRecdim = recdim(nc)
- 内容
-- nc -- "netcdf" object.
-- theDims -- List of "ncdim" dimension objects.
-- theVars -- List of "ncvar" variable objects.
-- theGAtts -- List of "ncatt" global attribute objects.
-- theRecdim -- The "ncdim" record-dimension object.
- 例
-- nc = netcdf('foo.nc', 'write')
-- if isempty(nc), error(' ## Bad netcdf operation.'), end
-- theDims = dim(nc)        % List of "ncdim" dimension objects.
-- theVars = var(nc)        % List of "ncvar" variable objects.
-- theGAtts = att(nc)       % List of "ncatt" global attribute objects.
-- theRecdim = recdim(nc)   % The "ncdim" record-dimension object.

*** オブジェクトからデータを得る [#n065f6ef]
- 文法
--  theVar = nc{'theVarname'}
-- theVar = ncvar('theVarname', nc)
- 内容
-- theVar -- The "ncvar" variable object.
-- nc -- The parent "netcdf" object.
-- theVarname -- The string-name of the variable.
- 例
--  theVar = nc{'elevation'}


*Link [#z7919b6c]
-[[CSIRO matlab/netCDF interface:http://www.marine.csiro.au/sw/matlab-netcdf.html]]
-[[MexCDF and NetCDF Toolbox For Matlab-5&6:http://woodshole.er.usgs.gov/staffpages/cdenham/public_html/MexCDF/nc4ml5.html]]
- [[NetCDF Toolbox Interface Descriptions:http://mexcdf.sourceforge.net/netcdf_toolbox_guide.html]]
- [[NetCDF Simple Demo:http://www.ems.psu.edu/~young/meteo473/netcdf_demo.m]]