5. API reference

5.1. deep_transit

class deep_transit.DeepTransit(lc_object=None, time=None, flux=None, flux_err=None, is_flat=False, lk_kwargs={}, flatten_kwargs={})[source]

The core class of transit detection.

__init__(lc_object=None, time=None, flux=None, flux_err=None, is_flat=False, lk_kwargs={}, flatten_kwargs={})[source]

Initial function for receiving an light curve object or a time series.

Parameters
  • lc_object (LightCurve instance) – Input light curve object

  • time (Time or iterable) – Time values. They can either be given directly as a Time array or as any iterable that initializes the Time class.

  • flux (Quantity or iterable) – Flux values for every time point.

  • flux_err (Quantity or iterable) – Uncertainty on each flux data point.

  • is_flat (bool) – True when receiving a flattened light, False will use the built-in flatten method.

  • lk_kwargs (dict) – Keyword arguments of LightCurve.

  • flatten_kwargs (dict) – Keyword arguments of detrend_light_curve method.

transit_detection(local_model_path, batch_size=2, confidence_threshold=0.6, nms_iou_threshold=0.1, device_str='auto', backend='pytorch')[source]

Searching transit signals from a given light curve.

Parameters
  • model_path (str) – The path of the model file.

  • batch_size (int) – Batch size for increasing detection speed, especially useful for GPU default value is 2, if using GPU, it can be higher depending on the limitation of the GPU memory.

  • confidence_threshold (float) – Confidence threshold for transit detection. If None, the value will be obtained from config. Default value is 0.6.

  • nms_iou_threshold (float) – IOU threshold for NMS algorithm. If None, the value will be obtained from config. Default value is 0.1.

  • device_str (str) – Device name. If “cuda”, it will use GPU. Default is “auto”.

  • backend (str) – Backend of the model. You can choose between “pytorch” or “megengine”. Default is “pytorch”.

Returns

final_bboxes – An (N, 5) shape numpy.ndarray of bounding boxes.

Return type

np.ndarray

deep_transit.detrend_light_curve(lc_object, window_length=0.5, edge_cutoff=0.5, break_tolerance=0.5, cval=5.0, sigma_upper=3, sigma_lower=20)[source]

Detrend a light curve for upcoming transit searching with wotan biweight method and sigma clipping https://github.com/hippke/wotan

Parameters
  • lc_object (LightCurve instance) – Input light curve object

  • window_length (float) – The length of the filter window in units of time, default is 0.5

  • edge_cutoff (float) – Length (in units of time) to be cut off each edge, default is 0.5

  • break_tolerance (float) – Split into segments at breaks longer than that, default is 0.5

  • cval (float) – Tuning parameter for the robust estimators, default is 5.0

  • sigma_upper (float) – Upper limit of standard deviations for sigma clipping

  • sigma_lower (float) – Lower limit of standard deviations for sigma clipping

Returns

flatten_lc

Return type

LightCurve instance

deep_transit.plot_lc_with_bboxes(lc_object, bboxes, ax=None, **kwargs)[source]

Plot light curve with bounding boxes

Parameters
  • lc_object (LightCurve instance) –

  • bboxes (list or np.ndarray) – Bounding boxes in shape (N, 5)

  • ax (axis instance) – Axis to plot to. If None, create a new one.

  • kwargs (dict) – Additional arguments to be passed to matplotlib.pyplot.plot

Returns

ax – The matplotlib axes object.

Return type

axis instance

5.2. deep_transit.config

deep_transit.config.IMAGE_SIZE = 416

Image size of you training data set, should be the multiples of 32

Type

int

deep_transit.config.LEARNING_RATE = 0.0001

Learning rate parameter of the Adam optimization

Type

float

deep_transit.config.WEIGHT_DECAY = 0.0001

Weight decay parameter of the Adam optimization

Type

float

deep_transit.config.NUM_EPOCHS = 100

Max number of epochs of you training

Type

int

deep_transit.config.BATCH_SIZE = 96

Batch size of you training

Type

int

deep_transit.config.CONF_THRESHOLD = 0.6

The confidence threshold for validation and detection. The number should be 0 to 1, it can be a represent of S/N

Type

float

deep_transit.config.MAP_IOU_THRESH = 0.5

The IOU threshold of the AP calculation

Type

float

deep_transit.config.NMS_IOU_THRESH = 0.1

The IOU threshold of the NMS calculation

Type

float

deep_transit.config.S = [13, 26, 52]

The feature size of three scales

Type

list

deep_transit.config.NUM_WORKERS = 0

Number of works for loading data set

Type

int

deep_transit.config.PIN_MEMORY = True

bool:

deep_transit.config.LOAD_MODEL = False

If true, it will require loading a previous checkpoint before training

Type

bool

deep_transit.config.SAVE_MODEL = False

If true, it will save model during the training step

Type

bool

deep_transit.config.ENABLE_AMP = True

If true, AMP (automatic mixed precision) will be enabled. Note: if AMD CPU, the ENABLE_AMP should be False.

Type

bool

deep_transit.config.ENABLE_WANDB = False

If true, a Weights & Biases offline stroage will be enabled

Type

bool

deep_transit.config.CHECKPOINT_FILE = 'checkpoint.pth.tar'

The path of checkpoint file

Type

str

deep_transit.config.DATASET = 'Data'

The path of data set

Type

str

deep_transit.config.IMG_DIR = 'Data/transit-images/'

The path of image directory

Type

str

deep_transit.config.LABEL_DIR = 'Data/transit-labels/'

The path of label directory

Type

str

5.3. deep_transit.train

deep_transit.train(patience=2, cooldown=3, enable_seed_everything=True)[source]

Function for training your own data set.

Parameters
deep_transit.save_checkpoint_to_model(checkpoint_path, model_path)[source]

Save trained a checkpoint to a model

Parameters
  • checkpoint_path (str) –

  • model_path (str) –