Python Scripted Calibration
===========================

First: do not run this on the Maxell gateway. Rather, `salloc`
a node for yourself first::

   salloc -p exfel/upex -t 01:00:00

where `-p` gives the partition to use: exfel or upex and `-t`
the duration the node should be allocated. Then `ssh` onto 
that node.

(optionally) Set up the environment::

   module load python3
   pip install --user ipython --upgrade
   pip install --user ipyparallel --upgrade
   pip install --user dill
   
If running headless (i.e. without X forwarding), be sure to set 
`MPLBACKEND=Agg`, via::

   export MPLBACKEND=Agg

Then start an `ipcluster`. If you followed the steps above this can be done
via::

   ~/.local/bin/ipcluster start --n=32


Run the script::

    python3 calibrate.py --input /gpfs/exfel/exp/SPB/201701/p002012/raw/r0100 \
       --output ../../test_out --mem-cells 30 --detector AGIPD --sequences 0,1   

Here `--input` should point to a directory of `RAW` files for the detector you
are calibrating. They will be output into the folder specified by `--output`, 
which will have the run number or the last folder in the hiearchy of the input
appended. Additionally, you need to specify the number of `--mem-cells` used
for the run, as well as the `--detector`. Finally, you can optionally 
specify to only process certain `--sequences` of files, matching the sequence
numbers of the `RAW` input. These should be given as a comma-separated list.

Finally, there is a `--no-relgain` option, which disables relative gain 
correction. This can be useful while we still further characterize the detectors
to provid accurate relative gain correction constants.

You'll get a series of plots in the output directory as well.