function [str]= CARPETListDataSetsHDF5(direc,var,unc) % % [str]= CARPETListDataSetsHDF5(direc,var,unc) % % EXAMPLE PARAMETERS % direc= 'data/hdf5' (if you have your hdf5 file sin data/hdf5) % var= 'rho' -> look for the file rho.h5 in data/hdf5 % for unchunked files % -> look for the file rho.file_0.h5 rho.file_1.h5 etc % in data/hdf5 for chuncked files % unc= 0 -> chunked; 1-> unchunked % % CREATE a list of all the datasets in a given HDF5 file % % str.names = ALL THE DATASETS' NAMES % str.rl = (vector) number of the last (finest) refinement level for each iteration % str.rlmin = (vector) number of the first (coarsest) refinement level for each iteration % str.c = (matrix) number of components for each iteration and ref-level % str.it = (vector) iterations EX: [0 20 40 60] % str.index = (vector) index corresponding to an iteration EX: [1 2 3 4] % str.num2name= (matrix) gives the index of the name in str.names % corresponding to an iteration, ref. level, and component % str.ranges = [first iterations, last iterations, step]; % % % str.filename = Filename; % str.info = info from hdf5info; % % HOW TO USE % for a=str.index % for b=str.rlmin(a):str.rl(a) % for c=1:str.c(a,b) % disp(str.names{str.num2name(a,b,c)}) % end % end % end % % Author: Gian Mario Manca, manca@fis.unipr.it % http://www.fis.unipr.it/~manca % % These scripts are distributed under the GNU General Public License (GPL) % 11 October 2006 cactusT = 0.00492549000000; % conversion factor form C.U. to msec if unc==0 filter=[direc '/' var '.file_*.h5']; else filter=[direc '/' var '.h5']; end lf=dir(filter); nfile=length(lf); if nfile==0 disp('ERROR!') disp(['I was looking for files like ' filter]) disp('and I didn''t find any file!!') disp('CHECK THE DIRECTORY OR THE CHUNKED-UNCHUNKED PARAMETER') str=[]; return end for i=1:nfile disp(['Found ' direc '/' lf(i).name]) info_tmp(i)=hdf5info([direc '/' lf(i).name]); % extract information from the hdf5 file ndatsets_tmp(i)=length(info_tmp(i).GroupHierarchy.Datasets); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FIRST INFORMATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% k=1; for j=1:nfile for i=1:ndatsets_tmp(j) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HERE IS EXTRACTED THE INFORMATION ABOUT ITERATION, REF. LEVEL, COMPONENT FROM THE STRING NAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% struct{k} = sscanf(info_tmp(j).GroupHierarchy.Datasets(i).Name,'%*s it=%d %*s rl=%d c=%d'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% iteration_all(k)=struct{k}(1); % iteration of every dataset times_all(k) =info_tmp(j).GroupHierarchy.Datasets(i).Attributes(5).Value; % time of every dataset names{k} =info_tmp(j).GroupHierarchy.Datasets(i).Name; % datasets' names str.info{k} =info_tmp(j).GroupHierarchy.Datasets(i).Attributes; % standard hdf5 attributes str.num2file(k)=j; k=k+1; end str.filename{j}=[direc '/' info_tmp(j).Filename]; end [iter,idxs]=unique(iteration_all); % eliminate repetitions in the iteration vector if length(iter)>1 range= [min(iter) max(iter) iter(2)-iter(1)]; % first iteration, last iteration, jump size else % (supposing the jump is always the same) range= [min(iter) max(iter) 1]; end delta=1; ndatsets=sum(ndatsets_tmp); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % REF. LEVEL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% str.rl=zeros(length(iter),1); % initialization str.rlmin=100000+zeros(length(iter),1); % initialization for i=1:ndatsets idx=(iteration_all(i)-range(1))/range(3)+delta; % index of the dataset str.rl(idx)=max([str.rl(idx) struct{i}(2)+1]); % number of ref.levels of the iteration str.rlmin(idx)=min([str.rlmin(idx) struct{i}(2)+1]); % number of ref.levels of the iteration end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % COMPONENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% str.c=ones(length(iter),max(str.rl)); % initialization for i=1:ndatsets x=(iteration_all(i)-range(1))/range(3)+delta;; y=struct{i}(2)+1; %[x y] if length(struct{i})>2 str.c(x,y)=max([str.c(x,y) struct{i}(3)+1]); end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % NUMBER TO NAME MATRIX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% str.num2name=zeros(length(iter),max(str.rl),max(max(str.c))); % initialization for i=1:ndatsets %struct{i} = sscanf(info.GroupHierarchy.Datasets(i).Name,'%*s it=%d %*s rl=%d c=%d'); ind=(iteration_all(i)-range(1))/range(3)+delta; rl=struct{i}(2)+1; c=1; if length(struct{i})>2 c=struct{i}(3)+1; end str.num2name(ind,rl,c)=i; end % saving some other information str.it =iter; % iteration of the dataset str.index =(1:length(iter)); str.time =times_all(idxs); % time in C.U. of the iteration str.timeMSEC =cactusT*str.time; % times converted in msec str.ranges =range; str.names =names; %str.filename =info.Filename; end