How to use contaminante
¶
This tutorial will show you how to use contaminante
. If you’d like
to try it yourself, you can use contaminante
online, in the cloud,
for free! Click
here
to run contaminante
online using Google’s Colaboratory.
Using contaminante
on Kepler data¶
To demonstrate contaminante
we’ll first use Kepler data. First
we’ll need a target to try contaminante
on. I’ve chosen KIC
6804648. This target was observed during the prime Kepler mission,
and was flagged as a planet candidate. In fact, the target has a
contaminating eclipsing binary. This binary is only obvious in some of
the Kepler quarters.
Below we run the target through contaminante
. Running this cell
should take less than 5 minutes.
In [1]:
%load_ext autoreload
%autoreload 2
In [2]:
import contaminante as ct
import lightkurve as lk
In [3]:
lk.__version__
Out[3]:
'2.0.9'
In [49]:
tpfs = lk.search_targetpixelfile('KIC 6804648', quarter=[10, 11, 12]).download_all()
period = 0.700606
t0 = 131.59767
duration = 0.993/24
In [59]:
result = ct.calculate_contamination(tpfs, period, t0, duration, plot=True, sff=False, spline_period=0.5, cbvs=True);
Modeling TPFs: 0%| | 0/3 [00:00<?, ?it/s]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:266: RuntimeWarning: invalid value encountered in true_divide
cxs, cys = [], []
Modeling TPFs: 33%|███▎ | 1/3 [00:06<00:12, 6.18s/it]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:266: RuntimeWarning: invalid value encountered in true_divide
cxs, cys = [], []
Modeling TPFs: 67%|██████▋ | 2/3 [00:11<00:05, 5.82s/it]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:266: RuntimeWarning: invalid value encountered in true_divide
cxs, cys = [], []
Modeling TPFs: 100%|██████████| 3/3 [00:16<00:00, 5.47s/it]



Using contaminante
we can see two pieces of evidence that this
target is contaminated. 1. There is a significant offset between the
center of the target (blue dot) in the image, and the source of
the transiting signal (red dot). NOTE: The blue dot is the weighted
average of the flux inside the pipeline aperture, for crowded sources
this may not be accurate. 2. There is a significant difference between
the target phase curve (blue phase curve) and the source of the
transiting signal phase curve (red phase curve).
We name the source of the transiting signal that contaminante
finds
the "contaminator".
The result is a list of dictionaries contains the depth and positions of the target and the "contamintor" for each quarter, including errors. The user is encouraged to 1) look at the phase curves 2) look at the positions of the contaminator and target and 3) the transit depths of the contaminator and the target before claiming that a target is contaminated. In the above cases there is a significant difference between the contaminator and the target.
In [60]:
result
Out[60]:
[{'target_depth': (2.6802764358274484e-05, 4.054373618487692e-06),
'target_ra': (298.48318669878716, 1.7445106673522628e-09),
'target_dec': (42.24187174849672, 1.1745150091724413e-09),
'target_lc': <KeplerLightCurve length=4436 LABEL="KIC 6804648" QUARTER=10 CAMPAIGN=None>
time flux ... cadenceno quality
...
object float64 ... int32 int32
------------------ ------------------ ... --------- -------
906.8458248060851 0.9998834409577795 ... 39049 0
906.8662592900218 1.000124118445111 ... 39050 0
906.886693673965 1.0000414874046624 ... 39051 0
906.9071281576762 1.0000099381260454 ... 39052 128
906.9275624413785 0.999892003922948 ... 39053 0
906.9479968246233 0.9999607055625797 ... 39054 0
906.9684313078615 0.9999491057129979 ... 39055 0
906.9888655908726 1.0000180109390528 ... 39056 0
907.0092999736517 0.9998898861670931 ... 39057 0
... ... ... ... ...
1000.0851898831825 0.9999551024001835 ... 43612 0
1000.1056229714231 1.0000391357585516 ... 43613 0
1000.1260561591916 0.9998485596466309 ... 43614 8192
1000.1464891469659 1.0000864769487188 ... 43615 0
1000.166922334276 0.9999897268297215 ... 43616 0
1000.1873554213453 1.0000424732681419 ... 43617 0
1000.2077884081882 1.0000830571070023 ... 43618 0
1000.2282215947926 0.9999801862137017 ... 43619 0
1000.2486546809378 1.000032779199553 ... 43620 0
1000.2690876668494 0.999811392172271 ... 43621 0,
'target_aper': array([[False, False, False, False, False, False, False],
[False, False, False, False, True, False, False],
[False, False, True, True, True, True, False],
[False, False, True, True, True, False, False],
[False, False, True, True, True, True, False],
[False, False, True, True, True, True, False],
[False, False, False, False, False, False, False]]),
'contaminator_ra': (298.48660320220324, 1.6574996887712306e-05),
'contaminator_dec': (42.241699727399876, 2.0935749766654715e-05),
'contaminator_depth': (0.0012007441556371587, 4.997062338284275e-05),
'contaminator_lc': <KeplerLightCurve length=4436 LABEL="KIC 6804648" QUARTER=10 CAMPAIGN=None>
time flux ... cadenceno quality
...
object float64 ... int32 int32
------------------ ------------------ ... --------- -------
906.8458248060851 1.000258333875035 ... 39049 0
906.8662592900218 0.9994980892841774 ... 39050 0
906.886693673965 0.9995369884744718 ... 39051 0
906.9071281576762 0.9991988302049277 ... 39052 128
906.9275624413785 0.9999732121814077 ... 39053 0
906.9479968246233 0.9992955066274554 ... 39054 0
906.9684313078615 1.0013237454436092 ... 39055 0
906.9888655908726 0.9986719083142246 ... 39056 0
907.0092999736517 0.9981485119448209 ... 39057 0
... ... ... ... ...
1000.0851898831825 0.9993106655937168 ... 43612 0
1000.1056229714231 0.9995725515281534 ... 43613 0
1000.1260561591916 1.0006020443006833 ... 43614 8192
1000.1464891469659 0.999553345398554 ... 43615 0
1000.166922334276 0.9994003978630305 ... 43616 0
1000.1873554213453 1.000156007992151 ... 43617 0
1000.2077884081882 1.0006825046920422 ... 43618 0
1000.2282215947926 1.0007822944331957 ... 43619 0
1000.2486546809378 0.9993891379492238 ... 43620 0
1000.2690876668494 0.9983383958109301 ... 43621 0,
'contaminator_aper': array([[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, True, False, False, False, False, False],
[False, True, True, False, False, False, False],
[False, False, False, False, False, False, False]]),
'delta_transit_depth[sigma]': 23.41568524018127,
'period': 0.700606,
't0': 131.59767,
'duration': 0.041375,
'centroid_shift': (<Quantity 12.31499272 arcsec>,
<Quantity 2.9999619 arcsec>),
'transit_depth': array([[ 0.00000000e+00, 0.00000000e+00, 2.51212318e-04,
-6.18675062e-05, -3.24107917e-04, -1.27717470e-04,
-3.11168403e-04],
[ 0.00000000e+00, 6.07204816e-04, -6.62213371e-04,
-1.17489077e-04, 2.12298293e-05, -6.56595881e-05,
-6.83488103e-05],
[-4.76153501e-03, -5.98350127e-04, 1.81242470e-05,
-1.51123289e-05, 3.42311056e-05, 4.60574553e-05,
-1.80697323e-04],
[-2.17706508e-03, 1.73032265e-04, -5.07045230e-06,
2.51473679e-05, -9.13165503e-06, -5.65080992e-05,
8.21840797e-04],
[ 2.92096860e-03, 3.09669560e-03, 1.89843166e-05,
-1.84933963e-05, 1.35129628e-05, -3.04517808e-05,
-3.23842300e-04],
[-1.06757110e-04, 2.84768261e-03, 3.17815637e-04,
-1.10234775e-04, -1.40851604e-04, 1.42629348e-04,
-5.34333381e-04],
[ 0.00000000e+00, 5.70787558e-04, 3.20865474e-04,
2.41066603e-04, 1.10746882e-03, 1.07930555e-03,
0.00000000e+00]]),
'transit_depth_err': array([[0.00000000e+00, 0.00000000e+00, 1.36503710e-04, 1.84539798e-04,
2.15612619e-04, 1.86051800e-04, 4.54683076e-04],
[0.00000000e+00, 8.59291049e-04, 6.05383109e-04, 1.39754442e-04,
5.01110421e-05, 8.43692154e-05, 1.70765426e-04],
[2.33797249e-03, 6.47270634e-04, 1.45983789e-04, 2.92233824e-05,
3.15265285e-05, 4.93980441e-05, 2.16399969e-04],
[1.26299239e-03, 2.98363926e-04, 1.38313794e-05, 9.72992923e-06,
2.08945566e-05, 8.20539015e-05, 3.80021098e-04],
[1.00316565e-03, 1.66018625e-04, 1.93459074e-05, 1.05310760e-05,
2.44854656e-05, 1.14963588e-04, 8.38188454e-04],
[9.54544367e-04, 1.70709074e-04, 5.84870868e-05, 7.10063135e-05,
9.83097584e-05, 1.44532769e-04, 5.87668637e-04],
[0.00000000e+00, 3.84894397e-04, 2.84336669e-04, 3.60349901e-04,
9.10805376e-04, 9.52575695e-04, 0.00000000e+00]]),
'fig': <Figure size 1224x252 with 2 Axes>},
{'target_depth': (3.280891994423971e-05, 5.746884280953689e-06),
'target_ra': (298.48326235630395, 1.117772385107976e-09),
'target_dec': (42.241906119791665, 9.618189665150718e-10),
'target_lc': <KeplerLightCurve length=4469 LABEL="KIC 6804648" QUARTER=11 CAMPAIGN=None>
time flux ... cadenceno quality
...
object float64 ... int32 int32
------------------ ------------------ ... --------- -------
1001.2089795090433 1.0001598488422307 ... 43667 0
1001.2294124814507 0.9998465327458866 ... 43668 393216
1001.2498456533867 1.000083434754878 ... 43669 393216
1001.2702787253293 1.000100040454004 ... 43670 0
1001.2907118967996 0.9998719490105065 ... 43671 393216
1001.3111448680429 0.9999475816086747 ... 43672 393216
1001.3315779390541 1.000245323243787 ... 43673 0
1001.352011109826 0.9999971279363663 ... 43674 393216
1001.3724440801379 0.9999938332355411 ... 43675 0
... ... ... ... ...
1098.1418292774033 1.0000587799957399 ... 48411 262144
1098.1622619840928 1.000001772308483 ... 48412 0
1098.1826948910675 0.9998936687642469 ... 48413 393216
1098.2031276982234 0.9999105425207185 ... 48414 0
1098.223560505612 1.0000306293444283 ... 48415 0
1098.2439933132264 0.9999973733694512 ... 48416 0
1098.2644261210808 1.0001470803190613 ... 48417 0
1098.2848589291098 1.0003168764208312 ... 48418 262144
1098.305291837365 0.9998587369048433 ... 48419 0
1098.3257245459172 1.000014852235992 ... 48420 0,
'target_aper': array([[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, True, True, False, False],
[False, False, False, True, True, False, False],
[False, False, False, True, True, False, False],
[False, False, False, False, False, False, False]]),
'contaminator_ra': (298.48623980534427, 8.460847563933589e-05),
'contaminator_dec': (42.241285137398634, 8.743546093021665e-05),
'contaminator_depth': (8.891706022692198e-05, 7.461014633030657e-06),
'contaminator_lc': <KeplerLightCurve length=4469 LABEL="KIC 6804648" QUARTER=11 CAMPAIGN=None>
time flux ... cadenceno quality
...
object float64 ... int32 int32
------------------ ------------------ ... --------- -------
1001.2089795090433 1.00029116684809 ... 43667 0
1001.2294124814507 0.999708988363655 ... 43668 393216
1001.2498456533867 1.0001570875001218 ... 43669 393216
1001.2702787253293 0.9998750674732719 ... 43670 0
1001.2907118967996 1.0000329477244871 ... 43671 393216
1001.3111448680429 1.0000071061394975 ... 43672 393216
1001.3315779390541 1.0003421551947482 ... 43673 0
1001.352011109826 0.9998674411729804 ... 43674 393216
1001.3724440801379 1.0000426780525622 ... 43675 0
... ... ... ... ...
1098.1418292774033 0.9999061343786573 ... 48411 262144
1098.1622619840928 0.9998645340177823 ... 48412 0
1098.1826948910675 0.9998235568653122 ... 48413 393216
1098.2031276982234 0.9998884271345754 ... 48414 0
1098.223560505612 1.000110826451896 ... 48415 0
1098.2439933132264 1.0001479430196016 ... 48416 0
1098.2644261210808 1.000217670177182 ... 48417 0
1098.2848589291098 1.0003246130295378 ... 48418 262144
1098.305291837365 0.9998597606756561 ... 48419 0
1098.3257245459172 0.9999778266375003 ... 48420 0,
'contaminator_aper': array([[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, False, True, False, False],
[False, False, True, False, False, False, False],
[False, False, True, False, False, False, False],
[False, False, False, False, False, False, False]]),
'delta_transit_depth[sigma]': 5.957721222464785,
'period': 0.700606,
't0': 131.59767,
'duration': 0.041375,
'centroid_shift': (<Quantity 10.94945899 arcsec>,
<Quantity 3.14557589 arcsec>),
'transit_depth': array([[ 0.00000000e+00, 0.00000000e+00, -7.48225204e-04,
-3.25819987e-04, 1.99047539e-04, 1.08158468e-04,
3.72271611e-04],
[ 0.00000000e+00, 2.23426932e-03, -5.31057461e-04,
-2.59273135e-04, 8.08360778e-05, 9.09016158e-05,
-5.54117884e-05],
[ 1.87417435e-03, 2.51154542e-03, -1.97079555e-04,
-9.21383178e-06, 5.38267709e-05, -1.18640793e-05,
-1.86566586e-04],
[ 9.54998925e-04, 4.18995937e-04, 3.89207525e-04,
4.83458711e-05, 5.90467968e-06, -2.75393312e-06,
-8.27574389e-04],
[ 4.36486578e-04, 5.57651765e-04, 4.88739470e-04,
1.15095060e-04, -1.94937768e-05, 3.34620640e-05,
3.02935399e-04],
[ 1.79913526e-03, 6.42365805e-05, 4.57902046e-04,
6.08771849e-05, -6.60732542e-05, 8.67218918e-04,
-2.68474550e-03]]),
'transit_depth_err': array([[0.00000000e+00, 0.00000000e+00, 6.72986807e-04, 4.72646360e-04,
2.70744890e-04, 1.59223447e-04, 3.30014365e-04],
[0.00000000e+00, 1.96872580e-03, 6.55465704e-04, 1.28371895e-04,
4.01786475e-05, 4.47620315e-05, 1.32626878e-04],
[2.56180000e-03, 1.32087206e-03, 1.66091266e-04, 1.27654142e-05,
1.03601293e-05, 3.52000125e-05, 1.87843907e-04],
[1.27848038e-03, 3.58680063e-04, 4.19253314e-05, 1.90436312e-05,
1.08431618e-05, 4.24067809e-05, 3.38275632e-04],
[8.76286293e-04, 2.04262459e-04, 6.22776798e-05, 3.53238242e-05,
3.20868498e-05, 6.54018972e-05, 3.24815220e-04],
[9.90470901e-04, 5.43199046e-04, 1.26355650e-04, 7.09594189e-05,
1.20106694e-04, 4.44665116e-04, 7.11890192e-04]]),
'fig': <Figure size 1224x252 with 2 Axes>},
{'target_depth': (3.648483017464817e-05, 6.396089618656753e-06),
'target_ra': (298.48321314392695, 1.970981158110348e-09),
'target_dec': (42.24185195533414, 1.1092308120007133e-09),
'target_lc': <KeplerLightCurve length=3551 LABEL="KIC 6804648" QUARTER=12 CAMPAIGN=None>
time flux ... cadenceno quality
...
object float64 ... int32 int32
------------------ ------------------ ... --------- -------
1099.4086567242412 0.9999593555535635 ... 48473 0
1099.4290896451857 1.0000261394915797 ... 48474 0
1099.4495224662533 0.9999657838464447 ... 48475 0
1099.4699553876635 1.0000522319757283 ... 48476 0
1099.490388109196 0.9999555418788456 ... 48477 0
1099.5108209310783 0.9999968772333804 ... 48478 0
1099.5312538530707 0.9998928054125967 ... 48479 0
1099.5516866754188 1.0000450210920993 ... 48480 0
1099.5721193978825 0.9999051152038142 ... 48481 0
... ... ... ... ...
1181.8372239690434 0.9997375870576969 ... 52507 16
1181.857658085697 1.0002860050899494 ... 52508 2192
1181.8780921026992 0.9999405748490529 ... 52509 393232
1181.8985263199284 0.9999769896739221 ... 52510 0
1181.918960437397 1.0000510376760354 ... 52511 0
1181.939394455214 1.0000061903839086 ... 52512 0
1181.959828673258 1.000107547385251 ... 52513 0
1181.9802627916579 0.9996734943604437 ... 52514 128
1182.000697010284 1.0001163827874393 ... 52515 128
1182.0211310292652 0.9999751252805572 ... 52516 393216,
'target_aper': array([[False, False, False, False, False, False, False],
[False, False, False, False, True, False, False],
[False, False, True, True, True, True, False],
[False, False, True, True, True, False, False],
[False, True, True, True, True, False, False],
[False, False, True, True, False, False, False],
[False, False, False, False, False, False, False]]),
'contaminator_ra': (298.48463521691394, 0.0002666450864180023),
'contaminator_dec': (42.242167847923696, 0.00010504481613920637),
'contaminator_depth': (0.0003138058905226885, 3.198751158928448e-05),
'contaminator_lc': <KeplerLightCurve length=3551 LABEL="KIC 6804648" QUARTER=12 CAMPAIGN=None>
time flux ... cadenceno quality
...
object float64 ... int32 int32
------------------ ------------------ ... --------- -------
1099.4086567242412 0.9994858551792853 ... 48473 0
1099.4290896451857 0.99943671464258 ... 48474 0
1099.4495224662533 0.9998727094521473 ... 48475 0
1099.4699553876635 0.9992327713114555 ... 48476 0
1099.490388109196 0.9998430757935566 ... 48477 0
1099.5108209310783 0.999439445570721 ... 48478 0
1099.5312538530707 1.000191386538218 ... 48479 0
1099.5516866754188 1.0001198631917458 ... 48480 0
1099.5721193978825 0.999587167344224 ... 48481 0
... ... ... ... ...
1181.8372239690434 0.998282722644458 ... 52507 16
1181.857658085697 1.002084092374199 ... 52508 2192
1181.8780921026992 0.9991804040523726 ... 52509 393232
1181.8985263199284 0.9999069152082476 ... 52510 0
1181.918960437397 1.0000293433278986 ... 52511 0
1181.939394455214 0.9998031444864035 ... 52512 0
1181.959828673258 0.9997107427583123 ... 52513 0
1181.9802627916579 0.9980680714219937 ... 52514 128
1182.000697010284 1.0010286650823037 ... 52515 128
1182.0211310292652 0.9989945830230331 ... 52516 393216,
'contaminator_aper': array([[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, True, False, False, False, False],
[False, False, False, False, False, False, False],
[False, False, False, False, False, False, False]]),
'delta_transit_depth[sigma]': 8.501379712824566,
'period': 0.700606,
't0': 131.59767,
'duration': 0.041375,
'centroid_shift': (<Quantity 5.24424952 arcsec>,
<Quantity 4.00402976 arcsec>),
'transit_depth': array([[ 0.00000000e+00, 0.00000000e+00, 2.79946630e-05,
-6.16471978e-05, 1.40346452e-04, 4.34710997e-04,
0.00000000e+00],
[ 0.00000000e+00, -2.39609811e-04, 1.24946964e-03,
-5.13822070e-05, 3.98804442e-04, 1.34233263e-04,
1.08329430e-04],
[ 4.25502682e-04, -1.41581815e-03, 6.01449410e-05,
-2.70647544e-05, 7.70819744e-05, 1.58005988e-04,
-5.90924371e-04],
[ 1.25273790e-03, 3.79003526e-04, -2.05278223e-05,
-3.99257681e-05, 4.44786157e-05, 6.56061719e-05,
6.94009858e-04],
[-2.75975751e-04, 4.33128955e-04, 3.12276153e-04,
-4.44513841e-05, 2.57696035e-05, 1.39884484e-04,
0.00000000e+00],
[ 1.16062058e-04, 2.09262604e-04, 2.75360185e-04,
7.73344656e-06, -1.51279609e-04, -1.08777546e-03,
0.00000000e+00],
[ 0.00000000e+00, 1.68383509e-03, -4.65887119e-04,
1.53895470e-04, 8.76055472e-04, 0.00000000e+00,
0.00000000e+00]]),
'transit_depth_err': array([[0.00000000e+00, 0.00000000e+00, 5.19088607e-04, 2.30953975e-04,
2.68626837e-04, 3.17335134e-04, 0.00000000e+00],
[0.00000000e+00, 9.68641022e-04, 8.06302844e-04, 3.67088697e-04,
8.81393490e-05, 1.07950478e-04, 3.11239845e-04],
[2.58404008e-03, 8.01930989e-04, 1.00387962e-04, 3.14780849e-05,
1.99042128e-05, 5.79862261e-05, 3.41252348e-04],
[1.37435597e-03, 2.74177148e-04, 3.36076275e-05, 1.06462500e-05,
1.03851180e-05, 8.20084078e-05, 6.55617738e-04],
[5.43109437e-04, 9.26440053e-05, 3.63623799e-05, 2.37981070e-05,
2.28500690e-05, 2.14215191e-04, 0.00000000e+00],
[5.80530031e-04, 1.42705717e-04, 7.38367753e-05, 4.96975321e-05,
1.51293756e-04, 8.47462038e-04, 0.00000000e+00],
[0.00000000e+00, 6.11313151e-04, 2.35612250e-04, 2.46859586e-04,
9.35762412e-04, 0.00000000e+00, 0.00000000e+00]]),
'fig': <Figure size 1224x252 with 2 Axes>}]
To compare, we can look at a target that is a true, confirmed planet.
Below I run the parameters for Kepler-10 through contaminate
.
In [7]:
tpfs = lk.search_targetpixelfile('Kepler-10', quarter=[10, 11], cadence='long', mission='Kepler').download_all()
period = 0.837491
t0 = 2454964.57513 - 2454833
duration = 1.8076/24
result = ct.calculate_contamination(tpfs, period, t0, duration, plot=True);
Modeling TPFs: 0%| | 0/2 [00:00<?, ?it/s]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:265: RuntimeWarning: invalid value encountered in true_divide
aper = (thumb / err > 3) & aper
Modeling TPFs: 50%|█████ | 1/2 [00:07<00:07, 7.70s/it]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:265: RuntimeWarning: invalid value encountered in true_divide
aper = (thumb / err > 3) & aper
Modeling TPFs: 100%|██████████| 2/2 [00:14<00:00, 7.18s/it]


Sometimes there will be no significant transiting source that was not
the target, and so the contaminator
and target
fields will be
very similar. Sometimes there will be a weak detection due to a slight
difference in optimal aperture. If there is only a small change in
centroid (\(<<\) than a pixel width) and only a small change in
transit depth, this would indicate there is no contaminant.
Using contaminante
on TESS Data¶
contaminante
works on TESS data too. We don’t currently have a way
to remove TESS background, so make sure to pass in TPFs that have
already been background corrected.
In [8]:
# TESS Data
tpfs = lk.search_targetpixelfile('TIC 267263253', sector=1).download()
period = 4.12688
t0 = 2458325.78297 - 2457000
duration = 0.3
result = ct.calculate_contamination(tpfs, period, t0, duration, plot=True);
/Users/ch/.pyenv/versions/3.8.0/lib/python3.8/site-packages/lightkurve/search.py:346: LightkurveWarning: Warning: 2 files available to download. Only the first file has been downloaded. Please use `download_all()` or specify additional criteria (e.g. quarter, campaign, or sector) to limit your search.
warnings.warn(
Modeling TPFs: 0%| | 0/1 [00:00<?, ?it/s]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:457: RuntimeWarning: invalid value encountered in log10
np.log10(np.nanmedian(np.nan_to_num(tpf.flux.value), axis=0)),
Modeling TPFs: 100%|██████████| 1/1 [00:45<00:00, 45.75s/it]

In this case, it looks like there is a small offset, however the transit
depth from contaminante is actually shallower. The aperture selected by
contaminante
is quite large, we can see this when we plot the two
apertures side by side:
In [11]:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 2, figsize=(8, 4))
ax[0].imshow(result[0]['target_aper'], cmap='Greys')
ax[1].imshow(result[0]['contaminator_aper'], cmap='Greys')
ax[0].set(title='Pipeline Aperture', xticks=[], yticks=[])
ax[1].set(title='`contaminante` Aperture', xticks=[], yticks=[])
Out[11]:
[Text(0.5, 1.0, '`contaminante` Aperture'), [], []]

This causes contaminante
to produce a slightly shallower transit
(because we’re including more noise and flux from objects that aren’t
the target). Because the transit depth is shallower, even though there
is a small offset, we shouldn’t believe this is a contaminant.
If you want to see more of where the transit is coming from, you can look at the transit depth in each pixel.
In [12]:
plt.imshow(result[0]['transit_depth']/result[0]['transit_depth_err'], vmin=0, vmax=20)
plt.title("Sigificance of Transit Detection")
cbar = plt.colorbar()
cbar.set_label("Transit Depth/\n Transit Depth Err")

Using contaminante
on K2 Data¶
contaminante
works on K2 data too. The motion noise is removed using
a similar approach to the Self Flat Fielding technique used in
lightkurve
. Because of the K2 motion the results may be a little
harder to interpret. For example, below there is a slight shift in the
centroid, but the light curve from that target is not different from the
main target. This is likely due to the pipeline apertures for K2 being
slightly too small.
Below are a couple of examples of the tool running on K2 data
In [14]:
tpfs = lk.search_targetpixelfile("EPIC 211732801").download_all()
period = 2.1316925
t0 = 2308.407161
duration = 0.3
result = ct.calculate_contamination(tpfs, period, t0, duration, plot=True, sff=True);
Modeling TPFs: 0%| | 0/3 [00:00<?, ?it/s]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:265: RuntimeWarning: invalid value encountered in true_divide
aper = (thumb / err > 3) & aper
Modeling TPFs: 33%|███▎ | 1/3 [00:10<00:20, 10.33s/it]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:265: RuntimeWarning: invalid value encountered in true_divide
aper = (thumb / err > 3) & aper
Modeling TPFs: 67%|██████▋ | 2/3 [00:25<00:13, 13.29s/it]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:265: RuntimeWarning: invalid value encountered in true_divide
aper = (thumb / err > 3) & aper
Modeling TPFs: 100%|██████████| 3/3 [00:33<00:00, 11.26s/it]



In [15]:
tpfs = lk.search_targetpixelfile("EPIC 201127519").download_all(quality_bitmask=None)[1:]
period = 6.178369
t0 = 2457585.55131 - 2454833
duration = 0.1
result = ct.calculate_contamination(tpfs, period, t0, duration, plot=True, sff=True);
Modeling TPFs: 0%| | 0/1 [00:00<?, ?it/s]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:265: RuntimeWarning: invalid value encountered in true_divide
aper = (thumb / err > 3) & aper
Modeling TPFs: 100%|██████████| 1/1 [00:10<00:00, 10.37s/it]

contaminante
does try to produce reasonable results for saturated
targets, but especially for K2 this can be quite hard.
In [48]:
tpfs = lk.search_targetpixelfile("HD 3167").download_all(quality_bitmask=None)
period = 0.959624
t0 = 2457393.41539 - 2454833
duration = 1.622/24
result = ct.calculate_contamination(tpfs, period, t0, duration, plot=True, sff=True, windows=20, bins=15, spline_period=1.5, cbvs=False);
Modeling TPFs: 0%| | 0/1 [00:00<?, ?it/s]/Users/ch/K2/projects/contaminante/contaminante/contaminante.py:266: RuntimeWarning: invalid value encountered in true_divide
cxs, cys = [], []
Modeling TPFs: 100%|██████████| 1/1 [00:23<00:00, 23.57s/it]

Usage notes¶
- Different quarters, campaigns and sectors. If a target has multiple quarters, campaigns or sectors you can expect each dataset to have some slight offset, due to the target falling on different pixels.
- Shallower contaminator light curves.
Contaminante
looks at each pixel individually to see if there is a significant transit signal. Because faint pixels can contribute a transiting signal at a lower, less significant level, some faint pixels can be missed in contaminante. In the case that the contaminator light curve is shallower than the target light curve, it is likely that some faint pixels have been missed from the optimum aperture. This does not indicate that there is any contamination.