Exemple #1
0
def transitmodel (sol,time, itime=-1, ntt=0, tobs=0, omc=0, dtype=0 ): 
    "read in transitmodel solution"  
    nplanet=int((len(sol)-8)/10) #number of planets
    
    if type(itime) is int :
        if itime < 0 :
            itime=ones(len(time))*0.020434
        else:
            itime=ones(len(time))*float(itime)
    
    if type(ntt) is int :
        nttin=  zeros(nplanet, dtype="int32") #number of TTVs measured 
        tobsin= zeros(shape=(nplanet,len(time))) #time stamps of TTV measurements (days)
        omcin=  zeros(shape=(nplanet,len(time))) #TTV measurements (O-C) (days)
    else:
        nttin=ntt
        tobsin=tobs
        omcin=omc
    
    if type(dtype) is int :
        dtypein=ones(len(time), dtype="int32")*int(dtype) #contains data type, 0-photometry,1=RV data

    tmodel= zeros(len(time)) #contains the transit model
    tfit5.transitmodel(nplanet,sol,time,itime,nttin,tobsin,omcin,tmodel,dtypein)
    return tmodel;
Exemple #2
0
def transitmodel (sol,time, itime=-1, ntt=0, tobs=0, omc=0, dtype=0 ): 
    "read in transitmodel solution"  
    nplanet=int((len(sol)-8)/10) #number of planets
    
    if type(itime) is float :
        if itime < 0 :
            itime=ones(len(time))*0.020434
        else:
            itime=ones(len(time))*float(itime)
    
    if type(ntt) is int :
        nttin=  zeros(nplanet, dtype="int32") #number of TTVs measured 
        tobsin= zeros(shape=(nplanet,len(time))) #time stamps of TTV measurements (days)
        omcin=  zeros(shape=(nplanet,len(time))) #TTV measurements (O-C) (days)
    else:
        nttin=ntt
        tobsin=tobs
        omcin=omc
    
    if type(dtype) is int :
        dtypein=ones(len(time), dtype="int32")*int(dtype) #contains data type, 0-photometry,1=RV data

    tmodel= zeros(len(time)) #contains the transit model
    tfit5.transitmodel(nplanet,sol,time,itime,nttin,tobsin,omcin,tmodel,dtypein)
    return tmodel;
Exemple #3
0
def transitmodel (sol,time,ld1,ld2,ld3,ld4,rdr,tarray,\
    itime=-1, ntt=0, tobs=0, omc=0, dtype=0 ):
    """Get a transit model
    Usage: tmodel = transitmodel(sol,time,ld1,ld2,ld3,ld4,rdr,tarray,\
      itime=-1, ntt=0, tobs=0, omc=0, dtype=0)

    Inputs:
      sol - Transit model parameters
      time - time array
      ld1,ld2,ld3,ld4 - limb-darkening array
      rdr - Rp/R* array
      tarray - Thermal eclipse array

    Outputs:
      tmodel - relative flux at times given by time array
    """
    nplanet = int((len(sol) - 8) / 10)  #number of planets

    if type(itime) is float:
        if itime < 0:
            itime = np.ones(len(time)) * 0.020434
        else:
            itime = np.ones(len(time)) * float(itime)

    if type(ntt) is int:
        nttin = np.zeros(nplanet, dtype="int32")  #number of TTVs measured
        tobsin = np.zeros(
            shape=(nplanet,
                   len(time)))  #time stamps of TTV measurements (days)
        omcin = np.zeros(shape=(nplanet,
                                len(time)))  #TTV measurements (O-C) (days)
    else:
        nttin = ntt
        tobsin = tobs
        omcin = omc

    if type(dtype) is int:
        dtypein = np.ones(len(time), dtype="int32") * int(
            dtype)  #contains data type, 0-photometry,1=RV data

    tmodel = np.zeros(len(time))  #contains the transit model
    tfit5.transitmodel(nplanet,sol,time,itime,nttin,tobsin,omcin,tmodel,dtypein,\
        ld1,ld2,ld3,ld4,rdr,tarray)
    return tmodel
Exemple #4
0
def transitplot(time,flux,sol,nplanetplot=1, itime=-1, ntt=0, tobs=0, omc=0, dtype=0):
    "plot the transit model"
    nplanet=int((len(sol)-8)/10) #number of planets

    #deal with input vars and translating to FORTRAN friendly.
    
    if type(itime) is int :
        if itime < 0 :
            itime=ones(len(time))*0.020434
        else:
            itime=ones(len(time))*float(itime)
    
    if type(ntt) is int :
        nttin=  zeros(nplanet, dtype="int32") #number of TTVs measured 
        tobsin= zeros(shape=(nplanet,len(time))) #time stamps of TTV measurements (days)
        omcin=  zeros(shape=(nplanet,len(time))) #TTV measurements (O-C) (days)
    else:
        nttin=ntt
        tobsin=tobs
        omcin=omc
 
    if type(dtype) is int :
        dtypein=ones(len(time), dtype="int32")*int(dtype) #contains data type, 0-photometry,1=RV data
    
    #remove other planets for plotting
    sol2=np.copy(sol)
    for i in range(1,nplanet+1):
        if i!=nplanetplot:
            nc=8+10*(i-1)
            sol2[nc+3]=0.0 #rdrs
    tmodel= zeros(len(time)) #contains the transit model
    tfit5.transitmodel(nplanet,sol2,time,itime,nttin,tobsin,omcin,tmodel,dtypein)
    stdev=np.std(flux-tmodel)
    #print(stdev)
    
    #make a model with only the other transits to subtract
    nc=8+10*(nplanetplot-1)
    sol2=np.copy(sol)
    sol2[nc+3]=0.0 #rdrs
    tmodel2= zeros(len(time)) #contains the transit model
    tfit5.transitmodel(nplanet,sol2,time,itime,nttin,tobsin,omcin,tmodel2,dtypein)
    
    epo=sol[nc+0] #time of center of transit
    per=sol[nc+1] #orbital period
    zpt=sol[7] #photometric zero-point
    
    tdur=tfit5.transitdur(sol,1)/3600.0 #transit duration in hours
    
    ph1=epo/per-math.floor(epo/per) #calculate phases
    phase=[]
    tcor=tfit5.lininterp(tobsin,omcin,nplanetplot,nttin,epo)
    #print(tcor,nttin,tobsin[1,1],omcin[1,1])
    for x in time:
        if nttin[nplanetplot-1] > 0:
            tcor=tfit5.lininterp(tobsin,omcin,nplanetplot,nttin,x)
        else:
            tcor=0.0
        t=x-tcor
        ph=(t/per-math.floor(t/per)-ph1)*per*24.0 #phase in hours offset to zero.
        phase.append(ph)
        
    phase = np.array(phase) #convert from list to array
    
    phasesort=np.copy(phase)
    fluxsort=np.copy(tmodel)
    p=ones(len(phase), dtype="int32") #allocate array for output. FORTRAN needs int32 
    tfit5.rqsort(phase,p)    
    i1=0
    i2=len(phase)-1
    for i in range(0,len(phase)):
        phasesort[i]=phase[p[i]-1]
        fluxsort[i]=tmodel[p[i]-1]
        if phasesort[i] < -tdur:
            i1=i
        if phasesort[i] <  tdur:
            i2=i
    
    fplot=flux-tmodel2+1.0
    
    plt.figure(figsize=(12,10)) #adjust size of figure
    matplotlib.rcParams.update({'font.size': 22}) #adjust font
    plt.scatter(phase, fplot, c="blue", s=100.0, alpha=0.35, edgecolors="none") #scatter plot
    plt.plot(phasesort, fluxsort, c="red", lw=3.0)
    plt.xlabel('Phase (hours)') #x-label
    plt.ylabel('Relative Flux') #y-label
    x1,x2,y1,y2 = plt.axis()    #get range of plot
    ymin=min(fluxsort[i1:i2])
    ymax=max(fluxsort[i1:i2])
    y1=ymin-0.1*(ymax-ymin)-2.0*stdev
    y2=ymax+0.1*(ymax-ymin)+2.0*stdev
    plt.axis((-tdur,tdur,y1,y2)) #readjust range
    plt.show()  #show the plot
        
    return;
        
    return;
Exemple #5
0
def transitplot(time,flux,sol,nplanetplot=1, itime=-1, ntt=0, tobs=0, omc=0, dtype=0):
    "plot the transit model"
    nplanet=int((len(sol)-8)/10) #number of planets

    #deal with input vars and translating to FORTRAN friendly.
    
    if type(itime) is int :
        if itime < 0 :
            itime=ones(len(time))*0.020434
        else:
            itime=ones(len(time))*float(itime)
    
    if type(ntt) is int :
        nttin=  zeros(nplanet, dtype="int32") #number of TTVs measured 
        tobsin= zeros(shape=(nplanet,len(time))) #time stamps of TTV measurements (days)
        omcin=  zeros(shape=(nplanet,len(time))) #TTV measurements (O-C) (days)
    else:
        nttin=ntt
        tobsin=tobs
        omcin=omc
 
    if type(dtype) is int :
        dtypein=ones(len(time), dtype="int32")*int(dtype) #contains data type, 0-photometry,1=RV data
    
    #remove other planets for plotting
    sol2=np.copy(sol)
    for i in range(1,nplanet+1):
        if i!=nplanetplot:
            nc=8+10*(i-1)
            sol2[nc+3]=0.0 #rdrs
    tmodel= zeros(len(time)) #contains the transit model
    tfit5.transitmodel(nplanet,sol2,time,itime,nttin,tobsin,omcin,tmodel,dtypein)
    stdev=np.std(flux-tmodel)
    #print(stdev)
    
    #make a model with only the other transits to subtract
    nc=8+10*(nplanetplot-1)
    sol2=np.copy(sol)
    sol2[nc+3]=0.0 #rdrs
    tmodel2= zeros(len(time)) #contains the transit model
    tfit5.transitmodel(nplanet,sol2,time,itime,nttin,tobsin,omcin,tmodel2,dtypein)
    
    epo=sol[nc+0] #time of center of transit
    per=sol[nc+1] #orbital period
    zpt=sol[7] #photometric zero-point
    
    tdur=tfit5.transitdur(sol,1)/3600.0 #transit duration in hours
    
    ph1=epo/per-math.floor(epo/per) #calculate phases
    phase=[]
    tcor=tfit5.lininterp(tobsin,omcin,nplanetplot,nttin,epo)
    #print(tcor,nttin,tobsin[1,1],omcin[1,1])
    for x in time:
        if nttin[nplanetplot-1] > 0:
            tcor=tfit5.lininterp(tobsin,omcin,nplanetplot,nttin,x)
        else:
            tcor=0.0
        t=x-tcor
        ph=(t/per-math.floor(t/per)-ph1)*per*24.0 #phase in hours offset to zero.
        phase.append(ph)
        
    phase = np.array(phase) #convert from list to array
    
    phasesort=np.copy(phase)
    fluxsort=np.copy(tmodel)
    p=ones(len(phase), dtype="int32") #allocate array for output. FORTRAN needs int32 
    tfit5.rqsort(phase,p)    
    i1=0
    i2=len(phase)-1
    for i in range(0,len(phase)):
        phasesort[i]=phase[p[i]-1]
        fluxsort[i]=tmodel[p[i]-1]
        if phasesort[i] < -tdur:
            i1=i
        if phasesort[i] <  tdur:
            i2=i
    
    fplot=flux-tmodel2+1.0
    
    plt.figure(figsize=(12,10)) #adjust size of figure
    matplotlib.rcParams.update({'font.size': 22}) #adjust font
    plt.scatter(phase, fplot, c="blue", s=100.0, alpha=0.35, edgecolors="none") #scatter plot
    plt.plot(phasesort, fluxsort, c="red", lw=3.0)
    plt.xlabel('Phase (hours)') #x-label
    plt.ylabel('Relative Flux') #y-label
    x1,x2,y1,y2 = plt.axis()    #get range of plot
    ymin=min(fluxsort[i1:i2])
    ymax=max(fluxsort[i1:i2])
    y1=ymin-0.1*(ymax-ymin)-2.0*stdev
    y2=ymax+0.1*(ymax-ymin)+2.0*stdev
    plt.axis((-tdur,tdur,y1,y2)) #readjust range
    plt.show()  #show the plot
        
    return;
        
    return;