ramjet.photometric_database.microlensing_label_per_time_step_database¶
Code for representing a database for microlensing with lightcurves for binary classification with a single label per time step.
Module Contents¶
-
class
MicrolensingLabelPerTimeStepDatabase(data_directory='data/moa_microlensing')[source]¶ -
A representation of a database for microlensing of lightcurves for binary classification with a single label per time step.
-
static
load_microlensing_meta_data(meta_data_file_path: str)[source]¶ Loads a microlensing meta data file into a Pandas data frame.
Parameters: meta_data_file_path – The path to the original meta data CSV. Returns: The meta data frame.
-
static
einstein_normalized_separation_in_direction_of_motion(observation_time: np.float32, minimum_separation_time: np.float32, einstein_crossing_time: np.float32)[source]¶ Gets the einstein normalized separation of the source relative to the minimum separation position due to motion. This will be the separation perpendicular to the line between the minimum separation position and the lens. Broadcasts for arrays times. \(u_v = 2 \dfrac{t-t_0}{t_E}\)
Parameters: - observation_time – \(t\), current time of the observation.
- minimum_separation_time – \(t_0\), the time the minimum separation between source and lens occurs at.
- einstein_crossing_time – \(t_E\), the time it would take the source to cross the center of the Einstein ring
Returns: \(u_v\), the separation in the direction of source motion.
-
calculate_magnification(self, observation_time: np.float32, minimum_separation_time: np.float32, minimum_einstein_separation: np.float32, einstein_crossing_time: np.float32)[source]¶ Calculates the magnification of a microlensing event for a given time step. Broadcasts for arrays of times. Allows an infinite magnification in cases where the separation is zero. With \(u\) as the einstein normalized separation, does
\[u_v = 2 \dfrac{t-t_0}{t_E} u = \sqrt{u_0^2 + u_v^2} A = \dfrac{u^2 + 2}{u \sqrt{u^2 + 4}}\]Parameters: - observation_time – \(t\), current time of the observation.
- minimum_separation_time – \(t_0\), the time the minimum separation between source and lens occurs at.
- minimum_einstein_separation – \(u_0\), the minimum einstein normalized separation.
- einstein_crossing_time – \(t_E\), the time it would take the source to cross the center of the Einstein ring
Returns: \(A\), the magnification for the passed time step(s).
-
get_meta_data_for_lightcurve_file_path(self, lightcurve_file_path: Union[str, Path], meta_data_frame: pd.DataFrame)[source]¶ Gets the meta data for a lightcurve based on the file name from the meta data frame.
Parameters: - lightcurve_file_path – The lightcurve file path.
- meta_data_frame – The meta data frame.
Returns: The lightcurve meta data.
-
check_if_meta_data_exists_for_lightcurve_file_path(self, lightcurve_file_path: Union[str, Path], meta_data_frame: pd.DataFrame)[source]¶ Gets the meta data for a lightcurve based on the file name from the meta data frame.
Parameters: - lightcurve_file_path – The lightcurve file path.
- meta_data_frame – The meta data frame.
Returns: The lightcurve meta data.
-
static
get_meta_data_frame_for_lightcurve_file_path(lightcurve_file_path: Union[str, Path], meta_data_frame: pd.DataFrame)[source]¶ Gets the meta data frame containing all rows for a lightcurve based on the file name from the meta data frame.
Parameters: - lightcurve_file_path – The lightcurve file path.
- meta_data_frame – The meta data frame.
Returns: The lightcurve meta data frame.
-
magnification_threshold_label_for_lightcurve_meta_data(self, observation_times: np.float32, lightcurve_meta_data: pd.Series, threshold: float)[source]¶ Gets the binary per time step label for a lightcurve based on a microlensing magnification threshold.
Parameters: - observation_times – The observation times to calculate magnifications of.
- lightcurve_meta_data – The microlensing meta data for magnifications to be based off.
- threshold – The magnification threshold required for a time step to be labeled positive.
Returns: The label containing a binary value per time step.
-
calculate_magnifications_for_lightcurve_meta_data(self, times: np.float32, lightcurve_microlensing_meta_data: pd.Series)[source]¶ Calculates the magnification values for a given set of times based on the meta data of a specific lightcurve.
Parameters: - times – The observation times to calculate magnifications for.
- lightcurve_microlensing_meta_data – The microlensing meta data for magnifications to be based off.
Returns: An array of the magnification of each time.
-
remove_file_paths_with_no_meta_data(self, file_paths: List[Path], meta_data_frame: pd.DataFrame)[source]¶ Filters file paths on whether or not the meta data frame contains an entry for them.
Parameters: - file_paths – The file paths to be filtered.
- meta_data_frame – The meta data frame.
Returns: The filtered file paths containing only paths which appear in the meta data frame.
-
generate_datasets(self, positive_data_directory: str = 'positive', negative_data_directory: str = 'negative', meta_data_file_path: str = 'candlist_RADec.dat.feather')[source]¶ Generates the training and validation datasets.
Parameters: - positive_data_directory – The relative path from the data directory to the directory containing the positive example files.
- negative_data_directory – The relative path from the data directory to the directory containing the negative example files.
- meta_data_file_path – The relative path from the data directory to the microlensing meta data file.
Returns: The training and validation datasets.
-
static