Azzera filtri
Azzera filtri

open-read-write multiple files

3 visualizzazioni (ultimi 30 giorni)
David du Preez
David du Preez il 29 Mar 2017
Modificato: Jan il 29 Mar 2017
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.

Risposta accettata

Jan
Jan il 29 Mar 2017
Modificato: Jan il 29 Mar 2017
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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by