Auto-setup

From MCEWiki
Revision as of 16:34, 12 March 2012 by Mhasse (talk | contribs) (class config.configFile)

Overview

The python-based auto-setup provides a more modular, flexible approach to tuning than the previous IDL code. The actions of acquisition, analysis, and plotting have been carefully separated. The analysis code has been centralized to reduce code duplication. Objects have been introduced to manage the locations of data and outputs to improve flexibility. Tools are provided to assist with loading and analyzing existing tuning data.

Currently the python auto-setup still relies on scripts such as ramp_sa_bias and the mux_lock C programs to acquire the tuning data. Inside the python environment, data is loaded and manipulated as numpy arrays.


Obtaining python auto_setup

The python auto_setup is currently being developed and maintained in the trunk of mce_script. The py_auto_setup branch should no-longer be used, and is slated for termination.

Script-level support

Pass "-h" to any of the scripts below to get a usage message.

auto_setup

The executable script auto_setup can be used to tune SQUID arrays from the command line.

plot_tuning

The executable script plot_tuning can be used create plots from existing tuning data.


The "auto_setup" module

The following classes may be useful for off-line analysis of tuning data. Note that the *Ramp and *Servo classes all inherit from the RCData class, takes a slightly eccentric approach to indexing the data it contains.

class util.FileSet and

The FileSet class can be used to locate and group tuning data files, so that they can be more easily loaded as *Ramp and *Servo objects. Use like this:

import auto_setup as ast
tuning_dir = '/data/cryo/current_data/1234560000'
fs = ast.util.FileSet(tuning_dir)
for stage in ['sa_ramp', 'sq2_servo', 'sq1_servo', 'sq1_ramp']:
  print fs.stage_all(stage)

This will print out the data files associated with each tuning stage. They can be loaded and combined using a join method, e.g.:

sa_ramps = [SARamp(f) for f in fs.stage_all('sa_ramp')]  # individual ramps per RC
sa_ramp = SARamp.join(sa_ramps)                          # single, coherent ramp data object

Note that this join procedure isn't necessary if there is only one data file per squid stage (the default in modern python auto_setup). Older code acquired tuning data on each readout card individually; so the join procedure outlined should permit convenient loading of legacy data.


class SARamp

class SQ2Servo

class SQ1Servo

class SQ1Ramp

class RCData

This class stores time-ordered data for some set of detectors. Tuning data sets can be quite complex (consider a multi-bias, all-row SQ1 Servo for example) and so a certain convention has been adopted to indicate different structuring of the data. In all cases, the data themselves are stored in a 2-d numpy array, with the second index representing the time index and the first index encapsulating all other degrees of freedom (row, column, bias index,...). The underlying data shape is contained in the attribute data_shape. This is not to be confused with data.shape, which is the actual numpy dimensionality of the data array.

Form of data data_shape data.shape gridded rows cols
One time-stream per channel (n_row, n_col, n_time) (n_row*n_col, n_time) True list of rows (size n_row) list of columns (size n_col)
Multi-bias data; n_bias time-stream per channel (n_bias, n_row, n_col, n_time) (n_bias*n_row*n_col, n_time) True list of rows (size n_chan) list of columns (size n_chan)
One time stream for some set of row, column pairs (1, n_chan, n_time) (n_chan, n_time) False list of rows (size n_chan) list of columns (size n_chan)
Multi-bias data; for some set of row, column pairs (n_bias, 1, n_chan, n_time) (n_bias*n_chan, n_time) False list of rows (size n_chan) list of columns (size n_chan)

class config.configFile

This is a class for reading and modifying simple libconfig configuration files, such as experiment.cfg. The class extends the python "dict" class; keys from the configuration file become the keys of the dictionary. The class calls mas_param to decode the specified config file, including type information. Array data are stored as numpy arrays.

Typical usage in a script, to obtain access to experiment.cfg parameters, is done like this:

from auto_setup.config import configFile
cfg = configFile('/data/cryo/current_data/experiment.cfg')

print cfg['default_num_rows']
print cfg['sa_bias']

Output:

33
[42000 15000 16500 15000 15000 15000 15000 15000     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0     0
     0     0]

Updating values

There are two ways to update values in the target configuration file. The first is to use "set_param":

cfg.set_param('sa_bias', [65535] * 32)    # write 65535 to all 32 entries of SA bias

This will immediately update the target configuration file, with a single call to mas_param to set the 'sa_bias' key.

The second way may be more convenient when modifying a large number of parameters. One updates the dict with new values and then calls the .write() method:

cfg['sa_bias'] = [65535] * 32
cfg['sa_offset'] = [1000] * 32
cfg['sq2_bias'] = [0] * 32
cfg.write()

Note that cfg.write() will rewrite *all* of the keys, not just the ones you have changed. This will make it somewhat slower and potentially more confusing than using cfg.set_param. So you might just want to stick with set_param.