% FROMVALUES construct a pest object from different values.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromValues
%
% DESCRIPTION: Construct a pest object from different values.
%
% CALL:        pe = fromValues(pe, pli)
%
% PARAMETER:   pe  - empty pest object
%              pli - input plist
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function obj = fromValues(obj, pli)
  
  VERSION = '$Id: fromValues.m,v 1.6 2011/08/16 05:16:32 hewitson Exp $';
  
  % get pzmodel info
  ii = pest.getInfo('pest', 'From Values');
  
  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);
  
  % Combine input plist with default values
  pl = applyDefaults(ii.plists, pli);
  
  % get values
  obj.y      = pl.find('y');
  obj.names  = pl.mfind('paramNames', 'names', 'params');
  obj.dy     = pl.find('dy');
  obj.cov    = pl.find('cov');
  obj.corr   = pl.find('corr');
  obj.chi2   = pl.find('chi2');
  obj.dof    = pl.find('dof');
  obj.models = pl.find('models');
  obj.pdf    = pl.find('pdf');
  
  % Add history
  obj.addHistory(ii, pl, [], []);
  
  % Set object properties
  obj.setObjectProperties(pl);
  
end
