Exemplo n.º 1
0
 def test_setup_transit_adjust_params(self):
     sherlock = Sherlock([
         SherlockTarget(object_info=None,
                        max_runs=5,
                        period_protect=5,
                        period_min=1,
                        period_max=2,
                        bin_minutes=5,
                        cpu_cores=3,
                        snr_min=6,
                        sde_min=5,
                        mask_mode="subtract",
                        best_signal_algorithm="quorum",
                        quorum_strength=2)
     ])
     self.assertEqual(5, sherlock.sherlock_targets[0].max_runs)
     self.assertEqual(5, sherlock.sherlock_targets[0].period_protect)
     self.assertEqual(1, sherlock.sherlock_targets[0].period_min)
     self.assertEqual(2, sherlock.sherlock_targets[0].period_max)
     self.assertEqual(5, sherlock.sherlock_targets[0].bin_minutes)
     self.assertEqual(3, sherlock.sherlock_targets[0].cpu_cores)
     self.assertEqual(6, sherlock.sherlock_targets[0].snr_min)
     self.assertEqual(5, sherlock.sherlock_targets[0].sde_min)
     self.assertEqual("subtract", sherlock.sherlock_targets[0].mask_mode)
     self.assertEqual("quorum",
                      sherlock.sherlock_targets[0].best_signal_algorithm)
     self.assertEqual(2, sherlock.sherlock_targets[0].quorum_strength)
Exemplo n.º 2
0
 def test_setup_detrend(self):
     object_info = MissionObjectInfo("TIC 12345",
                                     sectors="all",
                                     smooth_enabled=False,
                                     high_rms_enabled=False,
                                     high_rms_threshold=3,
                                     high_rms_bin_hours=9,
                                     auto_detrend_enabled=True,
                                     auto_detrend_ratio=1 / 2,
                                     auto_detrend_method="cosine")
     sherlock = Sherlock([
         SherlockTarget(object_info=object_info,
                        detrends_number=2,
                        detrend_method="gp",
                        cpu_cores=3)
     ])
     self.assertEqual(
         False, sherlock.sherlock_targets[0].object_info.smooth_enabled)
     self.assertEqual(
         False, sherlock.sherlock_targets[0].object_info.high_rms_enabled)
     self.assertEqual(
         3, sherlock.sherlock_targets[0].object_info.high_rms_threshold)
     self.assertEqual(
         9, sherlock.sherlock_targets[0].object_info.high_rms_bin_hours)
     self.assertEqual(2, sherlock.sherlock_targets[0].detrends_number)
     self.assertEqual("gp", sherlock.sherlock_targets[0].detrend_method)
     self.assertEqual(3, sherlock.sherlock_targets[0].cpu_cores)
     self.assertEqual(
         True,
         sherlock.sherlock_targets[0].object_info.auto_detrend_enabled)
     self.assertEqual(
         1 / 2, sherlock.sherlock_targets[0].object_info.auto_detrend_ratio)
     self.assertEqual(
         "cosine",
         sherlock.sherlock_targets[0].object_info.auto_detrend_method)
Exemplo n.º 3
0
 def test_run_with_rms_mask(self):
     run_dir = "TIC181804752_FFI_[9]"
     try:
         Sherlock([
             SherlockTarget(MissionFfiIdObjectInfo("TIC 181804752", [9],
                                                   high_rms_enabled=True),
                            max_runs=1,
                            oversampling=0.05)
         ]).run()
         self.__assert_run_files(run_dir)
     finally:
         self.__clean(run_dir)
Exemplo n.º 4
0
 def test_run(self):
     run_dir = "TIC181804752_FFI_[9]"
     try:
         Sherlock([
             SherlockTarget(MissionFfiIdObjectInfo("TIC 181804752", [9],
                                                   smooth_enabled=False,
                                                   high_rms_enabled=False),
                            detrends_number=1,
                            max_runs=1,
                            oversampling=0.05)
         ]).run()
         self.__assert_run_files(run_dir, assert_rms_mask=False)
     finally:
         self.__clean(run_dir)
Exemplo n.º 5
0
 def test_run_with_explore(self):
     run_dir = None
     try:
         Sherlock([
             SherlockTarget(MissionFfiIdObjectInfo("TIC 181804752", [9],
                                                   high_rms_enabled=True),
                            detrends_number=1,
                            oversampling=0.05)
         ], True).run()
         run_dir = "TIC181804752_FFI_[9]"
         self.assertTrue(os.path.exists(run_dir))
         self.assertTrue(
             os.path.exists(
                 run_dir + "/Periodogram_Initial_TIC181804752_FFI_[9].png"))
         self.assertFalse(os.path.exists(run_dir + "/1"))
     finally:
         self.__clean(run_dir)
Exemplo n.º 6
0
 def test_run_with_star_info(self):
     run_dir = None
     try:
         Sherlock([
             SherlockTarget(MissionFfiIdObjectInfo(
                 "TIC 181804752", [9],
                 high_rms_enabled=True,
                 star_info=StarInfo(ld_coefficients=(0.15, 0.25),
                                    teff=4000,
                                    lum=1.50,
                                    logg=0.15,
                                    radius=0.4,
                                    radius_min=0.10,
                                    radius_max=0.15,
                                    mass=0.3,
                                    mass_min=0.05,
                                    mass_max=0.075,
                                    ra=13.132258,
                                    dec=64.334238)),
                            detrends_number=1,
                            max_runs=1,
                            oversampling=0.05)
         ], True).run()
         run_dir = "TIC181804752_FFI_[9]"
         self.assertTrue(os.path.exists(run_dir))
         self.assertTrue(
             os.path.exists(
                 run_dir + "/Periodogram_Initial_TIC181804752_FFI_[9].png"))
         self.assertFalse(os.path.exists(run_dir + "/1"))
         with open(run_dir + '/TIC181804752_FFI_[9]_report.log') as f:
             content = f.read()
             self.assertTrue('mass = 0.3' in content)
             self.assertTrue('mass_min = 0.25' in content)
             self.assertTrue('mass_max = 0.375' in content)
             self.assertTrue('radius = 0.4' in content)
             self.assertTrue('radius_min = 0.3' in content)
             self.assertTrue('radius_max = 0.55' in content)
             self.assertTrue(
                 'limb-darkening estimates using quadratic LD (a,b)= (0.15, 0.25)'
                 in content)
             self.assertTrue('teff = 4000' in content)
             self.assertTrue('logg = 0.15' in content)
             self.assertTrue('lum = 1.50' in content)
     finally:
         self.__clean(run_dir)
Exemplo n.º 7
0
 def test_run_with_autodetrend(self):
     run_dir = None
     try:
         Sherlock([
             SherlockTarget(MissionObjectInfo("TIC 259377017", [5],
                                              auto_detrend_enabled=True),
                            detrends_number=1,
                            max_runs=1,
                            oversampling=0.05)
         ], True).run()
         run_dir = "TIC259377017_[5]"
         self.assertTrue(os.path.exists(run_dir))
         self.assertTrue(
             os.path.exists(
                 run_dir +
                 "/Phase_detrend_period_TIC259377017_[5]_0.52_days.png"))
     finally:
         self.__clean(run_dir)
Exemplo n.º 8
0
 def test_run_with_transit_customs(self):
     run_dir = None
     try:
         sherlock = Sherlock([SherlockTarget(MissionFfiIdObjectInfo("TIC 181804752", [9], high_rms_enabled=True),
                                             detrends_number=1, max_runs=1, oversampling=0.1, t0_fit_margin=0.09,
                                             duration_grid_step=1.075, fit_method="bls",
                                             best_signal_algorithm="quorum", quorum_strength=0.31)], False)\
             .run()
         run_dir = "TIC181804752_FFI_[9]"
         with open(run_dir + '/TIC181804752_FFI_[9]_report.log') as f:
             content = f.read()
             self.assertTrue('Fit method: box' in content)
             self.assertTrue('Duration step: 1.075' in content)
             self.assertTrue('T0 Fit Margin: 0.09' in content)
             self.assertTrue('Oversampling: 0.1' in content)
             self.assertTrue('Signal scoring algorithm: quorum' in content)
             self.assertTrue(
                 'Quorum algorithm vote strength: 0.31' in content)
         self.__assert_run_files(run_dir)
     finally:
         self.__clean(run_dir)
Exemplo n.º 9
0
 def test_scoring_algorithm(self):
     sherlock = Sherlock(
         [SherlockTarget(object_info=None, best_signal_algorithm="basic")])
     self.assertTrue(
         isinstance(
             sherlock.sherlock_targets[0].signal_score_selectors["basic"],
             BasicSdeSignalSelector))
     sherlock = Sherlock([
         SherlockTarget(object_info=None,
                        best_signal_algorithm="border-correct")
     ])
     self.assertTrue(
         isinstance(
             sherlock.sherlock_targets[0].
             signal_score_selectors["border-correct"],
             SdeBorderCorrectedSignalSelector))
     sherlock = Sherlock(
         [SherlockTarget(object_info=None, best_signal_algorithm="quorum")])
     self.assertTrue(
         isinstance(
             sherlock.sherlock_targets[0].signal_score_selectors["quorum"],
             QuorumSdeBorderCorrectedSignalSelector))
     sherlock = Sherlock([
         SherlockTarget(object_info=None, best_signal_algorithm="basic-snr")
     ])
     self.assertTrue(
         isinstance(
             sherlock.sherlock_targets[0].
             signal_score_selectors["basic-snr"], BasicSignalSelector))
     sherlock = Sherlock([
         SherlockTarget(object_info=None,
                        best_signal_algorithm="border-correct-snr")
     ])
     self.assertTrue(
         isinstance(
             sherlock.sherlock_targets[0].
             signal_score_selectors["border-correct-snr"],
             SnrBorderCorrectedSignalSelector))
     sherlock = Sherlock([
         SherlockTarget(object_info=None,
                        best_signal_algorithm="quorum-snr")
     ])
     self.assertTrue(
         isinstance(
             sherlock.sherlock_targets[0].
             signal_score_selectors["quorum-snr"],
             QuorumSnrBorderCorrectedSignalSelector))
Exemplo n.º 10
0
 def test_run_epic_ffi(self):
     run_dir = None
     try:
         Sherlock([
             SherlockTarget(MissionFfiIdObjectInfo(
                 "EPIC 249631677",
                 'all',
                 high_rms_enabled=True,
                 auto_detrend_enabled=False),
                            detrends_number=1,
                            max_runs=1,
                            oversampling=0.05)
         ], False).run()
         run_dir = "EPIC249631677_FFI_all"
         self.assertTrue(os.path.exists(run_dir))
         self.assertTrue(
             os.path.exists(
                 run_dir +
                 "/Periodogram_Initial_EPIC249631677_FFI_all.png"))
         self.assertTrue(os.path.exists(run_dir + "/1"))
     finally:
         self.__clean(run_dir)
Exemplo n.º 11
0
@contextmanager
def elapsed_timer():
    start = default_timer()
    elapser = lambda: str(default_timer() - start)
    yield lambda: elapser()
    end = default_timer()
    elapser = lambda: str(end - start)


with elapsed_timer() as elapsed:
    # We will use only one object id so we can explain better the detrend configs that the coder can select
    # We will:
    # 1 Enable the initial smooth function, which reduces local noise in the signal.
    # 2 Enable the initial High RMS areas masking. This procedure will mask all the lightcurve time binned ranges by
    # the 'initial_rms_bin_hours' value with a threshold of the 'initial_rms_threshold' value * RMS_median.
    # 3 Set the number of detrends to be done from PDCSAP_FLUX for each run.
    # 4 Set the SHERLOCK PDCSAP_FLUX detrends method to Gaussian Processes.
    # 5 Set the number of CPU cores to be used by the detrending procedure.
    # 6 Enable the Auto-Detrend detection, which will search for strong periodicities in the light curve and do an
    # initial detrend for it based on the selected 'auto_detrend_method' method and the value of the
    # 'auto_detrend_ratio' value, which ensures that we are detrending the light curve at 'auto_detrend_ratio' times
    # the stronger period.
    sherlock = Sherlock([SherlockTarget(object_info=MissionObjectInfo("TIC 181804752", 'all'),
                                        smooth_enabled=True, high_rms_enabled=True, high_rms_threshold=2.5, high_rms_bin_hours=3,
                                        detrends_number=12, detrend_method="gp", cpu_cores=2,
                                        auto_detrend_enabled=True, auto_detrend_ratio=0.33,
                                        auto_detrend_method="cosine")]) \
        .run()
    print("Analysis took " + elapsed() + "s")
Exemplo n.º 12
0
from sherlockpipe.sherlock import Sherlock
from lcbuilder.objectinfo.InputObjectInfo import InputObjectInfo
from lcbuilder.objectinfo.MissionFfiCoordsObjectInfo import MissionFfiCoordsObjectInfo
from lcbuilder.objectinfo.MissionFfiIdObjectInfo import MissionFfiIdObjectInfo
from lcbuilder.objectinfo.MissionInputObjectInfo import MissionInputObjectInfo
from lcbuilder.objectinfo.MissionObjectInfo import MissionObjectInfo

from sherlockpipe.sherlock_target import SherlockTarget


@contextmanager
def elapsed_timer():
    start = default_timer()
    elapser = lambda: str(default_timer() - start)
    yield lambda: elapser()
    end = default_timer()
    elapser = lambda: str(end - start)


with elapsed_timer() as elapsed:
    # Adding several kinds of objects to the run: one short cadence TIC, one FFI TIC, one coordinates FFI, one input
    # file related to a TIC and one plain input file.
    # Ensure that your input light curve CSV files have three columns: #TBJD,flux,flux_err
    sherlock = Sherlock([SherlockTarget(MissionObjectInfo("TIC 181804752", 'all')),
                                        SherlockTarget(MissionFfiIdObjectInfo("TIC 259168516", [14, 15])),
                                        SherlockTarget(MissionFfiCoordsObjectInfo(14, 19, 'all')),
                                        SherlockTarget(MissionInputObjectInfo("TIC 470381900", "example_lightcurve.csv")),
                                        SherlockTarget(InputObjectInfo("example_lc.csv"))])\
        .run()
    print("Analysis took " + elapsed() + "s")
Exemplo n.º 13
0
from examples.custom_algorithms.ButterworthCurvePreparer import ButterworthCurvePreparer
from examples.custom_algorithms.NeptunianDesertSearchZone import NeptunianDesertSearchZone
from examples.custom_algorithms.RandomSignalSelector import RandomSignalSelector
from sherlockpipe.sherlock import Sherlock
from lcbuilder.objectinfo.MissionFfiIdObjectInfo import MissionFfiIdObjectInfo

from sherlockpipe.sherlock_target import SherlockTarget


@contextmanager
def elapsed_timer():
    start = default_timer()
    elapser = lambda: str(default_timer() - start)
    yield lambda: elapser()
    end = default_timer()
    elapser = lambda: str(end - start)


with elapsed_timer() as elapsed:
    # We will use one TIC from the TESS mission and add provide external customized algorithms for light curve
    # preparation, signal selection and search zone settings. These algorithms are extensions from SHERLOCK abstract
    # classes as you can inspect under the examples/custom_algorithms directory.
    sherlock = Sherlock(update_ois=False, sherlock_targets=[
        SherlockTarget(object_info=MissionFfiIdObjectInfo("TIC 181804752", 'all'), smooth_enabled=False, high_rms_enabled=False,
                       cpu_cores=2, auto_detrend_enabled=False, prepare_algorithm=ButterworthCurvePreparer(),
                       max_runs=10, custom_search_zone=NeptunianDesertSearchZone(),
                       custom_selection_algorithm=RandomSignalSelector())]) \
        .run()
    print("Analysis took " + elapsed() + "s")
from contextlib import contextmanager
from timeit import default_timer
from sherlockpipe.sherlock import Sherlock
from lcbuilder.objectinfo.MissionObjectInfo import MissionObjectInfo

from sherlockpipe.sherlock_target import SherlockTarget


@contextmanager
def elapsed_timer():
    start = default_timer()
    elapser = lambda: str(default_timer() - start)
    yield lambda: elapser()
    end = default_timer()
    elapser = lambda: str(end - start)


with elapsed_timer() as elapsed:
    # We will use only one mission object and set the period to be initially detrended with a window size of 1/3 times
    # the given period.
    sherlock = Sherlock([SherlockTarget(MissionObjectInfo("TIC 181804752", 'all'), auto_detrend_ratio=1 / 3)])\
        .run()
    print("Analysis took " + elapsed() + "s")
from contextlib import contextmanager
from timeit import default_timer
from sherlockpipe.sherlock import Sherlock
from lcbuilder.objectinfo.MissionObjectInfo import MissionObjectInfo

from sherlockpipe.sherlock_target import SherlockTarget


@contextmanager
def elapsed_timer():
    start = default_timer()
    elapser = lambda: str(default_timer() - start)
    yield lambda: elapser()
    end = default_timer()
    elapser = lambda: str(end - start)


with elapsed_timer() as elapsed:
    # We will use only one mission object and will mask a time range from 1550 to 1551 and from 1560 to 1561
    sherlock = Sherlock([SherlockTarget(MissionObjectInfo("TIC 181804752", 'all',
                                                    initial_mask=[[1550, 1551], [1560, 1561]]))])\
        .run()
    print("Analysis took " + elapsed() + "s")
Exemplo n.º 16
0
    # 'auto_detrend_ratio' value, which ensures that we are detrending the light curve at 'auto_detrend_ratio' times
    # the stronger period.

    # 7 Set the maximum number of runs to be executed.
    # 8 Select the period protect value, which restricts the minimum detrending window length.
    # 9 Select the min period for a transit to be fit.
    # 10 Select the max period for a transit to be fit.
    # 11 Select the binning to calculate RMS
    # 12 Select the number of CPU cores to be used for the transit search.
    # 13 Select the found transits masking method. We use subtract here as example, but it is discouraged.
    # 14 Select the best signal algorithm, which provides a different implementation to decide which of the detrend
    # signals is the stronger one to be selected.
    # 15 Set the strength of the quorum algorithm votes, which makes every vote that is found to increase the SNR by
    # a factor of 1.2 for our selection.
    arguments = {"smoooth_enabled": True, "high_rms_enabled": True, "high_rms_threshold": 2.5,
                 "high_rms_bin_hours": 3,
                 "detrends_number": 12, "detrend_method": "gp", "cpu_cores": 2, "auto_detrend_enabled": True,
                 "auto_detrend_ratio": 0.33, "auto_detrend_method": "cosine",
                 "max_runs": 10, "period_protect": 12, "period_min": 1, "period_max": 10, "bin_minutes": 20,
                 "run_cores": 3, "snr_min": 6, "sde_min": 6, "mask_mode": "subtract",
                 "best_signal_algorithm": 'quorum', "quorum_strength": 1.2}
    sherlock = Sherlock([SherlockTarget(MissionFfiIdObjectInfo("TIC 181804752", 'all'), **arguments),
                                        SherlockTarget(MissionObjectInfo("TIC 259168516", [15]), **arguments),
                                        SherlockTarget(MissionObjectInfo('KIC 10905746', 'all'), **arguments),
                                        SherlockTarget(MissionObjectInfo('EPIC 249631677', 'all'), **arguments),
                                        SherlockTarget(MissionInputObjectInfo("TIC 181804752", 'example_lc.csv',
                                                               initial_mask=[[1625, 1626], [1645, 1646]]), **arguments),
                                        SherlockTarget(InputObjectInfo("example_lc.csv", initial_detrend_period=0.8), **arguments)]) \
        .run()
    print("Analysis took " + elapsed() + "s")
Exemplo n.º 17
0
             aperture, eleanor_corr_flux, outliers_sigma,
             high_rms_enabled, high_rms_threshold,
             high_rms_bin_hours, smooth_enabled,
             auto_detrend_enabled, auto_detrend_method,
             auto_detrend_ratio, auto_detrend_period,
             prepare_algorithm, reduce_simple_oscillations,
             oscillation_snr_threshold,
             oscillation_amplitude_threshold,
             oscillation_ws_scale, oscillation_min_period,
             oscillation_max_period, exptime_binning)
         sherlock_target = SherlockTarget(
             built_object_info, detrend_method, detrend_l_min,
             detrend_l_max, detrends_number, detrend_cores,
             custom_selection_algorithm,
             custom_transit_template, search_zone,
             custom_search_zone, snr_min, sde_min, min_sectors,
             max_sectors, bin_minutes, mask_mode, cpu_cores,
             max_runs, period_min, period_max, period_protect,
             best_signal_algorithm, quorum_strength, min_quorum,
             fit_method, oversampling, t0_fit_margin,
             duration_grid_step, args.properties)
         sherlock_targets.append(sherlock_target)
 if mode == "SECTOR" or mode == "BOTH" and isinstance(
         built_object_info,
     (MissionObjectInfo, MissionFfiCoordsObjectInfo,
      MissionFfiIdObjectInfo)):
     if sectors == 'all':
         sectors = extract_sectors(built_object_info, cache_dir)
     sectors_unique = np.unique(np.array(sectors).flatten())
     for sector in sectors_unique:
         object_info = lcbuilder.build_object_info(