필터 지우기
필터 지우기

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 CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by