use numpy array instead of list
This commit is contained in:
parent
b0d5d2593e
commit
62790e68de
@ -26,9 +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(), SpectralQty(self.wl, [4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
|
||||
1.33846280e-94] << u.W / (u.m ** 2 * u.nm * u.sr)))
|
||||
self.assertEqual(comp.calcNoise(),
|
||||
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(), SpectralQty(self.wl, [4.31413931e-96, 1.37122214e-95, 4.30844544e-95,
|
||||
1.33846280e-94] << u.W / (u.m ** 2 * u.nm * u.sr)))
|
||||
self.assertEqual(comp.calcNoise(),
|
||||
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)))
|
||||
|
@ -16,20 +16,22 @@ class TestAOpticalComponent(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.target = BlackBodyTarget(self.wl, temp=5778 * u.K, mag=10 * u.mag, band="U")
|
||||
self.comp = OpticalComponent(self.target, SpectralQty(self.wl, [0.5] * 4),
|
||||
SpectralQty(self.wl, [1e-5] * 4 << u.W / (u.m ** 2 * u.nm * u.sr)),
|
||||
self.comp = OpticalComponent(self.target, SpectralQty(self.wl, np.repeat(0.5, 4) << u.dimensionless_unscaled),
|
||||
SpectralQty(self.wl, np.repeat(1e-5, 4) << u.W / (u.m ** 2 * u.nm * u.sr)),
|
||||
obstruction=0.1, obstructor_temp=300 * u.K, obstructor_emissivity=1)
|
||||
|
||||
def test_calcSignal(self):
|
||||
self.assertEqual(self.comp.calcSignal(), SpectralQty(self.wl, [1.25575776e-17, 5.50570557e-18, 2.77637739e-18,
|
||||
1.54664415e-18] << u.W / (u.m ** 2 * u.nm)))
|
||||
self.assertEqual(self.comp.calcSignal(),
|
||||
SpectralQty(self.wl, np.array([1.25575776e-17, 5.50570557e-18, 2.77637739e-18,
|
||||
1.54664415e-18]) << u.W / (u.m ** 2 * u.nm)))
|
||||
|
||||
def test_calcNoise(self):
|
||||
self.assertEqual(self.comp.calcNoise(),
|
||||
SpectralQty(self.wl, [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, [0.5] * 4),
|
||||
SpectralQty(self.wl, [0] * 4 << u.W / (u.m ** 2 * u.nm * u.sr)),
|
||||
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(), SpectralQty(self.wl, [1.09186581e-04, 3.81889092e-04, 7.54879773e-04,
|
||||
10.92866544e-04] << u.W / (u.m ** 2 * u.nm * u.sr)))
|
||||
self.assertEqual(comp.calcNoise(),
|
||||
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)))
|
||||
|
@ -6,16 +6,18 @@ import astropy.units as u
|
||||
|
||||
class TestFilter(TestCase):
|
||||
def test_fromBand(self):
|
||||
wl = [400, 500, 501, 545, 589, 590, 600] << u.nm
|
||||
wl = np.array([400, 500, 501, 545, 589, 590, 600]) << u.nm
|
||||
target = BlackBodyTarget(wl, temp=5778 * u.K, mag=10 * u.mag, band="U")
|
||||
filt = Filter.fromBand(target, "V")
|
||||
self.assertEqual(filt.calcSignal(), SpectralQty(wl, [0.0, 0.0, 5.46516556e-15, 5.37748512e-15, 5.15313966e-15,
|
||||
0.0, 0.0] << u.W / (u.m ** 2 * u.nm)))
|
||||
self.assertEqual(filt.calcSignal(), SpectralQty(wl, np.array([0.0, 0.0, 5.46516556e-15, 5.37748512e-15,
|
||||
5.15313966e-15, 0.0, 0.0]) << u.W /
|
||||
(u.m ** 2 * u.nm)))
|
||||
|
||||
def test_fromFile(self):
|
||||
target = FileTarget("data/target/target_demo_1.csv", np.arange(200, 210, 1) << u.nm)
|
||||
filt = Filter.fromFile(target, "data/filter/filter_transmittance.csv")
|
||||
self.assertEqual(filt.calcSignal(), SpectralQty(np.arange(200, 210, 1) << u.nm,
|
||||
[1.10e-15, 1.20e-15, 1.30e-15, 1.40e-15, 1.35e-15, 1.44e-15,
|
||||
1.53e-15, 1.44e-15, 1.52e-15, 1.40e-15] << u.W / (
|
||||
u.m ** 2 * u.nm)))
|
||||
self.assertEqual(filt.calcSignal(),
|
||||
SpectralQty(np.arange(200, 210, 1) << u.nm, np.array([1.10e-15, 1.20e-15, 1.30e-15, 1.40e-15,
|
||||
1.35e-15, 1.44e-15, 1.53e-15, 1.44e-15,
|
||||
1.52e-15, 1.40e-15]) << u.W /
|
||||
(u.m ** 2 * u.nm)))
|
||||
|
@ -11,12 +11,13 @@ class TestStrayLight(TestCase):
|
||||
|
||||
def test_calcSignal(self):
|
||||
self.assertEqual(self.zodiac.calcSignal(),
|
||||
SpectralQty(np.arange(200, 210) << u.nm, [1.1e-15, 1.2e-15, 1.3e-15, 1.4e-15, 1.5e-15, 1.6e-15,
|
||||
1.7e-15, 1.8e-15, 1.9e-15, 2.0e-15] << u.W /
|
||||
(u.m ** 2 * u.nm)))
|
||||
SpectralQty(np.arange(200, 210) << u.nm, np.array([1.1e-15, 1.2e-15, 1.3e-15, 1.4e-15, 1.5e-15,
|
||||
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(),
|
||||
SpectralQty(np.arange(200, 210) << u.nm, [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 /
|
||||
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 /
|
||||
(u.m ** 2 * u.nm * u.sr)))
|
||||
|
@ -11,12 +11,10 @@ class TestBlackBodyTarget(TestCase):
|
||||
temp=5778 * u.K, mag=10 * u.mag, band="U")
|
||||
|
||||
def test_signal(self):
|
||||
signal = SpectralQty(np.arange(400, 800, 100) << u.nm,
|
||||
[4.77851291e-15, 5.46505832e-15, 5.08243077e-15,
|
||||
4.31009246e-15] << u.W / (u.m ** 2 * u.nm))
|
||||
signal = SpectralQty(np.arange(400, 800, 100) << u.nm, np.array([4.77851291e-15, 5.46505832e-15, 5.08243077e-15,
|
||||
4.31009246e-15]) << u.W / (u.m ** 2 * u.nm))
|
||||
self.assertTrue(self.target.calcSignal().__eq__(signal))
|
||||
|
||||
def test_noise(self):
|
||||
noise = SpectralQty(np.arange(400, 800, 100) << u.nm,
|
||||
[0.] * 4 << u.W / (u.m ** 2 * u.nm * u.sr))
|
||||
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)
|
||||
|
@ -16,5 +16,5 @@ class TestFileTarget(TestCase):
|
||||
|
||||
def test_noise(self):
|
||||
noise = SpectralQty(np.arange(200, 210, 1) << u.nm,
|
||||
[0.] * 10 << u.W / (u.m ** 2 * u.nm * u.sr))
|
||||
np.repeat(0, 10) << u.W / (u.m ** 2 * u.nm * u.sr))
|
||||
self.assertEqual(self.target.calcNoise(), noise)
|
||||
|
Loading…
x
Reference in New Issue
Block a user