Using PlateMaker in the EM challenge¶
Origin: | $HeadURL: https://desi.lbl.gov/svn/code/online/PlateMaker/trunk/doc/calibproc.rst $ |
---|---|
Revision: | $Rev: 4907 $ |
Date: | $Date: 2016-06-08 16:13:50 -0500 (Wed, 08 Jun 2016) $ |
Author: | $Author: neilsen $ |
Preparing the test environment¶
Cleaning the working directory¶
The examples here assume a clean working directory, which needs to be set
by the data_dir
parameter in the PLATEMAKER
role definition in the
example platemaker.ini
file, found in $PLATEMAKER_DIR/etc
.
Make sure the parent directory exists:
>>> from os import mkdir
>>> try:
... mkdir('/tmp/test_platemaker_data')
... except FileExistsError:
... pass
but the test subdirectory does not. (PlateMaker
generates it
automatically.):
>>> from shutil import rmtree
>>> try:
... rmtree('/tmp/test_platemaker_data/52256')
... except FileNotFoundError:
... pass
Loading test input data¶
These examples require data to be provided to PlateMaker
. These
can be loaded from pickles
in the PlateMaker
product:
>>> from PlateMaker.PlateMakerTestData import PlateMakerTestData
>>> test_data = PlateMakerTestData('em2', 52256)
>>> seq_id = test_data.seq_id
>>> positioners = test_data.positioners
>>> merged_fvc_spots = test_data.merged_fvc_spots
Preparing to interact using PML¶
The architect with a PlateMaker
role needs to be up and running,
and the environment variables need to be set up so that the python
process can find it, for example with dos_env.csh
.
Then, start a python interactive process and establish a connection
to the PlateMaker
role:
>>> from DOSlib.PML import dos_connection
>>> pm = dos_connection('PLATEMAKER')
Running calibprep
¶
The first step in running calibprep
is to set the instrument. In
this example, I begin by setting parent directory for the instrument definition files:
>>> pm.execute('configure')
'SUCCESS'
>>> pm.execute('set', instrument_dir=test_data.instrument_dir)
'SUCCESS'
This value can also be set in the PlateMaker
section of the
architect configuration file; if it is set there, setting it as above
is unnecessary.
Once PlateMaker
is told where to look for instrument definitions,
tell it what instrument to use:
>>> pm.execute('set', instrument='em2')
'SUCCESS'
Now you can set the sequence id, seq_id
:
>>> pm.execute('set', seq_id=seq_id)
'SUCCESS'
calibprep
can be run thus:
>>> pm.execute('set', positioners=positioners)
'SUCCESS'
>>> pm.execute('calibprep')
'SUCCESS'
Note that the set
and the calibprep
executions can be combined
into a single call:
>>> pm.execute('calibprep', positioners=positioners)
'SUCCESS'
After calibprep
is run, the data can be retrieved thus:
>>> fiber_pos = pm.execute('get', 'fiber_pos')
Running calibproc
¶
calibproc
can be run thus:
>>> pm.execute('calibproc', positioners=positioners,
... merged_fvc_spots=merged_fvc_spots)
...
'SUCCESS'
Again, when run after prior commands which have provided the necessary data, the previously provided keywords may be omitted:
>>> pm.execute('calibproc', positioners=positioners, merged_fvc_spots=merged_fvc_spots)
'SUCCESS'
After calibproc
is run, the data can be retrieved thus:
>>> positioner_calib = pm.execute('get', 'positioner_calib')