Demeter

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

NAME

Demeter::Mode - Demeter's sentinel system

VERSION

This documentation refers to Demeter version 0.9.26.

DESCRIPTION

This special object is used to store global attributes of an instance of Demeter in a way that makes those attributes available to any Demeter object.

Access to this object is via the get_mode and set_mode methods of the Demeter base class. The convenience methods co and po of the Demeter base class are used to gain access to the Config and Plot objects. Any of these methods can be called by any Demeter object:

  $to_screen = $data_object     -> get_mode('screen');
  $to_screen = $gds_object      -> get_mode('screen');
  $to_screen = $path_object     -> get_mode('screen');
  $to_screen = $scattering_path -> get_mode('screen');
  $to_screen = $prj_object      -> get_mode('screen');
    ## and so on ...

This object also monitors the creation and destruction of Demeter objects (Atoms, Data, Data::Prj, Data::JSON, Data::MultiChannel, Data::BulkMerge, Feff, Feff::External, Fit, GDS, Path, Plot, Plot::Indicator, ScatteringPath, SSPath, VPath, etc.) and provides methods which give a way for one object to affect any other objects created during the instance of Demeter. For example, when the kweight value of the Plot object is changed, it is necessary to signal all Data objects that they will need to update their forward Fourier transforms. This object is the glue that allows things like that to happen.

ATTRIBUTES

Disposal modes

backend

Dispose commands to Larch or Ifeffit, as appropriate, when true.

screen

Dispose commands to STDOUT when true.

plotscreen

Dispose plotting commands to STDOUT when true.

repscreen

Dispose reprocessed commands to STDOUT when true.

file

Dispose commands to a file when a filename is given.

plotfile

Dispose plotting commands to a file when a filename is given.

repfile

Dispose reprocessed commands to a file when a filename is given.

buffer

Dispose commands to a string or array when given a reference to a string or array.

plotbuffer

Optionally dispose of plotting commands to a difference string or array reference.

callback

Dispose commands by sending them as the argument to a user-supplied code rerference.

plotcallback

Optionally dispose of plotting commands to a difference code reference.

feedback

A code ref for disposing of feedback from Ifeffit or Larch.

Template objects

config

A reference to the singleton Config object. $C is the special template variable.

plot

A reference to the current Plot object. $P is the special template variable.

fit

A reference to the current Fit object. $F is the special template variable.

standard

A reference to the current Data object used as a data processing standard. $DS is the special template variable.

theory

A reference to the current Feff object. $T is the special template variable.

path

A reference to the current Path object. $PT is the special template variable.

Template sets

template_process

The template set to use for processing data.

template_fit

The template set to use for fitting data.

template_analysis

The template set to use for analyzing mu(E) data.

template_plot

The template set to use for plotting data.

template_feff

The template set to use for writing feff.inp files.

template_test

A special template set used for testing Demeter.

Object collections

Atoms

A list of all Atoms objects created during this instance of Demeter.

Data

A list of all Data objects created during this instance of Demeter.

Feff

A list of all Feff objects created during this instance of Demeter.

External

A list of all Feff::External objects created during this instance of Demeter.

Fit

A list of all Fit objects created during this instance of Demeter.

GDS

A list of all GDS objects created during this instance of Demeter.

Path

A list of all Path objects created during this instance of Demeter.

Plot

A list of all Plot objects created during this instance of Demeter.

ScatteringPath

A list of all ScatteringPath objects created during this instance of Demeter.

VPath

A list of all VPath objects created during this instance of Demeter.

SSPath

A list of all SSPath objects created during this instance of Demeter.

Prj

A list of all Data::Prj objects created during this instance of Demeter.

JSON

A list of all Data::JSON objects created during this instance of Demeter.

Other attributes

iwd

The initial working directory when Demeter starts.

cwd

Demeter's current working directory.

echo

???

datadefault

This is a Data object used as a fallback. For instance, one might want to process and plot Path objects without having imported a Data object. This global attribute will be used in that case to properly process and plot the Path.

feffdefault

This is a Feff object used as a fallback in some Path-like objects.

external_plot_object

For plotting backends that have an objective interface, this global attribute carried the refernece to that object. For example, in the gnuplot backend, this contains a reference to the Graphics::GnuplotIF object.

ui

This is a string identifying the user interface backend.

When set to screen, it tells triggers the import of curses-based methods in Demeter::UI::Screen::Interview and Demeter::UI::Screen::Progress. Other options used at this time are wx and web.

This is normally set at import, as in

  use Demeter qw(:ui=screen);

The default is either the value of $ENV{DEMETER_MODE} or none. Setting $ENV{DEMETER_MODE} is done when the mode setting must be specified very early in startup. This is done, for example, in WebAtoms to set the ui to web.

silently_ignore_unplottable

When true, this averts croaking in certain situations where an attempt is made to plot an object in a way that it cannot be plotted (for example, attempting to plot in energy a Data object of datatype chi). This is useful in the context of a GUI, but is stringly discouraged in a command line script.

SENTINEL FUNCTIONALITY

It should rarely be necessary that a user script needs to access this part of this object. Mostly the sentinel functionality is handled behind the scenes, during object creation or destruction or at the end of a script. The details are documented here for those times when one needs to see under the hood.

Each Demeter object (Atoms, Data, Data::Prj, Data::MultiChannel, Data::BulkMerge, Feff, Feff::External, Fit, GDS, Path, Plot, Plot::Indicator, ScatteringPath, SSPath, VPath, etc.) (Data::Prj is refered to just as Prj, other Data::* classes are the same) has each of the following three function associated with it.

All of my examples use the Data object.

Object

This is the accessor for the attribute which holds the list of all Data objects created during this instance of Demeter.

  my @list = @{ $object->mo->Data };
push_Object

This is the method used to append an object to the list;

  $data_object->push_Data($data_object);

This happens automatically when a Data object is created.

clear_Object

This method is used to clear the contents of the list.

  $data_object->clear_Data;

This is not used for anything at this time, but it seemed useful.

Sentinel methods

fetch

This method returns an object reference given its group name.

  $object = $demeter_object->mo->fetch("ScatteringPath", $group);

In this example, the ScatteringPath object whose group name is $group will be returned. The first argument is one of the Demeter object types. This method was written to facilitate drag and drop in the Wx version of Artemis. Wx's drag and drop capability does not easily do DND on blessed references. It was much easier to do DND on an array of group names, which are simple strings. I then needed this method to convert the list of group names back into a list of object references.

reset_path_index

This resets the path counter to 1. This is used when closing one project and starting a new one so that path indexing can start at 1 in the new fit. See close_project in Demeter::UI::Artemis::Project.

DIAGNOSTICS

Moose type constraints are used on several of the GDS object attributes. Error messages appropriate to the type constrain will be generated.

SERIALIZATION AND DESERIALIZATION

See the discussion of serialization and deserialization in Demeter::Fit.

CONFIGURATION AND ENVIRONMENT

See Demeter::Config for a description of the configuration system.

DEPENDENCIES

Demeter's dependencies are in the Build.PL file.

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.