Example #1
0
    def test_filter_fwhm(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")
        filter_fwhm = read_filter.filter_fwhm()

        assert filter_fwhm == pytest.approx(0.2956945960962718,
                                            rel=self.limit,
                                            abs=0.0)
Example #2
0
    def test_get_filter_photon_counter(self):
        read_filter = species.ReadFilter("Keck/NIRC2.J")
        filter_profile = read_filter.get_filter()

        assert filter_profile.shape == (1054, 2)
        assert np.sum(filter_profile) == pytest.approx(2038.0486,
                                                       rel=1e-6,
                                                       abs=0.0)
Example #3
0
    def test_get_filter(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")
        filter_profile = read_filter.get_filter()

        assert filter_profile.shape == (970, 2)
        assert np.sum(filter_profile) == pytest.approx(2089.2432,
                                                       rel=1e-6,
                                                       abs=0.0)
Example #4
0
    def test_interpolate_filter(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")
        interp_filter = read_filter.interpolate_filter()

        assert interp_filter.x.shape == (970, )
        assert interp_filter.y.shape == (970, )

        assert np.sum(interp_filter.x) == pytest.approx(1575.1079,
                                                        rel=1e-8,
                                                        abs=0.0)
        assert np.sum(interp_filter.y) == pytest.approx(514.135186,
                                                        rel=1e-6,
                                                        abs=0.0)
Example #5
0
    def test_spectral_library(self):
        spectrum = species.ReadSpectrum(spectrum='irtf', filter_name='MKO/NSFCam.H')
        specbox = spectrum.get_spectrum(sptypes=('L', ))

        wavelength = specbox.wavelength[0]
        flux = specbox.flux[0]

        assert wavelength.shape == (1000, )
        assert flux.shape == (1000, )

        assert np.allclose(np.sum(wavelength), 1611.2432, rtol=1e-7, atol=0.)
        assert np.allclose(np.sum(flux), 2.3606193e-11, rtol=1e-7, atol=0.)

        spectrum = species.ReadSpectrum(spectrum='irtf', filter_name='MKO/NSFCam.H')
        specbox = spectrum.get_spectrum(sptypes=('L', ))

        synphot = species.SyntheticPhotometry(filter_name='MKO/NSFCam.H')
        phot = synphot.spectrum_to_photometry(wavelength=wavelength, flux=flux)

        assert np.allclose(phot, 2.595779e-14, rtol=1e-7, atol=0.)

        transmission = species.ReadFilter(filter_name='MKO/NSFCam.H')
        wl_mean = transmission.mean_wavelength()

        assert np.allclose(wl_mean, 1.6298258, rtol=1e-7, atol=0.)

        photbox = species.create_box(boxtype='photometry',
                                     name='L0 dwarf',
                                     wavelength=wl_mean,
                                     flux=phot)

        assert photbox.name == 'L0 dwarf'
        assert np.allclose(photbox.wavelength, 1.6298258, rtol=1e-7, atol=0.)
        assert np.allclose(photbox.flux, 2.595779e-14, rtol=1e-7, atol=0.)

        species.plot_spectrum(boxes=(specbox, photbox),
                              filters=('MKO/NSFCam.H', ),
                              output='photometry.pdf',
                              xlim=(1., 2.5),
                              offset=(-0.08, -0.06))

        assert os.path.exists('photometry.pdf')
Example #6
0
    def test_mean_wavelength(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")
        mean_wavel = read_filter.mean_wavelength()

        assert mean_wavel == pytest.approx(1.6298258, rel=1e-6, abs=0.0)
Example #7
0
    def test_wavelength_range(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")
        min_wavel, max_wavel = read_filter.wavelength_range()

        assert min_wavel == pytest.approx(1.382, rel=1e-6, abs=0.0)
        assert max_wavel == pytest.approx(1.8656, rel=1e-8, abs=0.0)
Example #8
0
    def test_detector_type_photon(self):
        read_filter = species.ReadFilter("Keck/NIRC2.J")
        det_type = read_filter.detector_type()

        assert det_type == "photon"
Example #9
0
    def test_detector_type(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")
        det_type = read_filter.detector_type()

        assert det_type == "energy"
Example #10
0
    def test_read_filter(self):
        read_filter = species.ReadFilter("MKO/NSFCam.H")

        assert read_filter.filter_name == "MKO/NSFCam.H"