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. |
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 lightcurve 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.EnumAn 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.EnumAn 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.lightcurve_database.LightcurveDatabaseAn abstract class allowing for any number and combination of standard and injectable/injectee lightcurve 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.
-
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, repeat: bool = True, shuffle: bool = True)[source]¶ Generates a paths dataset for a lightcurve collection.
Parameters: - lightcurve_collection – The lightcurve 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_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_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 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_fluxes_and_flux_errors_from_path_function – The function defining how to load the times and fluxes of a lightcurve from a path.
- load_label_from_path_function – The function to load the label to use for the lightcurves 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 lightcurve 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_lightcurve(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]], lightcurve_path_tensor: tf.Tensor, evaluation_mode: bool = False, request_queue: Optional[Queue] = None, example_queue: Optional[Queue] = None)[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_fluxes_and_flux_errors_from_path_function – The function to load the lightcurve times and fluxes from a file.
- load_label_from_path_function – The function to load the label to assign to the lightcurve.
- lightcurve_path_tensor – The tensor containing the path to the lightcurve 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_lightcurve_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 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_fluxes_and_flux_errors_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_fluxes_and_flux_errors_from_path_function: Callable[[Path], Tuple[np.ndarray, np.ndarray, Union[np.ndarray, None]]], 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_fluxes_and_flux_errors_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_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 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_fluxes_and_flux_errors_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_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 lightcurves 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 lightcurve example and label dataset.
-
preprocess_injected_lightcurve(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_lightcurve_path_tensor: tf.Tensor, injectable_lightcurve_path_tensor: tf.Tensor, evaluation_mode: bool = False, request_queue: Optional[Queue] = None, example_queue: Optional[Queue] = None)[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_fluxes_and_flux_errors_from_path_function – The function to load the injectee lightcurve times and fluxes from a file.
- injectable_load_times_magnifications_and_magnification_errors_from_path_function – The function to load the injectee lightcurve times and signal from a file.
- load_label_from_path_function – The function to load 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.
- 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_lightcurve(self, lightcurve_fluxes: np.ndarray, lightcurve_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 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.
- wandb_loggable_injection – The object to log the injection process.
Returns: The fluxes with the injected signal.
-
-
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.