pow method added

This commit is contained in:
Lukas Klass 2020-07-14 11:59:50 +02:00
parent 838b53318f
commit b3fb5197e9
2 changed files with 21 additions and 3 deletions

View File

@ -182,7 +182,7 @@ class SpectralQty:
Returns
-------
sum : SpectralQty
diff : SpectralQty
The difference of both objects
"""
# Subtrahend is of type int or float, use same unit
@ -228,7 +228,7 @@ class SpectralQty:
Returns
-------
sum : SpectralQty
prod : SpectralQty
The product of both objects
"""
# Factor is of type int, float or Quantity, just multiply
@ -270,7 +270,7 @@ class SpectralQty:
Returns
-------
sum : SpectralQty
quot : SpectralQty
The quotient of both objects
"""
# Factor is of type int, float or Quantity, just multiply
@ -297,6 +297,24 @@ class SpectralQty:
else:
logger.error("Units are not matching for division.")
def __pow__(self, other: Union[int, float]) -> "SpectralQty":
"""
Raise to spectral quantity to the given power.
Parameters
----------
other : Union[int, float]
The exponent for this object.
Returns
-------
prod : SpectralQty
The spectral quantity raised to the given power.
"""
# Factor is of type int, float or Quantity, just multiply
if isinstance(other, int) or isinstance(other, float):
return SpectralQty(self.wl, self.qty ** other)
def rebin(self, wl: u.Quantity) -> "SpectralQty":
"""
Resample the spectral quantity sqty(wl) over the new grid wl, rebinning if necessary, otherwise interpolates.