:py:mod:`nessai.livepoint` ========================== .. py:module:: nessai.livepoint .. autoapi-nested-parse:: Functions related to creating live points and converting to other common data-types. .. !! processed by numpydoc !! Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: nessai.livepoint.get_dtype nessai.livepoint.live_points_to_array nessai.livepoint.parameters_to_live_point nessai.livepoint.numpy_array_to_live_points nessai.livepoint.dict_to_live_points nessai.livepoint.live_points_to_dict nessai.livepoint.dataframe_to_live_points Attributes ~~~~~~~~~~ .. autoapisummary:: nessai.livepoint.LOGL_DTYPE nessai.livepoint.DEFAULT_FLOAT_DTYPE .. py:data:: LOGL_DTYPE :annotation: = f8 .. !! processed by numpydoc !! .. py:data:: DEFAULT_FLOAT_DTYPE :annotation: = f8 .. !! processed by numpydoc !! .. py:function:: get_dtype(names, array_dtype=DEFAULT_FLOAT_DTYPE) Get a list of tuples containing the dtypes for the structured array :Parameters: **names** : list of str Names of parameters **array_dtype** : optional dtype to use :Returns: list of tuple Dtypes as tuples with (field, dtype) .. !! processed by numpydoc !! .. py:function:: live_points_to_array(live_points, names=None) Converts live points to unstructured arrays for training. :Parameters: **live_points** : structured_array Structured array of live points **names** : list 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 .. !! processed by numpydoc !! .. py:function:: 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: **parameters** : tuple Float point values for each parameter **names** : tuple Names for each parameter as strings :Returns: structured_array Numpy structured array with fields given by names plus logP and logL .. !! processed by numpydoc !! .. py:function:: numpy_array_to_live_points(array, names) Convert a numpy array to a numpy structure array with the correct fields :Parameters: **array** : np.ndarray Instance of np.ndarray to convert to a structured array **names** : tuple Names for each parameter as strings :Returns: structured_array Numpy structured array with fields given by names plus logP and logL .. !! processed by numpydoc !! .. py:function:: 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: **d** : dict 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 .. !! processed by numpydoc !! .. py:function:: 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_points** : structured_array Array of live points **names** : list 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 .. !! processed by numpydoc !! .. py:function:: 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** : :obj:`pandas.DataFrame` Pandas DataFrame to convert to live points :Returns: structured_array Numpy structured array with fields given by column names plus logP and logL. .. !! processed by numpydoc !!