Getting Started

  1. Get an account at the FACT data center at ISDC
  2. Setup your environment variables
  3. Checkout the pyfact software repository
  4. Try a few examples

2. Environment variables

set the following env variables depending on the SHELL you are using, for instance in .bashrc or .tcshrc

  • ROOTSYS: /swdev_nfs/root_v5.28.00

  • PATH: add $ROOTSYS/bin

  • PATH: add /swdev_nfs/FACT++

  • LD_LIBRARY_PATH: $ROOTSYS/lib:/swdev_nfs/FACT++/.libs

  • PYTHONPATH: $ROOTSYS/lib

  • PYTHONPATH: add all directories where python should search for modules. At least:
    • pyscripts/pyfact
    • pyscript/tools
    • pyscripts/ecamples
    • py

the absolute path depends on where you have checked (or will check) out the pyscripts repository

3. Check out the repository

svn co https://fact.isdc.unige.ch/svn/fact/tools/pyscripts/

4. Create pyfits library

FACT data are stored in (gzipped) fits files, but the data files are too large to be read by the default tool:

pyfits <http://www.stsci.edu/institute/software_hardware/pyfits>.

To mitigate this problem a C++ class defined in fits.h is used. A simple possibility to create an interface of this C++ class and python is to use the

pyroot http://root.cern.ch/drupal/category/package-context/pyroot> module.

simple:

[pceth118] /home/luster/py > root
ROOT 5.28/00h (branches/v5-28-00-patches@42209, Feb 13 2012, 23:52:00 on linux)
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L fits.h++
Info in <TUnixSystem::ACLiC>: creating shared library /home/luster/py/./fits_h.so
root [1]

5. Run examples

Classes

pyfact.py

rawdata access

class pyfact.RawData(data_file_name, calib_file_name, user_action_calib=<function <lambda> at 0xa818844>, baseline_file_name='', return_dict=None)

raw data access and calibration

  • open raw data file and drs calibration file
  • performs amplitude calibration
  • performs baseline substraction if wanted
  • provides all data in an array: row = number of pixel col = length of region of interest

initialize object

open data file and calibration data file get basic information about the data in data_file_name allocate buffers for data access

data_file_name : fits or fits.gz file of the data including the path calib_file_name : fits or fits.gz file containing DRS calibration data baseline_file_name : npy file containing the baseline values

baseline_correct()

subtract baseline from the data

baseline_read_values(file, bsl_hist='bsl_sum/hplt_mean')

open ROOT file with baseline histogram and read baseline values file name of the root file bsl_hist path to the histogram containing the basline values

board_times

time when the FAD was triggered, in some strange units...

calib_file

drs calibration file

calibrate_drs_amplitude()

perform the drs amplitude calibration of the event data

data

1D array with raw data

data_file

data file (fits object)

info()

print run information

nevents

number of events in the data run

next()

used by __iter__

next_event()

load the next event from disk and calibrate it

npix

number of pixels (should be 1440)

nroi

region of interest (number of DRS slices read)

start_cells

slice where drs readout started

fnames of a data run

class pyfact.fnames(specifier=['012', '023', '2011', '11', '24'], rpath='/scratch_nfs/res/bsl/', zipped=True)

organize file names of a FACT data run

specifier : list of strings defined as:
[ ‘DRS calibration file’, ‘Data file’, ‘YYYY’, ‘MM’, ‘DD’]

rpath : directory path for the results; YYYYMMDD will be appended to rpath zipped : use zipped (True) or unzipped (Data)

info()

print complete filenames

make(specifier, rpath, zipped)

create (make) the filenames

names : dictionary of filenames, tags { ‘data’, ‘drscal’, ‘results’ } data : name of the data file drscal : name of the drs calibration file results : radikal of file name(s) for results (to be completed by suffixes)