예제 #1
0
    def test_load(self):
        """Test loading a filter."""

        # load it via Filter
        f = Filter('V', path=data_filename('filters'))

        # load it as Spectrum
        s = Spectrum.load(data_filename('filters/V.txt'))

        # should be identical
        assert np.array_equal(f.wave, s.wave)
        assert np.array_equal(f.throughput, s.flux)
예제 #2
0
    def test_squared(self):
        # filename for spectrum
        filename = data_filename('spectra/ngc6397id000010554jd2456865p5826f000.fits')

        # load spectrum and sigma
        spec = Spectrum.load(filename)
        sigma = fits.getdata(filename, 'SIGMA')

        # create weight
        weight = WeightFromSigma(squared=True)

        # compare
        diff = weight(spec, filename) - 1./sigma**2
        assert np.max(np.abs(diff)) < 1e-5
예제 #3
0
    def test_default(self):
        # filename for spectrum
        filename = data_filename(
            'spectra/ngc6397id000010554jd2456865p5826f000.fits')

        # load spectrum and sigma
        spec = Spectrum.load(filename)

        # create weight
        weight = WeightRanges(ranges=[(4841., 4881., 10.)], initial=1.)
        w = weight(spec, filename)

        # first pixel should be one
        assert w[0] == 1.

        # get pixel at 4861AA and test it
        i = spec.index_of_wave(4861)
        assert w[i] == 10.
예제 #4
0
    def test_apply(self):
        """Test applying a filter."""

        # load it via Filter
        f = Filter('V', path=data_filename('filters'))

        # load spectrum, fix flux (which is given in 1e20erg/s/cm/cm2) and resample filter
        s = Spectrum.load(
            data_filename('spectra/ngc6397id000010554jd2456865p5826f000.fits'))
        s /= 1e20
        f.resample(spec=s, inplace=True)

        # calculate V mag as ST and VEGAMAG
        st = f.stmag(s)
        vega = f.vegamag(s)

        # F606W mag is 13.17, V mag should be close to 13.4
        assert abs(st - 13.4) < 0.1
        assert abs(vega - 13.4) < 0.1
예제 #5
0
    def test_resample(self):
        """Test resampling a filter."""

        # load it via Filter
        f = Filter('V', path=data_filename('filters'))

        # integrate it
        int1 = np.trapz(f.throughput, f.wave)

        # load spectrum and resample filter
        s = Spectrum.load(
            data_filename('spectra/ngc6397id000010554jd2456865p5826f000.fits'))
        f.resample(spec=s, inplace=True)

        # integrate it again
        int2 = np.trapz(f.throughput, f.wave)

        # integral should not have changed significantly
        assert abs(int1 - int2) < 1