function zH5Data = getParamH5(stFileH5,varargin)
% getParamH5
% function h5Data = getParamH5(fileH5)
%   This function re4ads the properties of body1 in a h5 files and returns
%   it in a structure with the following fields:
%       addedMassC
%       radDampC
%       hydroStiffC
%       FKReal
%       FKImag
%       FKMag
%       FKPhase
%       DifracReal
%       DifracImag
%       DifracMag
%       DifracPhase
%
%   Project: IMPACT
%   Title of Code: getParamH5
%   Relevant additional documentation: NA
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with Wood
%   and acquiring permission. Wood is not liable for any
%   damage caused as a result of unauthorised changes to this
%   document.

if isempty(varargin)
    iCntBodies = 1;
    zH5Data.addedMassC = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/added_mass/all']);
    zH5Data.radDampC = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/radiation_damping/all']);
    zH5Data.hydroStiffC = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/linear_restoring_stiffness']);
    
    zH5Data.FKReal = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/re']);
    zH5Data.FKImag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/im']);
    zH5Data.FKMag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/mag']);
    zH5Data.FKPhase = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/phase']);
    
    zH5Data.DifracReal = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/re']);
    zH5Data.DifracImag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/im']);
    zH5Data.DifracMag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/mag']);
    zH5Data.DifracPhase = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/phase']);
    BEMPeriod = h5read(stFileH5,'/simulation_parameters/T');
    zH5Data.BEMFreq = 2*pi./BEMPeriod;
else
    iNumBodies = varargin{1};
    for iCntBodies =1:iNumBodies
        zH5Data(iCntBodies).addedMassC = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/added_mass/all']);
        zH5Data(iCntBodies).radDampC = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/radiation_damping/all']);
        zH5Data(iCntBodies).hydroStiffC = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/linear_restoring_stiffness']);
        
        zH5Data(iCntBodies).FKReal = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/re']);
        zH5Data(iCntBodies).FKImag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/im']);
        zH5Data(iCntBodies).FKMag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/mag']);
        zH5Data(iCntBodies).FKPhase = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/froude-krylov/phase']);
        
        zH5Data(iCntBodies).DifracReal = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/re']);
        zH5Data(iCntBodies).DifracImag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/im']);
        zH5Data(iCntBodies).DifracMag = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/mag']);
        zH5Data(iCntBodies).DifracPhase = h5read(stFileH5,['/body',num2str(iCntBodies),'/hydro_coeffs/excitation/scattering/phase']);
        BEMPeriod = h5read(stFileH5,'/simulation_parameters/T');
        zH5Data(iCntBodies).BEMFreq = 2*pi./BEMPeriod;
    end
end


