Example #1
0
def convertUnit(unitFrom, unitTo, xs, xErrs, legend):
    if unitTo is None: return None
    if unitFrom is None: return None

    unitFrom = unitFrom.replace('EV', 'eV')
    if 'PER-CENT' in unitFrom: unitFrom = 'PERCENT'
    elif 'no-dim' in unitFrom: unitFrom = ''
    elif 'DEG-K' in unitFrom: unitFrom = 'K'
    elif 'KeV' in unitFrom: unitFrom = 'keV'
    unit = unitFrom
    if ((unitFrom is not None) and (unitTo is not None)
            and (unitFrom != unitTo)):
        try:
            conversionFactor = PQU.valueOrPQ(1.0,
                                             unitFrom=unitFrom,
                                             unitTo=unitTo,
                                             asPQU=False)
        except TypeError, err:
            if legend is None: legend = "name suppressed"
            raise TypeError("In plot2d.convertUnit, " + err.message +
                            ', error from PQU: ' + unitFrom + ' -> ' + unitTo +
                            ' for dataset ' + str(legend))
        except NameError, err:
            if legend is None: legend = "name suppressed"
            raise NameError("In plot2d.convertUnit, " + err.message +
                            ', error from PQU: ' + unitFrom + ' -> ' + unitTo +
                            ' for dataset ' + str(legend))
Example #2
0
    def domainMax(self, unitTo=None, asPQU=False):

        return (PQU.valueOrPQ(self.functionals[-1].value,
                              unitFrom=self.getAxisUnitSafely(self.dimension),
                              unitTo=unitTo,
                              asPQU=asPQU))