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.

DOWNLOAD TEMPLATES

ATTENTION: if you had used the scripts before 2013/11, you many need to check the new versions because in the preparation to moving the Server from Windows to case-sensitive Linux, most of Server files were converted to lower case and therefore the old scripts may no longer work.

getX0hDB.pl A script returning the X0h database lists or dumps under various conditions (only crystals, only cubic crystals, only atomic materials, and etc.). This script can be used by other scripts to supply them with available materials and thus provide full-cycle automated remote access. (equivalent to this form).
getX0hCoords.pl
 
getX0hCoordsAll.pl
Example scripts returning original X0h records for a given material and all materials respectively. You can use output to verify coordinates of atoms in the unit cells of all materials contained in the X0h DB. (equivalent to this form).
getX0h_v2.pl
 
calcAttenuation.pl
Example scripts interfacing X0h. See explanations inside the scripts. (equivalent to X0h form).
getGID_query_post.pl Example script interfacing GID_sl. This script starts a calculation, then polls the server until it finishes, and downloads the results. It uses the CGI POST method which does not impose restrictions on the length of buffer describing surface profile -- see details here. (equivalent to this GID_sl form).
getTER_query_post.pl Example script interfacing TER_sl. This script starts a calculation, then polls the server until it finishes, and downloads the results. It uses the CGI POST method which does not impose restrictions on the length of buffer describing surface profile -- see details here. (equivalent to this TER_sl form).
getTER_sw_query_post.pl Example script requesting X-ray standing waves from TER_sl. This script starts a calculation, then polls the server until it finishes, and downloads the results. It uses the CGI POST method which does not impose restrictions on the length of buffer describing surface profile -- see details here. (equivalent to this TER_sl form).
getTRDS_query_post.pl Example script interfacing TRDS_sl. This script starts a calculation, then polls the server until it finishes, and downloads the results. It uses the CGI POST method which does not impose restrictions on the length of buffer describing surface profile -- see details here. (equivalent to this TRDS_sl form).
getMAG_query_post.pl Example script interfacing MAG_sl. This script starts a calculation, then polls the server until it finishes, and downloads the results. It uses the CGI POST method which does not impose restrictions on the length of buffer describing surface profile -- see details here. (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. If a parameter needs to be varied, it can be passed to the script as a command line argument.



X
Site navigation: