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 Center および File ExchangeHDF5 についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by