| Description | Perl tools for X-ray Absorption Spectroscopy |
Demeter::Tools - Utility methods for the Demeter class
This documentation refers to Demeter version 0.9.26.
This module contains a number of methods that work better (in Bruce's opinion) as class methods than as object methods.
simpleGDSThis is syntactic sugar for the GDS object constructor. The following are equivalent:
$gdsobject = Demeter::GDS ->
new(type => 'guess',
name => 'alpha',
mathexp => 0,
);
#
$gdsobject = $demeter_object -> simpleGDS("guess alpha = 0");
The text string that is the argument for this wrapper is parsed identically to how a guess parameter in a feffit.inp file is parsed.
distanceThis returns the Cartesian distance between two points.
my $d = distance(@point1, @point2);
Each of the arrays passed to this function must be exactly three elements long and are assumed to contain the x, y, and z Cartesian coordinates, in that order.
nowThis returns a string with the current date and time in a convenient, human-readable format.
print "The time is: ", $demeter_object -> now, $/;
howlongThis returns a string used for indicating an amount of elapsed time. The argument is a DataTime object made at the beginning of the event whose elapsed time is being measured.
my $start = DateTime->now( time_zone => 'floating' );
# ... do something
my $text = Demeter->howlong($start);
returns
That took NN seconds.
It can be customized:
my $text = Demeter->howlong($start, "Your fit");
returns
Your fit took NN seconds.
For something longer than a minute, it would return
Your fit took MM minutes and NN seconds.
environmentThis returns a string showing the version numbers of Demeter and perl, and the identifier string for your operating system.
print "You are running: ", $demeter_object -> environment, $/;
whoThis makes a halfhearted attempt to figure out who you are. On a unix machine, it returns a concatination of the USER and HOST environment variables. On Windows it currently returns the fairly stupid "you@your.computer".
print "You are: ", $demeter_object -> who, $/;
check_parensReturn 0 if a string has matching round braces (parentheses). A positive (negative) return value indicates the number of excess open (close) round braces. This can be used a boolean check on a string.
$is_mismatched = $demeter_object->check_parens($string);
This only matches round braces. It ignores square, curly, or angle braces, none of which serve a purpose in Ifeffit math expressions.
is_windowsReturn true if running on a Windows machine.
my $is_win = $demeter_object -> is_windows;
is_osxReturn true if running on a Macintosh OSX machine.
my $is_mac = $demeter_object -> is_osx;
halflengthGiven a list of references to arrays -- each of which contains the x, y, and z coordinates of an atom -- return the half length of the path. The half length is the sum of the individual legs divided by 2. The first item in the list is assumed to the absorber at and is tacked onto the end of the list to close the path.
my $hl = $demeter_object ->
halflength(\@coords1, \@coords2, ... \@coordsN);
euclidReturn the greatest common denominator of two numbers.
my $gcd = $demeter_object->euclid(1071, 462);
## $gcd is 21
This is used by Demeter::Atoms to determine stoichiometry for the feff8 input file's potentials list.
fractReturns a fraction of rational numbers given an input float,using 5 significant digits beyond the decimal.
my $frac = $demeter_object -> fract(0.5);
## will print as "1/2"
slurpSlurp a file into a scalar.
my $string = $demeter_object -> slurp('/path/to/file');
write_fileDump a string into a file.
$demeter_object -> write_file($file, $string);
randomstringReturn a rendom character string using random numbers from Math::Random
$string = Demeter->randomstring($length);
The resulting string will be $length characters long. If not specified, it will be 6 characters long.
DumpThis is just a wrapper around Data::Dump::Color, Data::Dump or Data::Dumper, whichever is installed. Pass it a reference and it will be pretty-printed;
print $any_object -> Dump(\@some_array);
tracePrint an ANSI-colorized stack trace to STDOUT from any location.
$any_object -> trace;
pjoinWrite stuff to the screen in an ugly but easy to read manner.
Demeter->pjoin($this, $that, @and_the_other);
unistripRemove non-ASCII characters from a string. This simple, blunt hammer is used to save just the text without the coloration from Athena's status bar buffer.
my $no_utf = Demeter->unistrip($text);
TouchThis is a wrapper around the touch method from File::Touch.
Demeter->Touch($some_file);
feffdocversionThis method attempts to determine the appropriate version of the Feff document to show. If the version is not specified, it will be determined from the value of the feff->feff-executable configuration parameter.
$version = Demeter->feffdocversion;
The only two options currently supported are 6 and 9.
feffdocThis returns the URL of the main page of the Feff documentation for either version 6 or 9, depending on which is requested or determined via the feffdocversion method.
$url = Demeter->feffdoc;
feffcardpageThis returns the URL for the page documenting a specific card in the Feff6 or Feff9 input file.
$url = Demeter->feffcardpage($card, $version);
Specifying the Feff version is optional. If not specified, it will use the value returned by the feffdocversion method.
See Demeter::Config for a description of the configuration system.
The dependencies of the Demeter system are listed in the Build.PL file.
The who method should poke at the registry on Windows.
The fract method should define what a small integer is and return a decimal representation when the ratio is not of small numbers.
Please report problems to the Ifeffit Mailing List (http://cars9.uchicago.edu/mailman/listinfo/ifeffit/)
Patches are welcome.
The euclid method was swiped from Math::Numbers by David Moreno Garza and is Copyright (C) 2007 and is licensed like Perl itself.
Bruce Ravel (http://bruceravel.github.io/home)
http://bruceravel.github.io/demeter/
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.