Home > database > ensemble_compare_params.m

ensemble_compare_params

PURPOSE ^

Compares a saved params struct with a given params struct in memory.

SYNOPSIS ^

function found = ensemble_compare_params(filename,params)

DESCRIPTION ^

 Compares a saved params struct with a given params struct in memory.

 Compares a set of params with a params struct saved in the 'data'
 field of a data structure stored in a file. It is assumed that
 the name of the data structure is the same as the params
 subfield.

 For example, if a set of ani parameters are passed in as
 params.ani (where params.ani.downSampleFactor and
 params.ani.FirstCBU specify two parameters of the ani), this
 function will attempt to load an 'ani' struct from the file
 specified by the input 'filename' and the 'params' data will be
 compared with the input params.

 If params contains any other fields, such as params.ci,
 params.pp, the file will also be searched for ci and pp data
 structures, so it is best to only pass the param fields that you
 wish to be compared with this file.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function found = ensemble_compare_params(filename,params)
0002 % Compares a saved params struct with a given params struct in memory.
0003 %
0004 % Compares a set of params with a params struct saved in the 'data'
0005 % field of a data structure stored in a file. It is assumed that
0006 % the name of the data structure is the same as the params
0007 % subfield.
0008 %
0009 % For example, if a set of ani parameters are passed in as
0010 % params.ani (where params.ani.downSampleFactor and
0011 % params.ani.FirstCBU specify two parameters of the ani), this
0012 % function will attempt to load an 'ani' struct from the file
0013 % specified by the input 'filename' and the 'params' data will be
0014 % compared with the input params.
0015 %
0016 % If params contains any other fields, such as params.ci,
0017 % params.pp, the file will also be searched for ci and pp data
0018 % structures, so it is best to only pass the param fields that you
0019 % wish to be compared with this file.
0020 
0021 if(~exist(filename,'file'))
0022   error(sprintf('Filename %s does not exist.',filename));
0023 end
0024 
0025 dataStructNames = fieldnames(params);
0026 
0027 for iDataStruct = 1:length(dataStructNames)
0028 
0029   thisDataStructName = dataStructNames{iDataStruct};
0030   
0031   fileData = load(filename,thisDataStructName);
0032   
0033   thisDataStruct = fileData.(thisDataStructName);
0034   thisDataStructCols = set_var_col_const(thisDataStruct.vars);
0035   
0036   if(~ismember('params',thisDataStructCols))
0037     disp([sprintf('Filename %s, data struct %s does not contain a',filename,thisDataStructName) ...
0038           ' params struct']);
0039     found = 0;
0040     return
0041   end
0042   
0043   loadedParams = thisDataStruct.data{thisDataStructCols.params};
0044   paramFields = fieldnames(params.(thisDataStructName));
0045   
0046   
0047   
0048 end

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003