Phasor

class typhoon.types.phasors.Phasor(number=None, mag=None, angle=None)

Bases: complex

Class implement Phasors, which subclass complex numbers but adds:

  • Methods to easily get angle and magnitude

  • Nicer string representation in terms of magnitude and angle

Parameters:
  • number (complex) – Complex number for the phasor to be created.

  • mag (float) – Magnitude of phasor to be created, if number is not provided.

  • angle (float) – Angle in degrees of phasor to be created, if number is not provided

Raises:

ValueError if neither number or mag and angle arguments are provided.

Notes

Resulting Phasor is a complex number (subclass).

Examples

>>> from typhoon.types.phasors import Phasor
>>> ph1 = Phasor(1)
>>> assert ph1.mag == 1
>>> assert ph1.angle == 0
>>> ph1 = Phasor(1j)
>>> assert ph1.mag == 1
>>> assert ph1.angle == 90
>>> ph1 = Phasor(mag=10, angle=90)
>>> assert ph1 == approx(10j)

Attributes Summary

angle

Phasor angle, in degrees

mag

Phasor magnitude

Attributes Documentation

angle

Phasor angle, in degrees

mag

Phasor magnitude