Exemple #1
0
    def evaluate(x, temperature):
        """Evaluate the model.

        Parameters
        ----------
        x : number or ndarray
            Wavelengths in Angstrom.

        temperature : number
            Temperature in Kelvin.

        Returns
        -------
        y : number or ndarray
            Blackbody radiation in PHOTLAM per steradian.

        """
        if ASTROPY_LT_2_0:
            from astropy.analytic_functions.blackbody import blackbody_nu
        else:
            from astropy.modeling.blackbody import blackbody_nu

        # Silence Numpy
        old_np_err_cfg = np.seterr(all='ignore')

        wave = np.ascontiguousarray(x) * u.AA
        bbnu_flux = blackbody_nu(wave, temperature)
        bbflux = (bbnu_flux * u.sr).to(
            units.PHOTLAM, u.spectral_density(wave)) / u.sr  # PHOTLAM/sr

        # Restore Numpy settings
        np.seterr(**old_np_err_cfg)

        return bbflux.value
    def evaluate(x, temperature):
        """Evaluate the model.

        Parameters
        ----------
        x : number or ndarray
            Wavelengths in Angstrom.

        temperature : number
            Temperature in Kelvin.

        Returns
        -------
        y : number or ndarray
            Blackbody radiation in PHOTLAM per steradian.

        """
        # Silence Numpy
        old_np_err_cfg = np.seterr(all="ignore")

        wave = np.ascontiguousarray(x) * u.AA
        bbnu_flux = blackbody_nu(wave, temperature)
        bbflux = (bbnu_flux * u.sr).to(units.PHOTLAM, u.spectral_density(wave)) / u.sr  # PHOTLAM/sr

        # Restore Numpy settings
        np.seterr(**old_np_err_cfg)

        return bbflux.value
Exemple #3
0
    def evaluate(x, temperature):
        """Evaluate the model.

        Parameters
        ----------
        x : number or ndarray
            Wavelengths in Angstrom.

        temperature : number
            Temperature in Kelvin.

        Returns
        -------
        y : number or ndarray
            Blackbody radiation in PHOTLAM per steradian.

        """
        # Silence Numpy
        old_np_err_cfg = np.seterr(all='ignore')

        wave = u.Quantity(np.ascontiguousarray(x), unit=u.AA)
        bbnu_flux = blackbody_nu(wave, temperature)
        bbflux = (bbnu_flux * u.sr).to(
            units.PHOTLAM, u.spectral_density(wave)) / u.sr  # PHOTLAM/sr

        # Restore Numpy settings
        dummy = np.seterr(**old_np_err_cfg)

        return bbflux.value
Exemple #4
0
def makeplot_v2(photdat, norm_wave=8, normval = None, specfile='../pb_m31_spectra/nucFLUX',spec_area =1500):
    '''plots photometry and some spectra on same plot'''
    # difference btw this one and makeplot() is how the normalization is done

    photwaves = photdat['Wavelength'] # known wavelengths
    photvals = photdat['MJy_counts']

    if normval == None:
        normval = photvals[np.searchsorted(photwaves, norm_wave)]

#    load the IRS spectrum and convert to MJy
    nuc_wave,nuc_irs = np.loadtxt(specfile,unpack=True, usecols=[0,1])
    nuc_irs = nuc_irs*((spec_area*u.arcsec**2).to(u.sr).value)
    # normalize
    nuc_irs = spect_norm(nuc_wave,nuc_irs, norm_wave, normval)

#   read the nu Pav spectrum
    nupav_wave, nupav_flux = np.loadtxt('nu_pav_spect.txt',unpack=True,usecols=[0,1])
    # normalize
    nupav_flux = spect_norm(nupav_wave,nupav_flux, norm_wave, normval)

#   create a RJ tail to compare to
    bb_wl = np.arange(1.0,22,0.4)
    bb = blackbody_nu(bb_wl*u.micron,5000)
    # normalize
    bb = spect_norm(bb_wl,bb, norm_wave, normval)

    # plot
    f,ax=plt.subplots()
    ax.plot(bb_wl, bb.value*1e6, ls='dashed', color='k',marker=None, lw=2, label = '5000K BB' )
    ax.plot(nupav_wave, nupav_flux*1e6, ls = 'solid', color='k',marker=None, lw=2,label='nu Pav')
    ax.plot(nuc_wave,nuc_irs*1e6,ls='solid',marker=None, lw=2,label= 'M31 IRS')
    ax.plot(photwaves[5:],photvals[5:]*1e6,ms=10,label='IRAC') # factor 1e6 makes plot in Jy, gives nice scale
    ax.set_xlabel('Wavelength [micron]')
    ax.set_ylabel('Flux density [Jy]')
    ax.legend(loc='best')
    ax.set_xlim(3,22)
    ax.set_ylim(0,4)
    return
Exemple #5
0
def makeplot(photdat=None, specfile='../pb_m31_spectra/nucFLUX',spec_area =1500):
    '''plots photometry and some spectra on same plot'''
    if photdat == None:
        # do photometry 
        photdat = dophot(imglist)
    photwaves = photdat['Wavelength'] # known wavelengths
    photvals = photdat['MJy_counts']

#    load the IRS spectrum and convert to MJy
    nuc_wave,nuc_irs = np.loadtxt(specfile,unpack=True,usecols=[0,1])
    nuc_irs = nuc_irs*((spec_area*u.arcsec**2).to(u.sr).value)

#   read the nu Pav spectrum
    nupav_wave, nupav_flux = np.loadtxt('nu_pav_spect.txt',unpack=True,usecols=[0,1])
    # normalize
    find_8micron = np.searchsorted(nupav_wave,8)
    nupav_flux = nupav_flux*(photvals[-1]/nupav_flux[find_8micron])

#   create a RJ tail to compare to
    bb_wl = np.arange(1.0,22,0.4)
    bb = blackbody_nu(bb_wl*u.micron,5000)
    # normalize it to the IRAC flux at 8um
    find_8micron = np.searchsorted(bb_wl,8)
    bb = bb*(photvals[-1]/bb[find_8micron].value)

    # plot
    f,ax=plt.subplots()
    ax.plot(nuc_wave,nuc_irs*1e6,ls='solid',marker=None, lw=2,label= 'M31 IRS')
    ax.plot(bb_wl, bb.value*1e6, ls='dashed', color='k',marker=None, lw=2, label = '5000K BB' )
    ax.plot(nupav_wave, nupav_flux*1e6, ls = 'solid', color='k',marker=None, lw=2,label='nu Pav')
    ax.plot(photwaves[0:2],photvals[0:2]*1e6,ms=10,label='HST') # factor 1e6 makes plot in Jy, gives nice scale
    ax.plot(photwaves[2:5],photvals[2:5]*1e6,ms=10,label='2MASS') # factor 1e6 makes plot in Jy, gives nice scale
    ax.plot(photwaves[5:],photvals[5:]*1e6,ms=10,label='IRAC') # factor 1e6 makes plot in Jy, gives nice scale
    ax.set_xlabel('Wavelength [micron]')
    ax.set_ylabel('Flux density [Jy]')
    ax.legend(loc='best')
    ax.set_xlim(0,22)
#    ax.set_ylim(0,10)
    return(photvals)