예제 #1
0
def misc():
    # get_vega() downloads this one
    synphot.specio.read_remote_spec(
        'http://ssb.stsci.edu/cdbs/calspec/alpha_lyr_stis_008.fits')

    # G5V of UVKLIB subset of Pickles library
    # see http://www.stsci.edu/hst/instrumentation/reference-data-for-calibration-and-tools/astronomical-catalogs/pickles-atlas.html
    synphot.specio.read_remote_spec(
        'http://ssb.stsci.edu/cdbs/grid/pickles/dat_uvk/pickles_uk_27.fits')

    # read the sourcespectrum
    spG5V = SourceSpectrum.from_file(
        'http://ssb.stsci.edu/cdbs/grid/pickles/dat_uvk/pickles_uk_27.fits')
    spG2V = SourceSpectrum.from_file(
        'http://ssb.stsci.edu/cdbs/grid/pickles/dat_uvk/pickles_uk_26.fits')

    filtR = SpectralElement.from_filter('johnson_r')
    spG2V_19r = spG2V.normalize(19 * synphot.units.VEGAMAG,
                                filtR,
                                vegaspec=SourceSpectrum.from_vega())

    bp = SpectralElement(Box1D, x_0=700 * u.nm, width=600 * u.nm)
    obs = Observation(spG2V_19r, bp)
    obs.countrate(area=50 * u.m**2)

    bp220 = SpectralElement(Box1D, x_0=800 * u.nm, width=400 * u.nm)
    bpCRed = SpectralElement(Box1D, x_0=1650 * u.nm, width=300 * u.nm) * 0.8

    Observation(spG2V_19r, bp220).countrate(area=50 * u.m**2)
    Observation(spG2V_19r, bpCRed).countrate(area=50 * u.m**2)

    spM0V_8R = get_normalized_star_spectrum('M0V', 8.0, 'johnson_r')

    uPhotonSecM2Micron = u.photon / (u.s * u.m**2 * u.micron)

    spG2V_8R = get_normalized_star_spectrum("G2V", 8.0, 'johnson_r')
    plt.plot(spG2V_8R.waveset,
             spG2V_8R(spG2V_8R.waveset).to(uPhotonSecM2Micron))

    # compare with Armando's
    spG2V_19R = get_normalized_star_spectrum("G2V", 19, 'johnson_r')
    bp = SpectralElement(Box1D, x_0=700 * u.nm, width=600 * u.nm)
    obs = Observation(spG2V_19R, bp)
    obs.countrate(area=50 * u.m**2)

    # zeropoint in filtro r in erg/s/cm2/A
    Observation(get_normalized_star_spectrum('A0V', 0, 'johnson_r'),
                SpectralElement.from_filter('johnson_r')).effstim('flam')
    # zeropoint in ph/s/m2
    Observation(get_normalized_star_spectrum('A0V', 0, 'johnson_r'),
                SpectralElement.from_filter('johnson_r')).countrate(area=1 *
                                                                    u.m**2)
예제 #2
0
def test_remote_band_v():
    sp1 = spparser.parse_spec('band(v)')
    _single_functioncall(
        sp1, spectrum.ObservationSpectralElement, Empirical1D, 'band(v)',
        ans_z=None)

    sp2 = SpectralElement.from_filter('johnson_v')
    _compare_spectra(sp1, sp2)
예제 #3
0
def test_remote_rn_powerlaw():
    sp1 = spparser.parse_spec('rn(pl(5000, 1, flam), band(v), 1, photlam)')
    _single_functioncall(sp1, SourceSpectrum, None,
                         'rn(pl(5000.0,1.0,flam),band(v),1.0,photlam)')

    pl = SourceSpectrum(PowerLawFlux1D, amplitude=1 * units.FLAM,
                        x_0=5000 * u.AA, alpha=-1)
    bp = SpectralElement.from_filter('johnson_v')
    sp2 = pl.normalize(1 * units.PHOTLAM, band=bp)
    _compare_spectra(sp1, sp2)
예제 #4
0
 def get(cls, filter_name):
     '''
     Return synphot.SpectralElement of the specified filter
     The list of available filter is accessible via Filters.names()
     '''
     if filter_name in cls.SYNPHOT:
         return SpectralElement.from_filter(filter_name)
     else:
         method_to_call = getattr(cls, '_%s' % filter_name)
         return method_to_call()
    def test_std_filter(self):
        obs1 = spectrum.band('johnson,v')
        obs2 = SpectralElement.from_filter('johnson_v', encoding='binary')
        w = obs1.waveset
        np.testing.assert_allclose(obs1(w), obs2(w))

        # No pixel scale
        with pytest.raises(synexceptions.SynphotError):
            obs1.thermback()

        # No binset
        with pytest.raises(synexceptions.UndefinedBinset):
            obs1.binned_waverange(5000, 2)
        with pytest.raises(synexceptions.UndefinedBinset):
            obs1.binned_pixelrange([5000, 5002])
예제 #6
0
def test_remote_rn_calspec_u():
    sp1 = spparser.parse_spec(
        'rn(crcalspec$bd_75d325_stis_002.fits, band(u), 9.5, vegamag) * '
        'band(fos, blue, 4.3, g160l)')
    # NOTE: No expr for this combo.
    _single_functioncall(sp1, SourceSpectrum, None, '')

    bd75 = SourceSpectrum.from_file(resolve_filename(
        os.environ['PYSYN_CDBS'], 'calspec', 'bd_75d325_stis_002.fits'))
    bp_u = SpectralElement.from_filter('johnson_u')
    bd75_norm = bd75.normalize(
        9.5 * units.VEGAMAG, band=bp_u, vegaspec=spectrum.Vega)
    bp_fos = spectrum.band('fos, blue, 4.3, g160l')
    sp2 = bd75_norm * bp_fos
    _compare_spectra(sp1, sp2)
예제 #7
0
    def test_std_filter(self):
        obs1 = spectrum.band('johnson,v')
        obs2 = SpectralElement.from_filter('johnson_v', encoding='binary')
        w = obs1.waveset
        np.testing.assert_allclose(obs1(w), obs2(w))

        # No pixel scale
        with pytest.raises(synexceptions.SynphotError):
            obs1.thermback()

        # No binset
        with pytest.raises(synexceptions.UndefinedBinset):
            obs1.binned_waverange(5000, 2)
        with pytest.raises(synexceptions.UndefinedBinset):
            obs1.binned_pixelrange([5000, 5002])