Importing multichannel data files

Often data files contain multiple columns of data that can be independently processed as μ(E) data. One way of handling that situation is to simply point several Data objects at the same file, specifying different columns for each object. That is fine and it certainly works, but it makes inefficient use of IFEFFIT.

Each time that a Data object imports its data file, it makes temporary arrays in IFEFFIT to hold the contents of each column. The creation and destruction of a possibly large number of unused arrays is noticeably time consuming. To get around the problem of repeatedly creating the same set of temporary arrays, use the Data::MultiChannel object.


 

Importing multi-element detector data

Like the Data::Prj object, The Data::MultiChannel object is a transitional object from which Data objects are created.

In this example, a four-element detector was used to measure fluorescence data and each data channel is imported into an individual Data object. Once all the channels are imported, they are plotted in energy for direct comparison.

  1. #!/usr/bin/perl
  2. use Demeter;
  3. my $file = 'med_data.000'
  4. my $mc = Demeter::Data::MultiChannel->new(file   => $file, energy => '$1', );
  5. $data[0] = $mc->make_data(numerator   => '$4', denominator => '$2',
  6.                           ln          =>  0,   name        => 'MED Channel 1', );
  7. $data[1] = $mc->make_data(numerator   => '$5', denominator => '$2',
  8.                           ln          =>  0,   name        => 'MED Channel 2', );
  9. $data[2] = $mc->make_data(numerator   => '$6', denominator => '$2',
  10.                           ln          =>  0,   name        => 'MED Channel 3', );
  11. $data[3] = $mc->make_data(numerator   => '$7', denominator => '$2',
  12.                           ln          =>  0,   name        => 'MED Channel 4', );
  13. $_ -> plot('E') foreach @data;

The Data::MultiChannel object is defined at line 5. This object is inherited from the normal Data object, which allows it to use the Data object's existing methods for file import. Although the Data::MultiChannel object has all the same attributes as the Data object, the only two that matter are file and energy. The column containing the energy must be specified so that the data can be sorted (DEMETER deals gracefully with data that are not in monotonically ascending order, which sometimes happens in some impementations of quick XAS). This value for the energy attribute is pushed onto the Data object created using the make_data method.

The make_data method is used to generate a Data object from the Data::MultiChannel object. You must specify the numerator, denominator, and ln attributes as arguments of the make_data method. You can specify any other Data attributes in the same manner as the Data creator method, new.

Once created by make_data, these Data objects are identical in every way to Data objects created in other ways.

Of course, another option is to use a normal Data object to import MED data and do the summation on the fly, like so


      $data = Demeter::Data->new(numerator   => '$4+$5+$6+$7', denominator => '$2',
                                 ln          => 0,             name        => 'MED data' );

The performance penalty discussed above wouold not be a problem for the on-the-fly summation. However, importing each individual channel into its own Data object is certainly better done with the Data::MultiChannel transitional object.


 

Importing data and reference

Another common use of the Data::MultiChannel object is to import the reference channel from a normal XAS data file. Here is an example:

  1. #!/usr/bin/perl
  2. use Demeter;
  3. my $file = 'fe2o3.000'
  4. my $mc = Demeter::Data::MultiChannel->new(file   => $file, energy => '$1', );
  5. $data = $mc->make_data(numerator   => '$2', denominator => '$3',
  6.                        ln          => 1,    name        => 'Fe2O3' );
  7. $ref  = $mc->make_data(numerator   => '$3', denominator => '$4',
  8.                        ln          => 1,    name        => '  Ref Fe2O3 (Fe foil)' );
  9. $data -> reference($ref);

In this example, the data are from a transmission experiment with a reference foil between the It and Ir detectors. In this case, μ(E) for the reference is ln(It/Ir), which are in columns 3 and 4. Line 11 then sets up the data/reference relationship so that energy shifts applied to the reference will also be applied to the data.


 

Multicolumn transmission data

Using the four-channel ionization chamber described in B. Ravel, et al., J. Synchrotron Rad., 17, (2010) p. 380 yields files which contain four independent transmission measurements on a common energy axis. For each measurement, there is a I₀ and an It column. The following script disentangles these columns by constructing the four measurements, plotting the four XANES spectra, and writing out an ATHENA project file.

  1. #!/usr/bin/perl
  2. use Demeter; # qw(:plotwith=gnuplot);
  3. use File::Basename;
  4. my $datafile = shift(@ARGV);    # take file name from command line
  5. my $mc = Demeter::Data::MultiChannel->new(file   => $file, energy => '$1', );
  6. $mc -> po -> set(title => $datafile, e_norm=>1, e_markers=>0, emin=>-40, emax=>60);
  7. $mc -> po -> start_plot;
  8. my @data;
  9. print "channel 1, ";
  10. $data[0] = $mc->make_data(numerator   => '$2', denominator => '$6',
  11.                           ln          =>  1,   name        => 'channel 1', ) -> plot('e');
  12. print "channel 2, ";
  13. $data[1] = $mc->make_data(numerator   => '$3', denominator => '$7',
  14.                           ln          =>  1,   name        => 'channel 2', ) -> plot('e');
  15. print "channel 3, ";
  16. $data[2] = $mc->make_data(numerator   => '$4', denominator => '$8',
  17.                           ln          =>  1,   name        => 'channel 3', ) -> plot('e');
  18. print "channel 4, ";
  19. $data[3] = $mc->make_data(numerator   => '$5', denominator => '$9',
  20.                           ln          =>  1,   name        => 'channel 4', ) -> plot('e');
  21. print "reference, ";
  22. $data[4] = $mc->make_data(numerator   => '$9', denominator => '$10',
  23.                           ln          =>  1,   name        => "$file Ref", );
  24. my $prjname = basename($datafile) . '.prj';
  25. print "exporting $prjfile ... ";
  26. $data[0]->write_athena($prjfile, @data);
  27. print $/;
  28. $data[0]->po->end_plot;
  29. $mc->discard;

Note that, at this time, the data/reference relationship can only be made between two Data objects. In a future version of DEMETER, the reference relationship will be extended to an arbitrary number of Data objects, which will be useful in this case, as well as for MED data.