From db0b61acff48fe2bb5f67918e57ffc82612b38e0 Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Tue, 14 Apr 2020 14:30:02 +0200 Subject: [PATCH] Initial commit --- .../data/atmosphere/atmosphere_emission_1.csv | 11 ++++++++++ .../atmosphere/atmosphere_transmittance_1.csv | 9 ++++++++ tests/data/straylight/zodiacal_emission_1.csv | 11 ++++++++++ tests/test_Atmosphere.py | 22 +++++++++++++++++++ tests/test_StrayLight.py | 22 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 tests/data/atmosphere/atmosphere_emission_1.csv create mode 100644 tests/data/atmosphere/atmosphere_transmittance_1.csv create mode 100644 tests/data/straylight/zodiacal_emission_1.csv create mode 100644 tests/test_Atmosphere.py create mode 100644 tests/test_StrayLight.py diff --git a/tests/data/atmosphere/atmosphere_emission_1.csv b/tests/data/atmosphere/atmosphere_emission_1.csv new file mode 100644 index 0000000..4b5a41a --- /dev/null +++ b/tests/data/atmosphere/atmosphere_emission_1.csv @@ -0,0 +1,11 @@ +wavelength,spectral flux density +200,1.1e-16 +201,1.2e-16 +202,1.3e-16 +203,1.4e-16 +204,1.5e-16 +205,1.6e-16 +206,1.7e-16 +207,1.8e-16 +208,1.9e-16 +209,2.0e-16 diff --git a/tests/data/atmosphere/atmosphere_transmittance_1.csv b/tests/data/atmosphere/atmosphere_transmittance_1.csv new file mode 100644 index 0000000..5a92fef --- /dev/null +++ b/tests/data/atmosphere/atmosphere_transmittance_1.csv @@ -0,0 +1,9 @@ +wavelength,spectral flux density +200,1 +201,1 +202,1 +203,0.9 +204,0.8 +205,0.7 +206,0.6 +207,0.5 diff --git a/tests/data/straylight/zodiacal_emission_1.csv b/tests/data/straylight/zodiacal_emission_1.csv new file mode 100644 index 0000000..4b5a41a --- /dev/null +++ b/tests/data/straylight/zodiacal_emission_1.csv @@ -0,0 +1,11 @@ +wavelength,spectral flux density +200,1.1e-16 +201,1.2e-16 +202,1.3e-16 +203,1.4e-16 +204,1.5e-16 +205,1.6e-16 +206,1.7e-16 +207,1.8e-16 +208,1.9e-16 +209,2.0e-16 diff --git a/tests/test_Atmosphere.py b/tests/test_Atmosphere.py new file mode 100644 index 0000000..13bc0ba --- /dev/null +++ b/tests/test_Atmosphere.py @@ -0,0 +1,22 @@ +from unittest import TestCase +from esbo_etc import Atmosphere, FileTarget, SpectralQty +import numpy as np +import astropy.units as u + + +class TestAtmosphere(TestCase): + def setUp(self): + self.target = FileTarget("data/target/target_demo_1.csv") + self.atmosphere = Atmosphere(self.target, "data/atmosphere/atmosphere_transmittance_1.csv", + "data/atmosphere/atmosphere_emission_1.csv") + + def test_calcSignal(self): + self.assertEqual(self.atmosphere.calcSignal(), + SpectralQty(np.arange(200, 208) << u.nm, [1.10e-15, 1.20e-15, 1.30e-15, 1.26e-15, 1.20e-15, + 1.12e-15, 1.02e-15, 0.9e-15] << u.W / ( + u.m ** 2 * u.nm))) + + def test_calcNoise(self): + self.assertEqual(self.atmosphere.calcNoise(), + SpectralQty(np.arange(200, 208) << 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] << u.W / (u.m ** 2 * u.nm * u.sr))) diff --git a/tests/test_StrayLight.py b/tests/test_StrayLight.py new file mode 100644 index 0000000..032b645 --- /dev/null +++ b/tests/test_StrayLight.py @@ -0,0 +1,22 @@ +from unittest import TestCase +from esbo_etc import StrayLight, FileTarget, SpectralQty +import numpy as np +import astropy.units as u + + +class TestStrayLight(TestCase): + def setUp(self): + self.target = FileTarget("data/target/target_demo_1.csv") + self.zodiac = StrayLight(self.target, "data/straylight/zodiacal_emission_1.csv") + + 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))) + + 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 / + (u.m ** 2 * u.nm * u.sr)))