Nino add up @Wiki
netCDFデータの読み込み・書き換え
最終更新:
nino-add-up
-
view
netCDF形式のデータをmatlabで読み書きする
- toolboxをダウンロードする
- sourceforge.net
- バージョンに合ったmexncをダウンロードする
- mexncができるので,それをC:\Program Files\MATLAB\R2007a\toolboxの中あたりの自分のわかりやすいところに移動させる
- matlabを起動する
- ファイルからパスの設定を開く
- フォルダを追加をクリックして,さっき移動させたフォルダを指定する
- 設定を保存する
- sourceforge.net
- netcdf_toolbox
- 同じページにあるnetcdf-toolboxをダウンロードする
- netcdf_toolboxができるので,mexncと同じように移動させる
- パスの設定を開く
- サブフォルダも追加をクリックして,さっきのフォルダを指定する
- パスの最後がCVSのものはいらないので削除する
- 設定を保存する
- netcdf_toolbox
- 使い方
- 基本的にはヘルプを見る(英語)
- ncload('ファイル名')でnetCDFのファイルを読める
- ncsave('ファイル名','変数名')で元々あるnetCDFファイルの変数を書き換えられる
- netCDFファイルの作成(以下を参考に)
% Create NetCDF file.
nc = netcdf('ncexample.nc', 'clobber');
% Global attributes.
nc.description = 'NetCDF Example';
nc.author = 'kin';
nc.date = '2008-1-1';
% Define dimensions.
nc('nx') = 10;
nc('ny') = 10;
% Define variables.
nc{'latitude'} = 'ny';
nc{'longitude'} = 'nx';
nc{'depth'} = {'ny', 'nx'};
% Attributes.
nc{'latitude'}.units = 'degrees';
nc{'longitude'}.units = 'degrees';
nc{'depth'}.units = 'meters';
% --- STORE THE DATA --- %
% Matlab data.
latitude = [0 10 20 30 40 50 60 70 80 90];
longitude = [0 20 40 60 80 100 120 140 160 180];
depth = rand(length(latitude), length(longitude));
% Put all the data.
nc{'latitude'}(:) = latitude;
nc{'longitude'}(:) = longitude;
nc{'depth'}(:,:) = depth;
nc = close(nc);
- NetCDFファイルにはlatitudeとlongitudeとdepthが保存される
- latやlongは保存されない
netCDFのデータの図をとりあえず見たいだけの場合
- ncx,NetCDF eXplorer
- クリックするだけで図の表示ができる.
[PR] メールフォーム