Demeter

Description Perl tools for X-ray Absorption Spectroscopy
Demeter > Perl Modules > Demeter::Plot::SingleFile
Source

NAME

Demeter::Plot::SingleFile - Sending a plot to a single file

VERSION

This documentation refers to Demeter version 0.9.26.

SYNOPSIS

This is used to send a plot to a single file for easy import into an external plotting program.

  #!/usr/bin/perl
  use Demeter qw(:ui=screen);

  my $file = 'examples/data/fe.060';
  my $data = Demeter::Data->new(file=>$file,);
  $data -> set(fft_kmax    => 3,    fft_kmin  => 14,
               bkg_spl2    => 18,
               bkg_nor2    => 1800,
               energy      => '$1',
               numerator   => '$2',
               denominator => '$3',
               ln          => 1,
              );

  ## set up the plot to output file
  $data->plot_with('singlefile');  # 1

  ## prep for the singlefile plot
  $data->po->prep(file=>"foo.dat", standard=>$data, space=>'k');

  ## prep is the same as doing the following
  #$data->standard;                 # 2
  #$data->po->space('k');           # 3
  #$data->po->file("foo.dat");      # 4
  #$data->po->start_plot;

  ## make a sequence of plots
  $data->po->set(kweight => 1, kmax => 17, space => 'k');
  $data->set(plot_multiplier => 5,   'y_offset'=>14, name=>'kw=1, scaled by 5');
  $data->plot;

  $data->po->kweight(2);
  $data->set(plot_multiplier => 1,   'y_offset'=>7,  name=>'kw=2, unscaled');
  $data->plot;

  $data->po->kweight(3);
  $data->set(plot_multiplier => 0.2, 'y_offset'=>0,  name=>'kw=3, scaled by 0.2');
  $data->plot;

  ## the finish method of the Demeter::Plot::SingleFile actually writes out the file
  $data->po->finish;               # 5

DESCRIPTION

This plotting backend does not work quite as transparently as the other plotting backends. In order to get the figure you actually want written correctly to an output file, a bit more care is required than for this than for other plotting backends. The following steps (marked by their numbers in the example above) must be taken when using this plotting backend:

  1. You must use the plot_with method to change to this plotting backend. You may not use the :plotwith= pragma at the top of your script to generate a column data file -- you must explicitly switch to this backend in the run-time part of your script. If you try to use the pragma, your script will fail with a confusing and misleading error message.

    Note that the start_plot method gets called automatically when you change plotting backends.

  2. You must set a data standard. This is required to correctly set the column containing the x-axis and is particularly important in energy plots where some data might need to be interpolated onto the correct grid.

  3. It is a good idea to explicitly declare the plotting space before calling start_plot. This is particularly true for kq plots, for which you should set the space to q.

  4. You must set the file attribute to the name of the target output file which will contain the data required to replicate the plot in another program. You should set this before starting to actually generate the plot.

  5. 2-4.

    Alternately, you can use the prep method of the SingleFile object to do steps 2 through 4 in one swoop.

  6. Calling the finish method of the SingleFile backend is what actually writes the output file to disk.

In a GUI, of course, all these steps will be handled behind the scenes.

BUGS AND LIMITATIONS

Please report problems to the Ifeffit Mailing List (http://cars9.uchicago.edu/mailman/listinfo/ifeffit/)

Patches are welcome.

AUTHOR

Bruce Ravel, http://bruceravel.github.io/home

http://bruceravel.github.io/demeter/

LICENCE AND COPYRIGHT

Copyright (c) 2006-2018 Bruce Ravel (http://bruceravel.github.io/home). All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlgpl.

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.