open-read-write multiple files

조회 수: 1 (최근 30일)
David du Preez
David du Preez 2017년 3월 29일
편집: Jan 2017년 3월 29일
Hi I have the following code used to open, read and write data from a .he5 file:
% Open the HDF5 File.
FILE_NAME = 'MLS-Aura_L2GP-O3_v04-23-c02_2016d364.SUB.he5';
file_id = H5F.open (FILE_NAME, 'H5F_ACC_RDONLY', 'H5P_DEFAULT');
% Open the dataset.
DATAFIELD_NAME = 'HDFEOS/SWATHS/O3 column/Data Fields/L2gpValue';
data_id = H5D.open (file_id, DATAFIELD_NAME);
TIME_NAME='HDFEOS/SWATHS/O3 column/Geolocation Fields/Time';
time_id=H5D.open(file_id, TIME_NAME);
% Read the dataset and dimension fields.
data1=H5D.read (data_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', ...
'H5P_DEFAULT');
time=H5D.read(time_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL',...
'H5P_DEFAULT');
%Time is second from TAI93.
time1lvl=datestr(datevec(datenum(1993,1,1,0,0,0)+time(2)/86400));
How can I change this script so that I can open multiple files. Only the last part of the file name changes depending on the day of the year (MLS-Aura_L2GP-O3_v04-23-c01_2016d 366.SUB.he5) Therefore the 3 digits after d will range from 001 to 366. The output values can all be written to the same file.

채택된 답변

Jan
Jan 2017년 3월 29일
편집: Jan 2017년 3월 29일
This is a frequently asked question and searching in this forum would reveal e.g.:
for k = 1:366
FILE_NAME = sprintf('MLS-Aura_L2GP-O3_v04-23-c02_2016d%03d.SUB.he5', k);
...
end
Don't forget to close the files.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 HDF5에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by