X0h on the Web! GID_sl on the Web! TER_sl on the Web!

Automated access and remote fitting

This page is meant for those who are willing to make a step beyond regular web browser access to X-ray Server. It demonstrates how using very limited amount of scripting one can automate the server access, implement remote fitting or embed server programs into his/her own software.

As an example, a diffraction program written by a user could remotely access X-ray structure amplitudes provided by X0h. This would make user's code much more lightweight and the effort much smaller since sorting out the business of calculating structure factors could be left out. Another example could be the need to calculate a series of structure factors or diffraction or reflectivity curves as a function of a parameter. It would be much easier to script such operation than run a session in a browser several hundred or so times.

A separate issue is fitting. There have been many requests from users to provide remote fitting of experimental data at X-ray server. The main problem here is the number of parameters: for example, the Bragg curves calculated with GID_sl can be specified with hundreds or even thousands of parameters describing the surface layer. The input form presented below corresponds to a typical material science application. It describes the surface layer consisting of 72 layers and containing more than 200 parameters like thickness, strain and structure factor.

GID_form example

So, the question is, how to choose a subset of fittable parameters without loss of general applicability because making everything fittable would obviously make the programs and the interface unpractically heavy.

The second issue is that when it comes to fitting, often the simulated curves need to be convoluted with the geometry of experiment; for example, with the incident beam spread after the monochromator or slits, and etc. Given the diversity of geometries at synchrotrons and lab sources, incorpoation of generic account for experimental resolution function and geometrical corrections does not seem to be feasible.

Therefore, the server suggests to move the choice of the range of fitted parameters as well as the account for experimental corrections to the client side. In other, words, the server can solve the physical problem of X-ray interaction with model media, and the specifics of experiment are left to client-side software. This can be presented on the following scheme:

Remote access fitting

A fitting routine written by a user runs in a loop on his client computer. It fits experimental data by requesting data from the server via a wrapper script at each step of the fitting loop. Examples of wrapper scripts are provided below at this page. If necessary, the simulated curves returned by the wrapper are convoluted with experiment in user's software. Also, it is user's software that determines the set of fitting parameters and their range.

getX0h.pl Script interfacing X0h. (equivalent to X0h form).
getGID.pl Script interfacing GID_sl. (equivalent to this GID_sl form).
getGID_useragent.pl Another example script interfacing GID_sl. This script is recommended for lengthy calculations with the duration exceeding 180 seconds when a simple getGID.pl times out. The getGID_useragent.pl script makes use of a more advanced UserAgent Perl library that allows to increase the timeout value. (equivalent to this GID_sl form).
getGID_query.pl Another example script interfacing GID_sl. This script should work for calculations of any length (duration). The script tracks and prints the progress of calculation for a little penalty of sending extra periodic requests to the server. (equivalent to this GID_sl form).
getTER.pl Script interfacing TER_sl. (equivalent to this TER_sl form).
getTER_sw.pl A script interfacing TER_sl and additionally
requesting X-ray standindg waves.
(equivalent to this TER_sl form).
getTRDS.pl A script interfacing TRDS_sl. (equivalent to this TRDS_sl form).
getMAG.pl A script interfacing MAG_sl. (equivalent to this MAG_sl form).

The above example scripts are written in Perl using Perl LWP module (WWW library for Perl). The latter is usually a part of standard Perl distribution. The Perl interpreter itself is default on UNIX and MAC OS. Freeware Perl distibution for Windows can be installed either as a part of Cygwin, or as a standalone package available from ActiveState.

The scripts can be called from user's software written in any language using the system function. In necessary to vary a parameter, it can be passed to the script as a command line argument.

Some more scripting examples including Bash scripts are provided at the X0h web page.



X
Site navigation: