Filter löschen
Filter löschen

Write ASCII file for each lat-long from netcdf

1 Ansicht (letzte 30 Tage)
Danilo M
Danilo M am 22 Dez. 2016
Kommentiert: KSSV am 22 Dez. 2016
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 Kommentare
Danilo M
Danilo M am 22 Dez. 2016
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 am 22 Dez. 2016
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?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by