Table of Contents

Package PSCalib

Module PSCalib.CalibFileFinder

PSCalib.CalibFileFinder is a python version of CalibFileFinder.cpp - finds calibration file

Usage:

from PSCalib.CalibFileFinder import CalibFileFinder

cdir  = '/reg/d/psdm/CXI/cxi83714/calib/'
group = 'CsPad::CalibV1'   # optional parameter, if not available will be set for src from dict 
src   = 'CxiDs1.0:Cspad.0'
type  = 'pedestals'
rnum  = 137

cff = CalibFileFinder(cdir, group, pbits=0377)
#OR
cff = CalibFileFinder(cdir)
fname = cff.findCalibFile(src, type, rnum)

fname_new = cff.makeCalibFileName(src, type, run_start, run_end=None)

#-----------------------------------------------
# ALTERNATIVE usage of direct access methods

from PSCalib.CalibFileFinder import find_calib_file, make_calib_file_name

fname_existing = find_calib_file(cdir, src, type, rnum, pbits=1)
fname_new      = make_calib_file_name(cdir, src, type, run_start, run_end=None, pbits=1)

#-----------------------------------------------
# Deploy file or numpy array as a file in the calibration store

# use optional dictionary of comments to save in the HISTORY and file
arr = np.ones((32,185,388))
cmts = {'exp':'cxi12345', 'ifname':'input-file-name', 'app':'my-app-name', 'comment':'my-comment'}
deploy_calib_array(cdir, src, type, run_start, run_end, arr, cmts, fmt='%.1f', pbits=1)

cmts = {'exp':'cxi12345', 'app':'my-app-name', 'comment':'my-comment'}
ifname='path-to-my-own-calibtation-file/file-name.txt'
deploy_calib_file(cdir, src, type, run_start, run_end, ifnameq, cmts, pbits=1)

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 12322 $

Version: $Id: CalibFileFinder.py 8469 2014-06-24 22:55:21Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.CalibFileFinder.deploy_calib_array

PSCalib.CalibFileFinder.deploy_calib_array(cdir, src, type, run_start, run_end=None, arr=None, dcmts={}, fmt='%.1f', pbits=1)[source]

Deploys array in calibration file

  • makes the new file name using make_calib_file_name(...)
  • if file with this name already exists - rename it with current timestamp in the name
  • save array in file
  • add history record

Function PSCalib.CalibFileFinder.deploy_calib_file

PSCalib.CalibFileFinder.deploy_calib_file(cdir, src, type, run_start, run_end=None, ifname='', dcmts={}, pbits=1)[source]

Deploys calibration file

  • makes the new file name using make_calib_file_name(...)
  • if file with this name already exists - rename it with current timestamp in the name
  • save array in file
  • add history record

Function PSCalib.CalibFileFinder.find_calib_file

PSCalib.CalibFileFinder.find_calib_file(cdir, src, type, rnum, pbits=1)[source]

Function PSCalib.CalibFileFinder.make_calib_file_name

PSCalib.CalibFileFinder.make_calib_file_name(cdir, src, type, run_start, run_end=None, pbits=1)[source]

Function PSCalib.CalibFileFinder.test01

PSCalib.CalibFileFinder.test01()[source]

Function PSCalib.CalibFileFinder.test_deploy_calib_array

PSCalib.CalibFileFinder.test_deploy_calib_array()[source]

Function PSCalib.CalibFileFinder.test_deploy_calib_file

PSCalib.CalibFileFinder.test_deploy_calib_file()[source]

Module PSCalib.CalibPars

CalibPars - abstract interface for access to calibration parameters.

Methods of this class should be re-implemented in derived classes with name pattern CalibPars<Detector> for different type of detectore. For example, CSPAD can be implemented in class PSCalib.CalibParsCspadV1 which enherits from PSCalib.CalibPars, etc. Currently implementation of this interface for all detectors is done in class PSCalib.GenericCalibPars. Access to all detectors is available through the factory method in class PSCalib.CalibParsStore.

Usage of (implemented) interface methods:

from PSCalib.CalibPars import CalibPars
import PSCalib.GlobalUtils as gu

cp = CalibPars()
cp.print_attrs()

size = cp.pedestals()
size = cp.pixel_status()
size = cp.pixel_rms()
size = cp.pixel_gain()
size = cp.pixel_mask()
size = cp.pixel_bkgd()
size = cp.common_mode()

ctype = gu.PEDESTALS # ex.: gu.PIXEL_STATUS, gu.PIXEL_RMS, gu.PIXEL_MASK, etc.
size = cp.ndim(ctype)
size = cp.size(ctype)
size = cp.shape(ctype)
size = cp.status(ctype)

See also: GenericCalibPars, PSCalib.CalibParsStore

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10647 $

Version: $Id: CalibPars.py 10647 2015-09-09 15:20:25Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseAcqirisV1

CalibParsBaseAcqirisV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10630 $

Version: $Id: CalibParsBaseAcqirisV1.py 10630 2015-08-27 23:07:27Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseAndor3dV1

CalibParsBaseAndor3dV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 11400 $

Version: $Id: CalibParsBaseAndor3dV1.py 11400 2016-02-23 00:07:50Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseAndorV1

CalibParsBaseAndorV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10630 $

Version: $Id: CalibParsBaseAndorV1.py 10630 2015-08-27 23:07:27Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseCameraV1

CalibParsBaseCameraV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10630 $

Version: $Id: CalibParsBaseCameraV1.py 10630 2015-08-27 23:07:27Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseCSPad2x2V1

CalibParsBaseCSPad2x2V1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10630 $

Version: $Id: CalibParsBaseCSPad2x2V1.py 10630 2015-08-27 23:07:27Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseCSPadV1

CalibParsBaseCSPadV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10630 $

Version: $Id: CalibParsBaseCSPadV1.py 10630 2015-08-27 23:07:27Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseEpix100aV1

CalibParsBaseEpix100aV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 12703 $

Version: $Id: CalibParsBaseEpix100aV1.py 12703 2016-10-03 21:13:53Z cpo@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBaseImpV1

CalibParsBaseImpV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10699 $

Version: $Id: CalibParsBaseImpV1.py 10699 2015-09-18 18:52:52Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBasePnccdV1

CalibParsBasePnccdV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10647 $

Version: $Id: CalibParsBasePnccdV1.py 10647 2015-09-09 15:20:25Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsBasePrincetonV1

CalibParsBasePrincetonV1 - holds basic calibration metadata parameters for associated detector.

See also: PSCalib.CalibPars, PSCalib.CalibParsStore.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10630 $

Version: $Id: CalibParsBasePrincetonV1.py 10630 2015-08-27 23:07:27Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.CalibParsStore

PSCalib.CalibParsStore - is a factory class/method to switch between different device-dependent segments/sensors to access their pixel geometry uling PSCalib.SegGeometry interface.

Usage:

# Import
from PSCalib.CalibParsStore import cps
from PSCalib.GlobalUtils import *

# Initialization
calibdir = env.calibDir()  # or e.g. '/reg/d/psdm/<INS>/<experiment>/calib'
group = None               # or e.g. 'CsPad::CalibV1'
source = 'Camp.0:pnCCD.1'
runnum = 10                # or e.g. evt.run()
pbits = 255
o = cps.Create(calibdir, group, source, runnum, pbits)

# or using different list of parameters to access calibration from hdf5 DCS file:
o = cps.CreateForEvtEnv(self, calibdir, group, source, evt, env, pbits=0)

# Access methods
nda = o.pedestals()
nda = o.pixel_status()
nda = o.pixel_rms()
nda = o.pixel_mask()
nda = o.pixel_gain()
nda = o.pixel_bkgd()
nda = o.common_mode()

status = o.status(ctype=PEDESTALS) # see list of ctypes in :py:class:`PSCalib.GlobalUtils`
shape  = o.shape(ctype)
size   = o.size(ctype)
ndim   = o.ndim(ctype)
@see
PSCalib.GenericCalibPars PSCalib.GlobalUtils PSCalib.CalibPars PSCalib.CalibParsStore PSCalib.CalibParsBaseAndorV1 PSCalib.CalibParsBaseAndor3dV1 PSCalib.CalibParsBaseCameraV1 PSCalib.CalibParsBaseCSPad2x2V1 PSCalib.CalibParsBaseCSPadV1 PSCalib.CalibParsBaseEpix100aV1 PSCalib.CalibParsBasePnccdV1 PSCalib.CalibParsBasePrincetonV1 PSCalib.CalibParsBaseAcqirisV1 PSCalib.CalibParsBaseImpV1

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.CalibParsStore.print_nda

PSCalib.CalibParsStore.print_nda(nda, cmt='')[source]

Function PSCalib.CalibParsStore.test_cps

PSCalib.CalibParsStore.test_cps()[source]

Module PSCalib.DCBase

PSCalib.DCBase - base class for the Detector Calibration (DC) project.

Usage:

# Import
from PSCalib.DCBase import DCBase

o = DCBase()

# Dictionary of parameters
# ========================

o.set_pars_dict(d)                   # set (dict) dictionary of pars.
o.add_par(k,v)                       # add (k,v) par to the dictionary of pars.
o.del_par(k)                         # delete par with key k. 
o.clear_pars()                       # delete all pars from the dictionary.
d = o.pars_dict()                    # returns (dict) dictionary of pars.
p = o.par(k)                         # returns par value for key k.
t = o.pars_text()                    # returns (str) text of all pars.

# History records
# ===============

o.set_history_dict(d)                # set (dict) dictionary of history from specified dictionary
o.add_history_record(rec, tsec=None) # add (str) record with (int) time[sec] to the history dictionary of (tsec:rec).
                                     # If tsec is None - current time is used as a key.
o.del_history_record(tsec)           # Delete one history record from the dictionary by its time tsec.
o.clear_history()                    # Delete all history records from the dictionary.
d = o.history_dict()                 # returns (dict) history dictionary associated with current object .
r = o.history_record(tsec)           # returns (str) history record for specified time tsec.
t = o.history_text(tsfmt=None)       # returns (str) all history records preceded by the time stamp as a text.

# Save and Load
# =============

o.save_history_file(path='history.txt', verb=False) # save history in the text file
o.load_history_file(path='history.txt', verb=False) # load history from the text file

o.save_base(grp)                     # save everything in hdf5 group
o.load_base(name, grp)               # load from hdf5 group

# Time convertors
# ===============

t_str = o.tsec_to_tstr(tsec, tsfmt=None) # converts (float) time[sec] to the (str) time stamp
t_sec = o.tstr_to_tsec(tstr, tsfmt=None) # converts (str) time stamp to (float) time[sec]
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCBase.py 12879 2016-11-17 22:15:26Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class PSCalib.DCBase.DCBase

class PSCalib.DCBase.DCBase(cmt=None)[source]

Base class for the Detector Calibration (DC) project.

Parameters

cmt : str - string of comment associated with derived class object.

_load_hystory_dict(grp)[source]
_load_pars_dict(grp)[source]
_save_hystory_dict(grp)[source]

Saves _dichist in the h5py group

_save_pars_dict(grp)[source]

Saves _dicpars in the h5py group

add_history_record(rec, tsec=None)[source]
add_par(k, v)[source]
clear_history()[source]
clear_pars()[source]
del_history_record(k)[source]
del_par(k)[source]
group_name(grp)[source]
history_dict()[source]
history_record(tsec)[source]
history_text(tsfmt=None)[source]

Returns (str) history records preceded by the time stamp as a text

is_base_group(name, grp)[source]
load_base(name, grp)[source]
load_history_file(path='history.txt', verb=False)[source]

Load history from the text file

make_record(action='', key='', cmt=False)[source]

Returns string record combined with comment.

Parameters

action : str - description of method action, key : str - key for hdf5 group or dataset name, cmt : str/None/False - additional comment or no-comment: False is used to turn off history record, None - no-comment.

par(k)[source]
pars_dict()[source]
pars_text()[source]
print_base(offset=' ')[source]

Print content of dictionaries of parameters and history

save_base(grp)[source]
save_history_file(path='history.txt', verb=False)[source]

Save history in the text file

set_history_dict(d)[source]
set_pars_dict(d)[source]
tsec_to_tstr(tsec, tsfmt=None, addfsec=True)[source]

converts float tsec like 1471035078.908067 to the string 2016-08-12T13:51:18.908067

tstr_to_tsec(tstr, tsfmt=None)[source]

converts string tstr like 2016-08-12T13:51:18.908067 to the float time in seconds 1471035078.908067

_offspace = ' '
_tsfmt = '%Y-%m-%dT%H:%M:%S'

Function PSCalib.DCBase.test_history

PSCalib.DCBase.test_history()[source]

Function PSCalib.DCBase.test_make_record

PSCalib.DCBase.test_make_record()[source]

Function PSCalib.DCBase.test_time_converters

PSCalib.DCBase.test_time_converters()[source]

Module PSCalib.DCConfigParameters

DCConfigParameters - class supporting configuration parameters for application.

See also: base class CalibManager.ConfigParameters

See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id:DCConfigParameters.py 11923 2016-05-17 21:14:33Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.DCConfigParameters.test_DCConfigParameters

PSCalib.DCConfigParameters.test_DCConfigParameters()[source]

Module PSCalib.DCDetectorId

PSCalib.DCDetectorId - class for the Detector Calibration (DC) project.

Usage:

# Import
from PSCalib.DCDetectorId import id_epix, id_cspad

# Parameters
dsn = 'exp=cxif5315:run=169'
# or
dsn = '/reg/g/psdm/detector/data_test/types/0003-CxiDs2.0-Cspad.0-fiber-data.xtc'
ds = psana.DataSource(dsn)
env = ds.env()
src = psana.Source('CxiDs2.0:Cspad.0') # or unique portion of the name ':Cspad.' or alias 'DsaCsPad'

# Access methods
ide = id_epix(env, src)
idc = id_cspad(env, src)
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCDetectorId.py 12871 2016-11-14 22:19:31Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.DCDetectorId.do_test

PSCalib.DCDetectorId.do_test()[source]

Function PSCalib.DCDetectorId.id_cspad

PSCalib.DCDetectorId.id_cspad(env, src)[source]

Returns detector full name for any src, e.g., XppGon.0:Cspad2x2.0

Function PSCalib.DCDetectorId.id_det_noid

PSCalib.DCDetectorId.id_det_noid(env, src)[source]

Returns detector full name for any src, e.g., XppGon.0:Cspad2x2.0

Function PSCalib.DCDetectorId.id_epix

PSCalib.DCDetectorId.id_epix(env, src)[source]

Returns Epix100 Id as a string, e.g., 3925999616-0996663297-3791650826-1232098304-0953206283-2655595777-0520093719

Function PSCalib.DCDetectorId.test_id_cspad

PSCalib.DCDetectorId.test_id_cspad()[source]

Function PSCalib.DCDetectorId.test_id_epix

PSCalib.DCDetectorId.test_id_epix()[source]

Module PSCalib.DCEmail

PSCalib.DCEmail - class for Detector Calibration Store (DCS) project.

Usage:

# Import
from PSCalib.DCEmail import send_text_email

# Send message via e-mail
send_text_email(msg='Text message',               subject='Text subject',               email_from='do-not-reply@slac.stanford.edu',               email_to='do-not-send@slac.stanford.edu')
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCEmail.py 12660 2016-09-27 00:33:40Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.DCEmail.send_text_email

PSCalib.DCEmail.send_text_email(msg=None, subject=None, email_from=None, email_to=None)[source]

Sends e-mail.

Function PSCalib.DCEmail.test_send_text_email

PSCalib.DCEmail.test_send_text_email()[source]

Module PSCalib.DCFileName

PSCalib.DCFileName - file name object for Detector Calibration Store (DCS) project.

Usage:

# Import
from PSCalib.DCFileName import DCFileName

# Instatiation
o = DCFileName(env, 'Epix', calibdir='path-to/calib')
# Methods
o.set_dettype(env, src)
o.set_detid(env, src)
status = o.make_path_to_calib_file(mode=0770)

dt  = o.dettype()
did = o.detid()
dn  = o.detname()

fname = o.calib_file_name()      # e.g., epix100a-3925868555.h5
fdir  = o.calib_file_dir()       # e.g., /reg/neh/home4/dubrovin/LCLS/rel-calib/calib
fpath = o.calib_file_path()      # e.g., /reg/neh/home4/dubrovin/LCLS/rel-calib/calib/epix100a/epix100a-3925868555.h5
fdir  = o.calib_file_dir_repo()  # e.g., /reg/g/psdm/detector/calib/epix100a/
fpath = o.calib_file_path_repo() # e.g., /reg/g/psdm/detector/calib/epix100a/epix100a-3925868555.h5
o.print_attrs() # print attributes
o.log_attrs()  # dump attributes in the logger
s = o.str_attrs() # returns a string of attributes
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCFileName.py 12777 2016-10-19 21:37:38Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.DCFileName.test_DCFileName

PSCalib.DCFileName.test_DCFileName()[source]

Function PSCalib.DCFileName.test_make_path_to_calib_file

PSCalib.DCFileName.test_make_path_to_calib_file()[source]

Module PSCalib.DCInterface

PSCalib.DCInterface - abstract interface for the Detector Calibration (DC) project.

See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCInterface.py 12730 2016-10-11 21:11:56Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class PSCalib.DCInterface.DCRangeI

class PSCalib.DCInterface.DCRangeI(begin, end, cmt=None)[source]

Abstract interface class for the Detector Calibration (DC) project

o = DCRangeI(begin, end)

tsbegin = o.begin() # (int) time stamp beginning validity range tsend = o.end() # (int) time stamp ending validity range dico = o.versions() # (list of uint) versions of calibrations vnum = o.vnum_def() # (DCVersion ~ h5py.Group) reference to the default version in the time-range object vo = o.version(vers) # (DCVersion ~ h5py.Group) specified version in the time-range object bool = o.tsec_in_range(tsec) # (bool) True/False if tsec is/not in the validity range bool = o.evt_in_range(evt) # (bool) True/False if evt is/not in the validity range o.set_begin(tsbegin) # set (int) time stamp beginning validity range o.set_end(tsend) # set (int) time stamp ending validity range o.add_version(vers) # set (DCVersion ~ h5py.Group) versions of calibrations o.set_versdef(vers) # set (DCVersion ~ h5py.Group) versions of calibrations vnum = o.mark_version(vers) # del version o.mark_versions() # del all registered versions

add_version(cmt=None)[source]
begin()[source]
clear_versions()[source]
end()[source]
evt_in_range(evt)[source]
load(group)[source]
mark_version(vnum)[source]
mark_versions()[source]
print_obj()[source]
save(group)[source]
set_begin(begin)[source]
set_end(end)[source]
set_vnum_def(vnum)[source]
tsec_in_range(tsec)[source]
version(vnum)[source]
versions()[source]
vnum_def()[source]
vnum_last()[source]

Class PSCalib.DCInterface.DCStoreI

class PSCalib.DCInterface.DCStoreI(fname, cmt=None)[source]

Abstract interface class for the Detector Calibration (DC) project

cs = DCStoreI(fname)

tscfile = cs.tscfile() # (int) time stamp of the file creation dettype = cs.dettype() # (str) detector type detid = cs.detid() # (str) detector id detname = cs.detname() # (str) detector name of self object predecessor = cs.predecessor() # (str) detname of predecessor or None successor = cs.successor() # (str) detname of successor or None ctypes = cs.ctypes() # (list) calibration types in the file cto = cs.ctypeobj(ctype) # (DCType ~ h5py.Group) calibration type object

cs.set_tscfile(ts) # set (int) time stamp of the file creation cs.set_dettype(dettype) # set (str) detector type cs.set_detid(detid) # set (str) detector id cs.set_detname(detname) # set (str) detector name of self object cs.set_predecessor(pred) # set (str) detname of predecessor or None cs.set_successor(succ) # set (str) detname of successor or None cs.add_ctype(ctype) # add (str) calibration type to the DCStore object ct = cs.mark_ctype(ctype) # mark ctype (str) from the DCStore object, returns (str) ctype or None cs.mark_ctypes() # mark all ctypes from the DCStore object cs.clear_ctypes(ctype) # clear dictionary of ctypes in the DCStore object cs.save(path, mode) # save current calibration in the file specified by path, if path is Null - update current file. cs.load(path) # load content of the file in DCStore object

add_ctype(ctype, cmt=None)[source]
clear_ctypes()[source]
ctypeobj(ctype)[source]
ctypes()[source]
detid()[source]
detname()[source]
dettype()[source]
load(path)[source]
mark_ctype(ctype)[source]
mark_ctypes()[source]
predecessor()[source]
print_obj(offset)[source]
save(path)[source]
set_detid(detid)[source]
set_detname(detname)[source]
set_dettype(dettype)[source]
set_predecessor(pred)[source]
set_successor(succ)[source]
set_tscfile(ts)[source]
successor()[source]
tscfile()[source]

Class PSCalib.DCInterface.DCTypeI

class PSCalib.DCInterface.DCTypeI(ctype, cmt=None)[source]

Abstract interface class for the Detector Calibration (DC) project

cto = DCTypeI(type)

ctype = cto.ctype() # (str) of ctype name ranges = cto.ranges() # (list) of time ranges for ctype ro = cto.rangeobj(begin, end) # (DCRange ~ h5py.Group) time stamp validity range object ro = cto.range_for_tsec(tsec) # (DCRange) range object for time stamp in (double) sec ro = cto.range_for_evt(evt) # (DCRange) range object for psana.Evt object cto.add_range(tsr) # add (str) of time ranges for ctype keyr = cto.mark_range(begin, end) # mark range from the DCType object keyr = cto.mark_range_for_key(keyr) # mark range from the DCType object cto.mark_ranges(tsr) # mark all ranges from the DCType object cto.print_obj()

add_range(begin, end, cmt=None)[source]
clear_ranges()[source]
ctype()[source]
load(path)[source]
mark_range(begin, end)[source]
mark_range_for_key(k)[source]
mark_ranges()[source]
print_obj()[source]
range(begin, end)[source]
range_for_evt(evt)[source]
range_for_tsec(tsec)[source]
ranges()[source]
save(group)[source]

Class PSCalib.DCInterface.DCVersionI

class PSCalib.DCInterface.DCVersionI(vnum, tsprod=None, arr=None, cmt=None)[source]

Abstract interface class for the Detector Calibration (DC) project

o = DCVersionI(vnum, tsprod=None, arr=None)

o.set_vnum(vnum) # sets (int) version o.set_tsprod(tsprod) # sets (double) time stamp of the version production o.add_data(nda) # sets (np.array) calibration array vnum = o.vnum() # returns (int) version number s_vnum = o.str_vnum() # returns (str) version number tsvers = o.tsprod() # returns (double) time stamp of the version production nda = o.data() # returns (np.array) calibration array o.save(group) # saves object content under h5py.group in the hdf5 file. o.load(group) # loads object content from the h5py.group of hdf5 file.

add_data(nda)[source]
data()[source]
load(group)[source]
print_obj()[source]
save(group)[source]
set_tsprod(tsprod)[source]
set_vnum(vnum)[source]
str_vnum()[source]
tsprod()[source]
vnum()[source]

Function PSCalib.DCInterface.print_warning

PSCalib.DCInterface.print_warning(obj, metframe)[source]

Function PSCalib.DCInterface.test_DCRangeI

PSCalib.DCInterface.test_DCRangeI()[source]

Function PSCalib.DCInterface.test_DCStoreI

PSCalib.DCInterface.test_DCStoreI()[source]

Function PSCalib.DCInterface.test_DCTypeI

PSCalib.DCInterface.test_DCTypeI()[source]

Function PSCalib.DCInterface.test_DCVersionI

PSCalib.DCInterface.test_DCVersionI()[source]

Module PSCalib.DCLogger

DCLogger - logger for Detector Calibration Store.

See also: base class CalibManager.Logger

See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id:DCLogger.py 11923 2016-05-17 21:14:33Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.DCMethods

PSCalib.DCMethods - contains a set of utilities for direct operations with calibration data.

Usage:

# Import
import PSCalib.DCMethods as dcm

# Example of parameters

dsname  = 'exp=cxif5315:run=129'
# or:
dsname   = '/reg/g/psdm/detector/data_test/xtc/cxif5315-e545-r0169-s00-c00.xtc'
src      = 'Cspad.' # 'Epix100a.', etc
ctype    = gu.PIXEL_MASK # OR: gu.PEDESTALS, gu.PIXEL_STATUS, etc.
vers     = None # or e.g. 5
calibdir = None # or e.g. './calib'
nda      = np.zeros((32,185,388))
pred     = 'CxiDs2.0:Cspad.0'
succ     = 'CxiDs2.0:Cspad.0'
range    = '1474587520-end'

# Methods with dynamically-reconstruction of calib file name
dcm.add_constants(nda, evt, env, src, ctype, calibdir, vers=None, pred=None, succ=None, cmt=None)
dcm.print_content(env, src, calibdir=None)
nda = dcm.get_constants(evt, env, src, ctype, calibdir=None, vers=None, verb=False)
dcm.delete_version(evt, env, src, ctype, calibdir=None, vers=None, verb=False)
dcm.delete_range  (evt, env, src, ctype, calibdir, range, cmt, verb)
dcm.delete_ctype  (evt, env, src, ctype, calibdir, cmt, verb)

# Methods using fname
dcm.add_constants_to_file(data, fname, par, env, ctype, vers=None, pred=None, succ=None, cmt=None) 
dcm.print_content_from_file(fname)
nda = dcm.get_constants_from_file(fname, evt, ctype, vers=None, verb=False)
dcm.delete_version_from_file(fname, ctype, vers=None, cmt=None, verb=False)
dcm.delete_range_from_file  (fname, ctype, range, cmt, verb)
dcm.delete_ctype_from_file  (fname, ctype, cmt, verb)
See also: methods
add_constants(), add_constants_to_file(), print_content(), print_content_from_file(), get_constants(), get_constants_from_file(), delete_version(), delete_version_from_file(), delete_range(), delete_range_from_file(), delete_ctype() delete_ctype_from_file()
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: 2016-09-23$

Author: Mikhail S. Dubrovin

Function PSCalib.DCMethods.add_constants

PSCalib.DCMethods.add_constants(data, evt, env, src='Epix100a.', ctype=4, calibdir=None, vers=None, pred=None, succ=None, cmt=None, verb=False)[source]

Adds specified numpy array to the hdf5 file.

Parameters

data : numpy.array or str - array or string of calibration constants/data to save in file env : psana.Env -> full detector name for psana.Source evt : psana.Event -> event time src : str - source short/full name, alias or full ctype: gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK calibdir : str - fallback path to calib dir (if xtc file is copied - calib and experiment name are lost) vers : int - calibration version pred : str - predecessor name succ : str - successor name cmt : str - comment saved as a history record within DCRange verb : bool - verbosity, default=False - do not prnt any message

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.add_constants_to_file

PSCalib.DCMethods.add_constants_to_file(data, fname, par, env=None, ctype=4, vers=None, pred=None, succ=None, cmt=None, verb=False)[source]

Adds specified numpy array to the hdf5 file.

Parameters

data : numpy.array or str - array or string of calibration constants/data to save in file fname: full path to the hdf5 file par : psana.Event | float - tsec event time env : psana.Env -> full detector name for psana.Source ctype: gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK vers : int - calibration version pred : str - predecessor name succ : str - successor name cmt : str - comment saved as a history record within DCRange verb : bool - verbosity, default=False - do not prnt any message

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.delete_ctype

PSCalib.DCMethods.delete_ctype(evt, env, src='Epix100a.', ctype=4, calibdir=None, cmt=None, verb=False)[source]

Delete specified ctype from calibration constants.

Parameters

evt : psana.Event -> event time env : psana.Env -> full detector name for psana.Source src : str - source short/full name, alias or full ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK calibdir : str - fallback path to calib dir (if xtc file is copied - calib and experiment name are lost) cmt : str - comment verb : bool - verbousity

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.delete_ctype_from_file

PSCalib.DCMethods.delete_ctype_from_file(fname, ctype=4, cmt=None, verb=False)[source]

Delete specified ctype from calibration constants.

Parameters

fname : full path to the hdf5 file ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK cmt : str - comment verb : bool - verbousity

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.delete_range

PSCalib.DCMethods.delete_range(evt, env, src='Epix100a.', ctype=4, calibdir=None, range=None, cmt=None, verb=False)[source]

Delete specified time range from calibration constants.

Parameters

evt : psana.Event -> event time env : psana.Env -> full detector name for psana.Source src : str - source short/full name, alias or full ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK calibdir : str - fallback path to calib dir (if xtc file is copied - calib and experiment name are lost) range : str - range, e.g. ‘1474587520-end’ cmt : str - comment verb : bool - verbousity

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.delete_range_from_file

PSCalib.DCMethods.delete_range_from_file(fname, ctype=4, range=None, cmt=None, verb=False)[source]

Delete specified time range from calibration constants.

Parameters

fname : full path to the hdf5 file ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK range : str - range, e.g. ‘1474587520-end’ cmt : str - comment verb : bool - verbousity

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.delete_version

PSCalib.DCMethods.delete_version(evt, env, src='Epix100a.', ctype=4, calibdir=None, vers=None, cmt=None, verb=False)[source]

Delete specified version from calibration constants.

Parameters

evt : psana.Event -> event time env : psana.Env -> full detector name for psana.Source src : str - source short/full name, alias or full ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK calibdir : str - fallback path to calib dir (if xtc file is copied - calib and experiment name are lost) vers : int - calibration version cmt : str - comment verb : bool - verbousity

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.delete_version_from_file

PSCalib.DCMethods.delete_version_from_file(fname, par, ctype=4, vers=None, cmt=None, verb=False)[source]

Delete specified version from calibration constants.

Parameters

fname : full path to the hdf5 file par : psana.Event | float - tsec event time ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK vers : int - calibration version cmt : str - comment verb : bool - verbousity

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.evt_to_tsec

PSCalib.DCMethods.evt_to_tsec(par)[source]

Checks if par is float or assumes that it is psana.Event and returns event time in (float) sec or None. Parameters

par : psana.Event | float - tsec event time | None

Function PSCalib.DCMethods.get_constants

PSCalib.DCMethods.get_constants(par, env, src='Epix100a.', ctype=4, calibdir=None, vers=None, verb=False)[source]

Returns specified array of calibration constants.

Parameters

par : psana.Event | float - tsec event time env : psana.Env -> full detector name for psana.Source src : str - source short/full name, alias or full ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK calibdir : str - fallback path to calib dir (if xtc file is copied - calib and experiment name are lost) vers : int - calibration version

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.get_constants_from_file

PSCalib.DCMethods.get_constants_from_file(fname, par, ctype=4, vers=None, verb=False)[source]

Returns specified array of calibration constants.

Parameters

fname : full path to the hdf5 file par : psana.Event | float - tsec event time ctype : gu.CTYPE - enumerated calibration type, e.g.: gu.PIXEL_MASK vers : int - calibration version

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.get_constants_v0

PSCalib.DCMethods.get_constants_v0(*par, **opt)[source]

Function PSCalib.DCMethods.is_good_fname

PSCalib.DCMethods.is_good_fname(fname, verb=False)[source]

Checks the hdf5 file name parameter fname validity, returns True or False.

Parameters

fname : str - full path to the file

Function PSCalib.DCMethods.print_content

PSCalib.DCMethods.print_content(env, src='Epix100a.', calibdir=None)[source]

Defines the file name and prints file content.

Parameters

env : psana.Env -> full detector name for psana.Source src : str - source short/full name, alias or full calibdir : str - fallback path to calib dir (if xtc file is copied - calib and experiment name are lost)

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.print_content_from_file

PSCalib.DCMethods.print_content_from_file(fname)[source]

Prints content of the file.

Parameters

fname : str - full path to the file

Back to PSCalib.DCMethods

Function PSCalib.DCMethods.set_parameters

PSCalib.DCMethods.set_parameters()[source]

Function PSCalib.DCMethods.test_add_constants

PSCalib.DCMethods.test_add_constants()[source]

Function PSCalib.DCMethods.test_add_constants_to_file

PSCalib.DCMethods.test_add_constants_to_file()[source]

Function PSCalib.DCMethods.test_add_constants_two

PSCalib.DCMethods.test_add_constants_two()[source]

Function PSCalib.DCMethods.test_add_text

PSCalib.DCMethods.test_add_text()[source]

Function PSCalib.DCMethods.test_add_text_to_file

PSCalib.DCMethods.test_add_text_to_file()[source]

Function PSCalib.DCMethods.test_delete_ctype

PSCalib.DCMethods.test_delete_ctype()[source]

Function PSCalib.DCMethods.test_delete_ctype_from_file

PSCalib.DCMethods.test_delete_ctype_from_file()[source]

Function PSCalib.DCMethods.test_delete_range

PSCalib.DCMethods.test_delete_range()[source]

Function PSCalib.DCMethods.test_delete_range_from_file

PSCalib.DCMethods.test_delete_range_from_file()[source]

Function PSCalib.DCMethods.test_delete_version

PSCalib.DCMethods.test_delete_version()[source]

Function PSCalib.DCMethods.test_delete_version_from_file

PSCalib.DCMethods.test_delete_version_from_file()[source]

Function PSCalib.DCMethods.test_get_constants

PSCalib.DCMethods.test_get_constants()[source]

Function PSCalib.DCMethods.test_get_constants_from_file

PSCalib.DCMethods.test_get_constants_from_file()[source]

Function PSCalib.DCMethods.test_misc

PSCalib.DCMethods.test_misc()[source]

Function PSCalib.DCMethods.test_print_content

PSCalib.DCMethods.test_print_content()[source]

Function PSCalib.DCMethods.test_print_content_from_file

PSCalib.DCMethods.test_print_content_from_file()[source]

Module PSCalib.DCRange

PSCalib.DCRange - class for the Detector Calibration (DC) project.

Usage:

# Import
from PSCalib.DCRange import DCRange

# Initialization
o = DCRange(begin, end=None, cmt=None)

# Methods
str_range   = o.range()               # (str) of the time stamp validity range
t_sec       = o.begin()               # (double) time stamp beginning validity range
t_sec       = o.end()                 # (double) time stamp ending validity range or (str) 'end'
dico        = o.versions()            # (list of uint) versions of calibrations
v           = o.vnum_def()            # returns default version number
v           = o.vnum_last()           # returns last version number 
vo          = o.version(vnum=None)    # returns version object for specified version
ts_in_range = o.tsec_in_range(tsec)   # (bool) True/False if tsec is/not in the validity range
evt_in_range= o.evt_in_range(evt)     # (bool) True/False if evt is/not in the validity range
o.set_begin(tsbegin)                  # set (int) time stamp beginning validity range
o.set_end(tsend)                      # set (int) time stamp ending validity range
o.add_version(vnum=None, tsec_prod=None, nda=None, cmt=None) # add object for new version of calibration data
o.set_vnum_def(vnum=None)             # set default version number, if available. vnum=None - use last available.
vd = o.mark_version(vnum=None)        # mark version for deletion, returns version number or None if nothing was deleted
o.mark_versions()                     # mark all registered versions for deletion

o.save(group)                         # saves object content under h5py.group in the hdf5 file. 
o.load(group)                         # loads object content from the hdf5 file. 
o.print_obj()                         # print info about this object and its children
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCRange.py 12730 2016-10-11 21:11:56Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class PSCalib.DCRange.DCRange

class PSCalib.DCRange.DCRange(begin, end=None, cmt=None)[source]

Class for the Detector Calibration (DC) project

Parameters

begin : double - time in sec end : double - time in sec or None meaning infinity cmt : str - comment

add_version(vnum=None, tsec_prod=None, nda=None, cmt=False)[source]
begin()[source]
clear_versions()[source]
end()[source]
evt_in_range(evt)[source]
load(grp)[source]
mark_version(vnum=None, cmt=False)[source]

Marks child object for deletion in save()

mark_versions()[source]

Marks all child objects for deletion in save()

print_obj()[source]
range()[source]
save(group)[source]
set_begin(begin)[source]
set_end(end=None)[source]
set_str_range(str_range)[source]
set_vnum_def(vnum=None)[source]
tsec_in_range(tsec)[source]
version(vnum=None)[source]
versions()[source]
vnum_def()[source]
vnum_last()[source]

Function PSCalib.DCRange.key

PSCalib.DCRange.key(begin, end=None)[source]

Return range as a string, ex.: 1471285222-1471285555 or 1471285222-end from double time like 1471285222.123456

Function PSCalib.DCRange.test_DCRange

PSCalib.DCRange.test_DCRange()[source]

Module PSCalib.DCStore

PSCalib.DCStore class for the Detector Calibration (DC) project.

Usage:

# Import
from PSCalib.DCStore import DCStore

# Initialization
o = DCStore(fpath)

# Methods
tscfile     = o.tscfile()               # (double) time stamp of the file creation
dettype     = o.dettype()               # (str) detector type
detid       = o.detid()                 # (str) detector id
detname     = o.detname()               # (str) detector name of self object
predecessor = o.predecessor()           # (str) detname of predecessor or None
successor   = o.successor()             # (str) detname of successor or None
ctypes      = o.ctypes()                # (list) calibration types in the file
cto         = o.ctypeobj(ctype)         # (DCType ~ h5py.Group) calibration type object
o.set_tscfile(tsec)                     # set (double) time stamp of the file creation 
o.set_dettype(dettype)                  # set (str) detector type
o.set_detid(detid)                      # set (str) detector id
o.set_detname(detname)                  # set (str) detector name of self object
o.set_predecessor(pred)                 # set (str) detname of predecessor or None
o.set_successor(succ)                   # set (str) detname of successor or None
o.add_ctype(ctype)                      # add (str) calibration type to the DCStore object
ctype = o.mark_ctype(ctype)              # delete ctype (str) from the DCStore object, returns ctype or None
o.mark_ctypes()                          # delete all ctypes (str) from the DCStore object
o.clear_ctype()                         # clear all ctypes (str) from the DCStore object dictionary

o.save(group, mode='r+')                # saves object in hdf5 file. mode='r+'/'w' update/rewrite file.
o.load(group)                           # loads object content from the hdf5 file. 
o.print_obj()                           # print info about this object and its children
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCStore.py 12730 2016-10-11 21:11:56Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class PSCalib.DCStore.DCStore

class PSCalib.DCStore.DCStore(path, cmt=None)[source]

Class for the Detector Calibration (DC) project

Parameters

path : str - path to the hdf5 file with calibration info cmt : str - comment

_set_file_name(path)[source]
add_ctype(ctype, cmt=False)[source]
clear_ctypes()[source]
ctypeobj(ctype)[source]
ctypes()[source]
detid()[source]
detname()[source]
dettype()[source]
load(path=None)[source]
mark_ctype(ctype, cmt=False)[source]

Marks child object for deletion in save()

mark_ctypes()[source]

Marks all child objects for deletion in save()

predecessor()[source]
print_obj()[source]
save(path=None, mode='r+')[source]
set_detid(detid)[source]
set_detname(detname)[source]
set_dettype(dettype)[source]
set_predecessor(pred=None)[source]
set_successor(succ=None)[source]
set_tscfile(tsec=None)[source]
successor()[source]
tscfile()[source]

Function PSCalib.DCStore.print_warning

PSCalib.DCStore.print_warning(obj, metframe)[source]

Function PSCalib.DCStore.test_DCStore

PSCalib.DCStore.test_DCStore()[source]

Function PSCalib.DCStore.test_DCStore_load

PSCalib.DCStore.test_DCStore_load()[source]

Function PSCalib.DCStore.test_DCStore_load_and_save

PSCalib.DCStore.test_DCStore_load_and_save()[source]

Function PSCalib.DCStore.test_DCStore_save

PSCalib.DCStore.test_DCStore_save()[source]

Module PSCalib.DCType

PSCalib.DCType - class for the Detector Calibration (DC) project.

Usage:

# Import
from PSCalib.DCType import DCType

# Initialization
o = DCType(type)

# Methods
o.set_ctype(ctype)                 # add (str) of time ranges for ctype.
ctype  = o.ctype()                 # returns (str) of ctype name.
ranges = o.ranges()                # returns (dict) of time range objects.
range  = o.range(begin, end)       # returns time stamp validity range object.
ro     = o.range_for_tsec(tsec)    # (DCRange) range object for time stamp in (double) sec
ro     = o.range_for_evt(evt)      # (DCRange) range object for psana.Evt object 
o.add_range(begin, end)            # add (str) of time ranges for ctype.
kr = o.mark_range(begin, end)      # mark range from the DCType object, returns (str) key or None
kr = o.mark_range_for_key(keyrange)# mark range specified by (str) keyrange from the DCType object, returns (str) key or None
o.mark_ranges()                    # mark all ranges from the DCType object
o.clear_ranges()                   # delete all range objects from dictionary.

o.save(group)                      # saves object content under h5py.group in the hdf5 file.
o.load(group)                      # loads object content from the hdf5 file. 
o.print_obj()                      # print info about this object and its children
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCType.py 12730 2016-10-11 21:11:56Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class PSCalib.DCType.DCType

class PSCalib.DCType.DCType(ctype, cmt=None)[source]

Class for the Detector Calibration (DC) project

Parameters

ctype : gu.CTYPE - enumerated calibration type cmt : str - comment

add_range(begin, end=None, cmt=False)[source]
clear_ranges()[source]
ctype()[source]
load(grp)[source]
mark_range(begin, end=None)[source]

Marks child object for deletion in save()

mark_range_for_key(keyrng, cmt=False)[source]

Marks child object for deletion in save()

mark_ranges()[source]

Marks all child objects for deletion in save()

print_obj()[source]
range(begin, end=None)[source]
range_for_evt(evt)[source]

Return DCRange object from all available which range validity is matched to the evt time.

range_for_tsec(tsec)[source]

Return DCRange object from all available which range validity is matched to tsec.

ranges()[source]
save(group)[source]
set_ctype(ctype)[source]

Module PSCalib.DCUtils

PSCalib.DCUtils - contains a set of utilities

Usage:

# Import
import PSCalib.DCUtils as gu

# Methods
# Get string with time stamp, ex: 2016-01-26T10:40:53
ts    = gu.str_tstamp(fmt='%Y-%m-%dT%H:%M:%S', time_sec=None)

usr   = gu.get_enviroment(env='USER')
usr   = gu.get_login()
host  = gu.get_hostname()
cwd   = gu.get_cwd()
gu.create_directory(dir, mode=0775)
gu.create_path(path, depth=2, mode=0775)
gu.save_string_as_dset(grp, name, s)
src   = gu.source_full_name(env, src)
dtype = gu.dettype_from_str_source(src)

src   = gu.string_from_source(source) # source is psana.Source object or string like
                                      # 'CxiDs2.0:Cspad.0' from 'DetInfo(CxiDs2.0:Cspad.0)'
dname  = gu.detector_full_name(env, src)
source = gu.psana_source(env, srcpar)
t_sec  = gu.evt_time(evt)
fid    = gu.evt_fiducials(evt)

# methods for HDF5 
sg = gu.get_subgroup(grp, subgr_name)
gu.delete_object(grp, oname)
gu.save_object_as_dset(grp, name, shape=None, dtype=None, data=0)
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.DCUtils.create_directory

PSCalib.DCUtils.create_directory(dir, mode=509)[source]

Function PSCalib.DCUtils.create_directory_v0

PSCalib.DCUtils.create_directory_v0(dir, verb=False)[source]

Function PSCalib.DCUtils.create_path

PSCalib.DCUtils.create_path(path, depth=2, mode=509)[source]

Function PSCalib.DCUtils.delete_object

PSCalib.DCUtils.delete_object(grp, oname)[source]

For hdf5: removes object from group.

Function PSCalib.DCUtils.detector_full_name

PSCalib.DCUtils.detector_full_name(env, src)[source]

Returns full detector name like ‘XppGon.0:Cspad2x2.0’ for short src, alias src, or psana.Source.

Function PSCalib.DCUtils.dettype_from_str_source

PSCalib.DCUtils.dettype_from_str_source(src)[source]

Returns the detector type from full psana source name (Ex.: Cspad2x2 from DetInfo(XppGon.0:Cspad2x2.0)

Function PSCalib.DCUtils.evt_fiducials

PSCalib.DCUtils.evt_fiducials(evt)[source]

Returns event fiducials.

Function PSCalib.DCUtils.evt_time

PSCalib.DCUtils.evt_time(evt)[source]

Returns event (double) time.

Function PSCalib.DCUtils.get_cwd

PSCalib.DCUtils.get_cwd()[source]

Returns current working directory

Function PSCalib.DCUtils.get_enviroment

PSCalib.DCUtils.get_enviroment(env='USER')[source]

Returns the value of specified by string name environment variable

Function PSCalib.DCUtils.get_hostname

PSCalib.DCUtils.get_hostname()[source]

Returns login name

Function PSCalib.DCUtils.get_login

PSCalib.DCUtils.get_login()[source]

Returns login name

Function PSCalib.DCUtils.get_subgroup

PSCalib.DCUtils.get_subgroup(grp, subgr_name)[source]

For hdf5: returns subgroup of the group if it exists or creates and returns new subgroup

Function PSCalib.DCUtils.psana_source

PSCalib.DCUtils.psana_source(env, srcpar)[source]

returns psana.Source(src) from other psana.Source brief src or alias.

Parameters

srcpar : str - regular source or its alias, ex.: ‘XppEndstation.0:Rayonix.0’ or ‘rayonix’ set_sub : bool - default=True - propagates source parameter to low level package

Function PSCalib.DCUtils.save_object_as_dset

PSCalib.DCUtils.save_object_as_dset(grp, name, shape=None, dtype=None, data=0)[source]

Saves object as h5py dataset

Currently supports scalar int, double, string and numpy.array

Function PSCalib.DCUtils.save_string_as_dset

PSCalib.DCUtils.save_string_as_dset(grp, name, s)[source]

Creates and returns the h5py dataset object with name for single string s

Function PSCalib.DCUtils.source_full_name

PSCalib.DCUtils.source_full_name(env, src)[source]

Returns full name like ‘DetInfo(XppGon.0:Cspad2x2.0)’ of the brief source or its alias using env.configStore().keys()

Function PSCalib.DCUtils.string_from_source

PSCalib.DCUtils.string_from_source(source)[source]

Returns string like ‘CxiDs2.0:Cspad.0’ from ‘DetInfo(CxiDs2.0:Cspad.0)’ or ‘DsaCsPad’ from ‘Source(‘DsaCsPad’)’ form input string or psana.Source object

Function PSCalib.DCUtils.str_tstamp

PSCalib.DCUtils.str_tstamp(fmt='%Y-%m-%dT%H:%M:%S', time_sec=None)[source]

Returns string timestamp for specified format and time in sec or current time by default

Function PSCalib.DCUtils.test_detector_full_name

PSCalib.DCUtils.test_detector_full_name()[source]

Function PSCalib.DCUtils.test_evt_time

PSCalib.DCUtils.test_evt_time()[source]

Function PSCalib.DCUtils.test_psana_source

PSCalib.DCUtils.test_psana_source()[source]

Function PSCalib.DCUtils.test_source_full_name

PSCalib.DCUtils.test_source_full_name()[source]

Function PSCalib.DCUtils.test_string_from_source

PSCalib.DCUtils.test_string_from_source()[source]

Module PSCalib.DCVersion

PSCalib.DCVersion - class for the Detector Calibration (DC) project.

Usage:

# Import
from PSCalib.DCVersion import DCVersion

# Initialization
o = DCVersion(vnum, tsprod=None, arr=None, cmt=None)

# Methods
o.set_vnum(vnum)            # sets (int) version 
o.set_tsprod(tsprod)        # sets (double) time stamp of the version production
o.add_data(data)            # sets (str or np.array) calibration data
vnum   = o.vnum()           # returns (int) version number
s_vnum = o.str_vnum()       # returns (str) version number
tsvers = o.tsprod()         # returns (double) time stamp of the version production
data   = o.data()           # returns (np.array) calibration array
o.save(group)               # saves object content under h5py.group in the hdf5 file. 
o.load(group)               # loads object content from the h5py.group of hdf5 file. 
o.print_obj()               # print info about this object.

# and all methods inherited from PSCalib.DCBase
See also: project modules

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: DCVersion.py 12898 2016-11-22 19:27:56Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Class PSCalib.DCVersion.DCVersion

class PSCalib.DCVersion.DCVersion(vnum, tsprod=None, arr=None, cmt=None)[source]

Class for the Detector Calibration (DC) project

Parameters

vnum : int - version number

tsprod : double - time in sec

arr : numpy.array - array of constants to save

cmt : str - comment

add_data(data)[source]
data()[source]
load(grp)[source]
print_obj()[source]
save(group)[source]
set_tsprod(tsprod)[source]
set_vnum(vnum)[source]
str_vnum()[source]
tsprod()[source]
vnum()[source]

Function PSCalib.DCVersion.test_DCVersion

PSCalib.DCVersion.test_DCVersion()[source]

Function PSCalib.DCVersion.version_int_to_str

PSCalib.DCVersion.version_int_to_str(vnum)[source]

Function PSCalib.DCVersion.version_str_to_int

PSCalib.DCVersion.version_str_to_int(vstr)[source]

Module PSCalib.GenericCalibPars

GenericCalibPars - implementation of CalibPars interface methods for generic detectors.

Usage:

# THIS CLASS IS NOT SUPPOSED TO BE USED AS SELF-DEPENDENT...
# USE :py:class:`PSCalib.CalibParsStore`

from PSCalib.GenericCalibPars import GenericCalibPars

from PSCalib.CalibParsBaseAndorV1     import CalibParsBaseAndorV1    
from PSCalib.CalibParsBaseCameraV1    import CalibParsBaseCameraV1   
from PSCalib.CalibParsBaseCSPad2x2V1  import CalibParsBaseCSPad2x2V1 
...
from PSCalib.CalibParsBasePnccdV1     import CalibParsBasePnccdV1    

cbase = CalibParsBasePnccdV1()    

calibdir = '/reg/d/psdm/CXI/cxif5315/calib'
group    = 'PNCCD::CalibV1'
source   = 'CxiDs2.0:Cspad.0'
runnum   = 60
pbits    = 255
ctype    = gu.PEDESTALS

gcp = GenericCalibPars(cbase, calibdir, group, source, runnum, pbits)

nda = gcp.pedestals()
nda = gcp.pixel_rms()
nda = gcp.pixel_mask()
nda = gcp.pixel_bkgd()
nda = gcp.pixel_status()
nda = gcp.pixel_gain()
nda = gcp.common_mode()

status = gcp.get_status(ctype=PEDESTALS) # see  list of ctypes in :py:class:`PSCalib.GlobalUtils`
shape  = gcp.get_shape(ctype)
size   = gcp.get_size(ctype)
ndim   = gcp.get_ndim(ctype)

nda = gcp.set_version(vers=None)
nda = gcp.constants_default(ctype)
nda = gcp.constants_calib(ctype)
nda = gcp.constants_dcs(ctype, vers=None, verb=False)
nda = gcp.constants(ctype, vers=None, verb=False)

See also: PSCalib.CalibPars, PSCalib.CalibParsStore, PSCalib.CalibParsCspad2x1V1, :py:class:`PSCalib.GlobalUtils

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 12953 $

Version: $Id: GenericCalibPars.py 12953 2016-12-08 17:21:15Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Module PSCalib.GeometryAccess

GeometryAccess - holds and access hierarchical geometry for generic pixel detector

Usage:

from PSCalib.GeometryAccess import GeometryAccess, img_from_pixel_arrays

fname_geometry = '/reg/d/psdm/CXI/cxitut13/calib/CsPad::CalibV1/CxiDs1.0:Cspad.0/geometry/0-end.data'
geometry = GeometryAccess(fname_geometry, 0377)

# load constants from geometry file
geometry.load_pars_from_file(path=None)

# load constants from '
‘-separated str / text object

geometry.load_pars_from_str(s)

# check if geometry info is available, returns bool status = geometry.is_valid()

# get pixel coordinate [um] arrays X, Y, Z = geometry.get_pixel_coords(oname=None, oindex=0, do_tilt=True)

# get pixel x,y coordinate [um] arrays projected toward origin on specified zplane, if zplane=None then zplane=Z.mean() X, Y = geometry.get_pixel_xy_at_z(zplane=None, oname=None, oindex=0, do_tilt=True)

# print a portion of pixel X, Y, and Z coordinate arrays geometry.print_pixel_coords(oname=None, oindex=0)

# get pixel area array; A=1 for regular pixels, =2.5 for wide. area = geometry.get_pixel_areas(oname=None, oindex=0)

# returns (smallest) pixel size [um] pixel_size = geometry.get_pixel_scale_size(oname=None, oindex=0)

# returns dictionary of comments associated with geometry (file) dict_of_comments = geometry.get_dict_of_comments()

# print comments associated with geometry (file) geometry.print_comments_from_dict()

# print list of geometry objects geometry.print_list_of_geos()

# print list of geometry object children geometry.print_list_of_geos_children()

# get pixel mask array; # mbits = +1-mask edges, +2-wide pixels, +4-non-bonded pixels, +8/+16 - four/eight neighbours of non-bonded mask = geometry.get_pixel_mask(oname=None, oindex=0, mbits=0377)

# get index arrays for entire detector iX, iY = geometry.get_pixel_coord_indexes(do_tilt=True)

# get index arrays for specified quad with offset iX, iY = geometry.get_pixel_coord_indexes(‘QUAD:V1’, 1, pix_scale_size_um=None, xy0_off_pix=(1000,1000), do_tilt=True)

# get index arrays for pixel coordinates projected toward origin on specified zplane iX, iY = geometry.get_pixel_xy_inds_at_z(zplane=None, oname=None, oindex=0, pix_scale_size_um=None, xy0_off_pix=None, do_tilt=True)

# get ix and iy indexes for specified point in [um]. By default p_um=(0,0) - detector origin coordinates (center). ix, iy = geometry.point_coord_indexes(p_um=(0,0)) # all other parameters should be the same as in get_pixel_coord_indexes method ix, iy = geometry.point_coord_indexes(p_um=(0,0), ‘QUAD:V1’, 1, pix_scale_size_um=None, xy0_off_pix=(1000,1000), do_tilt=True)

# get 2-d image from index arrays img = img_from_pixel_arrays(iX,iY,W=arr)

# Get specified object of the class GeometryObject, all objects are kept in the list self.list_of_geos geo = geometry.get_geo(‘QUAD:V1’, 1) # Get top GeometryObject - the object which includes all other geometry objects geo = geometry.get_top_geo()

# modify currect geometry objects’ parameters geometry.set_geo_pars(‘QUAD:V1’, 1, x0, y0, z0, rot_z, rot_y, rot_x, tilt_z, tilt_y, tilt_x) geometry.move_geo(‘QUAD:V1’, 1, 10, 20, 0) geometry.tilt_geo(‘QUAD:V1’, 1, 0.01, 0, 0)

# save current geometry parameters in file geometry.save_pars_in_file(fname_geometry_new)

# change verbosity bit-control word; to print everythisg use pbits = 0xffff geometry.set_print_bits(pbits=0)

# return geometry parameters in “psf” format as a tuple psf[32][3][3] psf = geometry.get_psf() geometry.print_psf()

See also: PSCalib.GeometryObject, PSCalib.SegGeometry, PSCalib.SegGeometryCspad2x1V1, PSCalib.SegGeometryStore

For more detail see Detector Geometry.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

$Revision: 12898 $

Version: $Id: GeometryAccess.py 12898 2016-11-22 19:27:56Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.GeometryAccess.divide_protected

PSCalib.GeometryAccess.divide_protected(num, den, vsub_zero=0)[source]

Returns result of devision of numpy arrays num/den with substitution of value vsub_zero for zero den elements.

Function PSCalib.GeometryAccess.img_default

PSCalib.GeometryAccess.img_default(shape=(10, 10), dtype=<type 'numpy.float32'>)[source]

Returns default image

Function PSCalib.GeometryAccess.img_from_pixel_arrays

PSCalib.GeometryAccess.img_from_pixel_arrays(iX, iY, W=None, dtype=<type 'numpy.float32'>, vbase=0)[source]

Returns image from iX, iY coordinate index arrays and associated weights W.

Function PSCalib.GeometryAccess.test_access

PSCalib.GeometryAccess.test_access(geometry)[source]

Tests geometry acess methods of the class GeometryAccess

Function PSCalib.GeometryAccess.test_cspad2x2

PSCalib.GeometryAccess.test_cspad2x2()[source]

Test cspad2x2 geometry table

Function PSCalib.GeometryAccess.test_cspad_xy_at_z

PSCalib.GeometryAccess.test_cspad_xy_at_z()[source]

Test cspad geometry table

Function PSCalib.GeometryAccess.test_epix100a

PSCalib.GeometryAccess.test_epix100a()[source]

Test test_epix100a geometry table

Function PSCalib.GeometryAccess.test_img_default

PSCalib.GeometryAccess.test_img_default()[source]

Test default image

Function PSCalib.GeometryAccess.test_load_pars_from_file

PSCalib.GeometryAccess.test_load_pars_from_file(geometry)[source]

Test default image

Function PSCalib.GeometryAccess.test_mask_quad

PSCalib.GeometryAccess.test_mask_quad(geometry, mbits)[source]

Tests geometry acess methods of the class GeometryAccess object for CSPAD quad

Function PSCalib.GeometryAccess.test_plot_cspad

PSCalib.GeometryAccess.test_plot_cspad(geometry, fname_data, amp_range=(0, 0.5))[source]

The same test as previous, but use get_pixel_coord_indexes(...) method

Function PSCalib.GeometryAccess.test_plot_quad

PSCalib.GeometryAccess.test_plot_quad(geometry)[source]

Tests geometry acess methods of the class GeometryAccess object for CSPAD quad

Function PSCalib.GeometryAccess.test_save_pars_in_file

PSCalib.GeometryAccess.test_save_pars_in_file(geometry)[source]

Test default image

Module PSCalib.GeometryObject

PSCalib.GeometryObject - building block for hierarchical geometry

Usage:

# Methods of this class are used internally in PSCalib.GeometryAccess
# and are not supposed to be used directly...

from PSCalib.GeometryObject import GeometryObject

# Instatiation of the geometry object
# d = <dictionary-of-input-parameters>
geo = GeometryObject(**d)

# test print methods:
geo.print_geo()
geo.print_geo_children()

# modification methods:
geo.set_geo_pars(self, x0, y0, z0, rot_z, rot_y, rot_x, tilt_z, tilt_y, tilt_x)
geo.move_geo(dx, dy, dz)
geo.tilt_geo(dt_x, dt_y, dt_z)

# access methods:
s      = geo.str_data()
parent = geo.get_parent()
list_of_children = geo.get_list_of_children()
oname  = geo.get_geo_name()
oindex = geo.get_geo_index()
pname  = geo.get_parent_name()
pindex = geo.get_parent_index()
X,Y,Z  = geo.get_pixel_coords(do_tilt=true)
X,Y    = geo.get_2d_pixel_coords(do_tilt=true)
area   = geo.get_pixel_area()
#mbits = +1-edges, +2-wide pixels, +4-non-bonded pixels, +8/+16 - four/eight neighbours of non-bonded
mask   = geo.get_pixel_mask(mbits=0377)
npixels= geo.get_size_geo_array()
pixsize= geo.get_pixel_scale_size()
x0, y0, z0             = geo.get_origin()
rot_z, rot_y, rot_x    = geo.get_rot()
tilt_z, tilt_y, tilt_x = geo.get_tilt()

# private methods for internal consumption:
geo.set_parent(parent)
geo.add_child(child)
Xt, Yt, Zt = geo.transform_geo_coord_arrays(X, Y, Z, do_tilt=True)
Xt, Yt     = geo.transform_2d_geo_coord_arrays(X, Y, do_tilt=True)

# global methods:
Xrot, Yrot = rotation_cs(X, Y, C, S)
Xrot, Yrot = rotation(X, Y, angle_deg)

# global methods only for CSPAD2x2 array conversion between (2,185,388) and (185,388,2):
arrTwo2x1 = data2x2ToTwo2x1(asData2x2)
asData2x2 = two2x1ToData2x2(arrTwo2x1)

See also: PSCalib.GeometryAccess

For more detail see Detector Geometry.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

$Revision: 11946 $

Version: $Id: GeometryObject.py 11946 2016-05-19 00:29:37Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.GeometryObject.data2x2ToTwo2x1

PSCalib.GeometryObject.data2x2ToTwo2x1(arr2x2)[source]

Converts array shaped as CSPAD2x2 data (185,388,2) to two 2x1 arrays with shape=(2,185,388)

Function PSCalib.GeometryObject.rotation

PSCalib.GeometryObject.rotation(X, Y, angle_deg)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot rotated by angle_deg

Function PSCalib.GeometryObject.rotation_cs

PSCalib.GeometryObject.rotation_cs(X, Y, C, S)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot

Function PSCalib.GeometryObject.two2x1ToData2x2

PSCalib.GeometryObject.two2x1ToData2x2(arrTwo2x1)[source]

Converts array shaped as two 2x1 arrays (2,185,388) or (2*185,388) to CSPAD2x2 data shape=(185,388,2)

Module PSCalib.GlobalUtils

PSCalib.GlobalUtils - contains a set of utilities

Usage:

# Import
import PSCalib.GlobalUtils as gu

# Methods
#resp = gu.<method(pars)>

dettype = gu.det_type_from_source(source)
detname = gu.string_from_source(source)

mmask = gu.merge_masks(mask1=None, mask2=None, dtype=np.uint8)
mask  = gu.mask_neighbors(mask_in, allnbrs=True, dtype=np.uint8)

arr2d = gu.reshape_nda_to_2d(nda)
arr3d = gu.reshape_nda_to_3d(nda)

# Get string with time stamp, ex: 2016-01-26T10:40:53
ts    = gu.str_tstamp(fmt='%Y-%m-%dT%H:%M:%S', time_sec=None)

usr   = gu.get_enviroment(env='USER')
usr   = gu.get_login()
host  = gu.get_hostname()
cwd   = gu.get_cwd()

gu.save_textfile(text, path, mode='w') # mode: 'w'-write, 'a'-append 

See also: other interface methods in PSCalib.CalibPars, PSCalib.CalibParsStore

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.GlobalUtils.alias_for_src_name

PSCalib.GlobalUtils.alias_for_src_name(env)[source]

Function PSCalib.GlobalUtils.calib_dir

PSCalib.GlobalUtils.calib_dir(env)[source]

Function PSCalib.GlobalUtils.create_directory

PSCalib.GlobalUtils.create_directory(dir, verb=False)[source]

Function PSCalib.GlobalUtils.det_type_from_source

PSCalib.GlobalUtils.det_type_from_source(source)[source]

Returns enumerated detector type for string source

Function PSCalib.GlobalUtils.do_test

PSCalib.GlobalUtils.do_test()[source]

Function PSCalib.GlobalUtils.exp_name

PSCalib.GlobalUtils.exp_name(env)[source]

Function PSCalib.GlobalUtils.get_cwd

PSCalib.GlobalUtils.get_cwd()[source]

Returns current working directory

Function PSCalib.GlobalUtils.get_enviroment

PSCalib.GlobalUtils.get_enviroment(env='USER')[source]

Returns the value of specified by string name environment variable

Function PSCalib.GlobalUtils.get_hostname

PSCalib.GlobalUtils.get_hostname()[source]

Returns login name

Function PSCalib.GlobalUtils.get_login

PSCalib.GlobalUtils.get_login()[source]

Returns login name

Function PSCalib.GlobalUtils.load_textfile

PSCalib.GlobalUtils.load_textfile(path)[source]

Returns text file as a str object

Function PSCalib.GlobalUtils.mask_edges

PSCalib.GlobalUtils.mask_edges(mask, mrows=1, mcols=1, dtype=<type 'numpy.uint8'>)[source]

Return mask with a requested number of row and column pixels masked - set to 0. mask : int - n-dimensional (n>1) array with input mask mrows : int - number of edge rows to mask mcols : int - number of edge columns to mask

Function PSCalib.GlobalUtils.mask_neighbors

PSCalib.GlobalUtils.mask_neighbors(mask, allnbrs=True, dtype=<type 'numpy.uint8'>)[source]

Return mask with masked eight neighbor pixels around each 0-bad pixel in input mask.

mask : int - n-dimensional (n>1) array with input mask allnbrs : bool - False/True - masks 4/8 neighbor pixels.

Function PSCalib.GlobalUtils.merge_masks

PSCalib.GlobalUtils.merge_masks(mask1=None, mask2=None, dtype=<type 'numpy.uint8'>)[source]

Merging masks using np.logical_and rule: (0,1,0,1)^(0,0,1,1) = (0,0,0,1)

Function PSCalib.GlobalUtils.reshape_nda_to_2d

PSCalib.GlobalUtils.reshape_nda_to_2d(arr)[source]

Reshape np.array to 2-d

Function PSCalib.GlobalUtils.reshape_nda_to_3d

PSCalib.GlobalUtils.reshape_nda_to_3d(arr)[source]

Reshape np.array to 3-d

Function PSCalib.GlobalUtils.save_textfile

PSCalib.GlobalUtils.save_textfile(text, path, mode='w')[source]

Saves text in file specified by path. mode: ‘w’-write, ‘a’-append

Function PSCalib.GlobalUtils.shape_nda_to_2d

PSCalib.GlobalUtils.shape_nda_to_2d(arr)[source]

Return shape of np.array to reshape to 2-d

Function PSCalib.GlobalUtils.shape_nda_to_3d

PSCalib.GlobalUtils.shape_nda_to_3d(arr)[source]

Return shape of np.array to reshape to 3-d

Function PSCalib.GlobalUtils.string_from_source

PSCalib.GlobalUtils.string_from_source(source)[source]

Returns string like “CxiDs2.0:Cspad.0” from “Source(‘DetInfo(CxiDs2.0:Cspad.0)’)” or “Source(‘DsaCsPad’)”

Function PSCalib.GlobalUtils.str_tstamp

PSCalib.GlobalUtils.str_tstamp(fmt='%Y-%m-%dT%H:%M:%S', time_sec=None)[source]

Returns string timestamp for specified format and time in sec or current time by default

Function PSCalib.GlobalUtils.test_mask_edges_2d

PSCalib.GlobalUtils.test_mask_edges_2d(mrows=1, mcols=1)[source]

Function PSCalib.GlobalUtils.test_mask_edges_3d

PSCalib.GlobalUtils.test_mask_edges_3d(mrows=1, mcols=1)[source]

Function PSCalib.GlobalUtils.test_mask_neighbors_2d

PSCalib.GlobalUtils.test_mask_neighbors_2d(allnbrs=True)[source]

Function PSCalib.GlobalUtils.test_mask_neighbors_3d

PSCalib.GlobalUtils.test_mask_neighbors_3d(allnbrs=True)[source]

Module PSCalib.h5constants

Class PSCalib.h5constants.ConstantsLoad

class PSCalib.h5constants.ConstantsLoad(file)[source]
loadCallBack(name, obj)[source]

called back by h5py routine visititems for each item (group/dataset) in the h5 file

setval(name, obj)[source]

see if this hdfname has a / in it. if so, create the dictionary object. if not, set our attribute value. call ourselves recursively to see if other dictionary levels exist.

Class PSCalib.h5constants.ConstantsStore

class PSCalib.h5constants.ConstantsStore(obj, file)[source]
dict(d, name)[source]

called for every dictionary level to create a new hdf group name. it then looks into the dictionary to see if other groups need to be created

dispatch(obj, name)[source]

either persist a supported object, or look into a dictionary to see what objects need to be persisted

popdir()[source]

move up a level and keep track of what hdf directory level we are in

pushdir(dir)[source]

move down a level and keep track of what hdf directory level we are in

storevalue(v, name)[source]

persist one of the supported types to the hdf file

typeok(obj, name)[source]

check if we support serializing this type to hdf

Function PSCalib.h5constants.load

PSCalib.h5constants.load(file)[source]

takes a string filename, and returns a constants object.

Function PSCalib.h5constants.save

PSCalib.h5constants.save(file, obj)[source]

store a constants object in an hdf5 file. the object can be a hierarchy (defined by python dictionaries) and hdf5 supported types (int, float, numpy.ndarray, string). the hierarchy can be created by having one value of a dictionary itself be a dictionary.

Module PSCalib.NDArrIO

PSCalib.NDArrIO - i/o methods to read/write numpy array in the text file

Usage:

# Import
from PSCalib.NDArrIO import save_txt, load_txt, list_of_comments

# Save n-dimensional numpy array in the text file.
save_txt(fname, arr, cmts=(), fmt='%.1f')

# Load 1-, 2-, n-dimensional array (if metadata available) from file .
arr = load_txt(fname)    # this version unpacks data directly in this script
# or
arr = load_txt_v2(fname) # v2 uses numpy.loadtxt(...) to load data (~30% slower then the load_txt) 

# Get list of str objects - comment records with '#' in 1st position from file.
cmts = list_of_comments(fname)

#------------------------------
# Example of the file header:
#------------------------------
# TITLE      File to load ndarray of calibration parameters
# 
# EXPERIMENT amo12345
# DETECTOR   Camp.0:pnCCD.1
# CALIB_TYPE pedestals

# DATE_TIME  2014-05-06 15:24:10
# AUTHOR     <user-login-name>

# line of comment always begins with # 
# Mandatory fields to define the ndarray<TYPE,NDIM> and its shape as unsigned shape[NDIM] = (DIM1,DIM2,DIM3)
# DTYPE       float
# NDIM        3
# DIM:1       3
# DIM:2       4
# DIM:3       8
#------------------------------

See also: Detector.AreaDetector

For more detail see AreaDetector.

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

$Revision: 12322 $

Version: $Id: NDArrIO.py 12322 2016-07-21 23:10:51Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.NDArrIO.list_of_comments

PSCalib.NDArrIO.list_of_comments(fname)[source]

Returns list of str objects - comment records from file. - fname - file name for text file.

Function PSCalib.NDArrIO.load_txt

PSCalib.NDArrIO.load_txt(fname)[source]

Reads n-dimensional numpy array from text file with metadata. - fname - file name for text file.

Function PSCalib.NDArrIO.load_txt_v2

PSCalib.NDArrIO.load_txt_v2(fname)[source]

Reads n-dimensional numpy array from text file with metadata. - fname - file name for text file.

Function PSCalib.NDArrIO.save_txt

PSCalib.NDArrIO.save_txt(fname='nda.txt', arr=None, cmts=(), fmt='%.1f', verbos=False, addmetad=True)[source]

Save n-dimensional numpy array to text file with metadata. - fname - file name for text file, - arr - numpy array, - cmts -list of comments which will be saved in the file header.

Function PSCalib.NDArrIO.test_load_txt

PSCalib.NDArrIO.test_load_txt()[source]

Function PSCalib.NDArrIO.test_save_txt

PSCalib.NDArrIO.test_save_txt()[source]

Module PSCalib.SegGeometry

SegGeometry - abstract class with interface description.

Methods of this class should be re-implemented in derived classes with name pattern SegGeometry<SensorVers> for pixel geometry description of all sensors. For example, CSPAD 2x1 sensor is implemented in class PSCalib.SegGeometryCspad2x1V1. Access to all implemented sensors is available through the factory method in class PSCalib.SegGeometryStore.

Usage of interface methods:

from SegGeometryCspad2x1V1 import cspad2x1_one as sg

sg.print_seg_info(pbits=0377)
size_arr = sg.size()
rows     = sg.rows()
cols     = sg.cols()
shape    = sg.shape()
pix_size = sg.pixel_scale_size()
area     = sg.pixel_area_array()
mask     = sg.pixel_mask(mbits=0377)    
sizeX    = sg.pixel_size_array('X')
sizeX, sizeY, sizeZ = sg.pixel_size_array()
X        = sg.pixel_coord_array('X')
X,Y,Z    = sg.pixel_coord_array()
xmin = sg.pixel_coord_min('X')
ymax = sg.pixel_coord_max('Y')
xmin, ymin, zmin = sg.pixel_coord_min()
xmax, ymax, zmax = sg.pixel_coord_mas()
...
print 'X.shape =', X.shape

See also: PSCalib.SegGeometry, PSCalib.SegGeometryCspad2x1V1, PSCalib.SegGeometryStore

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Revision: $Revision: 10629 $

Version: $Id: SegGeometry.py 10629 2015-08-27 23:05:30Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhail S. Dubrovin

Function PSCalib.SegGeometry.rotation

PSCalib.SegGeometry.rotation(X, Y, C, S)[source]

For numpy arrays X and Y returns the numpy arrays of Xrot and Yrot

Module PSCalib.SegGeometryCspad2x1V1

Class PSCalib.SegGeometryCspad2x1V1 describes the CSPAD 2x1 V1 sensor geometry.

In this class we use natural matrix notations like in data array (that is different from the DAQ notations where rows and cols are swapped).

We assume that

  • 2x1 has 185 rows and 388 columns,
  • X-Y coordinate system origin is in the sensor center,
  • pixel (r,c)=(0,0) is in the top left corner of the matrix, has coordinates (xmin,ymax), as shown below
(Xmin,Ymax)      ^ Y          (Xmax,Ymax)
(0,0)            |            (0,387)
   ------------------------------
   |             |              |
   |             |              |
   |             |              |
 --|-------------+--------------|----> X
   |             |              |
   |             |              |
   |             |              |
   ------------------------------
(184,0)          |           (184,387)
(Xmin,Ymin)                  (Xmax,Ymin)

Usage of interface methods:

from SegGeometryCspad2x1V1 import cspad2x1_one as sg

sg.print_seg_info(0377)

size_arr = sg.size()
rows     = sg.rows()
cols     = sg.cols()
shape    = sg.shape()
pix_size = pixel_scale_size()

area  = sg.pixel_area_array()
mask = sg.pixel_mask_array(mbits=0377)
# where mbits = +1  - edges,
#               +2  - wide pixels,
#               +4  - non-bonded pixels,
#               +8  - nearest four neighbours of non-bonded
#               +16 - eight neighbours of non-bonded

sizeX = sg.pixel_size_array('X')
sizeX, sizeY, sizeZ = sg.pixel_size_array()

X     = sg.pixel_coord_array('X')
X,Y,Z = sg.pixel_coord_array()
print 'X.shape =', X.shape

xmin, ymin, zmin = sg.pixel_coord_min()
xmax, ymax, zmax = sg.pixel_coord_max()
xmin = sg.pixel_coord_min('X')
ymax = sg.pixel_coord_max('Y')

# global method for rotation of numpy arrays:
Xrot, Yrot = rotation(X, Y, C, S)
...

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

See also: PSCalib.SegGeometry

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.SegGeometryCspad2x1V1.test_2x1_img

PSCalib.SegGeometryCspad2x1V1.test_2x1_img()[source]

Function PSCalib.SegGeometryCspad2x1V1.test_2x1_img_easy

PSCalib.SegGeometryCspad2x1V1.test_2x1_img_easy()[source]

Function PSCalib.SegGeometryCspad2x1V1.test_2x1_mask

PSCalib.SegGeometryCspad2x1V1.test_2x1_mask(mbits=255)[source]

Function PSCalib.SegGeometryCspad2x1V1.test_pix_sizes

PSCalib.SegGeometryCspad2x1V1.test_pix_sizes()[source]

Function PSCalib.SegGeometryCspad2x1V1.test_xyz_maps

PSCalib.SegGeometryCspad2x1V1.test_xyz_maps()[source]

Function PSCalib.SegGeometryCspad2x1V1.test_xyz_min_max

PSCalib.SegGeometryCspad2x1V1.test_xyz_min_max()[source]

Module PSCalib.SegGeometryEpix100V1

Class PSCalib.SegGeometryEpix100V1 describes the Epix100 V1 sensor geometry.

In this class we use natural matrix notations like in data array

We assume that

  • 2x2 ASICs has 704 rows and 768 columns,
  • Epix100 has a pixel size 50x50um, wide pixel size 50x175um
  • Epix10k has a pixel size 100x100um,
  • X-Y coordinate system origin is in the sensor center,
  • pixel (r,c)=(0,0) is in the top left corner of the matrix, has coordinates (xmin,ymax), as shown below
(Xmin,Ymax)      ^ Y          (Xmax,Ymax)
(0,0)            |            (0,768)
   ------------------------------
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   |             |              |
 --|-------------+--------------|----> X
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   |             |              |
   ------------------------------
(704,0)          |           (704,768)
(Xmin,Ymin)                  (Xmax,Ymin)

Usage of interface methods:

from SegGeometryEpix100V1 import epix2x2_one as sg

sg.print_seg_info(0377)

size_arr = sg.size()
rows     = sg.rows()
cols     = sg.cols()
shape    = sg.shape()
pix_size = pixel_scale_size()

area     = sg.pixel_area_array()
mask     = sg.pixel_mask_array(mbits=0377)
# where mbits = +1-edges, +2-wide pixels

sizeX = sg.pixel_size_array('X')
sizeX, sizeY, sizeZ = sg.pixel_size_array()

X     = sg.pixel_coord_array('X')
X,Y,Z = sg.pixel_coord_array()
print 'X.shape =', X.shape

xmin, ymin, zmin = sg.pixel_coord_min()
xmax, ymax, zmax = sg.pixel_coord_max()
xmin = sg.pixel_coord_min('X')
ymax = sg.pixel_coord_max('Y')

# global method for rotation of numpy arrays:
Xrot, Yrot = rotation(X, Y, C, S)
...

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

See also: PSCalib.SegGeometry

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.SegGeometryEpix100V1.test_2x2_img

PSCalib.SegGeometryEpix100V1.test_2x2_img()[source]

Function PSCalib.SegGeometryEpix100V1.test_2x2_img_easy

PSCalib.SegGeometryEpix100V1.test_2x2_img_easy()[source]

Function PSCalib.SegGeometryEpix100V1.test_2x2_mask

PSCalib.SegGeometryEpix100V1.test_2x2_mask(mbits=255)[source]

Function PSCalib.SegGeometryEpix100V1.test_pix_sizes

PSCalib.SegGeometryEpix100V1.test_pix_sizes()[source]

Function PSCalib.SegGeometryEpix100V1.test_xyz_maps

PSCalib.SegGeometryEpix100V1.test_xyz_maps()[source]

Function PSCalib.SegGeometryEpix100V1.test_xyz_min_max

PSCalib.SegGeometryEpix100V1.test_xyz_min_max()[source]

Module PSCalib.SegGeometryMatrixV1

Class PSCalib.SegGeometryMatrixV1 defines the matrix V1 (pnCCD, 512x512) sensor pixel coordinates in its local frame.

Default constructor parameters are set for pnCCD; 512x512 pixels with 75x75um pixel size. In this class we use natural matrix notations like in data array (that is different from the DAQ notations where rows and cols are swapped).

We assume that

  • segment has 512 rows and 512 columns,
  • X-Y coordinate system origin is in the top left corner,
  • ixel (r,c)=(0,0) is in the top left corner of the matrix which has coordinates (Xmin,Ymin) - is in origin.
MatrixV1 sensor coordinate frame has a matrix-style coordinate system:

@code
  (Xmin,Ymin)        (Xmin,Ymax)
  (0,0)              (0,512)
     +-----------------+----> Y
     |                 |
     |                 |
     |                 |
     |                 |
     |                 |
     |                 |
     |                 |
     |                 |
     +-----------------+
     |
   X V
  (512,0)           (512,512)
  (Xmax,Ymin)       (Xmax,Ymax)
@endcode

Usage of interface methods:

from SegGeometryMatrixV1 import cspad2x1_one as sg

sg.print_seg_info(0377)

size_arr = sg.size()
rows     = sg.rows()
cols     = sg.cols()
shape    = sg.shape()
pix_size = pixel_scale_size()

area  = sg.pixel_area_array()
mask = sg.pixel_mask_array(mbits=0377)
# where mbits = +1-edges, +2-wide pixels, +4-non-bonded pixels, +8-neighbours of non-bonded

sizeX = sg.pixel_size_array('X')
sizeX, sizeY, sizeZ = sg.pixel_size_array()

X     = sg.pixel_coord_array('X')
X,Y,Z = sg.pixel_coord_array()
print 'X.shape =', X.shape

xmin, ymin, zmin = sg.pixel_coord_min()
xmax, ymax, zmax = sg.pixel_coord_max()
xmin = sg.pixel_coord_min('X')
ymax = sg.pixel_coord_max('Y')

# global method for rotation of numpy arrays:
Xrot, Yrot = rotation(X, Y, C, S)
...

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

See also: PSCalib.SegGeometry

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.SegGeometryMatrixV1.matrix_pars

PSCalib.SegGeometryMatrixV1.matrix_pars(segname)[source]

Returns the matrix sensor parameters from its string-name, ex: MTRX:512:512:54:54

Function PSCalib.SegGeometryMatrixV1.test_img

PSCalib.SegGeometryMatrixV1.test_img()[source]

Function PSCalib.SegGeometryMatrixV1.test_img_easy

PSCalib.SegGeometryMatrixV1.test_img_easy()[source]

Function PSCalib.SegGeometryMatrixV1.test_mask

PSCalib.SegGeometryMatrixV1.test_mask(mbits=255)[source]

Function PSCalib.SegGeometryMatrixV1.test_pix_sizes

PSCalib.SegGeometryMatrixV1.test_pix_sizes()[source]

Function PSCalib.SegGeometryMatrixV1.test_xyz_maps

PSCalib.SegGeometryMatrixV1.test_xyz_maps()[source]

Function PSCalib.SegGeometryMatrixV1.test_xyz_min_max

PSCalib.SegGeometryMatrixV1.test_xyz_min_max()[source]

Module PSCalib.SegGeometryStore

PSCalib.SegGeometryStore - is a factory class/method to switch between different device-dependent segments/sensors to access their pixel geometry uling PSCalib.SegGeometry interface.

Usage:

from PSCalib.SegGeometryStore import sgs

sg = sgs.Create('SENS2X1:V1', pbits=0377)
sg2= sgs.Create('EPIX100:V1', pbits=0377)
sg3= sgs.Create('PNCCD:V1',   pbits=0377)
sg4= sgs.Create('ANDOR3D:V1', pbits=0377)

sg.print_seg_info(pbits=0377)
size_arr = sg.size()
rows     = sg.rows()
cols     = sg.cols()
shape    = sg.shape()
pix_size = sg.pixel_scale_size()
area     = sg.pixel_area_array()
mask     = sg.pixel_mask(mbits=0377)    
sizeX    = sg.pixel_size_array('X')
sizeX, sizeY, sizeZ = sg.pixel_size_array()
X        = sg.pixel_coord_array('X')
X,Y,Z    = sg.pixel_coord_array()
xmin = sg.pixel_coord_min('X')
ymax = sg.pixel_coord_max('Y')
xmin, ymin, zmin = sg.pixel_coord_min()
xmax, ymax, zmax = sg.pixel_coord_mas()
...

See also: other interface methods in PSCalib.SegGeometry, PSCalib.SegGeometryCspad2x1V1

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: 2013-03-08$

Author: Mikhail S. Dubrovin

Function PSCalib.SegGeometryStore.test_seggeom

PSCalib.SegGeometryStore.test_seggeom()[source]

Module PSCalib.SvnProps

Class SvnProps stores updated by svn properties.

NOTE: To update revision number in this file when revision changes, use command: psvn mktxtprop src/SvnProps.py or svn propset svn:keywords “Revision” src/SvnProps.py Also see: ~/.subversion/config

This software was developed for the SIT project. If you use all or part of it, please give an appropriate acknowledgment.

Version: $Id: SvnProps.py 9205 2014-11-05 00:58:52Z dubrovin@SLAC.STANFORD.EDU $

Author: Mikhai S. Dubrovin