4.4. Plot object¶
The Plot object is used to control the details of how plots are made and displayed by DEMETER programs. It is useful to consider how ATHENA works in order to understand the relationship of the Plot object to the rest of DEMETER. In ATHENA, the plot controls are separate from the controls for the parameters of any individual data set. For example, the range over which data are plotted in energy or R-space is, in some, sense, a global parameter not associated with a particular data set. The Plot object serves this role. The details of the plot in DEMETER are global. To plot a plottable object (Data, Path, or any of the Path-like objects), DEMETER consults the Plot object for those details.
To make the Plot object readily accessible at all times in your program,
the po
method is a method of the base class and is inherited by all
DEMETER objects. Thus, given any object, you can “find” the Plot object
like so:
$the_plot_object = $any_object -> po;
Any method of the plot object is easily called by chaining with the
po
method. For example to start a new plot (as opposed to
overplotting), you do this
$any_object -> po -> start_plot;
The start_plot
method reinitializes the Plot object to begin a new
plot. Along with clearing the plotting display, this restarts the trace
colors and resets the plot title.
4.4.1. Plotting in energy¶
4.4.1.1. Data, background, pre-edge, & post-edge¶
my @eplot = (e_mu => 1, e_bkg => 1,
e_norm => 0, e_der => 0,
e_pre => 1, e_post => 1,
e_i0 => 0, e_signal => 0,
e_markers => 1,
emin => -200, emax => 2000,
space => 'E',
);
$data -> po -> set(@eplot);
$data -> po -> start_plot;
$data -> plot;
Also note that, as was discussed in the chapter on the Data object, there is no need to explicitly perform the data normalization or background removal. DEMETER knows what needs to be done to bring the data up to date for plotting and will perform all necessary chores before actually generating the plot. This allows you to focus on what you need to accomplish.
One final point about this example. I have created the @eplot
array
to hold the attributes of the Plot object. I then pass that array as the
argument of the set
method of the Plot object. Those attributes
could be listed as explicit arguments of the set
method. As always
in perl, there's more than one way to do
it.
4.4.1.2. Normalized data & background¶
my @eplot = (e_mu => 1, e_bkg => 1,
e_norm => 1, e_der => 0,
e_pre => 0, e_post => 0,
e_i0 => 0, e_signal => 0,
e_markers => 1,
emin => -200, emax => 2000,
space => 'E',
);
$data -> po -> set(@eplot);
$data -> bkg_flatten(0);
$data -> po -> start_plot;
$data -> plot;
4.4.1.3. Flattened data & background¶
my @eplot = (e_mu => 1, e_bkg => 1,
e_norm => 1, e_der => 0,
e_pre => 0, e_post => 0,
e_i0 => 0, e_signal => 0,
e_markers => 1,
emin => -200, emax => 2000,
space => 'E',
);
$data -> po -> set(@eplot);
$data -> bkg_flatten(1);
$data -> po -> start_plot;
$data -> plot;
Note that the switch for turning flattening on and off is an attribute of the Data object not the Plot object. This allows the option of overplotting one data set that is normalized with another that is flattened.
4.4.1.4. Derivative of mu¶
my @eplot = (e_mu => 1, e_bkg => 0,
e_norm => 0, e_der => 1,
e_pre => 0, e_post => 0,
e_i0 => 0, e_signal => 0,
e_markers => 0,
emin => -20, emax => 120,
space => 'E',
);
$data -> po -> start_plot;
$data -> set(name=>'derivative') -> plot;
$data -> po -> e_norm(1);
$data -> set(name=>'norm. deriv.') -> plot;
This example shows two interesting features we haven't yet seen. The
overplotting happens simply by calling the plot
mthod a second
time without calling start_plot
. In this way, any number of things
can be overplotted.
Also note the use of chained method calls to set the Data object's
name
attribute appropriately before plotting. The name
method
always returns the object that called it, which allows for this sort
of chaining magic to happen. There is no advantage to chained method
calls – you could rename the Data object and then plot it in the
subsequent line. The cahined calls are a bit more concise.
4.4.1.5. Data, I0 channel, & signal channel¶
my @eplot = (e_mu => 1, e_bkg => 0,
e_norm => 0, e_der => 0,
e_pre => 0, e_post => 0,
e_i0 => 1, e_signal => 1,
e_markers => 0,
emin => -20, emax => 120,
space => 'E',
);
$data -> po -> start_plot;
$data -> plot;
4.4.1.6. Data at two different edges with E0 subtracted¶
my @common = (bkg_rbkg => 1.5,
bkg_spl1 => 0, bkg_spl2 => 18,
bkg_nor2 => 1800,
bkg_flatten => 1,
);
my @data = (Demeter::Data -> new(),
Demeter::Data -> new(),
);
foreach (@data) { $_ -> set(@common) };
$data[0] -> set(file => "$where/data/fe.060.xmu",
name => 'Fe 60K', );
$data[1] -> set(file => "$where/data/cu010k.dat",
name => 'Cu 10K', );
## decide how to plot the data
$plot -> set(e_mu => 1, e_bkg => 0,
e_norm => 1,
e_pre => 0, e_post => 0,
e_zero => 1,
emin => -30, emax => 150,
);
$data[0] -> po -> start_plot;
foreach (@data) { $_ -> plot('E') };
4.4.2. Plotting in k¶
4.4.2.1. Plotting in k-space¶
$data -> po -> start_plot;
$data -> po -> kweight(2);
$data -> plot('k');
4.4.2.2. Plotting in chi(k) in energy¶
$data -> po -> start_plot;
$data -> po -> set(kweight=>2, chie=>1);
$data -> plot('k');
4.4.3. Plotting in R¶
4.4.3.1. Magnitude in R-space & R-space window¶
$data -> po -> set(kweight => 2, r_pl => 'm', space => 'r', );
$data -> po -> start_plot;
$data -> plot -> plot_window;
Note that the plot_window
method was indicated in a chained method
call. This is not required, but is possible because the plot
method returns the calling object.
The plot_window
method observes the value of the Plot object's
space
attribute. That is, if the plot s being made in k or q, the
k-space window will be plotted. If the plot is being made in R, the
R-space window will be plotted.
4.4.3.2. Data in R-space as envelope, real part, & imaginary part¶
$data -> po -> set(kweight => 2, r_pl => 'e', space => 'r');
$data -> po -> start_plot;
$data -> plot;
$data -> set(name=>'Real part');
$data -> po -> set(r_pl => 'r', );
$data -> plot;
$data -> set(name=>'Imaginary part');
$data -> po->set(r_pl => 'i', );
$data -> plot;
$data -> set(name=>'fe.060'); ## reset original name
4.4.3.4. Magnitude and real part in R space¶
$data -> po -> start_plot;
$data -> po -> kweight(2);
$data -> plot('rmr');
4.4.4. Plotting in q¶
4.4.4.1. Plotting in back-transform k-space¶
$data -> po -> set(kweight => 2, q_pl => 'r');
$data -> po -> start_plot;
$data -> plot('q');
4.4.4.2. k-space & the real part of back-transform k-space¶
$data -> po -> start_plot;
$data -> po -> kweight(2);
$data -> plot('kq');
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.