sherlockpipe.single_transits.search.MoriartySearch
- class sherlockpipe.single_transits.search.MoriartySearch(object_dir, object_id, is_candidate_from_search, candidates_df, transits_mask=[], batch_size=256, threshold=0.5, cache_dir='/home/docs/')
Bases:
ToolWithCandidateSearches for single transit events using the SANTO neural network model.
Extends ToolWithCandidate to perform single transit detection: loads a pre-trained SANTO model, predicts transit probabilities over the light curve, identifies positive regions, fits box-shaped transit models, and estimates orbital periods.
- __init__(object_dir, object_id, is_candidate_from_search, candidates_df, transits_mask=[], batch_size=256, threshold=0.5, cache_dir='/home/docs/') None
Initialize the Moriarty single-transit search.
Parameters
- object_dirstr or None
Directory containing the object’s data files.
- object_idstr
Identifier for the target object.
- is_candidate_from_searchbool
Whether the candidate comes from a SHERLOCK search.
- candidates_dfpandas.DataFrame
DataFrame of candidate information for transit masking.
- transits_masklist of dict, optional
List of transit masks with keys ‘P’, ‘T0’, ‘D’ to exclude known transits.
- batch_sizeint, optional
Batch size for SANTO predictions. Default is 256.
- thresholdfloat, optional
Probability threshold for single-transit classification. Default is 0.5.
- cache_dirstr, optional
Directory to cache downloaded models. Default is user home.
Methods
__init__(object_dir, object_id, ...[, ...])Initialize the Moriarty single-transit search.
greater_than_snr_projected(max_period, ...)Check if projected SNR for a given period exceeds the threshold.
in_transit_mask(t0, duration_mins)Check if a given time and duration overlaps with any masked transit windows.
Boolean return to inform whether the candidate to be processed comes from SHERLOCK searches or is user-given.
mask_previous_candidates(time, flux, ...)Masks all the candidates found in previous runs in the SHERLOCK search.
nearest_epoch_offset(ts, t0, P[, signed])Devuelve la diferencia temporal entre ts y el t0 periódico más cercano.
Return the object data directory.
plot_lc_preds_spectrum_broken_x(time, flux, ...)Figura 3x1 con 'broken X' en las dos primeras filas (curva de luz y predicciones) y el espectro completo en la tercera fila.
plot_light_curve_broken_x(time, flux, ...[, ...])Broken-X light curve.
roche_limit_period(M_star_sun, R_star_sun[, ...])Approximate orbital period (in days) at the fluid Roche limit for a planet orbiting a star, assuming a fiducial planet density.
run(cpus, **kwargs)Execute the single-transit search pipeline.
sample_periods_single_transit(M_star_sun, ...)Estima una distribución de períodos plausibles para un tránsito único, asumiendo órbita circular y aproximación geométrica simple.
Attributes
watson- greater_than_snr_projected(max_period, depth, duration_s, time_array, flux_std, single_snr, t0=0, projected_snr=10)
Check if projected SNR for a given period exceeds the threshold.
For a given orbital period, this function estimates how many transits could occur within the observation window and calculates the projected SNR from combining multiple transits.
Projected SNR = single_snr * sqrt(n_transits)
Returns True if projected_snr > threshold (reject the candidate).
Parameters
- max_periodfloat
Maximum orbital period to consider (days)
- depth_pptfloat
Transit depth in parts per thousand
- duration_hfloat
Transit duration in hours
- time_arraynp.ndarray
Time array of observations (days)
- flux_stdfloat
Flux standard deviation (ppt)
- single_snrfloat
Single-transit SNR
- t0float
Transit epoch (days, default 0)
- projected_snrfloat
SNR threshold (default 10)
Returns
- bool
True if projected SNR exceeds threshold (reject), False otherwise
- in_transit_mask(t0, duration_mins)
Check if a given time and duration overlaps with any masked transit windows.
Parameters
- t0float
Transit epoch in days.
- duration_minsfloat
Transit duration in minutes.
Returns
- bool
True if the transit overlaps with any existing transit mask, False otherwise.
- is_candidate_aware()
Boolean return to inform whether the candidate to be processed comes from SHERLOCK searches or is user-given.
- Returns:
boolean with the value
- mask_previous_candidates(time, flux, flux_err, candidate_id)
Masks all the candidates found in previous runs in the SHERLOCK search.
- Parameters:
time – the time array
flux – the flux measurements array
flux_err – the flux error measurements array
candidate_id – the candidate number
- Returns:
time, flux and flux_err with previous candidates in-transit data masked
- nearest_epoch_offset(ts, t0, P, signed=True)
Devuelve la diferencia temporal entre ts y el t0 periódico más cercano. ts, t0, P en las mismas unidades (p.ej., días BJD_TDB). Acepta escalares o arrays (vectorizado).
- plot_lc_preds_spectrum_broken_x(time, flux, predictions, power_x, spectra, zero_epsilon, lcs_dir, target_file, gap_threshold=0.5, max_panels=6, min_points_per_panel=200, marker_size=1, dpi=300)
Figura 3x1 con ‘broken X’ en las dos primeras filas (curva de luz y predicciones) y el espectro completo en la tercera fila.
No se colapsa el eje tiempo: se divide en segmentos (columnas) por huecos > gap_threshold.
Se muestran hasta ‘max_panels’ segmentos (los mayores), en orden cronológico.
La tercera fila (espectro) ocupa todo el ancho (no se divide).
- Parámetros clave:
time, flux, predictions: arrays 1D (se usan hasta N puntos = len(predictions)). power_x, spectra: arrays para el espectro (no dependen de time). zero_epsilon: umbral para calcular límites Y robustos del panel de flux.
- plot_light_curve_broken_x(time, flux, half_duration_points, t0, cadence, moriarty_dir, object_id, target_fit, out_path, gap_threshold=0.5, max_panels=6, min_points_per_panel=200, color_oot='blue', color_it='red', marker_size=6, draw_t0_line=True)
Broken-X light curve. In-transit = exactly half_duration_points samples on each side of the sample whose time is nearest to t0 (index-based definition).
- roche_limit_period(M_star_sun, R_star_sun, rho_p=5500.0)
Approximate orbital period (in days) at the fluid Roche limit for a planet orbiting a star, assuming a fiducial planet density.
- Uses the classical fluid Roche limit:
a_R = 2.44 * R_star * (rho_star / rho_p)**(1/3)
- and Kepler’s third law:
P = 2π * sqrt(a_R^3 / (G * M_star))
Parameters
- M_star_sunfloat
Stellar mass in solar masses.
- R_star_sunfloat
Stellar radius in solar radii.
- rho_pfloat, optional
Assumed mean planetary density in kg/m^3. Default is 5500 kg/m^3 (Earth-like).
Returns
- P_roche_daysfloat
Orbital period at the Roche limit in days.
- run(cpus, **kwargs)
Execute the single-transit search pipeline.
Downloads the SANTO model if needed, runs predictions on the light curve, identifies positive regions, fits box-shaped transit models, estimates orbital periods, generates diagnostic plots, and creates a PDF report.
Parameters
- cpusint
Number of CPUs to use.
- **kwargsdict
Additional keyword arguments (currently unused).
- sample_periods_single_transit(M_star_sun, R_star_sun, T14_days, T14_err_days=None, R_p_earth=1.0, n_samples=100000, b_max=0.9, geometric_b_prior=True, random_state=None)
Estima una distribución de períodos plausibles para un tránsito único, asumiendo órbita circular y aproximación geométrica simple.
Parámetros
- M_star_sunfloat
Masa estelar en masas solares.
- R_star_sunfloat
Radio estelar en radios solares.
- T14_daysfloat
Duración del tránsito (1º a 4º contacto) en días.
- T14_err_daysfloat or None
Incertidumbre (1 sigma) en la duración, en días. Si None, se toma fija.
- R_p_earthfloat
Radio planetario (valor más probable) en radios terrestres.
- n_samplesint
Número de muestras Monte Carlo.
- b_maxfloat
Máximo valor de parámetro de impacto que permitimos (en unidades de R*).
- geometric_b_priorbool
Si True, usa prior geométrico p(b) ∝ b en [0, b_max]. Si False, prior uniforme en b.
- random_stateint or None
Semilla para reproducibilidad.
Devuelve
- periods_daysnp.ndarray
Array de períodos en días (filtrado a valores físicos).
- summarydict
Diccionario con estadísticos (median, p16, p84, etc.).