Tutorial- lesson 10 - Script file

Not a lot of user practice Visual Spec in console mode. This console allows you to enter command lines. It is now possible to link them into a text file and run this as a script to automatize some processings.

Automatization of spectral processing shall be done with care. Make sure your results are consistent and less accurate than the manual, traditional, longer process

List of console command

List the file in the current working directory

cd nomrepertoire
Change directory

load nomfichier
Load the file, do not put the directory, it is the current working directory by default

save nomfichier
Save the file with the nomfichier name in the current working directory

affserie nomserie
Select and display the serie with the name seriename

formatx l1 l2
Force all the profile opened to be displayed between l1 and l2, l1 and l2 are on the x axis

Force all series and all profiles opened to be displayed between l1 and l2

decoupe l1 l2
Crop the profile between the l1 and l2 values, x axis

norma l1 l2
Normalize the current active serie by taking the average continuum between l1 and l2

comp 'operation' l1 l2
Compute the following operation between the values l1 and l2, x axis
e:standard deviation
l:equivalent width
s:signal-to-noise ratio

gaussfit l1 l2
Fit a gaussian to the profile section comprise between l1 and l2

serie_sel s1
Select the serie by its number s1
Serie number s1 are coded as followed:
- Intensity: 3
- Ref1:4
- Ref2:
- Normalise:
- added temporary series, incremented as they are added, first add start at

div s1
Divide the current active serie by the serie of number s1

file_sel nomfenetre
Make the profile in the window name nomfenetre the active profile document

div_sel nomfenetre
Divide the current serie of the current profile by the serie active of the profile in the window name nomfenetre

Compute the continuum from point list stored previously in the Liste.txt file

Compute the continuum by eliminating zone from the list stored previously in the Listezone.txt file

smooth p1
Smooth by spline function the current active serie, the smooth coefficient is p1

replace s1
Replace the serie of serienumber s1 by the current active serie

run nomprog.pgm p1 p2 p3
Run the script nomprog.pgm, can support 3 parameters

How to build / run a script

-Test your command sequence first in the single command mode in the console

-Open a text file, edit the command list, one command by line, up to 3 parameters $1, $2, $3 can be used

-Save the text file with a .pgm extension - the file shall be stored in the vspec.exe directory

-Run the script from the console by typing run nompgm (without .pgm) and the parameters if you have included them

A simple example

In this example, the script will load the $1 file, perform a zone continuum correction followed by a spline smooth with $3 smooth coefficient, select the intensity serie and divided it by the serie "8" which is the added serie "continuum.fit". It then normalize the profile, move the current serie in the intensity serie, save the file under the $2 name and reload it to display the result

load $1
smooth $3
serie_sel 3
div 8
norma 6590 6640
replace 3
save $2
load $2

The most important to know here is have previously stored the list of profile zone to eliminated before the continuum fit on a previous profile, this having being done the traditional way. The same way, the smooth coef $3 wold have been determined from another similar object processed manually. It may not be absolutly the same from one profile to another one... that's the limitation of automatisation.

Here are the files to process by the script

I picked the profile which exhibits the highest number of lines, to make sure all the zones where lines can be present are captured and eliminated. I choose the profile of alp cam.

This profile is then processed "manually" - first, extract the continuum

Then, eliminate the zone where there are lines

When done, just run the continuum extraction, and get the smooth box displayed - pick and note the smooth coefficient

you can stop here, or go up to the end, just to check that your process will be ok

Display the console

Enter the command to run the script with the name of the file to process as parameter 1, the name of file under you want to save the result as the second parameter and the smooth coefficient, which is 5 (the highest it is the smoother it will be). Run... and observe the sequence, at the end, the file with the resulting processed spectrum is saved and displayed. The list of commands executed are printed in green in the console.

You can repeat the script entering new object names - you can just edit the names on the same line, then select only few characters of the line and hit enter - the command will be run again.

You can also cut and paste to repeat the same script in a long text file with the different names of the object you want to process. And run just once... In all case, this is the reult of the automatisation of the continuum correction.

Not too bad...

Now, it is just "Imagination at Work (c)"