Updates the specified composition for the selected element. """ raise NotImplementedError class ElementByDifferenceRule(_CompositionRule): def update(self, composition): if self.z in composition: composition.pop(self.z) total = min(sum(composition.values()), 1.0) if total < 1.0: composition[self.z] = 1.0 - total XMLIO.register('{http://pymontecarlo.sf.net}elementByDifferenceRule', ElementByDifferenceRule) class FixedElementRule(_CompositionRule): """ Fixed weight fraction for an element. """ def __init__(self, z, wf): _CompositionRule.__init__(self, z) if wf <= 0.0 or wf > 1.0: raise ValueError, 'Weight fraction must be between ]0.0, 1.0]' self._wf = wf def __repr__(self): return '<%s(%i @ %s wt%%)>' % \
""" Creates the required options to simulate this measurement. :arg name: name of the options for this measurement :arg unkgeometry: geometry for the unknown """ options = copy.deepcopy(self._baseoptions) options.name = name options.geometry = unkgeometry return options def extract_unknown_intensities(self, results): """ Extracts the intensities from the simulation of the unknown of this measurements. Returns an array with the intensities. The value ordering and length of the array are equal to the one returned by :attr:`get_kratios`. :arg results: results for this measurement """ intensities = [] for transition in sorted(self._kratios.iterkeys()): val, _unc = results[self._detector_key].intensity(transition) intensities.append(val) return intensities XMLIO.register('{http://pymontecarlo.sf.net}measurement', Measurement)
def get_transitions(self): """ Returns a :class:`list` of all transitions where a k-ratio has been defined. """ return self._transitions.values() def get_kratios(self): """ Returns a :class:`dict` where the keys are atomic numbers and the values are tuples of the k-ratios and their uncertainties. """ return dict(self._kratios) # copy def get_standards(self): """ Returns a :class:`dict` where the keys are atomic numbers and the values are the geometry objects of the standards """ return dict(self._standards) # copy def get_rules(self): """ Returns a :class:`list` of all the defined rules. """ return self._rules.values() XMLIO.register('{http://pymontecarlo.sf.net}measurement', Measurement)
""" raise NotImplementedError class ElementByDifferenceRule(_CompositionRule): def update(self, composition): if self.z in composition: composition.pop(self.z) total = min(sum(composition.values()), 1.0) if total < 1.0: composition[self.z] = 1.0 - total XMLIO.register('{http://pymontecarlo.sf.net}elementByDifferenceRule', ElementByDifferenceRule) class FixedElementRule(_CompositionRule): """ Fixed weight fraction for an element. """ def __init__(self, z, wf): _CompositionRule.__init__(self, z) if wf <= 0.0 or wf > 1.0: raise ValueError, 'Weight fraction must be between ]0.0, 1.0]' self._wf = wf def __repr__(self): return '<%s(%i @ %s wt%%)>' % \