PyDataSource/src/psana_doc_info.py

Go to the documentation of this file.
00001 import psana
00002 
00003 def get_unit_from_doc(doc):
00004     """Parse the unit from the doc string.
00005     """
00006     invalid_units = ['this', 'long', 'all', 'setup', 'given', 'a', 'the']
00007     try:
00008         usplit = doc.rsplit(' in ')
00009         if 'Value' in doc and 'converted to' in doc:
00010             unit = '{:}'.format(doc.rsplit('converted to ')[-1].rstrip('.'))
00011         elif len(usplit) < 2:
00012             unit = ''
00013         else:
00014             unit = '{:}'.format(usplit[-1])
00015             unit = unit.rstrip('.').rstrip(',').rsplit(' ')[0].rstrip('.').rstrip(',')
00016             
00017             if unit.endswith('(') or unit in invalid_units:
00018                 unit = ''
00019         
00020     except:
00021         unit = ''
00022     return unit
00023 
00024 def get_type_from_doc(doc):
00025     """Parse the type from the doc string.
00026     """
00027     try:
00028         return  doc.replace('\n',' ').split('-> ')[1].split(' ')[0]
00029     except:
00030         return None
00031 
00032 # create dictionary of psana method doc and unit information
00033 psana_omit_list = ['logging', 'os', 'setConfigFile', 'setOption', 'setOptions']
00034 psana_doc_info = {a: {} for a in dir(psana) if not a.startswith('_') \
00035               and not a.startswith('ndarray') and a not in psana_omit_list}
00036 psana_attrs = {a: {} for a in dir(psana) if not a.startswith('_') \
00037               and not a.startswith('ndarray') and a not in psana_omit_list}
00038 
00039 for mod_name in psana_doc_info:
00040     mod = getattr(psana,mod_name)
00041     psana_doc_info[mod_name] = {a: {} for a in dir(mod) if not a.startswith('_')}
00042     for typ_name in psana_doc_info[mod_name]:
00043         typ = getattr(mod, typ_name)
00044         psana_doc_info[mod_name][typ_name] = {a: {} for a in dir(typ) if not a.startswith('_') }
00045         # Default convention is that attributes have lower case.  
00046         # Configure exceptions below (e.g. Generic1D)
00047         psana_attrs[mod_name][typ_name] = [a for a in dir(typ) if not a.startswith('_') and not a[0].isupper() ]
00048         for attr in psana_doc_info[mod_name][typ_name]:
00049             if attr in ['TypeId','Version']:
00050                 info = {'doc': '', 'unit': '', 'type': ''}
00051             else:
00052                 func = getattr(typ, attr)
00053                 doc = func.__doc__
00054                 if doc:
00055                     doc = doc.split('\n')[-1].lstrip(' ')
00056                     if doc.startswith(attr):
00057                         doc = ''
00058 
00059                 info = {'doc': doc, 
00060                         'unit': get_unit_from_doc(func.__doc__), 
00061                         'type': get_type_from_doc(func.__doc__)}
00062             
00063             psana_doc_info[mod_name][typ_name][attr] = info 
00064 
00065 # Updates to psana_doc_info info
00066 psana_doc_info['Bld']['BldDataEBeamV7']['ebeamDumpCharge']['unit'] = 'e-'
00067 psana_doc_info['Bld']['BldDataFEEGasDetEnergyV1']['f_11_ENRC']['unit'] = 'mJ'
00068 psana_doc_info['Bld']['BldDataFEEGasDetEnergyV1']['f_12_ENRC']['unit'] = 'mJ'
00069 psana_doc_info['Bld']['BldDataFEEGasDetEnergyV1']['f_21_ENRC']['unit'] = 'mJ'
00070 psana_doc_info['Bld']['BldDataFEEGasDetEnergyV1']['f_22_ENRC']['unit'] = 'mJ'
00071 psana_doc_info['Bld']['BldDataFEEGasDetEnergyV1']['f_63_ENRC']['unit'] = 'mJ'
00072 psana_doc_info['Bld']['BldDataFEEGasDetEnergyV1']['f_64_ENRC']['unit'] = 'mJ'
00073 psana_doc_info['Acqiris']['DataDescV1Elem']['nbrSamplesInSeg']['unit'] = ''
00074 psana_doc_info['Acqiris']['ConfigV1']['channelMask']['func_method'] = bin 
00075 psana_doc_info['Acqiris']['HorizV1']['sampInterval']['unit'] = 'sec'
00076 psana_doc_info['Acqiris']['HorizV1']['delayTime']['unit'] = 'sec'
00077 psana_doc_info['Camera']['FrameFexConfigV1']['threshold']['unit'] = ''
00078 psana_doc_info['Quartz']['ConfigV2']['gain_percent']['unit'] = ''
00079 psana_doc_info['Quartz']['ConfigV2']['max_taps']['unit'] = ''
00080 psana_doc_info['Quartz']['ConfigV2']['output_resolution']['unit'] = ''
00081 
00082 psana_doc_info['Generic1D']['DataV0']['data_u16']['func_shape'] = 8
00083 psana_doc_info['Generic1D']['DataV0']['data_u32']['func0'] = 8     # offset
00084 psana_doc_info['Generic1D']['DataV0']['data_u32']['func_shape'] = 8
00085 
00086 psana_attrs['Generic1D']['ConfigV0'] = [
00087                                          'Depth',
00088                                          'Length',
00089                                          'NChannels',
00090                                          'Offset',
00091                                          'Period',
00092                                          'SampleType',
00093                                          'Sample_Type',
00094                                          'data_offset']
00095 
00096 
00097 # Common mode not applicable?
00098 #psana_doc_info['CsPad']['ElementV2']['common_mode']['func_quads'] = 'quads_shape'
00099 psana_doc_info['Acqiris']['DataDescV1Elem']['timestamp']['func_len'] = 'nbrSegments'
00100 psana_doc_info['Acqiris']['DataDescV1']['data']['func_shape'] = 'data_shape'
00101 psana_doc_info['Acqiris']['ConfigV1']['vert']['list_len'] = 'nbrChannels'
00102 
00103 psana_doc_info['CsPad']['DataV1']['quads']['func_shape'] = 'quads_shape'
00104 #psana_doc_info['CsPad']['DataV1']['quads']['func_dict_len'] = 'quads_shape'
00105 psana_doc_info['CsPad']['DataV2']['quads']['func_shape'] = 'quads_shape'
00106 #psana_doc_info['CsPad']['DataV2']['quads']['func_dict_len'] = 'quads_shape'
00107 psana_doc_info['CsPad']['ConfigV3']['quads']['func_shape'] = 'quads_shape'
00108 #psana_doc_info['CsPad']['ConfigV3']['quads']['func_dict_len'] = 'quads_shape'
00109 psana_doc_info['CsPad']['ConfigV3']['numAsicsStored']['func_len'] = 'numQuads'
00110 psana_doc_info['CsPad']['ConfigV3']['roiMask']['func_len_hex'] = 'numQuads'
00111 psana_doc_info['CsPad']['ConfigV3']['roiMasks']['func_method'] = hex
00112 psana_doc_info['CsPad']['ConfigV4']['quads']['func_shape'] = 'quads_shape'
00113 #psana_doc_info['CsPad']['ConfigV4']['quads']['func_dict_len'] = 'quads_shape'
00114 psana_doc_info['CsPad']['ConfigV4']['numAsicsStored']['func_len'] = 'numQuads'
00115 psana_doc_info['CsPad']['ConfigV4']['roiMask']['func_len_hex'] = 'numQuads'
00116 psana_doc_info['CsPad']['ConfigV4']['roiMasks']['func_method'] = hex
00117 psana_doc_info['CsPad']['ConfigV5']['quads']['func_shape'] = 'quads_shape'
00118 #psana_doc_info['CsPad']['ConfigV5']['quads']['func_dict_len'] = 'quads_shape'
00119 
00120 # see https://confluence.slac.stanford.edu/display/PCDS/Discussion+of+timing+the+cspad+variants
00121 
00122 psana_doc_info['CsPad']['ConfigV5']['numAsicsStored']['func_len'] = 'numQuads'
00123 psana_doc_info['CsPad']['ConfigV5']['asicMask']['func_method'] = hex
00124 psana_doc_info['CsPad']['ConfigV5']['badAsicMask0']['func_method'] = hex
00125 psana_doc_info['CsPad']['ConfigV5']['badAsicMask1']['func_method'] = hex
00126 psana_doc_info['CsPad']['ConfigV5']['concentratorVersion']['func_method'] = hex
00127 psana_doc_info['CsPad']['ConfigV5']['quadMask']['func_method'] = bin
00128 psana_doc_info['CsPad']['ConfigV5']['roiMask']['func_len_hex'] = 'numQuads'
00129 psana_doc_info['CsPad']['ConfigV5']['roiMasks']['func_method'] = hex
00130 psana_doc_info['CsPad']['ElementV2']['common_mode']['func_shape'] = 32
00131 psana_doc_info['CsPad']['ConfigV3QuadReg']['ampIdle']['func_method'] = hex
00132 psana_doc_info['CsPad']['ConfigV3QuadReg']['biasTuning']['func_method'] = hex
00133 psana_doc_info['CsPad']['ConfigV3QuadReg']['digCount']['func_method'] = hex
00134 psana_doc_info['CsPad']['ConfigV3QuadReg']['acqDelay']['unit'] = 'x8ns'
00135 psana_doc_info['CsPad']['ConfigV3QuadReg']['acqDelay']['doc'] = 'delay before acquisition (350 typical)'
00136 psana_doc_info['CsPad']['ConfigV3QuadReg']['digDelay']['unit'] = 'x8ns'
00137 psana_doc_info['CsPad']['ConfigV3QuadReg']['digDelay']['doc'] = 'hold delay before A to D conversion (1000 typical)'
00138 psana_doc_info['CsPad']['ConfigV3QuadReg']['digPeriod']['unit'] = 'x8ns'
00139 psana_doc_info['CsPad']['ConfigV3QuadReg']['digPeriod']['doc'] = 'digitiztion perios'
00140 psana_doc_info['CsPad']['ConfigV3QuadReg']['intTime']['unit'] = 'x8ns'
00141 psana_doc_info['CsPad']['ConfigV3QuadReg']['intTime']['doc'] = 'duration of the integration window (5000 typical)'
00142 psana_doc_info['CsPad']['ConfigV3QuadReg']['readClkHold']['doc'] = '(should be 1)'
00143 psana_doc_info['CsPad']['ConfigV3QuadReg']['readClkSet']['doc'] = '(should be 2)'
00144 psana_doc_info['CsPad']['ConfigV3QuadReg']['rowColShiftPer']['doc'] = '(should be 3)'
00145 psana_doc_info['CsPad']['ConfigV3QuadReg']['digCount']['doc'] = '(max = 0x3ff)'
00146 psana_doc_info['CsPad']['CsPadReadOnlyCfg']['version']['func_method'] = hex
00147 
00148 psana_doc_info['CsPad2x2']['ConfigV2']['concentratorVersion']['func_method'] = hex
00149 psana_doc_info['CsPad2x2']['ConfigV2']['asicMask']['func_method'] = hex
00150 psana_doc_info['CsPad2x2']['ConfigV2']['badAsicMask']['func_method'] = hex
00151 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['pdpmndnmBalance']['doc'] = '2 bits per nibble, bit order pd00pm00nd00nm'
00152 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['pdpmndnmBalance']['unit'] = ''
00153 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['acqDelay']['unit'] = 'x8ns'
00154 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['acqDelay']['doc'] = 'delay before acquisition (280 typical)'
00155 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['digDelay']['unit'] = 'x8ns'
00156 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['digDelay']['doc'] = 'hold delay before A to D conversion (960 typical)'
00157 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['digPeriod']['unit'] = 'x8ns'
00158 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['digPeriod']['doc'] = 'digitiztion perios'
00159 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['intTime']['unit'] = 'x8ns'
00160 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['intTime']['doc'] = 'duration of the integration window (5000 typical)'
00161 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['readClkHold']['doc'] = '(should be 1)'
00162 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['readClkSet']['doc'] = '(should be 1)'
00163 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['rowColShiftPer']['doc'] = '(should be 3)'
00164 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['digCount']['doc'] = '(max = 0x3ff)'
00165 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['ampIdle']['func_method'] = hex
00166 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['biasTuning']['func_method'] = hex
00167 psana_doc_info['CsPad2x2']['ConfigV2QuadReg']['digCount']['func_method'] = hex
00168 psana_doc_info['CsPad2x2']['CsPad2x2ReadOnlyCfg']['version']['func_method'] = hex
00169 psana_doc_info['CsPad2x2']['CsPad2x2ReadOnlyCfg']['shiftTest']['func_method'] = hex
00170 psana_doc_info['CsPad2x2']['ElementV1']['common_mode']['func_shape'] = 2
00171 
00172 psana_doc_info['UsdUsb']['FexConfigV1']['name']['func_shape'] = 4
00173 
00174 psana_doc_info['Ipimb']['ConfigV1']['capacitorValue']['func_index'] = 'capacitorValues'
00175 psana_doc_info['Ipimb']['ConfigV2']['capacitorValue']['func_index'] = 'capacitorValues'
00176 #Need to understand the diode scale and base arrays.
00177 #psana_doc_info['Ipimb']['ConfigV2']['diode']['func_len'] = 4
00178 
00179 

Generated on 19 Dec 2016 for PSDMSoftware by  doxygen 1.4.7