Other api/dybdbi/dybdbi

Previous topic

DybDbi

Next topic

DybDbi.Wrap

This Page

Daya Bay Links

Content Skeleton

DybDbiΒΆ

DybDbi python package provides access to most Dbi functionality, with generation of classes based on .spec files and wrapping of the python classes for easier usage, enabling access to model objects via:

from DybDbi import GCalibPmtSpec
from DybDbi import *

Example of introspecting the specification:

sk = GCalibPmtSpec.SpecKeys().aslist()    # list of row names
sk
  ['PmtId',
   'Describ',
   'Status',
  ...

sl = GCalibPmtSpec.SpecList().aslod()    # list of row maps ... list-of-dict 
sl
  [{'code2db': '',
    'codetype': 'int',
    'dbtype': 'int(11)',
    'description': '',
    'legacy': 'PMTID',
    'memb': 'm_pmtId',
    'name': 'PmtId'},
   ...

sm = GCalibPmtSpec.SpecMap().asdod()     # map of row maps, keyed by name    dict-of-dict
sm
      {'AfterPulseProb': {'code2db': '',
                          'codetype': 'double',
                          'dbtype': 'float',
                          'description': 'Probability of afterpulsing',
                          'legacy': 'PMTAFTERPULSE',
                          'memb': 'm_afterPulseProb',
                          'name': 'AfterPulseProb'},
    ...

sm['TimeOffset']['description']    # access any aspect of spec "matrix" directly by name
     'Relative transit time offset'


sk = cls.SpecKeys().aslist()
sm = cls.SpecMap().asdod()
for k in sk:
    print sm[k]