コード例 #1
0
def inject_and_tls_search_by_tic(tic_id, sigma_multiplier=3, **kwargs):
    '''
    Summary:
    -------
    - wrapper around inject_and_tls_search()
    - retrieves the SPOC PDC-SAP lightcurve
    - retrieves all TIC catalog information from MAST
    - injects a planet signal via ellc, for a given period and radius (at random epoch)
    - runs TLS on these injected data and infos
    
    Inputs:
    -------
    tic_id : str or int
        TIC ID
        
    Optional Inputs:
    ----------------
    sigma_multiplier : float 
        set TLS' uniform bounds for the host's radius and mass at sigma_multiplier times the error bars from TICv8
        default is 3
    **kwargs : keyword arguments
        any other keyword arguments, see inject_and_tls_search()
        
    Returns:
    -------
    a list of all TLS results will get saved to a log file
    '''

    #::: format inputs
    tic_id = str(int(tic_id))

    #::: load data
    time, flux, flux_err = tessio.get(tic_id,
                                      pipeline='spoc',
                                      PDC=True,
                                      unpack=True)

    #::: load TIC info
    ldc, R_host, R_host_lerr, R_host_uerr, M_host, M_host_lerr, M_host_uerr = catalog_info(
        TIC_ID=int(tic_id))
    print('\nTICv8 info:')
    print('Quadratic limb darkening u_0, u_1', ldc[0], ldc[1])
    print('Stellar radius', R_host, '+', R_host_lerr, '-', R_host_uerr)
    print('Stellar mass', M_host, '+', M_host_lerr, '-', M_host_uerr)

    #::: run
    inject_and_tls_search(time,
                          flux,
                          flux_err,
                          R_host=R_host,
                          R_host_min=R_host - sigma_multiplier * R_host_lerr,
                          R_host_max=R_host + sigma_multiplier * R_host_uerr,
                          M_host=M_host,
                          M_host_min=M_host - sigma_multiplier * M_host_lerr,
                          M_host_max=M_host + sigma_multiplier * M_host_uerr,
                          ldc=ldc,
                          **kwargs)
コード例 #2
0
def tls_search_by_tic(tic_id,
                      tls_kwargs=None,
                      SNR_threshold=5.,
                      known_transits=None,
                      options=None):
    '''
    Summary:
    -------
    wrapper around tls_search()
    retrieves the SPOC PDC-SAP lightcurve
    retrieves all TIC catalog information from MAST
    calls tls_search()
    
    Inputs:
    -------
    tic_id : str
        TIC ID
        
    Optional Inputs:
    ----------------
    see tls_search()
        
    Returns:
    -------
    list of all TLS results
    '''

    #::: handle inputs
    if options is None: options = {}
    if 'show_plot' not in options: options['show_plot'] = False
    if 'save_plot' not in options: options['save_plot'] = False
    if 'outdir' not in options: options['outdir'] = ''

    #::: format inputs
    tic_id = str(int(tic_id))

    #::: load data and inject transit
    time, flux, flux_err = tessio.get(tic_id,
                                      pipeline='spoc',
                                      PDC=True,
                                      unpack=True)

    #::: load TIC info / tls kwargs
    tls_kwargs = get_tls_kwargs_by_tic(tic_id, tls_kwargs=tls_kwargs)

    return tls_search(time,
                      flux,
                      flux_err,
                      tls_kwargs=tls_kwargs,
                      SNR_threshold=SNR_threshold,
                      known_transits=known_transits,
                      options=options)
コード例 #3
0
def inject_and_tls_search_by_tic(tic_id,
                                 periods,
                                 rplanets,
                                 logfname,
                                 SNR_threshold=5.,
                                 known_transits=None,
                                 show_plot=False,
                                 save_plot=False):
    '''
    Inputs:
    -------
    tic_id : str or int
        TIC ID
    periods : float or array of float
        a period or list of periods for injections
    rplanets : float or array of float
        a planet radius or list of planet radii for injections
    logfname : str
        file path and name for the log file
    SNR_threshold : float
        the SNR threshold at which to stop the TLS search
    known_transits : None or dict
        if dict and one transit is already known: 
            known_transits = {'period':[1.3], 'duration':[2.1], 'epoch':[245800.0]}
        if dict and multiple transits are already known: 
            known_transits = {'period':[1.3, 21.0], 'duration':[2.1, 4.1], 'epoch':[245800.0, 245801.0]}
        'period' is the period of the transit
        'duration' must be the total duration, i.e. from first ingress point to last egrees point, in days
        'epoch' is the epoch of the transit
    show_plot : bool
        show a plot in the terminal or not
    save_plot : bool
        save a plot
        
    Summary:
    -------
        - retrieves the SPOC PDC-SAP lightcurve
        - retrieves all TIC catalog information from MAST
        - injects a planet signal via ellc, for a given period and radius (at random epoch)
        - runs TLS on these injected data and infos
    
    Returns:
    -------
        - a list of all TLS results will get saved to a log file
    '''

    #::: format inputs
    tic_id = str(int(tic_id))
    periods = np.atleast_1d(periods)
    rplanets = np.atleast_1d(rplanets)

    #::: load data
    dic = tessio.get(tic_id)
    time, flux, flux_err = dic['time'], dic['flux'], dic['flux_err']

    #::: load TIC info
    ab, R_star, R_star_lerr, R_star_uerr, M_star, M_star_lerr, M_star_uerr = catalog_info(
        TIC_ID=int(tic_id))
    print('TICv8 info:')
    print('Quadratic limb darkening a, b', ab[0], ab[1])
    print('Stellar radius', R_star, '+', R_star_lerr, '-', R_star_uerr)
    print('Stellar mass', M_star, '+', M_star_lerr, '-', M_star_uerr)

    #::: run
    inject_and_tls_search(time,
                          flux,
                          flux_err,
                          periods,
                          rplanets,
                          logfname,
                          SNR_threshold=SNR_threshold,
                          known_transits=known_transits,
                          R_star=R_star,
                          R_star_min=R_star - R_star_lerr,
                          R_star_max=R_star + R_star_uerr,
                          M_star=M_star,
                          M_star_min=M_star - M_star_lerr,
                          M_star_max=M_star + M_star_uerr,
                          show_plot=show_plot,
                          save_plot=save_plot)
コード例 #4
0
def inject_and_tls_search_by_tic(tic_id, 
                                  period_grid, r_companion_earth_grid, 
                                  SNR_threshold=5.,
                                  known_transits=None, 
                                  tls_kwargs=None,
                                  options=None):
    '''
    Inputs:
    -------
    tic_id : str or int
        TIC ID
    periods : float or array of float
        a period or list of periods for injections
    rplanets : float or array of float
        a planet radius or list of planet radii for injections
    logfname : str
        file path and name for the log file
    SNR_threshold : float
        the SNR threshold at which to stop the TLS search
    known_transits : None or dict
        if dict and one transit is already known: 
            known_transits = {'period':[1.3], 'duration':[2.1], 'epoch':[245800.0]}
        if dict and multiple transits are already known: 
            known_transits = {'period':[1.3, 21.0], 'duration':[2.1, 4.1], 'epoch':[245800.0, 245801.0]}
        'period' is the period of the transit
        'duration' must be the total duration, i.e. from first ingress point to last egrees point, in days
        'epoch' is the epoch of the transit
    show_plot : bool
        show a plot in the terminal or not
    save_plot : bool
        save a plot
        
    Summary:
    -------
        - retrieves the SPOC PDC-SAP lightcurve
        - retrieves all TIC catalog information from MAST
        - injects a planet signal via ellc, for a given period and radius (at random epoch)
        - runs TLS on these injected data and infos
    
    Returns:
    -------
        - a list of all TLS results will get saved to a log file
    '''
    
    #::: format inputs
    tic_id = str(int(tic_id))
    period_grid = np.atleast_1d(period_grid)
    r_companion_earth_grid = np.atleast_1d(r_companion_earth_grid)

    #::: load data
    dic = tessio.get(tic_id)
    time, flux, flux_err = dic['time'], dic['flux'], dic['flux_err']
    
    #::: load tls kwargs
    tls_kwargs = get_tls_kwargs_by_tic(tic_id, tls_kwargs=tls_kwargs)
    
    #::: run
    inject_and_tls_search(time, flux, flux_err, 
                          period_grid, r_companion_earth_grid, 
                          SNR_threshold=SNR_threshold,
                          known_transits=known_transits, 
                          tls_kwargs=tls_kwargs,
                          options=options)
コード例 #5
0
import seaborn as sns

sns.set(context='paper',
        style='ticks',
        palette='deep',
        font='sans-serif',
        font_scale=1.5,
        color_codes=True)
sns.set_style({"xtick.direction": "in", "ytick.direction": "in"})
sns.set_context(rc={'lines.markeredgewidth': 1})

#::: 0) tic_id
tic_id = '390651552'

#::: 1) load data
time, flux, flux_err = tessio.get(tic_id, unpack=True)
tessplot(time, flux, clip=False)
tessplot(time, flux)

#::: 2) prepare data
flux = sigma_clip(time, flux, high=3, low=20)
flux = slide_clip(time, flux, high=3, low=20)
flux = mask_regions(time,
                    flux,
                    regions=[(2458865.5, 2458866), (2458990, 2458990.5)])
tessplot(time, flux)

#::: 3) estimate variability period
period = estimate_period(time, flux, flux_err)[0]

#::: 4) detrend data
コード例 #6
0
def inject_and_tls_search_by_tic(tic_id,
                                 period_grid,
                                 r_companion_earth_grid,
                                 known_transits=None,
                                 tls_kwargs=None,
                                 wotan_kwargs=None,
                                 options=None):
    '''
    Inputs:
    -------
    tic_id : str or int
        TIC ID
    periods : float or array of float
        a period or list of periods for injections
    rplanets : float or array of float
        a planet radius or list of planet radii for injections
    logfname : str
        file path and name for the log file
    SNR_threshold : float
        the SNR threshold at which to stop the TLS search
    known_transits : None or dict
        if dict and one transit is already known: 
            known_transits = {'period':[1.3], 'duration':[2.1], 'epoch':[245800.0]}
        if dict and multiple transits are already known: 
            known_transits = {'period':[1.3, 21.0], 'duration':[2.1, 4.1], 'epoch':[245800.0, 245801.0]}
        'period' is the period of the transit
        'duration' must be the total duration, i.e. from first ingress point to last egrees point, in days
        'epoch' is the epoch of the transit
    show_plot : bool
        show a plot in the terminal or not
    save_plot : bool
        save a plot
        
    Summary:
    -------
        - retrieves the SPOC PDC-SAP lightcurve
        - retrieves all TIC catalog information from MAST
        - injects a planet signal via ellc, for a given period and radius (at random epoch)
        - runs TLS on these injected data and infos
    
    Returns:
    -------
        - a list of all TLS results will get saved to a log file
    '''

    #::: format inputs
    tic_id = str(int(tic_id))
    period_grid = np.atleast_1d(period_grid)
    r_companion_earth_grid = np.atleast_1d(r_companion_earth_grid)

    #::: load data
    time, flux, flux_err = tessio.get(tic_id, unpack=True)
    if (time is None) or (
            len(time) < 5000
    ):  #abort if no reasonable data was found (at least 5000 exposures, aka 7 days of data)
        print('Skipped. No data was found for TIC ' + tic_id + '.')
        return None

    #::: load tls kwargs
    tls_kwargs = get_tls_kwargs_by_tic(tic_id, tls_kwargs=tls_kwargs)
    if any(
            np.isnan([
                tls_kwargs['u'][0], tls_kwargs['u'][1], tls_kwargs['R_star'],
                tls_kwargs['M_star']
            ])):  #abort if TICv8 doesn't hold the stellar info
        print('Skipped. No TICv8 information was found for TIC ' + tic_id +
              '.')
        return None

    #::: run
    inject_and_tls_search(time,
                          flux,
                          flux_err,
                          period_grid,
                          r_companion_earth_grid,
                          known_transits=known_transits,
                          tls_kwargs=tls_kwargs,
                          wotan_kwargs=wotan_kwargs,
                          options=options)
コード例 #7
0
def tls_search_by_tic(tic_id,
                      time=None,
                      flux=None,
                      flux_err=None,
                      SNR_threshold=5.,
                      known_transits=None,
                      show_plot=False,
                      save_plot=False,
                      outdir=''):
    '''
    Inputs:
    -------
    tic_id : str
        TIC ID
        
    Optional Inputs:
    ----------------
    time : array of flaot
        time stamps of observations (to overwrite the SPOC PDC SAP lightcurve)
    flux : array of flaot
        normalized flux (to overwrite the SPOC PDC SAP lightcurve)
    flux_err : array of flaot
        error of normalized flux (to overwrite the SPOC PDC SAP lightcurve)
    SNR_threshold : float
        the SNR threshold at which to stop the TLS search
    known_transits : None or dict
        if dict and one transit is already known: 
            known_transits = {'period':[1.3], 'duration':[2.1], 'epoch':[245800.0]}
        if dict and multiple transits are already known: 
            known_transits = {'period':[1.3, 21.0], 'duration':[2.1, 4.1], 'epoch':[245800.0, 245801.0]}
        'period' is the period of the transit
        'duration' must be the total duration, i.e. from first ingress point to last egrees point, in days
        'epoch' is the epoch of the transit
        
    Summary:
    -------
        - retrieves the SPOC PDC-SAP lightcurve
        - retrieves all TIC catalog information from MAST
        - runs TLS on these data and infos
    
    Returns:
    -------
        - list of all TLS results
    '''

    #::: format inputs
    tic_id = str(int(tic_id))

    #::: load data and inject transit
    dic = tessio.get(tic_id, pipeline='spoc', PDC=True)
    if time is None: time = dic['time']
    if flux is None: flux = dic['flux']
    if flux_err is None: flux_err = dic['flux_err']

    #::: load TIC info
    ab, R_star, R_star_lerr, R_star_uerr, M_star, M_star_lerr, M_star_uerr = catalog_info(
        TIC_ID=int(tic_id))
    print('TICv8 info:')
    print('Quadratic limb darkening a, b', ab[0], ab[1])
    print('Stellar radius', R_star, '+', R_star_lerr, '-', R_star_uerr)
    print('Stellar mass', M_star, '+', M_star_lerr, '-', M_star_uerr)

    return tls_search(time,
                      flux,
                      flux_err,
                      R_star=R_star,
                      R_star_min=R_star - R_star_lerr,
                      R_star_max=R_star + R_star_uerr,
                      M_star=M_star,
                      M_star_min=M_star - M_star_lerr,
                      M_star_max=M_star + M_star_uerr,
                      known_transits=known_transits,
                      show_plot=show_plot,
                      save_plot=save_plot,
                      outdir=outdir)