示例#1
0
    def __loadxml__(cls, element, *args, **kwargs):
        child = element.find('baseoptions')
        if child is None:
            raise IOError, 'Base options missing'
        baseoptions = XMLIO.from_xml(list(child)[0])

        detector_key = element.get('detector_key')
        detector = baseoptions.detectors[detector_key]

        measurement = cls(baseoptions, detector)

        for child in element.iterfind('kratio'):
            val = float(child.get('val'))
            unc = float(child.get('unc'))

            grandchild = child.find('transition')
            if grandchild is None:
                raise IOError, 'kratio does not have a transition'
            transition = XMLIO.from_xml(list(grandchild)[0])

            grandchild = child.find('standard')
            if grandchild is None:
                raise IOError, 'kratio does not have a standard'
            standard = XMLIO.from_xml(list(grandchild)[0])

            measurement.add_kratio(transition, val, unc, standard)

        return measurement
示例#2
0
    def __loadxml__(cls, element, *args, **kwargs):
        child = element.find('baseoptions')
        if child is None:
            raise IOError, 'Base options missing'
        baseoptions = XMLIO.from_xml(list(child)[0])

        detector_key = element.get('detector_key')
        detector = baseoptions.detectors[detector_key]

        measurement = cls(baseoptions, detector)

        for child in element.iterfind('kratio'):
            val = float(child.get('val'))
            unc = float(child.get('unc'))

            grandchild = child.find('transition')
            if grandchild is None:
                raise IOError, 'kratio does not have a transition'
            transition = XMLIO.from_xml(list(grandchild)[0])

            grandchild = child.find('standard')
            if grandchild is None:
                raise IOError, 'kratio does not have a standard'
            standard = XMLIO.from_xml(list(grandchild)[0])

            measurement.add_kratio(transition, val, unc, standard)

        return measurement
示例#3
0
    def __loadxml__(cls, element, *args, **kwargs):
        # Options
        parent = element.find('options')
        if parent is None:
            raise IOError, 'No options defined.'
        child = list(parent)[0]
        ops = XMLIO.from_xml(child)

        # Unknown body
        bodies = list(ops.geometry.get_bodies())
        indexes = map(attrgetter('_index'), bodies)
        bodies_lookup = dict(zip(indexes, bodies))

        index = int(element.get('body'))
        unknown_body = bodies_lookup[index]

        # Detector
        parent = element.find('detector')
        if parent is None:
            raise IOError, 'No detector defined.'
        child = list(parent)[0]
        detector = XMLIO.from_xml(child)

        measurement = cls(ops, unknown_body, detector)

        # k-ratios
        parent = element.find('kratios')
        if parent is not None:
            for child in parent:
                val = float(child.get('val'))
                unc = float(child.get('unc', 0.0))

                grandchild = child.find('transition')
                if grandchild is None:
                    raise IOError, 'kratio does not have a transition'
                transition = XMLIO.from_xml(list(grandchild)[0])

                grandchild = child.find('standard')
                if grandchild is None:
                    raise IOError, 'kratio does not have a standard'
                standard = XMLIO.from_xml(list(grandchild)[0])

                measurement.add_kratio(transition, val, unc, standard)

        # Rules
        parent = element.find('rules')
        if parent is not None:
            for child in parent:
                rule = XMLIO.from_xml(child)
                measurement.add_rule(rule)

        return measurement
示例#4
0
    def __loadxml__(cls, element, *args, **kwargs):
        # Options
        parent = element.find('options')
        if parent is None:
            raise IOError, 'No options defined.'
        child = list(parent)[0]
        ops = XMLIO.from_xml(child)

        # Unknown body
        bodies = list(ops.geometry.get_bodies())
        indexes = map(attrgetter('_index'), bodies)
        bodies_lookup = dict(zip(indexes, bodies))

        index = int(element.get('body'))
        unknown_body = bodies_lookup[index]

        # Detector
        parent = element.find('detector')
        if parent is None:
            raise IOError, 'No detector defined.'
        child = list(parent)[0]
        detector = XMLIO.from_xml(child)

        measurement = cls(ops, unknown_body, detector)

        # k-ratios
        parent = element.find('kratios')
        if parent is not None:
            for child in parent:
                val = float(child.get('val'))
                unc = float(child.get('unc', 0.0))

                grandchild = child.find('transition')
                if grandchild is None:
                    raise IOError, 'kratio does not have a transition'
                transition = XMLIO.from_xml(list(grandchild)[0])

                grandchild = child.find('standard')
                if grandchild is None:
                    raise IOError, 'kratio does not have a standard'
                standard = XMLIO.from_xml(list(grandchild)[0])

                measurement.add_kratio(transition, val, unc, standard)

        # Rules
        parent = element.find('rules')
        if parent is not None:
            for child in parent:
                rule = XMLIO.from_xml(child)
                measurement.add_rule(rule)

        return measurement