Ejemplo n.º 1
0
Archivo: TM.py Proyecto: zkbt/transit
	def stellar_rv(self, rvc=None, t=None):
		self.set_ebparams()

		# by default, will use the linked RVC, but could use a custom one (e.g. high-resolution for plotting), or just times
		if rvc is None:
			rvc = self.RVC

		if t is None:
			t = rvc.bjd

		# make sure the types are okay for Jonathan's inputs
		typ = np.empty_like(t, dtype=np.uint8)
		typ.fill(eb.OBS_VRAD1)

		rv = self.planet.semiamplitude.value*eb.model(self.ebparams, t, typ) + self.star.gamma.value
		assert(np.isfinite(rv).all())
		return rv
Ejemplo n.º 2
0
Archivo: TM.py Proyecto: zkbt/transit
	def planet_model(self, tlc=None, t=None):
		'''Model of the planetary transit.'''
		self.set_ebparams()

		# by default, will use the linked TLC, but could use a custom TLC
		# 	 (e.g. a high-resolution one, for plotting)
		if tlc is None:
			tlc = self.TLC

		# if called with a "t=" keyword set, then will use those custom times
		if t is None:
			t = tlc.bjd

		# make sure the types are okay for Jonathan's inputs
		typ = np.empty_like(t, dtype=np.uint8)
		typ.fill(eb.OBS_MAG)

		# work in relative flux (rather than magnitudes) -- why did I do this?
		return 10**(-0.4*eb.model(self.ebparams, t, typ))
Ejemplo n.º 3
0
 def fit_func (trial_parm, ymod):
   eb.model(trial_parm, phi, typ, eb.FLAG_PHI, out=ymod)
Ejemplo n.º 4
0
pdur=pe-ps

# Centre for plots.
pa=0.5*(ps+pe)

# Generate phase array, making sure there is a reasonable amount
# of baseline available for fitting.
phi = numpy.linspace(pa-2*pdur, pa+2*pdur, 5000)

# Tell the model to compute magnitudes (author's preference when
# fitting, can be changed to OBS_LIGHT to compute normalized flux).
typ = numpy.empty_like(phi, dtype=numpy.uint8)
typ.fill(eb.OBS_MAG)

# Compute model.
y = eb.model(parm, phi, typ, eb.FLAG_PHI)

# Are we fitting?
if do_fit:
  # Make sure we always get the same random deviates.
  numpy.random.seed(42)

  # Add noise.
  nois = 30.0e-6  # 30 ppm
  
  yobs = y + numpy.random.normal(loc=0.0, scale=nois, size=y.shape)

  # Observational uncertainties for fitter.  We'll be nice here and
  # use the correct answer.
  e_yobs = numpy.empty_like(y, dtype=numpy.double)
  e_yobs.fill(nois)
Ejemplo n.º 5
0
def Make_Transit(data, phase=True, noise=False, noise_level=0):
    """
    EXPERIMENTAL
    Desctiption:
        Built a transiet light curve using the python mobule eb
        This method attempts to wrap eb in a more pythonic interface
    Args:
        data - data dictionary to be used in eb calls (dict)
        phase - should the retunes be in phase space or time space (bool)
                ** Currently only phase space is working **
        noise - Should noise be introcued (bool)
        noise_level - amount of noise to introduce into the light curve
    Returns:
        Dataframe of the light curve:
            Phase / **time** - x array
            flux - y array
    Raises:
        N/A
    """
    import eb
    keys = [
        'J', 'RASUM', 'RR', 'COSI', 'Q', 'KTOT', 'LDLIN1', 'LDNON1', 'GD1',
        'REFL1', 'ROT1', 'FSPOT1', 'OOE1O', 'OOE11A', 'OOE11B', 'LDLIN2',
        'LDNON2', 'GD2', 'REFL2', 'ECOSW', 'ESINW', 'LOGG1', 'LOGG2', 'P'
    ]
    data = initialize_dict(data, keys)
    parm = np.zeros(eb.NPAR, dtype=np.double)
    parm[eb.PAR_J] = data['J']
    parm[eb.PAR_RASUM] = data['RASUM']
    parm[eb.PAR_RR] = data['RR']
    parm[eb.PAR_COSI] = data['COSI']
    parm[eb.PAR_Q] = data['Q']
    parm[eb.PAR_CLTT] = 1000.0 * data['KTOT'] / eb.LIGHT
    parm[eb.PAR_LDLIN1] = data['LDLIN1']
    parm[eb.PAR_LDNON1] = data['LDNON1']
    parm[eb.PAR_GD1] = data['GD1']
    parm[eb.PAR_REFL1] = data['REFL1']
    parm[eb.PAR_ROT1] = data['ROT1']
    parm[eb.PAR_FSPOT1] = data['FSPOT1']
    parm[eb.PAR_OOE1O] = data['OOE1O']  # Those are Os not zeros
    parm[eb.PAR_OOE11A] = data['OOE11A']
    parm[eb.PAR_OOE11B] = data['OOE11B']
    parm[eb.PAR_LDLIN2] = data['LDLIN2']
    parm[eb.PAR_LDNON2] = data['LDNON2']
    parm[eb.PAR_GD2] = data['GD2']
    parm[eb.PAR_REFL2] = data['REFL2']
    parm[eb.PAR_ECOSW] = data['ECOSW']
    parm[eb.PAR_ESINW] = data['ESINW']
    parm[eb.PAR_P] = data['P']
    parm[eb.PAR_T0] = data['TO']
    parm[eb.PAR_LOGG1] = data['LOGG1']
    parm[eb.PAR_LOGG2] = data['LOGG2']

    (ps, pe, ss, se) = eb.phicont(parm)
    if ps > 0.5:
        ps -= 1.0

    pdur = pe - ps
    sdur = se - ss
    if pdur > sdur:
        mdur = pdur
    else:
        mdur = sdur

    pa = 0.5 * (ps + pe)
    sa = 0.5 * (ss + se)

    phi = np.empty([3, data['N']], dtype=np.double)
    phi[0] = np.linspace(pa - mdur, pa + mdur, phi.shape[1])
    phi[1] = np.linspace(sa - mdur, sa + mdur, phi.shape[1])
    phi[2] = np.linspace(data['Pstart'], data['Pend'], phi.shape[1])

    typ = np.empty_like(phi, dtype=np.uint8)
    typ.fill(eb.OBS_MAG)

    y = eb.model(parm, phi, typ, eb.FLAG_PHI)
    if noise is True:
        Flux = np.random.normal(y[2], noise_level, data['N'])
    else:
        Flux = y[2]
    data = {'Phase': phi[2], 'Flux': Flux}
    return pd.DataFrame(data=data)
Ejemplo n.º 6
0
pa=0.5*(ps+pe)
sa=0.5*(ss+se)

# Generate phase array: primary, secondary, and out of eclipse
# in leading dimension.
phi = numpy.empty([3, 1000], dtype=numpy.double)
phi[0] = numpy.linspace(pa-mdur, pa+mdur, phi.shape[1])
phi[1] = numpy.linspace(sa-mdur, sa+mdur, phi.shape[1])
phi[2] = numpy.linspace(-0.25, 1.25, phi.shape[1])

# All magnitudes.
typ = numpy.empty_like(phi, dtype=numpy.uint8)
typ.fill(eb.OBS_MAG)

# These calls both do the same thing.  First, phase.
y = eb.model(parm, phi, typ, eb.FLAG_PHI)
# Alternative using time.
#t = parm[eb.PAR_T0] + phi*parm[eb.PAR_P]
#y = eb.model(parm, t, typ)

# Plot eclipses in top 2 panels.  Manual y range, forced same on
# both plots.  x range is already guaranteed to be the same above.
ymin = y.min()
ymax = y.max()
yrange = ymax - ymin

plt.subplot(2, 2, 1)
plt.ylim(ymax+0.05*yrange, ymin-0.05*yrange)
plt.plot(phi[0], y[0])

plt.plot([ps, ps], [ymax, ymin], linestyle='--')