资源说明:A prototype framework for obtaining XANES and XES spectra from a bent Laue analyzer and a Pilatus detector
#+STARTUP: showall * Convert bent-Laue analyzer images to XANES data ** Synopsis A measurement set consists of + A column data file with columns of energy and scalars from the measurement. + One Pilatus image for each energy point in the XANES scan containing the HERFD signal at that point. + A set of Pilatus images taken at energies around the fluorescence energy. These are used to make a mask which identifies which pixels contain signal related to specific emission energies. This software uses perl, [[https://metacpan.org/release/Moose][Moose]], and [[http://pdl.perl.org][PDL]] to process the images into a high resolution XANES spectrum. The GUI, called Metis, uses WxWidgets and its perl bindings. See [[file:lib/Xray/BLA/Image.pm][Xray::BLA::Image]] for how to import the signed 32 bit tiff images directly into PDL. ** Installation To install, do the following: : perl Build.PL : sudo ./Build installdeps ## (if any dependencies are not met) : ./Build : ./Build test : sudo ./Build install The requirement ~Graphics::Gnuplot::Palettes~ is not on CPAN and will not be installed at the ~Build installdeps~ step. Download this package from https://github.com/bruceravel/Graphics-Gnuplot-Palettes ** Usage ~bla~, found in the ~bin/~ folder, is a wrapper script around the various bent Laue tasks: 1. ~herfd~: make a single HERFD spectrum at a specific emission energy 2. ~rixs~: generate a sequence of HERFD spectra at a sequence of emission energies 3. ~xes~: compute the emission spectrum for a specific incident energy 4. ~plane~: compute the resonant XES plane 5. ~map~: convert a series of elastic images to an energy vs. pixel map 6. ~mask~: compute the mask file for a specific emission energy 7. ~point~: convert a specified BLA image to its HERFD value for a specified emission energy *** The bla script : bla herfd [cxespvnfqh]: bla rixs [cxspvnfqh] : bla xes [cipvnqh] : bla plane [cpvnqh] : bla map [crpvnqh] : bla mask [csvnfqh] : bla point [ceih] : : --config | -c [string] configuration file (required) : --energy | -e [integer] emission energy (required for herfd/point tasks) : --incident | -i [integer] data point at which compute HERFD (required for point/xes task) : --xdiini | -x [string] XDI configuration file : --reuse | -r [flag] reuse mask files for energy map if in outfolder : --save | -s [flag] save mask as gif : --plot | -p [flag] plot data (herfd/rixs/map/xes tasks) : --verbose | -v [flag] write progress messages : --nocolor | -n [flag] turn off color coding of screen output : --format | -f [string] output static image format, gif or tif : --quiet | -q [flag] suppress progress messages : --help | -h [flag] write this message and exit The ~bla~ script assumes that scan files and image files have related names. In this example, the scan file is called ~Aufoil1.001~ and the image files are called ~Aufoil1_NNNNN.tif~. The ~NNNNN~ in the image file name indicates the data point and is reflected in one of the columns of the scan file. If your data do not follow these patterns, this script will fail. File locations are specified in the configuration file. : examples: bla herfd -c=/path/to/config.ini -e=9713 Aufoil1 : bla rixs -c=/path/to/config.ini Aufoil1 : bla map -c=/path/to/config.ini Aufoil1 : bla xes -c=/path/to/config.ini -i=11970 Aufoil1 : bla plane -c=/path/to/config.ini Aufoil1 : bla mask -c=/path/to/config.ini -e=9713 Aufoil1 : bla point -c=/path/to/config.ini -e=9713 -p=10 Aufoil1 Here, "Aufoil1" is the stub, i.e. the basename of the scan and image files, and the ~-c~ and ~-e~ command line options are demonstrated. The ~-i~ flag, used by ~point~ and ~xes~ can take either an integer, indicating the index of the data point, or a number, indicating the incident energy of the datapoint. So the following may be equivalent: : bla point -c=/path/to/config.ini -e=9713 -i=69 Aufoil1 : bla point -c=/path/to/config.ini -e=9713 -i=12000 Aufoil1 For the ~point~ task, the ~-i~ flag *must* be specified. For the ~xes~ task, if the ~-i~ flag is omited, the midpoint of the scan (in index, not in energy) will be used. Options that are not used by a function (for example ~-e~ for ~rixs~ or ~map~, or ~-i~ for any task other than ~point~ or ~xes~) will be silently ignored. ~-c~ is required for all functions unless the ~BLACONFIG~ environment variable is set. The ~-r~ flag is a time-saver for the ~rixs~, ~map~, and ~xes~ tasks. When present, this flag tells the program to reuse any mask images or scan files found in the output folder. This is safe so long as the mask creation parameters in the configuration file have not been changed. Since the ~point~ task returns a number intended for use during data acquisition, verbosity is turned off regardless of the command line switches. Use the ~-q~ flag if you want to suppress screen messages during the ~mask~ task. Saving is turned on for the ~mask~ task regardless of the command line switches. ~-p~ will cause a plot to be made using Gnuplot before exiting for the ~herfd~, ~xes~, and ~map~ tasks. The program and plot will exit when you hit return. For the ~rixs~ task, the most recent HERFD spectrum will be plotted before immediately going on to the next emmission eenrgy. The HERFD plots are quite crude, without axis labels or other ornaments. *** Environment variables Use of the ~-c~ flag can be avoided by setting the ~BLACONFIG~ environment variable. The following are equivalent: : bla herfd -c=/path/to/config.ini -e=9713 Aufoil1 : : export BLACONFIG=/path/to/config.ini : bla herfd -e=9713 Aufoil1 Use of the ~-e~ flag can be avoided by setting the ~BLAENERGY~ environment variable. The following are equivalent: : bla herfd -c=/path/to/config.ini -e=9713 Aufoil1 : : export BLAENERGY=9713 : bla herfd -c=/path/to/config.ini Aufoil1 You can also avoid using the ~-e~ flag by setting a single energy in the ~emission~ line of the configuration file. (Of course, having only a single energy in that list will hamper the ~rixs~, ~map~, and ~xes~ tasks....) Use of the ~-x~ flag can be avoided by setting the ~BLAXDIINI~ environment variable. The following are equivalent: : bla herfd -c=/path/to/config.ini -x /path/to/xdi.ini -e=9713 Aufoil1 : : export BLAXDIINI=/path/to/xdi.ini : bla herfd -c=/path/to/config.ini -e 9713 Aufoil1 Each environment variable is overridden by its respective command line switch. *** Output + The output of the ~herfd~ task is a data file containing the HERFD spectrum at the specified emission energy and, if requested, gif images with the mask. At each energy point, the HERFD signal is computed from the Pilatus image using the mask created as described above. The counts on each pixel lying within the illuminated portion of the mask are summed. This sum is the HERFD signal at that incident energy. A column data file is written containing the energy and several scalars from the original measurement and a column containing the HERFD signal. This file can be imported directly into Athena. + The output of the ~rixs~ task is the same as for the ~herfd~ script at each emission energy. + The output of the ~xes~ task is a data file containing the XES spectrum from that incident energy with the signal from each emission energy weighted by the number of illuminated pixels in that mask. + The output of the ~map~ task is a data file in a [[http://gnuplot.info/docs_4.2/gnuplot.html#x1-33600045.1.2][simple format]] which can be read by gnuplot and a gnuplot script for displaying the data. The resulting image will plot a map of detector column vs detector row with the color axis showing energy. Gif files for the masks at each emission energy are also written. + The output of the ~mask~ task is a single gif file containing the mask for the specified emission energy. + The output of the ~point~ task is the HERFD value extracted from a specified BLA image for a specified emission energy. The value is printed to STDOUT. If files containing the BLA image or the emission mask do not exist or if any other problem is encountered, 0 is printed to STDOUT. On Windows, tiff files are written rather than gif files. The ~herfd~, ~rixs~, ~xes~, and ~map~ tasks are intended for post-processing of a full data set. The ~mask~ and ~point~ tasks are intended for inlining in the data acquisition process. The ~mask~ task should be run after measuring the elastic images at the emission energy and before measuring the HERFD data. The ~mask~ task takes about 10 seconds. The ~point~ task is intended for generating the HERFD value at a specific emission energy during the scan. This value can be used for plotting or storing to the output data file. The ~point~ task takes less than 1 second. *** The configuration file The configuration file is in the Windows-style ini format. Here is an example: #+BEGIN_SRC conf [measure] emission = 9703 9705 9707 9709 9711 9713 9715 9717 9719 scanfolder = /home/bruce/Data/NIST/10ID/2011.12/scans tiffolder = /home/bruce/Data/NIST/10ID/2011.12/tiffs outfolder = /home/bruce/Data/NIST/10ID/2011.12/processed element = Au line = La1 [files] scan = %s.001 elastic = %s_elastic_%e_%t.tif image = %s_%c.tif [steps] steps = < +/- ~ will be included in the mask. Note that it makes no sense to use this step with any step other than the bad/weak step, which should precede this step. 7. Use the entire image. The syntax is ~entire image~. This step just sets all the pixels in the mask to 1 so that the entire image is used to compute the energy point. Note that it makes no sense to use this step with any step other than the bad/weak step, which should precede this step. The steps can come in any order and can be repeated. At the end of the final step, the illuminated pixels in the mask will be set to a value of 1 so that the final mask can be used as an AND mask to create the HERFD spectra. Care is taken at the end to remove bad pixels that might have been restored by the areal or social pixel steps. *** Error checking The library is not particularly robust in terms of flagging problems. You should not expect particularly useful error messages if the folders in the configuration file are not correct or if you give an emission energy value that was not measured as an elastic image. In those cases, the program will almost certainly fail with some kind of stack trace, but probably not with an immediately useful error message. To say this another way, it's up to you to do file management sensibly. *** Saving masks as image files In order to save mask images, you may need to install some additional software on your computer. PDL uses the NetPBM package for image format manipulation. On Ubuntu, the package is called ~netpbm~ and is likely already installed. This is not installed by the Demeter installer for Windows, so you have to install it separately. Download and install [[http://gnuwin32.sourceforge.net/packages/netpbm.htm][the NetPBM Windows installer]]. Note where the binaries get installed. You must add that location to the execution path. This can be done at the Windows command prompt by : set PATH=%PATH%;C:\GnuWin32\bin substituting ~C:\GnuWin32\bin~ with the location on your computer. Without NetPBM, an invocation of the bla script with the ~-s~ flags will not run to completion. *** Animations Using ImageMagick on the output masks: #+BEGIN_SRC sh convert -layers OptimizePlus -delay 5x100 *mask.gif -loop 0 mask_animation.gif #+END_SRC *** XDI Output When a configuration file containing XDI metadata is used, the output files will be written in XDI format. This is particularly handy for the RIXS function. If XDI metadata is provided, then the ~BLA.pixel_ratio~ metadatum will be written to the output file. This number is computed from the number of pixels illuminated in the mask at each emission energy. The pixel ratio for an emission energy is the number of pixels from the emission energy with the largest number of illuminated pixels divided by the number of illuminated pixels at that energy. The pixel ratio can be used to normalize the mu(E) data from each emission energy. The concept is that the normalized mu(E) data are an approximation of what they would be if each emission energy was equally represented on the face of the detector. The version of Athena based on Demeter will be able to use these values as importance or plot multiplier values if the ~Xray::XDI~ module is available. *** PDL and Gnuplot Apply ~share/PGG/PGG.patch~ to ~/usr/local/share/perl/5.20.2/PDL/Graphics/Gnuplot.pm~ to suppress the ~Reading ras files from sequential devices not supported~ warning when using the qt terminal. This is a qt issue and appears to be of no consequence. Around line 3116 of ~PDL::Graphics::Gnuplot~, add the following line: #+BEGIN_SRC perl $optionsWarnings =~ s/^Reading ras files from sequential devices not supported.*$//mg; $optionsWarnings = '' if($optionsWarnings =~ m/^\s+$/s); #+END_SRC Similar near lines 3256, 3301.
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。