Ifeffit::Demeter::Fit - OO interface to performing EXAFS fits using Ifeffit.
This documentation refers to Ifeffit::Demeter version 0.0.1
my $fitobject = Ifeffit::Demeter::Fit ->
new({gds => \@gds_objects,
data => [$data_object],
paths => \@path_objects,
});
$fitobject -> fit;
$fitobject -> evaluate;
$fitobject -> logfile("cufit.log");
This class collects and organizes all the components of a fit using Ifeffit. As you can see from the example, the bulk of a script involves setting up all the data, paths, and parameters that go into the fit. Once that is done, you pass that information to the Fit object as array references. It collates all of the information, resolves the connections between Path and Data objects, performs a number of sanity checks on the input information, and generates the sequence of Ifeffit commands needed to perform the fit. After the hard work of setting up the Data, Path, and GDS objects is done, you are just a few more lines away from a complete fitting script!
Three attributes define a fit. These are gds, data, and
paths. Each takes an reference to an array of other objects. The
gds attribute takes a reference to an array of GDS objects, and so
on. All other attributes are properties of a fit and are scalar valued.
The set method will throw an exception if the argument to gds,
data, and paths is not a reference to an array. Similarly, the
get method returns array references for those three attributes.
Here is a list of the scalar valued attributes.
Short descriptive text for this fit.
Longer descriptive text for this fit.
A figure of merit for this fit. This is intended for reports on multiple fits. An example might be the temperature of the data fit where the report is then intended to show the temperature dependence of the fit.
This is filled in with information about the versions of Demeter and perl and the operating system used.
This is filled in with text identifying the user interface.
This is filled in with the time stamp when the fit finishes.
This is filled in with an attempt to identify the person performing the fit.
This may be filled in with information about how to contact the person performing the fit.
Minimum correlation reported in the log file. This must be a number between 0 and 1.
fit
This method returns the sequence of commands to perform a fit in
Ifeffit. This sequence will include lines defining each guess, def,
set, and restrain parameter. The data will be imported by the
read_data() command. Each path associated with the data set will
be defined. Then the text of the feffit() command is generated.
Finally, commands for defining the after parameters and for computing
the residual arrays are made.
$fitobject -> fit;
A number of sanity checks are made on the fitting model before the fit is performed. For the complete list of these sanity checks, see the Ifeffit::Demeter::Fit::Sanity manpage.
ff2chi
This method is exactly like the fit method, except that the command returned perform a sum over paths rather than a fit. All the same sanity checks are run.
This takes one argument -- the Data object from the data attribute
whose paths are to be summed.
$fitobject -> fit($data);
It is useful to remember that a fit can be one a single data set or on multiple data sets. An ff2chi is always on a single data set.
gds
This method returns a reference to the list of GDS objects in this fit.
data
This method returns a reference to the list of Data objects in this fit.
paths
This method returns a reference to the list of Path objects in this fit.
set_all
This method is used to set attributes of every Data, Path, or GDS in a
fit. For instance, this example sets rmin for each data set to 1.2:
$fitobject -> set_all("data", {rmin=>1.2});
and this example sets the sigma2 math expression for each Path in the
fit:
$fitobject -> set_all("path", {sigma2=>"debye(temp, thetad)"});
The first argument is one of ``data'', ``paths'', ``gds'' and the second is a reference to a hash of valid attributes for the object type.
This returns 0 if the arguments cannot be correctly interpretted, 1 otherwise.
evaluate
This method is called after the fit or ff2chi method. This will
evaluate all path parameters, all GDS parameters, and all correlations between
guess parameters and store them in the appropriate objects. This is typically
called by the fit method once the fit is finished, thus it is rarely
necessary for you to need to make an explicit call.
$fitobject -> fit; $fitobject -> evaluate;
logfile
This write a log file from the results of a fit and an ff2chi.
$fitobject($filename, $header, $footer);
The first argument is the name of the output file. The other two arguments are arbitrary text that will be added to the top and bottom of the log file.
statistic
This returns the value of one of the fitting statistics, assuming the
evaluate method has been called.
$fitobject -> statistic("chi_reduced");
An exception is thrown is the argument is not one of the following:
n_idp n_varys chi_square chi_reduced r_factor epsilon_k epsilon_r data_total
statistics_report
This method returns a block of text summarizing all the fitting
statistics, assuming the evaluate method has been called. This
method is used by the logfile method.
$text = $fitobject -> statistics_report;
correl
This returns the correlation between any two parameters, assuming the
evaluate method has been called.
my $cor = $fitobject->correl("delr", "enot");
all_correl
This returns a complete hash of correlations between parameters,
assuming the evaluate method has been called.
my %correls = $fitobject -> all_correl;
correl_report
This method returns a block of text summarizing all the correlations
above the value given as the first argument, assuming the evaluate
method has been called. This method is used by the logfile method.
my $text = $fitobject -> correl_report(0.4);
A fit can be serialized to a zip file containing YAML serializations of the various parts of the fit.
$fitobject->serialize("filename");
One of these zip files can be deserialized to a Fit object:
$fitobject = Ifeffit::Demeter::Fit->deserialize("datafile");
freeze and thaw are other names for the serialize and
deserialize methods.
These messages are classified as follows (listed in increasing order of desperation):
(W) A warning (optional).
(F) A fatal error (trappable).
(F) You have attempted to set one of the Fit attributes to something that is not a reference to an array.
(W) You have attempted to get an attribute value that is not one of
gds, data, paths.
(F) You have neglected to define one of the attributes of the Fit object.
(F) One or more of the sanity checks has failed. Other diagnostic messages with more details will be issued.
(W) You have asked for a fitting statitstic that is not one of the ones available (n_idp n_varys chi_square chi_reduced r_factor epsilon_k epsilon_r data_total).
See the Ifeffit::Demeter manpage for a description of the configuration system.
See the Ifeffit::Demeter manpage for a list of dependencies.
This uses Ifeffit::Demeter::Fit::Sanity as part of its base.
The sum method is probably broken at this time.
Please report problems to Bruce Ravel (bravel AT anl DOT gov)
Patches are welcome.
Bruce Ravel (bravel AT anl DOT gov)
http://cars9.uchicago.edu/~ravel/software/
Copyright (c) 2006-2007 Bruce Ravel (bravel AT anl DOT gov). All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.