ramjet.photometric_database.standard_and_injected_lightcurve_database

An abstract class allowing for any number and combination of standard and injectable/injectee lightcurve collections.

Module Contents

Classes

OutOfBoundsInjectionHandlingMethod() An enum of approaches for handling cases where the injectable signal is shorter than the injectee signal.
StandardAndInjectedLightcurveDatabase() An abstract class allowing for any number and combination of standard and injectable/injectee lightcurve collections
class OutOfBoundsInjectionHandlingMethod[source]

Bases: enum.Enum

An enum of approaches for handling cases where the injectable signal is shorter than the injectee signal.

ERROR = error
REPEAT_SIGNAL = repeat_signal
RANDOM_INJECTION_LOCATION = random_inject_location
class StandardAndInjectedLightcurveDatabase[source]

Bases: ramjet.photometric_database.lightcurve_database.LightcurveDatabase

An abstract class allowing for any number and combination of standard and injectable/injectee lightcurve collections to be used for training.

__init__(self)[source]

Initialize self. See help(type(self)) for accurate signature.

generate_datasets(self)[source]

Generates the training and validation datasets for the database.

Returns:The training and validation dataset.
generate_paths_datasets_group_from_lightcurve_collections_group(self, standard_lightcurve_collections: List[LightcurveCollection], injectee_lightcurve_collection: LightcurveCollection, injectable_lightcurve_collections: List[LightcurveCollection], shuffle: bool = True)[source]

Create the path dataset for each lightcurve collection in the standard, injectee, and injectable sets.

Parameters:
  • standard_lightcurve_collections – The standard lightcurve collections.
  • injectee_lightcurve_collection – The injectee lightcurve collection.
  • injectable_lightcurve_collections – The injectable lightcurve collections.
  • shuffle – Whether to shuffle the dataset or not.
Returns:

The standard, injectee, and injectable paths datasets.

generate_paths_dataset_from_lightcurve_collection(self, lightcurve_collection: LightcurveCollection, shuffle: bool = True)[source]

Generates a paths dataset for a lightcurve collection.

Parameters:
  • lightcurve_collection – The lightcurve collection to generate a paths dataset for.
  • shuffle – Whether to shuffle the dataset or not.
Returns:

The paths dataset.

generate_paths_datasets_from_lightcurve_collection_list(self, lightcurve_collections: List[LightcurveCollection], shuffle: bool = True)[source]

Generates a paths dataset for each lightcurve collection in a list.

Parameters:
  • lightcurve_collections – The list of lightcurve collections.
  • shuffle – Whether to shuffle the datasets or not.
Returns:

The list of paths datasets.

generate_standard_lightcurve_and_label_dataset(self, paths_dataset: tf.data.Dataset, load_times_and_fluxes_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], label: float)[source]

Generates a lightcurve and label dataset from a paths dataset using a passed function defining how to load the values from the lightcurve file and the label value to use.

Parameters:
  • paths_dataset – The dataset of paths to use.
  • load_times_and_fluxes_from_path_function – The function defining how to load the times and fluxes of a lightcurve from a path.
  • label – The label to use for the lightcurves in this dataset.
Returns:

The resulting lightcurve example and label dataset.

preprocess_standard_lightcurve(self, load_times_and_fluxes_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], label: float, lightcurve_path_tensor: tf.Tensor)[source]

Preprocesses a individual standard lightcurve from a lightcurve path tensor, using a passed function defining how to load the values from the lightcurve file and the label value to use. Designed to be used with partial to prepare a function which will just require the lightcurve path tensor, and can then be mapped to a dataset.

Parameters:
  • load_times_and_fluxes_from_path_function – The function to load the lightcurve times and fluxes from a file.
  • label – The label to assign to the lightcurve.
  • lightcurve_path_tensor – The tensor containing the path to the lightcurve file.
Returns:

The example and label arrays shaped for use as single example for the network.

generate_infer_path_and_lightcurve_dataset(self, paths_dataset: tf.data.Dataset, load_times_and_fluxes_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]])[source]

Generates a path and lightcurve dataset from a paths dataset using a passed function defining how to load the values from the lightcurve file.

Parameters:
  • paths_dataset – The dataset of paths to use.
  • load_times_and_fluxes_from_path_function – The function defining how to load the times and fluxes of a lightcurve from a path.
Returns:

The resulting lightcurve example and label dataset.

preprocess_infer_lightcurve(self, load_times_and_fluxes_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], lightcurve_path_tensor: tf.Tensor)[source]

Preprocesses a individual standard lightcurve from a lightcurve path tensor, using a passed function defining how to load the values from the lightcurve file and returns the path and lightcurve. Designed to be used with partial to prepare a function which will just require the lightcurve path tensor, and can then be mapped to a dataset.

Parameters:
  • load_times_and_fluxes_from_path_function – The function to load the lightcurve times and fluxes from a file.
  • lightcurve_path_tensor – The tensor containing the path to the lightcurve file.
Returns:

The path and example array shaped for use as single example for the network.

generate_injected_lightcurve_and_label_dataset(self, injectee_paths_dataset: tf.data.Dataset, injectee_load_times_and_fluxes_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], injectable_paths_dataset: tf.data.Dataset, injectable_load_times_and_magnifications_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], label: float)[source]

Generates a lightcurve and label dataset from an injectee and injectable paths dataset, using passed functions defining how to load the values from the lightcurve files for each and the label value to use.

Parameters:
  • injectee_paths_dataset – The dataset of paths to use for the injectee lightcurves.
  • injectee_load_times_and_fluxes_from_path_function – The function defining how to load the times and fluxes of an injectee lightcurve from a path.
  • injectable_paths_dataset – The dataset of paths to use for the injectable lightcurves.
  • injectable_load_times_and_magnifications_from_path_function – The function defining how to load the times and magnifications of an injectable signal from a path.
  • label – The label to use for the lightcurves in this dataset.
Returns:

The resulting lightcurve example and label dataset.

preprocess_injected_lightcurve(self, injectee_load_times_and_fluxes_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], injectable_load_times_and_magnifications_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray]], label: float, injectee_lightcurve_path_tensor: tf.Tensor, injectable_lightcurve_path_tensor: tf.Tensor)[source]

Preprocesses a individual injected lightcurve from an injectee and an injectable lightcurve path tensor, using a passed function defining how to load the values from each lightcurve file and the label value to use. Designed to be used with partial to prepare a function which will just require the lightcurve path tensor, and can then be mapped to a dataset.

Parameters:
  • injectee_load_times_and_fluxes_from_path_function – The function to load the injectee lightcurve times and fluxes from a file.
  • injectable_load_times_and_magnifications_from_path_function – The function to load the injectee lightcurve times and signal from a file.
  • label – The label to assign to the lightcurve.
  • injectee_lightcurve_path_tensor – The tensor containing the path to the injectee lightcurve file.
  • injectable_lightcurve_path_tensor – The tensor containing the path to the injectable lightcurve file.
Returns:

The injected example and label arrays shaped for use as single example for the network.

flux_preprocessing(self, fluxes: np.ndarray, evaluation_mode: bool = False, seed: int = None)[source]

Preprocessing for the flux.

Parameters:
  • fluxes – The flux array to preprocess.
  • evaluation_mode – If the preprocessing should be consistent for evaluation.
  • seed – Seed for the randomization.
Returns:

The preprocessed flux array.

inject_signal_into_lightcurve(self, lightcurve_fluxes: np.ndarray, lightcurve_times: np.ndarray, signal_magnifications: np.ndarray, signal_times: np.ndarray)[source]

Injects a synthetic magnification signal into real lightcurve fluxes.

Parameters:
  • lightcurve_fluxes – The fluxes of the lightcurve to be injected into.
  • lightcurve_times – The times of the flux observations of the lightcurve.
  • signal_magnifications – The synthetic magnifications to inject.
  • signal_times – The times of the synthetic magnifications.
Returns:

The fluxes with the injected signal.

static intersperse_datasets(dataset_list: List[tf.data.Dataset])[source]

Intersperses a list of datasets into one joint dataset. (e.g., [0, 2, 4] and [1, 3, 5] to [0, 1, 2, 3, 4, 5]).

Parameters:dataset_list – The datasets to intersperse.
Returns:The interspersed dataset.
generate_inference_dataset(self)[source]

Generates the dataset to infer over.

Returns:The inference dataset.