Xray::BLA::Tools

NAME

Xray::BLA::Tools - A role with tools and conveniences for BLA

VERSION

See Xray::BLA

METHODS

file_template

Construct a file name from BLA object attributes using a simple %-sign substitution scheme:

%s : stub
%e : emission energy
%i : incident energy
%t : tiffcounter
%T : padded, 3-digit energy index
%c : energy index counter
%% : literal %

As an example:

$bla->file_template('%s_elastic_%e_%t.tif')

might evaluate to Aufoil1_elastic_9711_00001.tif.

Optional arguments:

$bla->file_template('%s_elastic_%e_%t.tif', {counter=>$n, re=>1})

counter is used to increment a file name counter. re indicates that the template should return a suitable regular expression for %e and %c.

howlong

Report on a time span in human readable terms.

my $start = DateTime->now( time_zone => 'floating' );
##
## do stuff...
##
print $spectrum->howlong($start, $text);

The first argument is a DateTime object created at the beginning of a lengthy chore. The second argument is text that will be reported in the return string, as in "$text took NN seconds".

randomstring

Return a random string of a specified length, used to make temporary files and folders.

my $string = $spectrum->randomstring(6);

The default is a 6-character string.

is_windows, is_osx

Return true is the operating system is Windows or OSX. This is a simple heuristic based on $^O (see http://perldoc.perl.org/perlvar.html);

AUTHOR

Bruce Ravel (bravel AT bnl DOT gov)

http://github.com/bruceravel/BLA-XANES