Exemplo n.º 1
0
class LoadOptionsTest(unittest.TestCase):
    loadOptions = LoadOptions()

    def test_loadFile(self):
        self.loadOptions(filename=payload_file())
        with self.assertRaises(IOError):
            self.loadOptions(filename=os.path.join(
                test_dir, 'payload_example_missing_data_file.xml'))
        with self.assertRaises(IOError):
            self.loadOptions(
                filename=os.path.join(path, 'test_data/payload_example.csv'))
        with self.assertRaises(IOError):
            self.loadOptions(
                filename=os.path.join(path, 'test_data/payload_example1.xml'))

        self.loadOptions(filename=os.path.join(
            test_dir, 'payload_example_missing_config.xml'),
                         config_path=str(path.parent.absolute()))

    def test_loadpickle(self):
        if not os.path.exists(os.path.join(test_dir, 'spec.pickle')):
            options = self.loadOptions(filename=payload_file())
            import pickle
            filehandler = open(os.path.join(test_dir, 'spec.pickle'), 'wb')
            pickle.dump(options['channel']['Spec'], filehandler)
            filehandler.close()
        options2 = self.loadOptions(filename=payload_file(
            name='payload_test_pickle_spec.xml'))
Exemplo n.º 2
0
class Spectrometer_from_pickle_Test(unittest.TestCase):
    setLogLevel(logging.DEBUG)
    loadOptions = LoadOptions()
    options2 = loadOptions(filename=payload_file(
        name='payload_test_pickle_spec.xml'))
    spectrometer = Spectrometer('Spec', options2['channel']['Spec'], options2)
    spectrometer.build()

    def test_spectrometer_table(self):
        self.assertEqual(self.spectrometer.table['Wavelength'].size, 12)
        # self.assertListEqual(list(self.spectrometer.table['TR'].value), [0.5] * 12)
        self.assertListEqual(list(self.spectrometer.table['QE'].value),
                             [0.7] * 12)
Exemplo n.º 3
0
class LoadOptionsTest(unittest.TestCase):
    loadOptions = LoadOptions()

    def test_loadFile(self):
        self.loadOptions(
            filename=os.path.join(data_dir, 'payload_example.xml'))
        with self.assertRaises(IOError):
            self.loadOptions(filename=os.path.join(
                test_dir, 'payload_example_missing_data_file.xml'))
        with self.assertRaises(IOError):
            self.loadOptions(
                filename=os.path.join(path, 'test_data/payload_example.csv'))
        with self.assertRaises(IOError):
            self.loadOptions(
                filename=os.path.join(path, 'test_data/payload_example1.xml'))
Exemplo n.º 4
0
import os
import pathlib
import unittest

import astropy.units as u
import numpy as np

from exorad.log import setLogLevel
from exorad.models.instruments import Photometer, Spectrometer
from exorad.models.optics.opticalPath import OpticalPath
from exorad.tasks.loadOptions import LoadOptions

path = pathlib.Path(__file__).parent.absolute()
data_dir = os.path.join(path.parent.absolute(), 'examples')

loadOptions = LoadOptions()
options = loadOptions(filename=os.path.join(data_dir, 'payload_example.xml'))


class InstrumentDiffuseLightTest(unittest.TestCase):
    def test_transmission(self):

        wl_grid = np.logspace(
            np.log10(options['channel']['Phot']['detector']['wl_min']
                     ['value'].value),
            np.log10(options['channel']['Phot']['detector']['cut_off']
                     ['value'].value), 6000) * u.um
        telescope = OpticalPath(wl=wl_grid, description=options)
        tel = telescope.chain()
        phot = OpticalPath(wl=wl_grid, description=options['channel']['Phot'])
        phot.prepend_optical_elements(telescope.optical_element_dict)