ESBO-ETC/tests/sensor/test_Imager.py

45 lines
2.3 KiB
Python
Raw Permalink Normal View History

2020-05-19 10:45:50 +02:00
from unittest import TestCase
import astropy.units as u
import numpy as np
from esbo_etc.classes.Config import Configuration
from esbo_etc.classes.target.FileTarget import FileTarget
from esbo_etc.classes.target.BlackBodyTarget import BlackBodyTarget
from esbo_etc.classes.optical_component.StrayLight import StrayLight
from esbo_etc.classes.sensor.Imager import Imager
class TestImager(TestCase):
def setUp(self):
2020-07-21 15:37:49 +02:00
self.config = Configuration("tests/data/esbo-etc_defaults.xml").conf
2020-05-19 10:45:50 +02:00
self.imager_args = dict(quantum_efficiency=0.9 * u.electron / u.photon,
pixel_geometry=np.array([1024, 1024]) << u.pix,
pixel_size=6.5 * u.um, sigma_read_out=1.4 * u.electron ** 0.5 / u.pix,
2020-05-19 10:45:50 +02:00
dark_current=0.6 * u.electron / u.pix / u.second, well_capacity=30000 * u.electron,
f_number=13, common_conf=self.config.common, center_offset=np.array([0, 0]) << u.pix,
shape="circle", contained_energy="FWHM", aperture_size=None)
2020-07-21 15:37:49 +02:00
self.target = FileTarget("tests/data/target/target_demo_1.csv", np.arange(200, 210) << u.nm)
self.zodiac = StrayLight(self.target, "tests/data/straylight/zodiacal_emission_1.csv")
2020-05-19 10:45:50 +02:00
self.imager = Imager(self.zodiac, **self.imager_args)
def test_getSNR(self):
snr = self.imager.getSNR(0.1 * u.s)
2020-09-09 16:59:40 +02:00
self.assertAlmostEqual(snr.value, 7.112939048582188)
2020-05-19 10:45:50 +02:00
def test_getExpTime(self):
exp_time = 0.1 * u.s
snr = self.imager.getSNR(exp_time)
exp_time_ = self.imager.getExpTime(snr)
self.assertAlmostEqual(exp_time.value, exp_time_.value)
def test_getSensitivity(self):
exp_time = 100 * u.s
2020-05-19 16:52:29 +02:00
target = BlackBodyTarget(np.arange(200, 210) << u.nm, mag=20 * u.mag)
2020-07-21 15:37:49 +02:00
zodiac = StrayLight(target, "tests/data/straylight/zodiacal_emission_1.csv")
2020-05-19 16:52:29 +02:00
imager = Imager(zodiac, **self.imager_args)
snr = imager.getSNR(exp_time)
2020-05-19 10:45:50 +02:00
target = BlackBodyTarget(np.arange(200, 210) << u.nm, mag=10 * u.mag)
2020-07-21 15:37:49 +02:00
zodiac = StrayLight(target, "tests/data/straylight/zodiacal_emission_1.csv")
2020-05-19 10:45:50 +02:00
imager = Imager(zodiac, **self.imager_args)
2020-05-19 16:52:29 +02:00
sensitivity = imager.getSensitivity(exp_time, snr, 10 * u.mag)
self.assertAlmostEqual(sensitivity.value, 20)