Module: result_list#

class kbmod.result_list.ResultList(all_times, track_filtered=False)[source]#

This class stores a collection of related data from all of the kbmod results.

Methods

append_result(res)

Add a single ResultRow to the result set.

append_result_dict(res_dict)

Append all the results in a dictionary (as defined by gen_results_dict) to the current result list.

apply_filter(filter_obj[, num_threads])

Apply the given filter object to the ResultList.

clear()

Clear the list of results.

extend(result_list)

Append the results in a second ResultSet to the current one.

filter_results(indices_to_keep[, label])

Filter the rows in the ResultList to only include those indices in the list indices_to_keep.

get_filtered([label])

Get the results filtered at a given stage or all stages.

num_results()

Return the number of results in the list.

save_to_files(res_filepath, out_suffix)

This function saves results from a search method to a series of files.

to_result_dict()

Transform the ResultsSet into a dictionary as defined by gen_results_dict.

zip_phi_psi_idx()

Create and return a list of tuples for each psi/phi curve.

append_result(res)[source]#

Add a single ResultRow to the result set.

Parameters:
resResultRow

The new result to add.

append_result_dict(res_dict)[source]#

Append all the results in a dictionary (as defined by gen_results_dict) to the current result list. Used for backwards compatibility.

Parameters:
res_dictdict

A dictionary of results as defined by gen_results_dict.

apply_filter(filter_obj, num_threads=1)[source]#

Apply the given filter object to the ResultList.

Modifies the ResultList in place.

Parameters:
filter_objFilter

The filtering object to use.

Returns:
selfResultList

Returns a reference to itself to allow chaining.

clear()[source]#

Clear the list of results.

extend(result_list)[source]#

Append the results in a second ResultSet to the current one.

Parameters:
result_listResultList

The data structure containing additional ResultRow elements to add.

filter_results(indices_to_keep, label=None)[source]#

Filter the rows in the ResultList to only include those indices in the list indices_to_keep.

Parameters:
indices_to_keeplist

The indices of the rows to keep.

labelstring

The label of the filtering stage to use. Only used if we keep filtered trajectories.

Returns:
selfResultList

Returns a reference to itself to allow chaining.

get_filtered(label=None)[source]#

Get the results filtered at a given stage or all stages.

Parameters:
labelstr

The filtering stage to use. If no label is provided, return all filtered rows.

Returns:
resultslist

A list of all filtered rows.

num_results()[source]#

Return the number of results in the list.

Returns:
int

The number of results in the list.

save_to_files(res_filepath, out_suffix)[source]#

This function saves results from a search method to a series of files.

Parameters:
res_filepathstring

The directory in which to store the results.

out_suffixstring

The suffix to append to the output file name

to_result_dict()[source]#

Transform the ResultsSet into a dictionary as defined by gen_results_dict. Used for backwards compatibility.

Returns:
keepdict

A results dictionary as generated by SharedTools.gen_results_dict.

zip_phi_psi_idx()[source]#

Create and return a list of tuples for each psi/phi curve.

Returns:
iterable

A list of tuples with (psi_curve, phi_curve, index) for each result in the ResultList.

class kbmod.result_list.ResultRow(trj, num_times)[source]#

This class stores a collection of related data from a single kbmod result.

Attributes:
all_stamps
final_likelihood
light_curve

Compute the light curve from the psi and phi curves.

likelihood_curve

Compute the likelihood curve for each point (based on psi and phi).

num_times
phi_curve
psi_curve
stamp
trajectory
valid_indices

Methods

filter_indices(indices_to_keep)

Remove invalid indices and times from the ResultRow.

set_psi_phi(psi, phi)

Set the psi and phi curves and auto calculate the light curve.

valid_indices_as_booleans()

Get a Boolean vector indicating which indices are valid.

valid_times(all_times)

Get the times for the indices marked as valid.

filter_indices(indices_to_keep)[source]#

Remove invalid indices and times from the ResultRow. This uses relative filtering where valid_indices[i] is kept for all i in indices_to_keep. Updates the trajectory’s likelihood using only the new valid indices.

Parameters:
indices_to_keeplist

A list of which of the current indices to keep.

Raises:
ValueError: If any of the given indices are out of bounds.
property light_curve#

Compute the light curve from the psi and phi curves.

Returns:
lclist

The likelihood curve. This is an empty list if either psi or phi are not set.

property likelihood_curve#

Compute the likelihood curve for each point (based on psi and phi).

Returns:
lhlist

The likelihood curve. This is an empty list if either psi or phi are not set.

set_psi_phi(psi, phi)[source]#

Set the psi and phi curves and auto calculate the light curve.

Parameters:
psilist

The psi curve.

philist

The phi curve.

Raises:
ValueError

If the phi and psi lists are not the same length as the number of times.

valid_indices_as_booleans()[source]#

Get a Boolean vector indicating which indices are valid.

Returns:
resultlist

A list of bool indicating which indices appear in valid_indices

valid_times(all_times)[source]#

Get the times for the indices marked as valid.

Parameters:
all_timeslist

A list of all time stamps.

Returns:
list

The times for the valid indices.

class kbmod.result_list.SharedTools[source]#

This class manages tools that are shared by the classes Interface and PostProcess.

Notes

Legacy approach. Soon to be deprecated.

Methods

gen_results_dict()

Return an empty results dictionary.

gen_results_dict()[source]#

Return an empty results dictionary. All values needed for a results dictionary should be added here. This dictionary gets passed into and out of most Interface and PostProcess methods, getting altered and/or replaced by filtering along the way.

Returns:
keepdict

The result dictionary.

kbmod.result_list.load_result_list_from_files(res_filepath, suffix, all_mjd=None)[source]#

Create a new ResultList from outputted files.

Parameters:
res_filepathstring

The directory in which the results are stored.

suffixstring

The suffix appended to the output file names.

all_mjdlist

A list of all the MJD timestamps (optional). If not provided, the function loads from the all_times file.

Returns:
resultsResultList

The results stored in the given directory with the correct suffix.