% ***********  Call Script and Example Usage of generic HDF5 reader  ***********
%  
%  SCRIPT: callFuncs_ReadHDF5.m
%  
%  DESCRIPTION
%   - Illustrates how the HDF5 reader function is called from within a simple Matlab script
%   - This script can be used to read any arbitrary HDF5 file , display its metadata, and
%       optionally list all file meta/data elements.
%
%  USAGE
%   Run the script either from the Matlab command prompt or by executing via the GUI.  The script minimally invokes the 
%   data reader function to read all HDF5 file meta/data to memory, and optionally provide listings according to user selections.
%
%  DEPENDENCIES
%   The script calls the following source files and functions written in Matlab and provided by PO.DAAC:
%       readHDF5.m          readHDF5(fpath,fname,ListFlag)
%   Note: see these source .m for complete function documentation.
%
%  INPUTS   ("User Inputs" code block section)
%       fpath: file path
%       fname: file name of source HDF5 data file
%       ListFlag: True/False setting to optionally output complete metadata & data listings sequentially for each file element
       
%  OUTPUTS
%       numGlobalAttributes: variable with a count of the total number of global file Attributes
%       numDatasets: variable with a count of the total number of file Datasets
%       numGroups: variable with a count of the total number of file Groups
%       globalMetadata: structure containing global file attributes
%       dataset: structure variable (dimensioned by numDatasets) of the form dataset(n).Name|Attributes|Data, where
%           Name: element name
%           Attributes: concatenated element attributes (types & values)
%           Data: element data array
%       group: structure variable (dimensioned by numGroups) of the form 
%           group(m).Name|numAttributes|Attributes|numDatasets
%           group(m).dataset(n).Name|Attributes|Data, where ...
%           numAttributes: number of element attributes
%           numDatasets: number of element datasets
%           Name: element name
%           Attributes: concatenated element attributes (types & values)
%           Data: element data array
%       [Optional] - complete listing of all HDF5 file metadata and data elements to screen
%  
%  NOTES
%      1. This read software was created using Matlab version 7.14
%      2. Please email all comments and questions concerning these routines
%           to podaac@podaac.jpl.nasa.gov.
%
%  CREATED:
%       7/11/2013: Vardis Tsontos, PO.DAAC, NASA-JPL CalTech
%
%  UPDATED:
%       7/11/2013: Vardis Tsontos, PO.DAAC, NASA-JPL CalTech
%
%  VERSION & REVISION:
%       v1.0    (001)
%
%======================================================================
% Copyright (c) 2013, California Institute of Technology
%======================================================================



% ****** User Inputs Section ***********            % User inputs entered here
Path = 'C:\Users\vtsontos\Desktop\';                % Enter the data directory path here (for both L3 and L2); inlude terminal "\" in the path string
FileName = 'SMAP_L2B_SSS_04892_20160101T005507_R13080.h5';        % Enter the data filename to be read (for both L3 and L2) 
ListFlag = false;                                   % Output data listings: specify true or false (for both L3 and L2)
% ---------------------------------------------------------------------------------------------------------------------


% Calls the 'readAquarius()' function and returns all HDF5 file Metadata and Data as variables/structures
[numGlobalAttributes,numDatasets,numGroups,globalMetadata,dataset,group, groupInfo] = readHDF5(Path,FileName,ListFlag);  

% *******************************    END   *******************************
