JokerSamples#

class thejoker.JokerSamples(samples=None, t_ref=None, n_offsets=None, poly_trend=None, **kwargs)#

Bases: object

Attributes Summary

isscalar

n_offsets

orbits

A generator that successively returns twobody.KeplerOrbit objects for each sample.

par_names

poly_trend

t_ref

Methods Summary

copy()

Return a copy of this instance

from_inference_data(prior, idata, data[, ...])

Create a JokerSamples instance from an arviz object.

get_orbit([index])

Get a twobody.KeplerOrbit object for the samples at the specified index.

get_t0([t_ref])

get_time_with_phase([phase, t_ref])

Use the phase at reference time to convert to a time with given phase.

ln_unmarginalized_likelihood(data)

Compute the log (unmarginalized) likelihood of the data for each sample

mean()

Return a new scalar object by taking the mean across all samples

median_period()

Return a new scalar object by taking the median in period, and returning the values for that sample

pack([units, names, nonlinear_only])

Pack the sample data into a single numpy array (i.e. strip the units and return those separately).

read(filename[, path])

Read the samples data to a file.

std()

Return a new scalar object by taking the standard deviation across all samples

unpack(packed_samples, units, **kwargs)

Unpack the array of packed (prior) samples and return a ~thejoker.JokerSamples instance.

wrap_K()

Change negative K values to positive K values and wrap omega to adjust

write(output[, overwrite, append])

Write the samples data to a file.

Attributes Documentation

isscalar#
n_offsets#
orbits#

A generator that successively returns twobody.KeplerOrbit objects for each sample. See docstring for thejoker.JokerSamples.get_orbit for more information.

par_names#
poly_trend#
t_ref#

Methods Documentation

copy()#

Return a copy of this instance

classmethod from_inference_data(prior, idata, data, prune_divergences=True)#

Create a JokerSamples instance from an arviz object.

Parameters:
  • prior (thejoker.JokerPrior) –

  • idata (arviz.InferenceData) –

  • data (thejoker.RVData) –

  • prune_divergences (bool (optional)) –

get_orbit(index=None, **kwargs)#

Get a twobody.KeplerOrbit object for the samples at the specified index.

Parameters:
  • index (int (optional)) – The index of the samples to turn into a twobody.KeplerOrbit instance. If the samples object is scalar, no index is necessary.

  • **kwargs – Other keyword arguments are passed to the twobody.KeplerOrbit initializer. For example, you can specify the inclination by passing i=...`, or  longitude of the ascending node by passing ``Omega=....

Returns:

orbit – The samples converted to an orbit object. The barycenter position and distance are set to arbitrary values.

Return type:

twobody.KeplerOrbit

get_t0(t_ref=None)#
get_time_with_phase(phase=<Quantity 0. rad>, t_ref=None)#

Use the phase at reference time to convert to a time with given phase.

Parameters:
  • phase (quantity_like [angle] (optional)) – Get the time at which the phase is equal to this value.

  • t_ref (~astropy.time.Time (optional)) – The reference time.

ln_unmarginalized_likelihood(data)#

Compute the log (unmarginalized) likelihood of the data for each sample

mean()#

Return a new scalar object by taking the mean across all samples

median_period()#

Return a new scalar object by taking the median in period, and returning the values for that sample

pack(units=None, names=None, nonlinear_only=True)#

Pack the sample data into a single numpy array (i.e. strip the units and return those separately).

Parameters:
  • units (dict (optional)) – If specified, this controls the units that the samples are converted to before packing into a single array.

  • names (list (optional)) – The order of names to pack into.

  • nonlinear_only (bool (optional)) – Only pack the data for the nonlinear parameters into the returned array.

Returns:

  • packed_samples (numpy.ndarray) – The samples data packed into a single numpy array with no units.

  • units (~collections.OrderedDict) – The units of the packed sample data.

classmethod read(filename, path=None)#

Read the samples data to a file.

Currently, we only support writing to / reading from HDF5 and FITS files, so the filename must end in a .hdf5, .h5, or .fits extension.

Parameters:

filename (str, h5py.File, h5py.Group) – The output filename or HDF5 group.

std()#

Return a new scalar object by taking the standard deviation across all samples

classmethod unpack(packed_samples, units, **kwargs)#

Unpack the array of packed (prior) samples and return a ~thejoker.JokerSamples instance.

Parameters:
  • packed_samples (array_like) –

  • units (~collections.OrderedDict, dict_like) – The units of each column in the packed samples array. The order of columns in this dictionary determines the assumed order of the columns in the packed samples array.

  • **kwargs – Additional keyword arguments are passed through to the initializer, so this supports any arguments accepted by the initializer (e.g., t_ref, n_offsets, poly_trend)

Returns:

samples – The unpacked samples.

Return type:

~thejoker.JokerSamples

wrap_K()#

Change negative K values to positive K values and wrap omega to adjust

write(output, overwrite=False, append=False)#

Write the samples data to a file.

Currently, we only support writing to / reading from HDF5 files, so the filename must end in a .hdf5 or .h5 extension.

Parameters:
  • output (str, h5py.File, h5py.Group) – The output filename or h5py group.

  • overwrite (bool (optional)) – Overwrite the existing file.

  • append (bool (optional)) – Append the samples to an existing table in the specified filename.