nessai.livepoint
Functions related to creating live points and converting to other common data-types.
Module Contents
Functions
|
Get a list of tuples containing the dtypes for the structured array |
|
Converts live points to unstructured arrays for training. |
|
Take a list or array of parameters for a single live point |
|
Convert a numpy array to a numpy structure array with the correct fields |
Convert a dictionary with parameters names as keys to live points. |
|
|
Convert a structured array of live points to a dictionary with |
Convert and pandas dataframe to live points. |
Attributes
- nessai.livepoint.LOGL_DTYPE = f8
- nessai.livepoint.DEFAULT_FLOAT_DTYPE = f8
- nessai.livepoint.get_dtype(names, array_dtype=DEFAULT_FLOAT_DTYPE)
Get a list of tuples containing the dtypes for the structured array
- Parameters
- nameslist of str
Names of parameters
- array_dtypeoptional
dtype to use
- Returns
- list of tuple
Dtypes as tuples with (field, dtype)
- nessai.livepoint.live_points_to_array(live_points, names=None)
Converts live points to unstructured arrays for training.
- Parameters
- live_pointsstructured_array
Structured array of live points
- nameslist of str or None
If None all fields in the structured array are added to the dictionary else only those included in the list are added.
- Returns
- np.ndarray
Unstructured numpy array
- nessai.livepoint.parameters_to_live_point(parameters, names)
Take a list or array of parameters for a single live point and converts them to a live point.
Returns an empty array with the correct fields if len(parameters) is zero
- Parameters
- parameterstuple
Float point values for each parameter
- namestuple
Names for each parameter as strings
- Returns
- structured_array
Numpy structured array with fields given by names plus logP and logL
- nessai.livepoint.numpy_array_to_live_points(array, names)
Convert a numpy array to a numpy structure array with the correct fields
- Parameters
- arraynp.ndarray
Instance of np.ndarray to convert to a structured array
- namestuple
Names for each parameter as strings
- Returns
- structured_array
Numpy structured array with fields given by names plus logP and logL
- nessai.livepoint.dict_to_live_points(d)
Convert a dictionary with parameters names as keys to live points.
Assumes all entries have the same length. Also, determines number of points from the first entry by checking if the value has __len__ attribute, if not the dictionary is assumed to contain a single point.
- Parameters
- ddict
Dictionary with parameters names as keys and values that correspond to one or more parameters
- Returns
- structured_array
Numpy structured array with fields given by names plus logP and logL
- nessai.livepoint.live_points_to_dict(live_points, names=None)
Convert a structured array of live points to a dictionary with a key per field.
- Parameters
- live_pointsstructured_array
Array of live points
- nameslist of str or None
If None all fields in the structured array are added to the dictionary else only those included in the list are added.
- Returns
- dict
Dictionary of live points
- nessai.livepoint.dataframe_to_live_points(df)
Convert and pandas dataframe to live points.
Adds the additional parameters logL and logP initialised to zero.
Based on this answer on Stack Exchange: https://stackoverflow.com/a/51280608
- Parameters
- df
pandas.DataFrame
Pandas DataFrame to convert to live points
- df
- Returns
- structured_array
Numpy structured array with fields given by column names plus logP and logL.