h0rton.tdlmc_utils
¶
Submodules¶
Package Contents¶
Functions¶
convert_to_dataframe (rung, save_csv_path) |
Store the TDLMC closed and open boxes into a Pandas DataFrame and exports |
parse_closed_box (closed_box_path, row_dict=dict()) |
Parse the lines of an open-box TDLMX text file for Rungs 0, 1, and 2 |
parse_open_box (open_box_path, row_dict=dict()) |
Parse the lines of an open-box TDLMX text file for Rungs 0, 1, and 2 |
read_from_csv (csv_path) |
Read a Pandas Dataframe from the combined csv file of TDLMC data while |
format_results_for_tdlmc_metrics (version_dir, out_dir, rung_id=2) |
Format the BNN inference results so they can be read into the script that |
reorder_to_tdlmc (abcd_ordering_i, ra_img, dec_img, time_delays) |
Reorder the list of ra, dec, and time delays to conform to the |
get_goodness (h0_means, h0_errors, true_h0) |
Get the goodness of fit (chi square) |
get_precision (h0_errors, true_h0) |
Get the precision, i.e. how well-constrained were the estimates on average? |
get_accuracy (h0_means, true_h0) |
Get the accuracy, i.e. how close were the central estimates to the truth? |
format_submission (summary) |
Format the summary into submission form for getting the TDLMC metrics cornerplot |
-
h0rton.tdlmc_utils.
convert_to_dataframe
(rung, save_csv_path)[source]¶ Store the TDLMC closed and open boxes into a Pandas DataFrame and exports to a csv file at the same location
- rung : int
- rung number
- save_csv_path : str
- path of the csv file to be generated
- Pandas DataFrame
- the extracted rung data
-
h0rton.tdlmc_utils.
parse_closed_box
(closed_box_path, row_dict=dict())[source]¶ Parse the lines of an open-box TDLMX text file for Rungs 0, 1, and 2
- closed_box_path : str
- path to the closed box text file, lens_info_for_Good_team.txt.txt
- row_dict : dict
- dictionary of the row info to update. Default: dict()
- dict
- An updated dictionary containing the information in the closed box text file
-
h0rton.tdlmc_utils.
parse_open_box
(open_box_path, row_dict=dict())[source]¶ Parse the lines of an open-box TDLMX text file for Rungs 0, 1, and 2
- open_box_path : str
- path to the open box text file, lens_all_info.txt
- row_dict : dict
- dictionary of the row info to update. Default: dict()
- dict
- An updated dictionary containing the information in the open box text file
-
h0rton.tdlmc_utils.
read_from_csv
(csv_path)[source]¶ Read a Pandas Dataframe from the combined csv file of TDLMC data while evaluating all the relevant strings in each column as Python objects
- csv_path : str
- path to the csv file generated using convert_to_dataframe
- Pandas DataFrame
- the TDLMC data with correct Python objects
-
h0rton.tdlmc_utils.
format_results_for_tdlmc_metrics
(version_dir, out_dir, rung_id=2)[source]¶ Format the BNN inference results so they can be read into the script that generates the TDLMC metrics cornerplot
- version_dir : str or os.path object
- path to the folder containing inference results
- rung_id : int
- TDLMC rung ID
-
h0rton.tdlmc_utils.
reorder_to_tdlmc
(abcd_ordering_i, ra_img, dec_img, time_delays)[source]¶ Reorder the list of ra, dec, and time delays to conform to the order in the TDLMC challenge
- abcd_ordering_i : array-like
- ABCD in an increasing dec order if the keys ABCD mapped to values 0123, respectively, e.g. [3, 1, 0, 2] if D (value 3) is lowest, B (value 1) is second lowest
- ra_img : array-like
- list of ra from lenstronomy
- dec_img : array-like
- list of dec from lenstronomy, in the order specified by ra_img
- time_delays : array-like
- list of time delays from lenstronomy, in the order specified by ra_img
- tuple
- tuple of (reordered ra, reordered_dec, reordered time delays)
-
h0rton.tdlmc_utils.
get_goodness
(h0_means, h0_errors, true_h0)[source]¶ Get the goodness of fit (chi square)
- h0_means : np.array
- central estimate of H0 for each lens
- h0_errors : np.array
- errors corresponding to the h0_means
- true_h0 : np.array or float
- the true H0
- float
- the goodness of fit metric
-
h0rton.tdlmc_utils.
get_precision
(h0_errors, true_h0)[source]¶ Get the precision, i.e. how well-constrained were the estimates on average?
- h0_errors : np.array
- errors corresponding to the h0_means
- true_h0 : np.array or float
- the true H0
- float
- the precision metric