Skip to content

Commit

Permalink
add integration tests for atmosphere
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyneveu committed Sep 13, 2019
1 parent b0abc69 commit 986548b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_simulator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from numpy.testing import run_module_suite
import numpy as np

from spectractor import parameters
from spectractor.simulation.simulator import (SpectrumSimulator, SpectrumSimulatorSimGrid,
Expand All @@ -8,6 +9,38 @@
import os


def test_atmosphere():
a = Atmosphere(airmass=1.2, pressure=800, temperature=5)
transmission = a.simulate(ozone=400, pwv=5, aerosols=0.05)
assert transmission is not None
assert a.transmission(500) > 0
assert a.ozone == 400
assert a.pwv == 5
assert a.aerosols == 0.05
a.plot_transmission()

a = AtmosphereGrid(image_filename='tests/data/reduc_20170605_028.fits', pwv_grid = [5, 5, 1], ozone_grid = [400, 400, 1], aerosol_grid = [0.0, 0.1, 2])
atmospheric_grid = a.compute()
assert np.sum(atmospheric_grid) > 0
assert np.all(np.isclose(a.atmgrid[0, a.index_atm_data:], parameters.LAMBDAS))
assert not np.any(np.isclose(a.atmgrid[1, a.index_atm_data:], np.zeros_like(parameters.LAMBDAS), rtol=1e-6))
assert a.atmgrid.shape == (3, a.index_atm_data + len(parameters.LAMBDAS))
a.save_file(a.image_filename.replace('.fits', '_atmsim.fits'))
assert os.path.isfile('tests/data/reduc_20170605_028_atmsim.fits')
a.load_file(a.image_filename.replace('.fits', '_atmsim.fits'))
assert np.all(a.AER_Points == np.array([0., 0.1]))
assert np.all(a.PWV_Points == np.array([5.]))
assert np.all(a.OZ_Points == np.array([400.]))

a.plot_transmission()
a.plot_transmission_image()

a = AtmosphereGrid(filename='tests/data/reduc_20170530_134_atmsim.fits')
lambdas = np.arange(200, 1200)
transmission = a.simulate(ozone=400, pwv=5, aerosols=0.05)
assert np.max(transmission(lambdas)) < 1 and np.min(transmission(lambdas)) >= 0


def test_simulator():
file_names = ['tests/data/reduc_20170530_134_spectrum.fits']

Expand Down

0 comments on commit 986548b

Please sign in to comment.