def _tag2pole_or_zero(paz_element, count): """ Parses sc3ml paz format Uncertainties on poles removed, not present in sc3ml.xsd? Always put to None so no internal conflict The sanitization removes the first/last parenthesis and split by comma, real part is 1st, imaginary 2nd :param paz_element: string of poles or zeros e.g. (12320, 23020) """ paz_element = paz_element[1:-1] paz_element = paz_element.split(",") real = float(paz_element[0]) imag = float(paz_element[1]) if real is not None or imag is not None: real = real or 0 imag = imag or 0 x = ComplexWithUncertainties(real, imag) x.upper_uncertainty = None x.upper_uncertainty = None x.number = count return x
def _tag2pole_or_zero(paz_element, count): """ Parses arclinkXML paz format Uncertainties on poles removed, not present in fo Always put to None so no internal conflict The sanitization removes the first/last parenthesis and split by comma, real part is 1st, imaginary 2nd :param paz_element: string of poles or zeros e.g. (12320, 23020) :param count: sequential numbering of poles/zeros """ paz_element = paz_element[1:-1] paz_element = paz_element.split(",") real = float(paz_element[0]) imag = float(paz_element[1]) if real is not None or imag is not None: real = real or 0 imag = imag or 0 x = ComplexWithUncertainties(real, imag) x.upper_uncertainty = None x.upper_uncertainty = None x.number = count return x
def _tag2pole_or_zero(element): real = _tag2obj(element, _ns("Real"), float) imag = _tag2obj(element, _ns("Imaginary"), float) if real is not None or imag is not None: real = real or 0 imag = imag or 0 x = ComplexWithUncertainties(real, imag) real = _attr2obj(element.find(_ns("Real")), "minusError", float) imag = _attr2obj(element.find(_ns("Imaginary")), "minusError", float) if any([value is not None for value in (real, imag)]): real = real or 0 imag = imag or 0 x.lower_uncertainty = complex(real, imag) real = _attr2obj(element.find(_ns("Real")), "plusError", float) imag = _attr2obj(element.find(_ns("Imaginary")), "plusError", float) if any([value is not None for value in (real, imag)]): real = real or 0 imag = imag or 0 x.upper_uncertainty = complex(real, imag) x.number = _attr2obj(element, "number", int) return x
def _tag2pole_or_zero(paz_element, count): """ Parses sc3ml poles and zeros Uncertainties on poles removed, not present in sc3ml.xsd? Always put to None so no internal conflict The sanitization removes the first/last parenthesis and split by comma, real part is 1st, imaginary 2nd :param paz_element: tuple of poles or zeros e.g. ('12320', '23020') """ real, imag = map(float, paz_element) if real is not None or imag is not None: real = real or 0 imag = imag or 0 x = ComplexWithUncertainties(real, imag) x.upper_uncertainty = None x.upper_uncertainty = None x.number = count return x