Skip to content

Commit

Permalink
Implemented outlier test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonzink authored Oct 23, 2020
1 parent 2eb9718 commit f443faf
Show file tree
Hide file tree
Showing 7 changed files with 501 additions and 94 deletions.
Binary file modified EDIunplugged/__pycache__/main.cpython-36.pyc
Binary file not shown.
Binary file modified EDIunplugged/__pycache__/metrics.cpython-36.pyc
Binary file not shown.
109 changes: 61 additions & 48 deletions EDIunplugged/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Created by Jon Zink (jzink@astro.ucla.edu)
# Developed with python 3.7.1
#
# If you make use of this code, please cite:
# J. K. Zink et al. 2020a


import EDIunplugged.metrics as ediMet
import EDIunplugged.version as version
import warnings
Expand Down Expand Up @@ -31,7 +38,7 @@ class parameters(object):
# Working with the parameters
>>> params=EDI_Vetter.paramaters(tlsOut, limbDark=[0.48, 0.19], impact=0, snrThreshold=7, minTransit=3)
>>> params=EDI_Vetter.Go(params, delta_mag=2.7, delta_dist=1000, photoAp=25, telescope="Kepler")
>>> params=EDI_Vetter.Go(params, deltaMag=2.7, deltaDist=1000, photoAp=25, telescope="Kepler", )
"""

Expand All @@ -55,10 +62,41 @@ def __init__(self, tlsOut,limbDark=None, impact=None, snrThreshold=7, minTransit
print("WARNING: assuming default impact parameter value")
self.impact=0

def prettyPrint(params):
print("""
___________ _____ _ _ _ _
| ___| _ \_ _| | | | | | | | |
| |__ | | | | | |______| | | | ___| |_| |_ ___ _ __
| __|| | | | | |______| | | |/ _ \ __| __/ _ \ '__|
| |___| |/ / _| |_ \ \_/ / __/ |_| || __/ |
\____/|___/ \___/ \___/ \___|\__|\__\___|_| Unplugged
""")
print("Version "
+ version.EDI_VERSIONING
+ " ("
+ version.EDI_DATE
+ ")"
)
print("==========================================")
print(" Vetting Report")
print("==========================================")
print(" Flux Contamination : " + str(params.fluxContamFP))
print(" Too Many Outliers : " + str(params.outlierTranFP))
print(" Too Many Transits Masked : " + str(params.transMaskFP))
print("Odd/Even Transit Variation : " + str(params.evenOddFP))
print(" Signal is not Unique : " + str(params.uniqueFP))
print(" Secondary Eclipse Found : " + str(params.secEclipseFP))
# print(" Transit Mid-point Slipped : " + str(params.eph_slipFP))
# print(" Strong Harmonic Found : " + str(params.harmonicFP))
print("Low Transit Phase Coverage : " + str(params.phaseCoverFP) )
print(" Transit Duration Too Long : " + str(params.tranDurFP))
print("==========================================")
print("Signal is a False Positive : "+ str(params.FalsePositive))




def Go(params,delta_mag=float("Inf"),delta_dist=float("Inf"), photoAp=1, telescope=None):
def Go(params, deltaMag=float("Inf"), deltaDist=float("Inf"), photoAp=1, telescope=None, print=True):
"""Initialize All Vetting Metrics.
The Go function runs all of the EDI-Vetter metrics on the transit signal.
Expand All @@ -67,16 +105,18 @@ def Go(params,delta_mag=float("Inf"),delta_dist=float("Inf"), photoAp=1, telesco
params (Required[object]): the transit parameters needed to assess
the validity of the signal
delta_mag (optional[float]): magnitude difference between target star
deltaMag (optional[float]): magnitude difference between target star
and potential contaminate source in the Gaia G band
delta_dist (optional[float]): distance between the target star and the
deltaDist (optional[float]): distance between the target star and the
potential contaminate source in arc-seconds
photoAp (optional[int]): number of pixels used for the target aperture
telescope (optional[string]): name of telescope data was collected from
(i.e. "Kepler", "K2", or "TESS")
(i.e., "Kepler", "K2", or "TESS")
print (optional[boolean]): do you want EDI to print out the results
Output:
params : the modified transit parameters needed to assess
Expand All @@ -99,57 +139,30 @@ def Go(params,delta_mag=float("Inf"),delta_dist=float("Inf"), photoAp=1, telesco
pxScale=3.98

params.FalsePositive=False
############# Run EDI-Vetter ########
############# Exoplanet Detection Indicator - Vetter ######

print("""
___________ _____ _ _ _ _
| ___| _ \_ _| | | | | | | | |
| |__ | | | | | |______| | | | ___| |_| |_ ___ _ __
| __|| | | | | |______| | | |/ _ \ __| __/ _ \ '__|
| |___| |/ / _| |_ \ \_/ / __/ |_| || __/ |
\____/|___/ \___/ \___/ \___|\__|\__\___|_| Unplugged
""")
print("Version "
+ version.EDI_VERSIONING
+ " ("
+ version.EDI_DATE
+ ")"
)
params=ediMet.fluxContamination(params,delta_mag,delta_dist, photoAp,pxScale)
params=ediMet.outlierTransit(params)
params=ediMet.individual_transits(params)
params=ediMet.even_odd_transit(params)
params=ediMet.uniqueness_test(params)

############# Run EDI-Vetter Unplugged ########
############# Exoplanet Detection Indicator - Vetter ######

params=ediMet.fluxContam(params, deltaMag, deltaDist, photoAp,pxScale)
params=ediMet.outlierTran(params)
params=ediMet.transMask(params)
params=ediMet.evenOdd(params)
params=ediMet.unique(params)
# params=ephemeris_wonder(params)
params=ediMet.check_SE(params)
params=ediMet.secEclipse(params)
# params=harmonic_test(params)
# params=period_alias(params,cycle=True)
params=ediMet.phase_coverage(params)
params=ediMet.tdur_max(params)
params=ediMet.phaseCover(params)
params=ediMet.tranDur(params)

if params.fluxContaminationFP | params.outlierTransitFP | params.TransMaskFP | params.even_odd_transit_misfit | params.uniquenessFP | params.SeFP | params.phaseCoverFP | params.tdurFP :
if params.fluxContamFP | params.outlierTranFP| params.transMaskFP | params.evenOddFP | params.uniqueFP | params.secEclipseFP | params.phaseCoverFP | params.tranDurFP :
params.FalsePositive=True
else:
params.FalsePositive=False

print("==========================================")
print(" Vetting Report")
print("==========================================")
print(" Flux Contamination : " + str(params.fluxContaminationFP))
# print(" Too Many Outliers : " + str(params.outlierTransitFP))
print(" Too Many Transits Masked : " + str(params.TransMaskFP))
print("Odd/Even Transit Variation : " + str(params.even_odd_transit_misfit))
print(" Signal is not Unique : " + str(params.uniquenessFP))
print(" Secondary Eclipse Found : " + str(params.SeFP))
# print(" Transit Mid-point Slipped : " + str(params.eph_slipFP))
# print(" Strong Harmonic Found : " + str(params.harmonicFP))
print("Low Transit Phase Coverage : " + str(params.phaseCoverFP) )
print(" Transit Duration Too Long : " + str(params.tdurFP))
print("==========================================")
print("Signal is a False Positive : "+ str(params.FalsePositive))


if print==True:
prettyPrint(params)

return params


Expand Down
65 changes: 36 additions & 29 deletions EDIunplugged/metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Created by Jon Zink (jzink@astro.ucla.edu)
# Developed with python 3.7.1
#
# If you make use of this code, please cite:
# J. K. Zink et al. 2020a


import numpy as np
from astropy.stats import mad_std
from scipy import special

def fluxContamination(params,delta_mag,delta_dist, photoAp, pxScale):
def fluxContam(params,delta_mag,delta_dist, photoAp, pxScale):
"""Flux Contamination test
Look for transit contamination from nearby stars.
Expand Down Expand Up @@ -36,16 +43,16 @@ def fluxContamination(params,delta_mag,delta_dist, photoAp, pxScale):
# params.fluxContaminationFP=True

if (fit_rp*np.sqrt(fTotStar) + fit_b)>1.04:
params.fluxContaminationFP=True
params.fluxContamFP=True

elif (fit_rp)*np.sqrt(fTotStar)>0.3:
params.fluxContaminationFP=True
params.fluxContamFP=True
else:
params.fluxContaminationFP=False
params.fluxContamFP=False

return params

def outlierTransit(params):
def outlierTran(params):

"""Outlier Detection
Expand Down Expand Up @@ -75,13 +82,13 @@ def outlierTransit(params):
noDepthsd=mad_std(foldY[(foldX<.5-tdur/per/2) | (foldX>.5+tdur/per/2)])

if Depthsd>(0.4*mes-1.764)*noDepthsd:
params.outlierTransitFP=True
params.outlierTranFP=True
else:
params.outlierTransitFP=False
params.outlierTranFP=False

return params

def individual_transits(params):
def transMask(params):

"""Individual Transit Test
Expand Down Expand Up @@ -113,36 +120,36 @@ def individual_transits(params):


if nTr<params.minTransit:
params.TransMaskFP=True
params.transMaskFP=True
else:
params.TransMaskFP=False
params.transMaskFP=False

if (np.max(sESReal))>=(0.8*np.sqrt(3/params.minTransit)*np.sqrt(sEStot)):
params.TransMaskFP=True
params.transMaskFP=True
else:
pass

if np.sqrt(sEStot)<params.snrThreshold:
params.TransMaskFP=True
params.transMaskFP=True
else:
pass

return params


def even_odd_transit(params):
def evenOdd(params):

eoSig=params.tlsOut.odd_even_mismatch

if eoSig>5:
params.even_odd_transit_misfit=True
params.evenOddFP=True
else:
params.even_odd_transit_misfit=False
params.evenOddFP=False

return params


def uniqueness_test(params):
def unique(params):
per=params.tlsOut.period
tdur=params.tlsOut.duration
falseAlarm=params.tlsOut.FAP
Expand Down Expand Up @@ -173,17 +180,17 @@ def uniqueness_test(params):
signalSD=mad_std(signal[signal<signalMax])

if np.isnan(falseAlarm):
params.uniquenessFP=True
params.uniqueFP=True
elif signalTrue<signalAvg+falseAlarmFold*signalSD:
params.uniquenessFP=True
params.uniqueFP=True
elif falseAlarm>thershold:
params.uniquenessFP=True
params.uniqueFP=True
else:
params.uniquenessFP=False
params.uniqueFP=False
return params


def check_SE(params):
def secEclipse(params):
per=params.tlsOut.period
tdur=params.tlsOut.duration
foldY=params.tlsOut.folded_y
Expand All @@ -196,21 +203,21 @@ def check_SE(params):
if 0.1*depth<seDepth:
if fit_b>=.9:
params.SE_found=True
params.SeFP=True
params.secEclipseFP=True
else:
params.SE_found=True
params.SeFP=False
params.secEclipseFP=False
elif seDepth>3*seDepthsd:
params.SeFP=False
params.secEclipseFP=False
params.SE_found=True

else:
params.SeFP=False
params.secEclipseFP=False
params.SE_found=False
return params


def phase_coverage(params):
def phaseCover(params):

fit_P=params.tlsOut.period
fit_t0=params.tlsOut.T0
Expand Down Expand Up @@ -239,17 +246,17 @@ def allow_tol(x):

return params

def tdur_max(params):
def tranDur(params):
fit_P=params.tlsOut.period
fit_t0=params.tlsOut.T0
fit_tdur=params.tlsOut.duration

if fit_P<.5:
params.tdurFP=True
elif fit_tdur/fit_P>.1:
params.tdurFP=True
params.tranDurFP=True
else:
params.tdurFP=False
params.tranDurFP=False

return params

4 changes: 2 additions & 2 deletions EDIunplugged/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
EDI_VERSIONING = "0.1.2"
EDI_DATE = "11 Sept 2020"
EDI_VERSIONING = "0.1.3"
EDI_DATE = "23 October 2020"
Loading

0 comments on commit f443faf

Please sign in to comment.