필터 지우기
필터 지우기

Extracting and saving data from different .cdf files

조회 수: 5 (최근 30일)
Thishan Dharshana Karandana Gamalathge
댓글: Walter Roberson 2017년 8월 18일
I have a set of .cdf files inside which I have several variables which are common to each .cdf file. Each variable in different .cdf file has different amount of data. Rather than opening each .cdf file separately and extracting data for the variable of interest, I am looking a way to do it faster (probably using a loop) and save the results in a .mat file. Could you help me with that? Here is an example of how those .cdf file names look like and size of the variable I am interest at. Note that the file name contains the year, month, date (eg year 2010, month 10, day 15 for th 1st file). We can extract the data in first file as follows.
x1 = ncread('test.a1.20101015.000000.cdf', 'x');
test.a1.20101015.000000 size(x)= 86200x1
test.a1.20101016.000000 size(x)= 84000x1
test.a1.20101101.000000 size(x)= 85500x1
test.a1.20101102.000000 size(x)= 84890x1
Thanks a lot.
  댓글 수: 2
per isakson
per isakson 2017년 8월 17일
편집: per isakson 2017년 8월 17일
  • Why use ncread rather than cdfread, Read data from Common Data Format (CDF) file ?
  • Are the cdf-files in the same directory?
  • How (type of variable(s)) do you want to store the result?
  • "Note that the file name contains the year, month, date" How do you want to store the dates?
Walter Roberson
Walter Roberson 2017년 8월 18일
cdfread() is limited to the older original CDF format. ncread() can be used for those files and also for NETCDF files. cdfread() only supports 7-bit ASCII for attributes and comments.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 8월 18일
netcdf files are structured binary files that you cannot simply fseek() into and pull out data. You will not be able to avoid using ncread or cdfread once for each file.
However, if you use a particular portion of the data multiple times, it might be worth reading the data from the files and storing them either as .mat or as binary files for performance reasons.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by