Write ASCII file for each lat-long from netcdf

1 回表示 (過去 30 日間)
Danilo M
Danilo M 2016 年 12 月 22 日
コメント済み: KSSV 2016 年 12 月 22 日
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 件)

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by