Rameau software for baseline subtraction and water quantification using Raman spectroscopy. 
Part of the paper:
Determination of Water Content in Silicate Glasses using Raman Spectrometry, with implications for the study of explosive volcanism
Charles Le Losq, Daniel R. Neuville, Roberto Moretti and Jacques Roux
Submitted to American Mineralogist

WARNING: this software MUST NOT BE INSTALLED using the
usual "make ; sudo make install" nursery rhyme.
However some ancillary codes are required which need be installed
(conventionnally).

This package of softwares works on Linux distributions. For more information, please see the webpage of the various linux distribution. The software have been tested on Kubuntu and Ubuntu distributions and works well.

The intended usage is to place similar data spectra into a working
directory. Prepare some index table using a the system editor (kate under KDE
or any other) and/or "gx" GUI (which performs interactively all the calculations
on a file/file basis). Link such a directory into ./dat
        ln -sf ~/.../mydata ./dat
check the table.txt which should be similar to the examples provided and
just enter:
        make
to start the full calculation and pdf graphics generation. The
results will appear in result.txt, fig1.pdf fig2.pdf and calib.pdf.
Save the results where they belong then break the link (rm ./dat) and link
again ./dat to another set of data to process...

After decompressing the package, place the directory Rameau in any location you want, this directory will be the working directory for baseline subtraction.

Before trying read the following carefully which explains the
dependencies. All non standard softwares are provided in subdirectories
of the ./src or in ./bin; Installations of the dependencies are explained below.

****************************************************************
* fpc

The free Pascal compiler (freepascal.org) is required.
Install if needed the ubuntu fpc package
        sudo apt-get install fpc

****************************************************************
* gfortran

The GNU Fortran compiler is required to build the module smo
(general cross validated spline smoothing and interpolation).
It is available for major linux distro.

****************************************************************
* mtx09
A simple free Pascal matrix / array API: cf. ./src/mtx09
Download mtx09 module from svn repository into ./src directory (or some
other temporary workplace). fpc is needed to compile.
        cd ./src/mtx09
        make
        sudo make install
        cd -

Warning : fpc bug, wrong path value can be returned by mtx09 
installation... In this case, take the wrong path indicate 
during installation then go in the ./fpc/ folder and make a 
symbolic link between the bad path and the good directory.

****************************************************************
* ram3 / long3
A tool to calculate Long correction along with proper e.s.e. from
a raw file into a 3 cols. *.xy file which can be further processed
by the background, area calculation codes below. It also correct
some errors in the data file from the Raman spectrometer (negative counts
and ensures strict monotonous increase of the wavenumber).

Download ram3 from svn repository into ./src then
        cd ./src/ram3
        make
        sudo make install
        cd -

The code name is long3, read a short help using
        long3 -h
To apply Long's correction to a set of data files in ./raw directory
and get the long corrected files ( 3 cols ) in ./lng directory
one may use a command like this

mkdir lng
cd raw/
for f in *.dat do; long3 < $f > ../lng/${f%.*}.xy

The suffix .xy is required for the corrected files.

Then you may organise the data using symlinks, copying renaming etc...
or evaluate and prepare a table.txt using gx gui
TODO: step/step tutorial and some beginner/advanced guides for "gx".

****************************************************************
* gcv09 / smo

This command is provided by the package gcv09  which should be
in /usr/local/gcv09. If not build and install gcv09:
        cd ./src/gcv09
        make
        sudo make install
        cd -

WARNING: To build gcv09 one needs THE GNU FORTRAN
compiler "gfortran" ... install "gfortran" if needed using ubuntu
or other distro's package manager.

****************************************************************
* jog07 and ghostscript

jog is Jhack's own graphics in postscript:

First install ghostscript and ghostview (gv) using the distro's package
manager... if needed. hint: check gv command first.

Then install jog07 module if not already present (check /usr/local/jog07).
        cd ./src/jog07
        make
        sudo make install
        cd -

****************************************************************
* pdftk

A pdf manipulation tool used to bind into a single pdf document
a bunch of single page pdf figures (and more).

This may be the less commonly installed tool.
There is a ubuntu package with this tool:
        sudo apt-get install pdftk

****************************************************************
* epstopdf

A ghostcript based postscript to pdf converter.
This is part of TeX distributions and may be available on your system.
It is also available on ubuntu and all linux distro. For ubuntu for example, get it with:

		sudo apt-get install pdftk

********************************************************************************

TEST INSTALLATION

At this stage the software should be up and running. You may just enter
        make
and watch it perform the calculation and figures on the test data.
Check the pdf and the content of all subdirectories. NOTE that one
should NOT DELETE any of the subdirectories ! needed by the code as
working area.

You may restore a clean system using
        make distclean
to remove all results figures etc. and experiment with your own data.

********************************************************************************

USING THE SOFTWARE

-----------
0) Put the raw data into some working directory and use long3 to make
   Long's correction (./raw)
	see the help of long3 software if you want to change the
        temperature or the incident wavelength
-----------
1) Copy or link the Long corrected Raman spectra in the ./dat sub directory
   MANDATORY NAME CONVENTION suffix .xy such as ab1234.xy

-----------
2) Edit table.txt, may be starting from a spreadsheet and using cut/paste into
   table.txt, or with the help of the interactive graphic software gx
   which enable to perform all the calculation interactively. This may
   be needed to sort the data and figure out some sensible ROI's to define
   the smooth background. The present software is meant to provide a batch
   calculation to automatically process a large number of data files and
   generate a nice pdf report.

Each non-comment and non-empty line must be formatted as in the provided
example:

1st col: file name ommitting the .xy suffix
2d      : some short name to identify the nature of the sample
        albite, aoq and so on. I first had in mind to avoid typing in detail
        the zone to skip in the background smoothing operation ( -x option
        of smo command ; enter "smo -h" for details). This label will appear
        in the output figures along with other informations
3d      water weight %
4d      filter factor -f option of smo
5th     -x option of smo (along with -b option) to exclude zone to smooth
        and interpolate the background. NOTE: NO SPACES ! each excluded zone
        is given by the left and right boundary separated by a "," and zones
        are separated by ";". AGAIN NO SPACES ALLOWED !
        NOTE: table 3 list bkg zones whereas col 5 list the zone NOT belonging
        to the background.
6th     A composition group identifier. In the calbration curve all data
        of the same group are plotted with the same color. I suggest to use
        no more than 9 groups ...

NOTE: all file appearing in table.txt (1st col) must be found in ./dat folder;
but there may be other data files in ./dat which will be ignored if not
appearing in table.txt (or commented out with  # ibidem).

To run all the calculations and make all figures for the data listed in the
file table.txt one should just :

make

The file result.txt is a table duplicating table.txt with
the area ratio appearing in col. 4. This table can be used to plot the
calibration curve ( see calib.jog graphic file ).

The folder ./smo contain output tables constructed as: 1st column : independent variable; 
2nd : the baseline,  followings, 1st and 2nd derivative; and 5 column contain the background.
See smo help for more details.

The folder ./nrm contain the output table for each input data file appearing
in table.txt.

One can see the background suppressed output with gx using commands like:

        cd ./nrm
        COLY="1 2 3" gx ac8039

NOTE: currently gx is also a GUI to perform the same calculations, manually
selecting ROI's for the background (see smo -b option) along with the filter
factor used by smo -f option.

The ./fig folder contains the graphics in my own idiom (.jog). (use ge to
build an eps figure in this folder). NOTE: one may use File/Association of KDE,
so that a left-clic on a .jog file spawn "ge <this File>" and setup kate to use
postscript synstaxe highlighting for .jog files as well.

After this command one will get two pdf documents (several pages) fig1.pdf
and fig2.pdf showing the low and high frequency region respectively.
This process takes some time (about 1 sec/data file).

One also get the calibration curve in calib.eps and calib.pdf. Note that the
graphic layout is defined in calib.jog which should not be removed !

================================================================================
NOTES, TIPS and BUGS

FINAL installation note: THE directory structure MUST be preserved as
the script use all sub folders even though they appear empty at the end.

After the last line in the table.txt file, don't forget to ad another empty line. If not, the software crashes.

Use only plain caracters or numbers in table.txt (not _ for example), 
because Ghostscript don't work in that case...

If you encounter some issues with the graphics axes (too high or low), you can change their values in the rameau/bin/run2 script at lines 57 (for graphic 1, low wavenumbers) and 101 (for graphic 2, high wavenumber). Please make a copy before modifying the file, which is essential.

Some versions of ghostscript are known to have buggy bbox device.
This is a pain because it is needed to calculate the correct (hopefully)
bounding box to make clean eps and pdf figures. If updates of ghostscript
fail to fix this then you may comment line 50-54 and uncomment line 57 in
./bin/geps script to enforce a fixed safe Bounding Box and ignore the
faulty one.
================================================================================
