Create noise from wl_bins input parameter
This commit is contained in:
parent
e2f432137c
commit
2029d5230c
@ -11,7 +11,8 @@ class ATarget(IRadiant):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, sfd: SpectralQty):
|
||||
@u.quantity_input(wl_bins="length")
|
||||
def __init__(self, sfd: SpectralQty, wl_bins: u.Quantity):
|
||||
"""
|
||||
Initialize a new target
|
||||
|
||||
@ -21,6 +22,7 @@ class ATarget(IRadiant):
|
||||
The spectral flux density of the target
|
||||
"""
|
||||
self.__sfd = sfd
|
||||
self.__wl_bins = wl_bins
|
||||
|
||||
def calcNoise(self) -> SpectralQty:
|
||||
"""
|
||||
@ -31,7 +33,7 @@ class ATarget(IRadiant):
|
||||
noise : SpectralQty
|
||||
The spectral radiance of the target's noise
|
||||
"""
|
||||
return SpectralQty(self.__sfd.wl, np.repeat(0, len(self.__sfd.wl)) << u.W / (u.m**2 * u.nm * u.sr))
|
||||
return SpectralQty(self.__wl_bins, np.repeat(0, len(self.__wl_bins)) << u.W / (u.m**2 * u.nm * u.sr))
|
||||
|
||||
def calcSignal(self) -> SpectralQty:
|
||||
"""
|
||||
|
@ -53,4 +53,4 @@ class BlackBodyTarget(ATarget):
|
||||
sfd = bb(wl_bins) * factor * 10 ** (- 2 / 5 * mag / u.mag)
|
||||
|
||||
# Initialize super class
|
||||
super().__init__(SpectralQty(wl_bins, sfd))
|
||||
super().__init__(SpectralQty(wl_bins, sfd), wl_bins)
|
||||
|
@ -8,7 +8,8 @@ class FileTarget(ATarget):
|
||||
A class to create a target from a file containing the spectral flux densities
|
||||
"""
|
||||
|
||||
def __init__(self, file: str):
|
||||
@u.quantity_input(wl_bins="length")
|
||||
def __init__(self, file: str, wl_bins: u.Quantity):
|
||||
"""
|
||||
Initialize a new target from a file containing the spectral flux density values
|
||||
|
||||
@ -19,8 +20,10 @@ class FileTarget(ATarget):
|
||||
and the corresponding spectral flux density. The format of the file will be guessed by
|
||||
`astropy.io.ascii.read(). If the file doesn't provide units via astropy's enhanced CSV format, the units
|
||||
will be read from the column headers or otherwise assumed to be *nm* and *W / m^2 / nm*.
|
||||
wl_bins : length-Quantity
|
||||
Wavelengths used for binning
|
||||
"""
|
||||
# Create spectral quantity from file
|
||||
sfd = SpectralQty.fromFile(file, u.nm, u.W / (u.m ** 2 * u.nm))
|
||||
# Initialize the super class
|
||||
super().__init__(sfd)
|
||||
super().__init__(sfd, wl_bins)
|
||||
|
@ -7,7 +7,7 @@ import numpy as np
|
||||
|
||||
class TestFileTarget(TestCase):
|
||||
def setUp(self):
|
||||
self.target = FileTarget("../data/target/target_demo_1.csv")
|
||||
self.target = FileTarget("../data/target/target_demo_1.csv", np.arange(200, 210, 1) << u.nm)
|
||||
|
||||
def test_signal(self):
|
||||
signal = SpectralQty(np.arange(200, 210, 1) << u.nm,
|
||||
|
Loading…
x
Reference in New Issue
Block a user