ESBO-ETC/tests/psf/test_Zemax.py

35 lines
1.6 KiB
Python
Raw Normal View History

2020-04-29 17:08:03 +02:00
from unittest import TestCase
from esbo_etc.classes.psf.Zemax import Zemax
2020-05-14 16:48:46 +02:00
from esbo_etc.classes.sensor.PixelMask import PixelMask
2020-04-29 17:08:03 +02:00
import astropy.units as u
2020-05-14 16:48:46 +02:00
import numpy as np
2020-04-29 17:08:03 +02:00
class TestZemax(TestCase):
def setUp(self):
2020-05-11 13:52:14 +02:00
self.zemax = Zemax("data/psf_2um.txt", 13, 4 * u.um, 0.5 * u.m, 13, 6.5 * u.um)
2020-04-29 17:08:03 +02:00
def test_calcReducedObservationAngle(self):
2020-05-11 13:52:14 +02:00
# No jitter
2020-05-13 14:31:56 +02:00
self.assertAlmostEqual(self.zemax.calcReducedObservationAngle(80).value, 1.6563253147273092)
2020-05-11 13:52:14 +02:00
# Jitter
2020-05-13 14:31:56 +02:00
self.assertAlmostEqual(self.zemax.calcReducedObservationAngle(80, 1 * u.arcsec).value, 2.5910983637231553)
2020-05-14 16:48:46 +02:00
def test_mapToPixelArray(self):
# No jitter
reduced_observation_angle = self.zemax.calcReducedObservationAngle(80).value
d_ap = (reduced_observation_angle / (6.5 * u.um / (13.0 * 4 * u.um))).decompose() * u.pix
mask = PixelMask(np.array([1024, 1024]) << u.pix, 6.5 * u.um, np.array([0.5, 0.5]) << u.pix)
mask.createPhotometricAperture("circle", d_ap / 2)
mask = self.zemax.mapToPixelMask(mask)
self.assertAlmostEqual(mask.sum(), 0.8461957147744972)
# Jitter
reduced_observation_angle = self.zemax.calcReducedObservationAngle(80, 1 * u.arcsec).value
d_ap = (reduced_observation_angle / (6.5 * u.um / (13.0 * 4 * u.um))).decompose() * u.pix
mask = PixelMask(np.array([1024, 1024]) << u.pix, 6.5 * u.um, np.array([0.5, 0.5]) << u.pix)
mask.createPhotometricAperture("circle", d_ap / 2)
mask = self.zemax.mapToPixelMask(mask, 1 * u.arcsec)
self.assertAlmostEqual(mask.sum(), 0.8241591233169423)