필터 지우기
필터 지우기

Saving multiple ASCII files from NetCDF

조회 수: 1 (최근 30일)
Danilo M
Danilo M 2017년 1월 11일
I have an 145x157x1470 NetCDF file with this dimensions, and I need to save one ASCII file for each lat-lon. I could get to this code:
%Loading .nc
File = 'siprec_2009-2012.nc.nc';
ncdisp(File);
siprec = ncread(File,'SIPREC');
time = ncread(File,'time');
lat = ncread(File,'latitude');
lon = ncread(File,'longitude');
%
%loop for create ascii files
varInfo = ncinfo(File,'SIPREC');
disp(varInfo);
for latInd =1:varInfo.Size(1)
for lonInd =1:varInfo.Size(2)
fileName = ['siprec_',num2str(lat),'_',num2str(lonInd),'.srm'];
tSeries = [ncread('siprec_2009-2012.nc','SIPREC',[latInd, lonInd, 1],[1,1,varInfo.Size(3)])];
SerieFinal= [time squeeze(tSeries)];
dlmwrite(fileName,SerieFinal,'delimiter','\t','precision',5);
end
end
But, since this return more than 22k files, I need the value of lat and lon in each file name, but this code only save with the index of lat and long.
i.e. instead of 'siprec_25.35_49.27.srm', the file is saved as 'siprec_1_92.srm'.
What can I change to save the files with lat and lon values?

답변 (0개)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by