RAMjET

ramjet.photometric_database.standard_and_injected_light_curve_database

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

Module Contents

Classes

OutOfBoundsInjectionHandlingMethod An enum of approaches for handling cases where the injectable signal is shorter than the injectee signal.
BaselineFluxEstimationMethod An enum of to designate the type of baseline flux estimation method to use during training.
StandardAndInjectedLightCurveDatabase An abstract class allowing for any number and combination of standard and injectable/injectee light curve collections

Functions

repeat_each_element(element: tf.Tensor, number_of_repeats: int) → tf.data.Dataset A dataset mappable function which repeats the elements a given number of times.
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 BaselineFluxEstimationMethod[source]

Bases: enum.Enum

An enum of to designate the type of baseline flux estimation method to use during training.

MEDIAN = median
MEDIAN_ABSOLUTE_DEVIATION = median_absolute_deviation
class StandardAndInjectedLightCurveDatabase[source]

Bases: ramjet.photometric_database.light_curve_database.LightCurveDatabase

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

number_of_input_channels :int

Determines the number of input channels that should exist for this database.

Returns:The number of channels.
__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_light_curve_collections_group(self, standard_light_curve_collections: List[LightCurveCollection], injectee_light_curve_collection: LightCurveCollection, injectable_light_curve_collections: List[LightCurveCollection], shuffle: bool = True)[source]

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

Parameters:
  • standard_light_curve_collections – The standard light curve collections.
  • injectee_light_curve_collection – The injectee light curve collection.
  • injectable_light_curve_collections – The injectable light curve collections.
  • shuffle – Whether to shuffle the dataset or not.
Returns:

The standard, injectee, and injectable paths datasets.

generate_paths_dataset_from_light_curve_collection(self, light_curve_collection: LightCurveCollection, repeat: bool = True, shuffle: bool = True)[source]

Generates a paths dataset for a light curve collection.

Parameters:
  • light_curve_collection – The light curve collection to generate a paths dataset for.
  • repeat – Whether to repeat the dataset or not.
  • shuffle – Whether to shuffle the dataset or not.
Returns:

The paths dataset.

generate_paths_datasets_from_light_curve_collection_list(self, light_curve_collections: List[LightCurveCollection], shuffle: bool = True)[source]

Generates a paths dataset for each light curve collection in a list.

Parameters:
  • light_curve_collections – The list of light curve collections.
  • shuffle – Whether to shuffle the datasets or not.
Returns:

The list of paths datasets.

generate_standard_light_curve_and_label_dataset(self, paths_dataset: tf.data.Dataset, load_times_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], load_label_from_path_function: Callable[[Path], Union[float, np.ndarray]], evaluation_mode: bool = False, name: Optional[str] = None)[source]

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

Parameters:
  • paths_dataset – The dataset of paths to use.
  • load_times_fluxes_and_flux_errors_from_path_function – The function defining how to load the times and fluxes of a light curve from a path.
  • load_label_from_path_function – The function to load the label to use for the light curves in this dataset.
  • evaluation_mode – Whether or not the preprocessing should occur in evaluation mode (for repeatability).
  • name – The name of the dataset.
Returns:

The resulting light curve example and label dataset.

add_logging_queues_to_map_function(self, preprocess_map_function: Callable, name: Optional[str])[source]

Adds logging queues to the map functions.

Parameters:
  • preprocess_map_function – The function to map.
  • name – The name of the dataset.
Returns:

The updated map function.

preprocess_standard_light_curve(self, load_times_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], load_label_from_path_function: Callable[[Path], Union[float, np.ndarray]], light_curve_path_tensor: tf.Tensor, evaluation_mode: bool = False, request_queue: Optional[Queue] = None, example_queue: Optional[Queue] = None)[source]

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

Parameters:
  • load_times_fluxes_and_flux_errors_from_path_function – The function to load the light curve times and fluxes from a file.
  • load_label_from_path_function – The function to load the label to assign to the light curve.
  • light_curve_path_tensor – The tensor containing the path to the light curve file.
  • evaluation_mode – Whether or not the preprocessing should occur in evaluation mode (for repeatability).
  • request_queue – The logging request queue.
  • example_queue – The logging example queue.
Returns:

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

static expand_label_to_training_dimensions(label: Union[int, List[int], Tuple[int], np.ndarray])[source]

Expand the label to the appropriate dimensions for training.

Parameters:label – The label to convert.
Returns:The label with the correct dimensions.
generate_infer_path_and_light_curve_dataset(self, paths_dataset: tf.data.Dataset, load_times_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]])[source]

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

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

The resulting light curve example and label dataset.

preprocess_infer_light_curve(self, load_times_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], light_curve_path_tensor: tf.Tensor)[source]

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

Parameters:
  • load_times_fluxes_and_flux_errors_from_path_function – The function to load the light curve times and fluxes from a file.
  • light_curve_path_tensor – The tensor containing the path to the light curve file.
Returns:

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

generate_injected_light_curve_and_label_dataset(self, injectee_paths_dataset: tf.data.Dataset, injectee_load_times_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], injectable_paths_dataset: tf.data.Dataset, injectable_load_times_magnifications_and_magnification_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], load_label_from_path_function: Callable[[Path], Union[float, np.ndarray]], evaluation_mode: bool = False, name: Optional[str] = None)[source]

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

Parameters:
  • injectee_paths_dataset – The dataset of paths to use for the injectee light curves.
  • injectee_load_times_fluxes_and_flux_errors_from_path_function – The function defining how to load the times and fluxes of an injectee light curve from a path.
  • injectable_paths_dataset – The dataset of paths to use for the injectable light curves.
  • injectable_load_times_magnifications_and_magnification_errors_from_path_function – The function defining how to load the times and magnifications of an injectable signal from a path.
  • load_label_from_path_function – The function to load the label to use for the light curves in this dataset.
  • evaluation_mode – Whether or not the preprocessing should occur in evaluation mode (for repeatability).
  • name – The name of the dataset.
Returns:

The resulting light curve example and label dataset.

preprocess_injected_light_curve(self, injectee_load_times_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], injectable_load_times_magnifications_and_magnification_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], load_label_from_path_function: Callable[[Path], Union[float, np.ndarray]], injectee_light_curve_path_tensor: tf.Tensor, injectable_light_curve_path_tensor: tf.Tensor, evaluation_mode: bool = False, request_queue: Optional[Queue] = None, example_queue: Optional[Queue] = None)[source]

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

Parameters:
  • injectee_load_times_fluxes_and_flux_errors_from_path_function – The function to load the injectee light curve times and fluxes from a file.
  • injectable_load_times_magnifications_and_magnification_errors_from_path_function – The function to load the injectee light curve times and signal from a file.
  • load_label_from_path_function – The function to load the label to assign to the light curve.
  • injectee_light_curve_path_tensor – The tensor containing the path to the injectee light curve file.
  • injectable_light_curve_path_tensor – The tensor containing the path to the injectable light curve file.
  • evaluation_mode – Whether or not the preprocessing should occur in evaluation mode (for repeatability).
  • request_queue – The logging request queue.
  • example_queue – The logging example queue.
Returns:

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

inject_signal_into_light_curve(self, light_curve_fluxes: np.ndarray, light_curve_times: np.ndarray, signal_magnifications: np.ndarray, signal_times: np.ndarray, wandb_loggable_injection: Optional[WandbLoggableInjection] = None)[source]

Injects a synthetic magnification signal into real light curve fluxes.

Parameters:
  • light_curve_fluxes – The fluxes of the light curve to be injected into.
  • light_curve_times – The times of the flux observations of the light curve.
  • signal_magnifications – The synthetic magnifications to inject.
  • signal_times – The times of the synthetic magnifications.
  • wandb_loggable_injection – The object to log the injection process.
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.
repeat_each_element(element: tf.Tensor, number_of_repeats: int) → tf.data.Dataset[source]

A dataset mappable function which repeats the elements a given number of times.

Parameters:
  • element – The element to map to to repeat.
  • number_of_repeats – The number of times to repeat the element.
Returns:

The dataset with repeated elements.