import unittest from csst_cpic_sim.camera import EMCCD import numpy as np class TestEMCCD(unittest.TestCase): def test_emccd_normal(self): emccd = EMCCD() emccd.switch['flat'] = True emccd.switch['dark'] = True emccd.switch['stripe'] = True emccd.switch['cic'] = True emccd.switch['cte'] = True emccd.switch['badcolumn'] = True emccd.switch['nonlinear'] = True emccd.switch['cosmicray'] = True emccd.switch['blooming'] = True image_focal = np.zeros(emccd.flat_shape) + 1000 iamge_cosmic_ray = np.zeros(emccd.dark_shape) emgain = 10 expt = 10 image = emccd.readout(image_focal, emgain, expt, iamge_cosmic_ray) self.assertEqual(image.shape[0], emccd.image_shape[0]) self.assertEqual(image.shape[1], emccd.image_shape[1]) def test_emccd_allclose(self): emccd = EMCCD() emccd.switch['flat'] = False emccd.switch['dark'] = False emccd.switch['stripe'] = False emccd.switch['cic'] = False emccd.switch['cte'] = False emccd.switch['badcolumn'] = False emccd.switch['nonlinear'] = False emccd.switch['cosmicray'] = False emccd.switch['blooming'] = False image_focal = np.zeros(emccd.flat_shape) + 1000 emgain = 10 expt = 10 image = emccd.readout(image_focal, emgain, expt) self.assertEqual(image.shape[0], emccd.image_shape[0]) self.assertEqual(image.shape[1], emccd.image_shape[1]) def test_emccd_blooming(self): import numpy as np emccd = EMCCD() emccd.switch['flat'] = True emccd.switch['dark'] = True, emccd.switch['stripe'] = True emccd.switch['cic'] = True emccd.switch['cte'] = True emccd.switch['badcolumn'] = True emccd.switch['nonlinear'] = True emccd.switch['cosmicray'] = True emccd.switch['blooming'] = True image_focal = np.zeros(emccd.flat_shape) + 1000 image_focal[100:200, 100:200] = 500_000 iamge_cosmic_ray = np.zeros(emccd.dark_shape) emgain = 10 expt = 10 image = emccd.readout(image_focal, emgain, expt, iamge_cosmic_ray) self.assertEqual(image.shape[0], emccd.image_shape[0]) self.assertEqual(image.shape[1], emccd.image_shape[1]) if __name__ == '__main__': unittest.main()