2.1. μ(E) data files

The most basic form of data import is from a column data file with the first and second columns including energy and μ(E). In that case, the data has already been processed from its raw form and saved in this immediately useful form.

Importing a data file of this sort is very simple, as shown in this example:

1
2
3
4
5
6
7
 #!/usr/bin/perl
 use Demeter;

 my $data = Demeter::Data -> new(file => "data/fe.060.xmu",
                                 name => 'Fe 60K',
                                );
 $data -> plot('E');

As always, the program begins by importing the DEMETER package. At line 4, the Data object is created – as all DEMETER objects are created – by the new method. The object is given a name and the file containing the data is specified. The name will be used whenever the data needs to be identified, for instance in the legend of a plot.

For a data file containing μ(E) data, it is usually not necessary to explicitly identify the data as such. DEMETER will analyze the contents of the data file and recognize it as μ(E) data. In the rare case that μ(E) data is not recognized as such, it can be explicitly specified like so:

$data -> datatype('xmu');

Parameters for normalization, background removal, and Fourier transforms are set as attributes of the Data object. In this example, several basic data processing parameters (discussed in detail in the documentation for the Demeter::Data module) are set using the set method.

#!/usr/bin/perl
use Demeter;

my $data = Demeter::Data -> new(file => "data/fe.060.xmu",
                                name => 'Fe 60K',
                               );
$data -> set(bkg_rbkg    => 1.5,
             bkg_spl1    => 0,    bkg_spl2    => 18,
             bkg_nor1    => 100,  bkg_nor2    => 1800,
             fft_kmax    => 3,    fft_kmin    => 17,
            );
$data -> plot('E');

2.1.1. Setting attributes

Since the parameters used for normalization, background removal, Fourier transforms are all implemented as normal Moose attributes, they are accessed and evaluated as normal Moose attributes. There are several ways of doing this, including those inherent to Moose and those defined by the MooseX::SetGet module which comes with DEMETER.

To obtain bkg_rbkg, the Rbkg value for background removal, you can do this:

my $rbkg = $data -> bkg_rbkg;

To set a new value for Rbkg, do this:

$data -> bkg_rbkg(1.2);

Each attribute has an accessor method for getting and setting the value of the attribute that has the same name as the attribute itself.

To get and set several parameters at a time, you can use the get and set methods, which are thin wrappers around the normal accessors:

my @values = $data -> get('bkg_rbkg', 'bkg_nor1', 'bkg_nor2');
$data -> set(bkg_rbkg => 1.2, bkg_nor1 => 50, bkg_nor2 => 600);

Finally, parameters can be set at the time of object creation:

#!/usr/bin/perl
use Demeter;

my $data = Demeter::Data -> new(file => "data/fe.060.xmu",
                                name => 'Fe 60K',
                                bkg_rbkg => 1.5,
                                bkg_spl1 => 0,    bkg_spl2 => 18,
                                bkg_nor1 => 100,  bkg_nor2 => 1800,
                                fft_kmax => 3,    fft_kmin => 17,
                               );

All the arguments of new are passed to the set method.




DEMETER is copyright © 2009-2016 Bruce Ravel – This document is copyright © 2016 Bruce Ravel

This document is licensed under The Creative Commons Attribution-ShareAlike License.

If DEMETER and this document are useful to you, please consider supporting The Creative Commons.