Merging data

Merging data is one of the essential data processing steps. As with every thing, DEMETER tries to make merging as easy as possible:


      my $merged = $data[0]->merge('e', @data);

The first argument to the merge method specifies which spectrum is merged: e means to merge μ(E), n means to merge normalized μ(E), and k means to merge χ(k).

Care is taken not to double count the caller. This is a convenience because, as shown above, you can pass an entire array which also contains the caller.

The merge method returns a new Data object.

Both of the plot types below (stddev and varience) plot ignore many setting of the Plot object in order to plot the data in the form in which it was merged. Attempting to plot the standard deviation or variance plots with a Data object that does not contain merged data will return as error.

plot merged data with standard deviation
  1. #!/usr/bin/perl
  2. use Demeter;
  3. my @common = (energy => '$1', numerator => '$2', denominator => '$3', ln => 1,);
  4. my $prj = Demeter::Data::Prj -> new(file=>'U_DNA.prj');
  5. my @data = (
  6.             Demeter::Data -> new(file => 'examples/data/fe.060',
  7.                                  name => "Fe scan 1",
  8.                                  @common,
  9.                                 ),
  10.             Demeter::Data -> new(file => 'examples/data/fe.061',
  11.                                  name => "Fe scan 2",
  12.                                  @common,
  13.                                 ),
  14.             Demeter::Data -> new(file => 'examples/data/fe.062',
  15.                                  name => "Fe scan 3",
  16.                                  @common,
  17.                                 ),
  18.            );
  19. my $merged = $data[0] -> merge('e', @data);
  20. $merged -> plot('stddev');

This shows the merge of μ(E) of 3 iron foil scans along with the standard deviation array. The standard deviation has been added to and subtracted from the μ(E) spectrum, so the red trace is an error margin for the μ(E) spectrum. Note that this plot type can only be plotted using a Data object which contains the data from a merge. Trying to plot a non-merged Data object in this way will return a warning without plotting anything.

To do! I really need to show noisier data in this example.

plot_stddev.png


plot merged data with standard deviation
Change line 20 in the script shown above to this:

      $merged -> plot('variance');

This shows the merge of μ(E) of 3 iron foil scans along with the standard deviation array. The standard deviation has been scaled to plot with the μ(E) spectrum, with the scaling factor is given in the legend. This, then, is a way of visualizing how the standard deviation is distributed across the spectrum. Note that this plot type can only be plotted using a Data object which contains the data from a merge. Trying to plot a non-merged Data object in this way will return a warning without plotting anything.

plot_variance.png