Saving multiple ASCII files from NetCDF
2 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!