Close This Window

Merci de télécharger les logos officiels de l'ILL ici


Pour utiliser sur le web

Pour imprimer en haute résolution


Télécharger PNG

Télécharger TIF


Télécharger JPG

Télécharger EPS



Computing for Science

The Computing for Science (CS) group supports ILL scientists, students and visitors in a number of activities including data analysis, instrument simulation and sample simulation.

Back to ILL Homepage
English French Deutsch 

All Software

Examples

Example 1:

Reading data stored in x, y, error format, and fitting it to a Gaussian peak

Spec1d has built-in filters to load most types of data files. If the filter does not exist, then it is either easy to
create a new filter, or to convert the data to x, y, error format, and then read in using the 'xyeload' filter.
For example, the following commands can be used to load the file arraydat.dat (x, y and error stored in
column form), fit it to a Gaussian, and to plot it:

which produces the figure

The code generated the plot in the following way:

  • The loads function is used to load the data (x, y and error) from the file 'arraydat.dat' into the spec1d object s.
  • The spectrum in s is then fitted to a Gaussian lineshape using the fits function. As no initial parameter values were given, the fitting routine estimates them from a moment analysis using the function peakm. The parameters of the fit  are returned in the structure fitdata, and the fitted values and original data in sfit.
  • plot is used to plot the data and fit.
  • Finally, the fit parameters in fitdata are added to the plot using formatpars.

In this example, each command was typed at the matlab prompt. They can of course be placed in a file, which is then run from the commad line. This allows the steps used in a complex data analysis  to be stored for editing, and also as a record of what was done.

Both loads and fits are much more flexible than this example suggests, as will be made clear in the other examples. Check the
help supplied with each function for details.

Example 2:

Reading data from a formatted data file (ILL, SPEC, RISØ, etc)

Filters for most commonly encountered data files are available in the MFIT/MVIEW load library. Using these filters it is possible to specify the x and y variables, name of the column containing the errors (if it exists), the monitor, and even a normalisation value. The loads routine stores the values of these variables, so that in subsequent calls to loads only the variables that change (for example the
data file name or scan number) need to be specified. Let us imagine that we want to load two TASCOM files from Risø into separate spectra, and then overplot them. The desired x  and y variables are OM and I, the errors are calculated from the counting statistics, and the monitor is MON. The name of the data filter in this case is 'tasbatch', and the data file is 'beta0007.dat'.

Example 3:

Reading multiple files, or multiple scans from the same file