Skip to content

Commit

Permalink
Merge pull request #192 from salomon73/additional-routines
Browse files Browse the repository at this point in the history
Added the file read_boozer.m
  • Loading branch information
smiet authored Oct 16, 2023
2 parents 73459e1 + 77b93c0 commit 2e4ee07
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Utilities/matlabtools/read_boozer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%% read_boozer( FILENAME, ROOT)
% =============================
%
% Reads hdf5 output from Boozer_xForms
% and produces data struct
%
% INPUT
% -----
% -filename : name of Boz output
% -root : root directory
%
% ------------------------------------%
% Written by S.Guinchard (05/22) %
% from read_spec routine %
% ------------------------------------%

function g_data = read_boozer(filename, root )
g_data_info = h5info(filename, root);
ngroups = length(g_data_info.Groups);
nvars = length(g_data_info.Datasets);
% Get datasets in root node
for i = 1: nvars
g_data.([g_data_info.Datasets(i).Name]) = h5read(filename,[root '/' g_data_info.Datasets(i).Name]);
natts = length(g_data_info.Datasets(i).Attributes);
for j=1:natts
g_data.([g_data_info.Datasets(i).Attributes(j).Name]) = g_data_info.Datasets(i).Attributes(j).Value{1};
end
end
% get groups in root node
if ngroups > 0
for i = 1 : ngroups
g_path = strsplit(g_data_info.Groups(i).Name, '/');
g_data.([g_path{end}]) = read_boozer(filename, g_data_info.Groups(i).Name);
end
end
end

0 comments on commit 2e4ee07

Please sign in to comment.