Example #1
0
 def getDetectors(self):
     '''
     :return: a list of detectors in the configuration
     
     '''
     logger.debug("Enter")
     detectors = self.root.find(self.DETECTORS)
     if detectors is None:
         raise DetectorConfigException("No detectors found in detector " + \
                                       "config file")
     logger.debug("Exit")
     return detectors
Example #2
0
 def __init__(self, filename, nameSpace):
     '''
     initialize the class and make sure the file seems to be valid XML
     '''
     logger.debug("Enter")
     self._initXmlConstants(nameSpace)
     try:
         tree = ET.parse(filename)
     except IOError as ex:
         raise DetectorConfigException("Bad Detector Configuration File" + \
                                       str(ex))
     self.root = tree.getroot()
     logger.debug("Exit")
Example #3
0
    def getDetectorById(self, identifier):
        '''
        return a particular by specifying it's ID 
        :param identifier: the id of the specified detector 
        :return: The requested detector
        '''
        logger.debug("Enter")
        try:
            dets = self.getDetectors().findall(self.DETECTOR)
        except AttributeError:
            raise DetectorConfigException("No detectors found in detector " + \
                                          "config file")
        logger.debug(str(dets))
        for detector in dets:
            detId = detector.find(self.DETECTOR_ID)
            logger.debug("getDetectorById id found - " +
                         str(self.getDetectorID(detector)))

            if detId.text == identifier:
                logger.debug("Exit")
                return detector
        logger.debug("Exit w Exception")
        raise DetectorConfigException("Detector " + str(identifier) +
                                      " not found in detector config file")
Example #4
0
 def getCenterChannelPixel(self, detector):
     '''
     Return a list with two elements specifying the location of the center
     pixel
     :param detector: specifies the detector who's return value is requested
     :return: The location of the detector's center pixel 
     ''' 
     logger.debug(METHOD_ENTER_STR)
     try:
         centerPix = detector.find(self.CENTER_CHANNEL_PIXEL).text
     except AttributeError:
         raise DetectorConfigException(self.CENTER_CHANNEL_PIXEL + 
                                       " not found in detector config " + \
                                       "file")
     vals = centerPix.split()
     logger.debug(METHOD_EXIT_STR + str([int(vals[0]), int(vals[1])]) )
     return [int(vals[0]), int(vals[1])]
Example #5
0
    def __init__(self, filename):
        '''
        Constructor
        :param filename: name of the XML file holding the detector geomery
        '''
        super(DetectorGeometryForXrayutilitiesReader, self).__init__(filename, nameSpace)
        logger.debug(METHOD_ENTER_STR)
#         self.DETECTORS = nameSpace + "Detectors"
#         self.DETECTOR = nameSpace + "Detector"
#         self.DETECTOR_ID = nameSpace + "ID"
        self.PIXEL_DIRECTION1 = nameSpace + 'pixelDirection1'
        self.PIXEL_DIRECTION2 = nameSpace + 'pixelDirection2'
        self.CENTER_CHANNEL_PIXEL = nameSpace + 'centerChannelPixel'
#         self.NUMBER_OF_PIXELS = nameSpace + 'Npixels'
#         self.DETECTOR_SIZE = nameSpace + 'size'
        self.DETECTOR_DISTANCE = nameSpace + 'distance'
        try:
            tree = ET.parse(filename)
        except IOError as ex:
            raise DetectorConfigException("Bad Detector Configuration File" + \
                                          str(ex))
        self.root = tree.getroot()
        logger.debug(METHOD_EXIT_STR)