def newDetrendDataTask(clip): flux = clip['cotrend.flux_frac'] flags = clip['cotrend.flags'] nPoints = clip['config.nPointsForMedianSmooth'] #When you detrend, you must do something about the gaps and bad values. #This is the simplest possible thing. Replace all bad/missing data with #zeros. This is a placehold. Bad data inside a transit is replaced with #a zero, which is not what you want. flux[flags] = 0 #Do a simple detrend. detrend = kplrfits.medianSubtract1d(flux, nPoints) clip['detrend'] = dict() clip['detrend.flux_frac'] = detrend clip['detrend.flags'] = flags clip['detrend.source'] = "Simple Median detrend" rollTweakAmp = noise.computeRollTweakAmplitude(detrend[~flags]) clip['detrend.rollTweakAmp'] = rollTweakAmp cdpp6 = noise.computeSgCdpp_ppm(detrend[~flags]) clip['detrend.cdpp6_ppm'] = cdpp6 perPointScatter = noise.estimateScatterWithMarshallMethod(detrend[~flags]) clip['detrend.perPointScatter_ppm'] = 1e6*perPointScatter assert(detrend is not None) return clip
def newDetrendDataTask(clip): flux = clip['cotrend.flux_frac'] flags = clip['cotrend.flags'] nPoints = clip['config.nPointsForMedianSmooth'] #When you detrend, you must do something about the gaps and bad values. #This is the simplest possible thing. Replace all bad/missing data with #zeros. This is a placehold. Bad data inside a transit is replaced with #a zero, which is not what you want. flux[flags] = 0 #Do a simple detrend. detrend = kplrfits.medianSubtract1d(flux, nPoints) clip['detrend'] = dict() clip['detrend.flux_frac'] = detrend clip['detrend.flags'] = flags clip['detrend.source'] = "Simple Median detrend" rollTweakAmp = noise.computeRollTweakAmplitude(detrend[~flags]) clip['detrend.rollTweakAmp'] = rollTweakAmp cdpp6 = noise.computeSgCdpp_ppm(detrend[~flags]) clip['detrend.cdpp6_ppm'] = cdpp6 perPointScatter = noise.estimateScatterWithMarshallMethod(detrend[~flags]) clip['detrend.perPointScatter_ppm'] = 1e6 * perPointScatter assert (detrend is not None) return clip
def findBestPeak(blsArray, nPointsForSmooth=100, offset=0): """Find the index of the best peak in the bls spectrum. The best peak is not usually the strongest one. The noise floor of a BLS increases at long period, so this must be accounted for before selecting the strongest amplitude. Inputs: ------------- blsArray (3d numpy array) Optional Inputs: ----------------- nPointsForSmooth (int) Tuning parameter. This is the number of points near a given period used to determine what the typical background BLS value is. offset (int) Debugging option. Change the chosen period by this number of indices. Returns: ------------ A three element tuple of indices into blsArray giving the best period, duration and phase of transit. """ bb = blsArray.max(axis=1) bbb = bb.max(axis=1) # bbb is 1d array of strongest peak at each period. # We need to remove background trend before we decide which peak # is the best choice filt = kf.medianSubtract1d(bbb, nPointsForSmooth) iPer = np.argmax(filt) iPer += offset subArray = blsArray[iPer,:,:] iDur, iPhase = np.unravel_index(np.argmax(subArray), subArray.shape) return iPer, iDur, iPhase
def getBls(clip): bls = clip['bls.convolved_bls'] filt = kf.medianSubtract1d(bls, 100) return filt