Using perl to structure a fit

Using perl in your fitting model

It is very helpful to make use of perl's data structures and control structures when precessing large quatities of data. In this example, a list of attribute names and values common to all Data objects is defined starting at line 4 and then pushed onto each Data object at line before plotting at line 13. Because attributes were updated, the plot will trigger all appropriate data processing steps.

  1. #!/usr/bin/perl
  2. use Demeter;
  3. my @params = (bkg_pre1    => -30,  bkg_pre2    => -150,
  4.               bkg_nor1    => 150,  bkg_nor2    => 1757.5,
  5.               bkg_spl1    => 0.5,  bkg_spl2    => 22,
  6.               fft_kmax    => 3,    fft_kmin    => 14,);
  7. my $prj = Demeter::Data::Prj -> new(file=>'iron_data.prj');
  8. my ($data1, $data2) = $prj -> records(1,2);
  9. foreach my $obj ($data1, $data2) {
  10.    $obj -> set(@params);
  11.    $obj -> plot('R');
  12. };