Пример #1
0
def _bbChi(stuff, wave, flux):
    temp, const = stuff
    bb = BlackBody1D(temperature=temp * u.K)
    bbFlux = [x.value for x in bb(wave).to(FLAM, u.spectral_density(wave))]

    bbFlux = [x * const for x in bbFlux]
    return _chisq(bbFlux, flux)
Пример #2
0
def spec_model(T, F):

    bb = BlackBody1D(temperature=T * u.K,
                     bolometric_flux=F * u.erg / (u.cm**2 * u.s))
    wav = np.arange(1000, 110000) * u.AA
    flux = bb(wav).to(FLAM, u.spectral_density(wav))

    return wav, flux
Пример #3
0
def fluxFromBB(temp, const, wave):
    bb = BlackBody1D(temperature=temp * u.K)
    bbFlux = [
        x.value
        for x in bb(wave * u.AA).to(FLAM, u.spectral_density(wave * u.AA))
    ]
    bbFlux = np.array([x * const for x in bbFlux])
    return (bbFlux)
Пример #4
0
    def __init__(self,
                 ngrps=2,
                 nints=2,
                 teff=1800,
                 filter='CLEAR',
                 subarray='SUBSTRIP256',
                 run=True,
                 add_planet=False,
                 **kwargs):
        """Get the test data and load the object

        Parmeters
        ---------
        ngrps: int
            The number of groups per integration
        nints: int
            The number of integrations for the exposure
        teff: int
            The effective temperature of the test source
        filter: str
            The name of the filter to use, ['CLEAR', 'F277W']
        subarray: str
            The name of the subarray to use, ['SUBSTRIP256', 'SUBSTRIP96', 'FULL']
        run: bool
            Run the simulation after initialization
        add_planet: bool
            Add a transiting exoplanet
        """
        # Generate a blackbody at the given temperature
        bb = BlackBody1D(temperature=teff * q.K)
        wav = np.linspace(0.5, 2.9, 1000) * q.um
        flux = bb(wav).to(FLAM, q.spectral_density(wav)) * 1E-8

        # Initialize base class
        super().__init__(ngrps=ngrps,
                         nints=nints,
                         star=[wav, flux],
                         subarray=subarray,
                         filter=filter,
                         **kwargs)

        # Add planet
        if add_planet:
            self.planet = utils.PLANET_DATA
            self.tmodel = utils.transit_params(self.time)

        # Run the simulation
        if run:
            self.simulate()
Пример #5
0
            x = eventdata[event]["lambda"]
            y = np.abs(eventdata[event]["data"]) / np.max(
                np.abs(eventdata[event]["data"]))
            #plt.loglog(x,y,'-',c=colors[ii],label=event)
            idx = np.where((x >= 4000))[0]
            #s1 = InterpolatedUnivariateSpline(x[idx], y[idx], k=1.0)
            #plt.loglog(x,s1(x),'--',c=colors[ii])
            filtered = lowess(y[idx], x[idx], is_sorted=True, frac=0.10, it=0)
            plt.loglog(filtered[:, 0], filtered[:, 1], '--', c=colors[ii])

    from astropy.modeling.models import BlackBody1D
    from astropy.modeling.blackbody import FLAM
    from astropy import units as u
    from astropy.visualization import quantity_support

    bb = BlackBody1D(temperature=5000 * u.K)
    wav = np.arange(1000, 110000) * u.AA
    flux = bb(wav).to(FLAM, u.spectral_density(wav))

    plt.semilogx(wav, flux / np.max(flux))

    plt.xlim([3000, 30000])
    #plt.ylim([10.0**39,10.0**43])
    plt.xlabel(r'$\lambda [\AA]$', fontsize=24)
    plt.ylabel('Normalized Fluence [erg/s/cm2/A]', fontsize=24)
    plt.legend(loc="best")
    plt.grid()
    plt.savefig(plotName)
    plt.close()

elif opts.doLuminosity:
    return y

filename = "../spectra/G298048_XSH_20170821.dat"
data_out = np.loadtxt(filename)

lambdas = data_out[:,0]
spec = data_out[:,1]

spec_lowpass = butter_lowpass_filter(spec, 0.5, 1.0, order=5)

#analytic_signal = hilbert(spec)
#amplitude_envelope = np.abs(analytic_signal)

T = 2800
F = 8e-13
bb = BlackBody1D(temperature=T*u.K,bolometric_flux=F*u.erg/(u.cm**2 * u.s))
wav = np.arange(1000, 110000) * u.AA
flux = bb(wav).to(FLAM, u.spectral_density(wav))



plotDir = "../plots/whiten"
if not os.path.isdir(plotDir):
    os.makedirs(plotDir)

plotname = os.path.join(plotDir,'spec.pdf')

plt.figure()
plt.plot(lambdas,spec,'k-')
plt.plot(wav,flux,'r--')
plt.xlim([3500,25000])
Пример #7
0
def GreyBody(x, temperature, bolometric_flux, wave_0, beta):
    tau = (wave_0 / x)**beta
    
    bb = BlackBody1D(temperature,bolometric_flux)