Write ASCII file for each lat-long from netcdf

1 次查看(过去 30 天)
I have a netcdf file like this:
lat = 30x1
long = 15x1
sst = 30x15x1407
time = 1407x1
I need to write ASCII files for each lat-long (450 files) with [time sst] columns, where each file will be named as "sst_'lat'_lon'.txt". How can I create a loop to do that?
  2 个评论
Danilo M
Danilo M 2016-12-22
Working a little I reach to this:
varInfo = ncinfo('noaa-sst-1990-present.nc','sst');
disp(varInfo);
for latInd =1:varInfo.Size(1)
for lonInd =1:varInfo.Size(2)
fileName = ['sst_',num2str(latInd),'_',num2str(lonInd),'.txt'];
tSeries = [ncread('noaa-sst-1990-present.nc','sst',[latInd, lonInd, 1],[1,1,varInfo.Size(3)])];
dlmwrite(fileName,squeeze(tSeries),'delimiter','\t','precision',5);
end
end
But I could only write the sst columns, but I want to save [time sst]. I tried to manipulate tSeries to include time column, but didn't get it.
How can I get that?
KSSV
KSSV 2016-12-22
It can be done...But my question is why you want to do it? You have all the data happily in netcdf, ascii will occupy much space and lot of files. Why?

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by