calcNoise() renamed to calcBackground()

This commit is contained in:
Lukas Klass 2020-04-24 17:10:08 +02:00
parent 1d6c2b20c4
commit 17d7a12434
12 changed files with 36 additions and 37 deletions

View File

@ -66,27 +66,27 @@ class AOpticalComponent(IRadiant):
debug(signal)
return signal
def calcNoise(self) -> SpectralQty:
def calcBackground(self) -> SpectralQty:
"""
Calculate the spectral radiance of the target's noise
Calculate the spectral radiance of the background
Returns
-------
noise : SpectralQty
The spectral radiance of the target's noise
background : SpectralQty
The spectral radiance of the background
"""
parent = self.__parent.calcNoise()
parent = self.__parent.calcBackground()
info("Calculating Noise for class '" + self.__class__.__name__ + "'.")
parent = self._propagate(parent)
if self.__obstructor_temp > 0 * u.K:
bb = BlackBody(temperature=self.__obstructor_temp, scale=1. * u.W / (u.m ** 2 * u.nm * u.sr))
obstructor = bb(parent.wl) * self.__obstructor_emissivity
noise = parent * (1. - self.__obstruction) + obstructor * self.__obstruction
background = parent * (1. - self.__obstruction) + obstructor * self.__obstruction
else:
noise = parent * (1. - self.__obstruction)
noise = noise + self._ownNoise()
debug(noise)
return noise
background = parent * (1. - self.__obstruction)
background = background + self._ownNoise()
debug(background)
return background
def _propagate(self, rad: SpectralQty) -> SpectralQty:
"""

View File

@ -25,19 +25,19 @@ class ATarget(IRadiant):
self.__sfd = sfd
self.__wl_bins = wl_bins
def calcNoise(self) -> SpectralQty:
def calcBackground(self) -> SpectralQty:
"""
Calculate the spectral radiance of the target's noise
Calculate the spectral radiance of the target's background
Returns
-------
noise : SpectralQty
The spectral radiance of the target's noise
background : SpectralQty
The spectral radiance of the target's background
"""
info("Calculating Noise for class '" + self.__class__.__name__ + "'.")
noise = SpectralQty(self.__wl_bins, np.repeat(0, len(self.__wl_bins)) << u.W / (u.m**2 * u.nm * u.sr))
debug(noise)
return noise
background = SpectralQty(self.__wl_bins, np.repeat(0, len(self.__wl_bins)) << u.W / (u.m**2 * u.nm * u.sr))
debug(background)
return background
def calcSignal(self) -> SpectralQty:
"""

View File

@ -26,11 +26,11 @@ class TestAHotOpticalComponent(TestCase):
def test___init__(self):
comp = HotOpticalComponent(self.target, SpectralQty(self.wl, np.repeat(0.5, 4) << u.dimensionless_unscaled),
temp=300 * u.K)
self.assertEqual(comp.calcNoise(),
self.assertEqual(comp.calcBackground(),
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))
comp = HotOpticalComponent(self.target, "data/mirror/mirror_emissivity.csv", temp=300 * u.K)
self.assertEqual(comp.calcNoise(),
self.assertEqual(comp.calcBackground(),
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))

View File

@ -25,13 +25,13 @@ class TestAOpticalComponent(TestCase):
SpectralQty(self.wl, np.array([1.29074440e-17, 5.65909989e-18, 2.85372997e-18,
1.58973516e-18]) << u.W / (u.m ** 2 * u.nm)))
def test_calcNoise(self):
self.assertEqual(self.comp.calcNoise(),
def test_calcBackground(self):
self.assertEqual(self.comp.calcBackground(),
SpectralQty(self.wl, np.array([8.21976423e-05, 2.70268340e-04, 5.27503292e-04,
7.60597616e-04]) << u.W / (u.m ** 2 * u.nm * u.sr)))
comp = OpticalComponent(self.comp, SpectralQty(self.wl, np.repeat(0.5, 4) << u.dimensionless_unscaled),
SpectralQty(self.wl, np.repeat(0, 4) << u.W / (u.m ** 2 * u.nm * u.sr)),
obstruction=0.1, obstructor_temp=300 * u.K, obstructor_emissivity=1)
self.assertEqual(comp.calcNoise(),
self.assertEqual(comp.calcBackground(),
SpectralQty(self.wl, np.array([1.09186581e-04, 3.81889092e-04, 7.54879773e-04,
10.92866544e-04]) << u.W / (u.m ** 2 * u.nm * u.sr)))

View File

@ -16,8 +16,8 @@ class TestAtmosphere(TestCase):
np.array([1.10e-15, 1.20e-15, 1.30e-15, 1.26e-15, 1.20e-15, 1.12e-15, 1.02e-15,
0.9e-15, 0, 0]) << u.W / (u.m ** 2 * u.nm)))
def test_calcNoise(self):
self.assertEqual(self.atmosphere.calcNoise(),
def test_calcBackgrounde(self):
self.assertEqual(self.atmosphere.calcBackground(),
SpectralQty(np.arange(200, 208) << u.nm,
np.array([1.1e-16, 1.2e-16, 1.3e-16, 1.4e-16, 1.5e-16, 1.6e-16, 1.7e-16,
1.8e-16]) << u.W / (u.m ** 2 * u.nm * u.sr)))

View File

@ -15,7 +15,7 @@ class TestBeamSplitter(TestCase):
temp=300 * u.K)
def test___init__(self):
self.assertEqual(self.splitter.calcNoise(),
self.assertEqual(self.splitter.calcBackground(),
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))
self.assertEqual(self.splitter.calcSignal(),

View File

@ -14,7 +14,7 @@ class TestLens(TestCase):
self.lens = Lens(self.target, "data/lens/lens_transmittance.csv", 0.5, temp=300 * u.K)
def test___init__(self):
self.assertEqual(self.lens.calcNoise(),
self.assertEqual(self.lens.calcBackground(),
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))
self.assertEqual(self.lens.calcSignal(),

View File

@ -14,7 +14,7 @@ class TestMirror(TestCase):
self.mirror = Mirror(self.target, "data/mirror/mirror_reflectance.csv", 0.5, temp=300 * u.K)
def test___init__(self):
self.assertEqual(self.mirror.calcNoise(),
self.assertEqual(self.mirror.calcBackground(),
SpectralQty(self.wl, np.array([4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
1.33846280e-94]) << u.W / (u.m ** 2 * u.nm * u.sr)))
self.assertEqual(self.mirror.calcSignal(),

View File

@ -15,8 +15,8 @@ class TestStrayLight(TestCase):
1.6e-15, 1.7e-15, 1.8e-15, 1.9e-15,
2.0e-15]) << u.W / (u.m ** 2 * u.nm)))
def test_calcNoise(self):
self.assertEqual(self.zodiac.calcNoise(),
def test_calcBackground(self):
self.assertEqual(self.zodiac.calcBackground(),
SpectralQty(np.arange(200, 210) << u.nm, np.array([1.1e-16, 1.2e-16, 1.3e-16, 1.4e-16, 1.5e-16,
1.6e-16, 1.7e-16, 1.8e-16, 1.9e-16,
2.0e-16]) << u.W /

View File

@ -10,12 +10,11 @@ class TestBlackBodyTarget(TestCase):
self.target = BlackBodyTarget(wl_bins=np.arange(400, 800, 100) * u.nm,
temp=5778 * u.K, mag=10 * u.mag, band="U")
def test_signal(self):
def test_calcSignal(self):
signal = SpectralQty(np.arange(400, 800, 100) << u.nm, np.array([4.91164694e-15, 5.61732017e-15, 5.22403225e-15,
4.43017583e-15]) << u.W / (u.m ** 2 * u.nm))
print(self.target.calcSignal().qty)
self.assertEqual(self.target.calcSignal(), signal)
def test_noise(self):
def test_calcBackground(self):
noise = SpectralQty(np.arange(400, 800, 100) << u.nm, np.repeat(0, 4) << u.W / (u.m ** 2 * u.nm * u.sr))
self.assertEqual(self.target.calcNoise(), noise)
self.assertEqual(self.target.calcBackground(), noise)

View File

@ -9,12 +9,12 @@ class TestFileTarget(TestCase):
def setUp(self):
self.target = FileTarget("../data/target/target_demo_1.csv", np.arange(200, 210, 1) << u.nm)
def test_signal(self):
def test_calcSignal(self):
signal = SpectralQty(np.arange(200, 210, 1) << u.nm,
np.arange(1.1e-15, 2.0e-15, 1e-16) << u.W / (u.m ** 2 * u.nm))
self.assertTrue(self.target.calcSignal().__eq__(signal))
def test_noise(self):
def test_calcBackground(self):
noise = SpectralQty(np.arange(200, 210, 1) << u.nm,
np.repeat(0, 10) << u.W / (u.m ** 2 * u.nm * u.sr))
self.assertEqual(self.target.calcNoise(), noise)
self.assertEqual(self.target.calcBackground(), noise)

View File

@ -23,4 +23,4 @@ class TestRadiantFactory(TestCase):
parent_2 = oc.Lens(parent_2, "data/lens/transmittance.csv", "data/lens/emissivity.csv", 70 * u.K)
self.assertEqual(parent.calcSignal(), parent_2.calcSignal())
self.assertEqual(parent.calcNoise(), parent_2.calcNoise())
self.assertEqual(parent.calcBackground(), parent_2.calcBackground())