def initBackend(fname): lib = cal.loadLibrary(fname) backend = cal.loadBackend(lib) if not backend: raise Exception('unable to load %s' % fname) return backend
def init_adc_calibration_backend(self, adc_id): '''Initialize the backend which contains ADC calibration data. The data will be used to convert raw ADC values to voltages.''' backend = pycalibtic.loadBackend( pycalibtic.loadLibrary("libcalibtic_xml.so")) backend.init() self.adc_calib = pycalibtic.ADCCalibration() self.adc_calib.load(backend, adc_id)
def load_backend(path, ext): """ path: path to calibration files ext: extension of files aka backend type """ if ext == "xml": backend_type = "xml" elif ext == "dat": backend_type = "binary" elif ext == "txt": backend_type = "text" else: raise RuntimeError("no backend for extensions: {}".format(ext)) lib = pycalibtic.loadLibrary('libcalibtic_{}.so'.format(backend_type)) backend = pycalibtic.loadBackend(lib) backend.config('path', path) backend.init() return backend
def main(): parser = argparse.ArgumentParser() parser.add_argument('backend_path', type=str) args = parser.parse_args() lib = pycalibtic.loadLibrary('libcalibtic_xml.so') backend = pycalibtic.loadBackend(lib) backend.config('path', args.backend_path) backend.init() for calib in glob.glob('adc-*.xml'): print("*" * 80) adc = ADC(re.match(r'adc-([\w\d]+)\.xml', calib).group(1)) print(adc) calib = pycalibtic.ADCCalibration() meta = calib.load(backend, adc) qcalib = pycalibtic.ADCCalibration.convertToQuadraticADCCalibration(calib) print(meta) print(qcalib) pycalibtic.storeADCCalibration(backend, qcalib, meta, adc) meta = pycalibtic.MetaData() pycalibtic.loadADCCalibration(backend, meta, adc) print(meta) print(qcalib)