Exemple #1
0
def modshiftTask(clip):

    time = clip['serve.time']
    flux = clip['detrend.flux_frac']
    fl = clip['flags']

    epic = clip['value']
    basename = clip['config.modshiftBasename'] + "%010i" %(epic)
    period_days = clip['trapFit.period_days']
    epoch_bkjd = clip['trapFit.epoch_bkjd']
    dur_hrs =  clip['trapFit.duration_hrs']
    ingress_hrs = clip['trapFit.ingress_hrs']
    depth_ppm = 1e6*clip['trapFit.depth_frac']

    subSampleN= 15
    ioBlock = trapFit.trapezoid_model_onemodel(time[~fl], period_days, \
        epoch_bkjd, depth_ppm, dur_hrs, \
        ingress_hrs, subSampleN)
    model = ioBlock.modellc -1   #Want mean of zero
#    model *= -1  #Invert for testing

    basename = "%s-%010i" %(basename, epic)
    
    modplotint=1  # Change to 0 or anything besides 1 to not have modshift produce plot
    
    out = ModShift.runModShift(time[~fl], flux[~fl], model, basename, \
        "OBJECTNAME", period_days, epoch_bkjd, modplotint)

    clip['modshift'] = out

    #I don't know which values are important, so I can't enfornce contract yet
    return clip
Exemple #2
0
def injectTransitClip(clip):
    """
    The clipboard needs to contain
       clip.inject:  period_days,epoch_bkjd,depth_ppm,duration_hrs,ingress_hrs
       clip.serve: needs to contain the serve and cotrend keys
       
       the output clip has altered the clip.cotrend.flux_frac with
       transits specified in clip.inject
    """
    time_days=clip.serve.time    
    inj=clip.inject    
    influx=clip.cotrend.flux_frac
    
    
    subSampleN= 15
    time_days[~np.isfinite(time_days)] = 0  #Hide the Nans from one_model
    assert(np.all(np.isfinite(time_days)))
    ioBlock = tf.trapezoid_model_onemodel(time_days, inj['period_days'], \
                inj['epoch_bkjd'], inj['depth_ppm'], inj['duration_hrs'], \
                inj['ingress_hrs'], subSampleN)
    
    injModel = ioBlock.modellc - 1  #Want mean of zero

    clip.cotrend['flux_frac'] = influx + injModel
    
    clip.cotrend['source'] = "%s %s" % (clip.cotrend.source, "Injected")
    
    return clip
Exemple #3
0
def modshiftTask(clip):

    time = clip['serve.time']
    flux = clip['detrend.flux_frac']
    fl = clip['flags']

    epic = clip['value']
    basename = clip['config.modshiftBasename'] + "%010i" % (epic)
    period_days = clip['trapFit.period_days']
    epoch_bkjd = clip['trapFit.epoch_bkjd']
    dur_hrs = clip['trapFit.duration_hrs']
    ingress_hrs = clip['trapFit.ingress_hrs']
    depth_ppm = 1e6 * clip['trapFit.depth_frac']

    subSampleN = 15
    ioBlock = trapFit.trapezoid_model_onemodel(time[~fl], period_days, \
        epoch_bkjd, depth_ppm, dur_hrs, \
        ingress_hrs, subSampleN)
    model = ioBlock.modellc - 1  #Want mean of zero
    #    model *= -1  #Invert for testing

    basename = "%s-%010i" % (basename, epic)

    modplotint = 1  # Change to 0 or anything besides 1 to not have modshift produce plot

    out = ModShift.runModShift(time[~fl], flux[~fl], model, basename, \
        "OBJECTNAME", period_days, epoch_bkjd, modplotint)

    clip['modshift'] = out

    #I don't know which values are important, so I can't enfornce contract yet
    return clip
Exemple #4
0
def makeTestData():
    t = np.linspace(0, 60, 60*48)
    period = 2.41
    epoch = 1.1
    y = dtf.trapezoid_model_onemodel(t, period, epoch, 100, 6, 1, 15).modellc

    y /= np.mean(y)
    y-=1
    return t,y
Exemple #5
0
def getSnrOfTransit(time_days, flux_frac, unc, flags, period_days, phase_bkjd, \
    duration_hrs, depth_frac):
    """

    Inputs:
    ------------
    flux_frac
        (1d np array) Flux in fractional amplitude. The mean of this array
        should be zero for sane data. The trapezoid fit takes data with
        a mean of 1, the conversion is done within this function
    """

    idx = np.isfinite(time_days) & (np.isfinite(flux_frac))
    idx = idx & ~flags
    ioblk = tf.trapezoid_fit(time_days[idx], 1+flux_frac[idx], unc[idx], \
                  period_days, phase_bkjd, duration_hrs, \
                  1e6*depth_frac, fitTrialN=13, fitRegion=10.0, \
                  errorScale=1.0, debugLevel=0, \
                  sampleN=15)

    #Taken from trapfit.py around lines 434
    out = dict()
    out['period_days'] = period_days
    out['epoch_bkjd'] = ioblk.timezpt + ioblk.bestphysvals[0]
    out['duration_hrs'] = 24 * ioblk.bestphysvals[2]
    out['ingress_hrs'] = out['duration_hrs'] * ioblk.bestphysvals[3]
    out['depth_frac'] = ioblk.bestphysvals[1]

    #compute modelat all input time values
    subSampleN = 15
    time_days[~np.isfinite(time_days)] = 0  #Hide the Nans from one_model
    assert (np.all(np.isfinite(time_days)))
    ioBlock = tf.trapezoid_model_onemodel(time_days, period_days, \
                out['epoch_bkjd'], 1e6*out['depth_frac'], out['duration_hrs'], \
                out['ingress_hrs'], subSampleN)

    out['bestFitModel'] = ioBlock.modellc - 1  #Want mean of zero
    out['snr'] = estimateSnr(time_days, flux_frac, flags, out['period_days'], \
                    out['epoch_bkjd'], out['duration_hrs'], out['depth_frac'])

    #out['bestFitModel'] = time_days*0
    #out['snr'] = -1
    return out
Exemple #6
0
def getSnrOfTransit(time_days, flux_frac, unc, flags, period_days, phase_bkjd, \
    duration_hrs, depth_frac):
    """

    Inputs:
    ------------
    flux_frac
        (1d np array) Flux in fractional amplitude. The mean of this array
        should be zero for sane data. The trapezoid fit takes data with
        a mean of 1, the conversion is done within this function
    """

    idx = np.isfinite(time_days) & (np.isfinite(flux_frac))
    idx = idx & ~flags
    ioblk = tf.trapezoid_fit(time_days[idx], 1+flux_frac[idx], unc[idx], \
                  period_days, phase_bkjd, duration_hrs, \
                  1e6*depth_frac, fitTrialN=13, fitRegion=10.0, \
                  errorScale=1.0, debugLevel=0, \
                  sampleN=15)

    #Taken from trapfit.py around lines 434
    out = dict()
    out['period_days'] = period_days
    out['epoch_bkjd'] = ioblk.timezpt + ioblk.bestphysvals[0]
    out['duration_hrs'] = 24* ioblk.bestphysvals[2]
    out['ingress_hrs'] = out['duration_hrs'] * ioblk.bestphysvals[3]
    out['depth_frac'] = ioblk.bestphysvals[1]

    #compute modelat all input time values
    subSampleN= 15
    time_days[~np.isfinite(time_days)] = 0  #Hide the Nans from one_model
    assert(np.all(np.isfinite(time_days)))
    ioBlock = tf.trapezoid_model_onemodel(time_days, period_days, \
                out['epoch_bkjd'], 1e6*out['depth_frac'], out['duration_hrs'], \
                out['ingress_hrs'], subSampleN)
    
    out['bestFitModel'] = ioBlock.modellc - 1  #Want mean of zero
    out['snr'] = estimateSnr(time_days, flux_frac, flags, out['period_days'], \
                    out['epoch_bkjd'], out['duration_hrs'], out['depth_frac'])

    #out['bestFitModel'] = time_days*0
    #out['snr'] = -1
    return out