Takuya Miyashita
This site
Web
Start:
*NetCDF形式データの読み書き [#q2b15111]
**読み [#n3cc4983]
#codeprettify(lang-matlab){{
hogehoge = ncinfo('filename.nc');
}}
で返す構造体で変数一覧などが確認できる. ncdisp は容量が...
変数名がわかれば
#codeprettify(lang-matlab){{
var1 = ncread('filename.nc', 'varname');
}}
でOK.
**書き [#fdbacda9]
下記は単制度浮動小数点数の気圧時空間データをそれぞれの時...
#codeprettify(lang-matlab){{
%% output
ncdir = './slp_nc';
if exist(ncdir,'dir'); system(['rm -rf ', ncdir]); end
mkdir(ncdir);
ncfile_base = 'slp_XXX.nc';
nt = length(t);
for k = 1:nt
ncfile = fullfile(ncdir,strrep(ncfile_base,'XXX',spri...
disp([ncfile, ' ...']);
% % lonlat
nccreate(ncfile,'lon',"Dimensions",{"lon",nlon},"Fill...
nccreate(ncfile,'lat',"Dimensions",{"lat",nlat},"Fill...
ncwrite(ncfile,'lon',lon);
ncwrite(ncfile,'lat',lat);
% % pressure
nccreate(ncfile,'slp',"Dimensions",{"lon",nlon,"lat",...
ncwrite(ncfile,'slp',permute(flipud(pres(:,:,k)),[2,1...
% % time
nccreate(ncfile,'time',"Datatype", "single");
ncwrite(ncfile,'time',t(k));
end
}}
nccreate で変数を定義して ncwrite で MATLAB 上の変数を入...
スカラーじゃない場合は nccreate で 'Dimensions' なるもの...
2次元空間分布の場合などは次元の順番と向きに注意.~
***参考 MathWorks 公式 [#k588f20f]
-[[ncinfo>https://jp.mathworks.com/help/matlab/ref/ncinfo...
-[[ncread>https://jp.mathworks.com/help/matlab/ref/ncread...
-[[nccreate>https://jp.mathworks.com/help/matlab/ref/nccr...
-[[ncwrite>https://jp.mathworks.com/help/matlab/ref/ncwri...
End:
*NetCDF形式データの読み書き [#q2b15111]
**読み [#n3cc4983]
#codeprettify(lang-matlab){{
hogehoge = ncinfo('filename.nc');
}}
で返す構造体で変数一覧などが確認できる. ncdisp は容量が...
変数名がわかれば
#codeprettify(lang-matlab){{
var1 = ncread('filename.nc', 'varname');
}}
でOK.
**書き [#fdbacda9]
下記は単制度浮動小数点数の気圧時空間データをそれぞれの時...
#codeprettify(lang-matlab){{
%% output
ncdir = './slp_nc';
if exist(ncdir,'dir'); system(['rm -rf ', ncdir]); end
mkdir(ncdir);
ncfile_base = 'slp_XXX.nc';
nt = length(t);
for k = 1:nt
ncfile = fullfile(ncdir,strrep(ncfile_base,'XXX',spri...
disp([ncfile, ' ...']);
% % lonlat
nccreate(ncfile,'lon',"Dimensions",{"lon",nlon},"Fill...
nccreate(ncfile,'lat',"Dimensions",{"lat",nlat},"Fill...
ncwrite(ncfile,'lon',lon);
ncwrite(ncfile,'lat',lat);
% % pressure
nccreate(ncfile,'slp',"Dimensions",{"lon",nlon,"lat",...
ncwrite(ncfile,'slp',permute(flipud(pres(:,:,k)),[2,1...
% % time
nccreate(ncfile,'time',"Datatype", "single");
ncwrite(ncfile,'time',t(k));
end
}}
nccreate で変数を定義して ncwrite で MATLAB 上の変数を入...
スカラーじゃない場合は nccreate で 'Dimensions' なるもの...
2次元空間分布の場合などは次元の順番と向きに注意.~
***参考 MathWorks 公式 [#k588f20f]
-[[ncinfo>https://jp.mathworks.com/help/matlab/ref/ncinfo...
-[[ncread>https://jp.mathworks.com/help/matlab/ref/ncread...
-[[nccreate>https://jp.mathworks.com/help/matlab/ref/nccr...
-[[ncwrite>https://jp.mathworks.com/help/matlab/ref/ncwri...
Page:
Edit with a page name which already exists