示例#1
0
    def test_vega2ab(self, filt):
        """
        test if the convertion between AB and Vega is correct
        conversions taken from:  http://www.astronomy.ohio-state.edu/~martini/usefuldata.html

        absolute tolerance set to 0.15 mag to account for filter differences

        Parameters
        ----------
        filt: str
            name of the filter
        """
        ab2vega = {
            "U": 0.79,  # magAB - magVega taken from
            "B": -0.09,  #
            "V": 0.02,
            "R": 0.21,
            "I": 0.45,
            "J": 0.91,
            "H": 1.39,
            "Ks": 1.85
        }

        sp = Spextrum.flat_spectrum(amplitude=0 * u.ABmag)

        magAB = sp.get_magnitude(filt, system_name="AB")
        magVega = sp.get_magnitude(filt, system_name="vega")

        diff = (magAB.value - magVega.value)

        assert np.isclose(diff, ab2vega[filt], atol=0.15)
示例#2
0
    def test_ref_spectrum_is_right(self, unit):
        sp1 = Spextrum.flat_spectrum(amplitude=10 * unit)
        sp2 = Spextrum.flat_spectrum(amplitude=11 * unit)
        if unit == u.mag:
            flux1 = sp1(sp1.waveset[(sp1.waveset.value > 7000 - 200)
                                    & (sp1.waveset.value < 7000 + 200)]).value
            flux2 = sp2(sp2.waveset[(sp2.waveset.value > 7000 - 200)
                                    & (sp2.waveset.value < 7000 + 200)]).value

        else:
            waves = np.arange(1000, 1e4, 1) * u.AA
            flux1 = sp1(waves)
            flux2 = sp2(waves)

        mean = np.mean(flux1 / flux2)
        assert np.isclose(mean, 10**0.4)
示例#3
0
 def test_flat_spectrum(self, unit):
     sp = Spextrum.flat_spectrum(amplitude=10 * unit)
     assert isinstance(sp, Spextrum)