JokerSamples

class thejoker.JokerSamples(samples=None, t0=None, n_offsets=None, poly_trend=None, **kwargs)[source]

Bases: object

A dictionary-like object for storing prior or posterior samples from The Joker, with some extra functionality.

Parameters
samplesQTable, table-like (optional)

The samples data as an Astropy table object, or something convertable to an Astropy table (e.g., a dictionary with Quantity object values). This is optional because the samples data can be added later by setting keys on the resulting instance.

poly_trendint (optional)

Specifies the number of coefficients in an additional polynomial velocity trend, meant to capture long-term trends in the data. See the docstring for thejoker.JokerPrior for more details.

t0astropy.time.Time, numeric (optional)

The reference time for the orbital parameters.

**kwargs

Additional keyword arguments are stored internally as metadata.

Attributes Summary

isscalar

n_offsets

orbits

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

par_names

poly_trend

t0

Methods Summary

copy()

Return a copy of this instance

get_orbit([index])

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

mean()

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

median()

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.

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 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
t0

Methods Documentation

copy()[source]

Return a copy of this instance

get_orbit(index=None, **kwargs)[source]

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

Parameters
indexint (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
orbittwobody.KeplerOrbit

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

mean()[source]

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

median()[source]

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)[source]

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

Parameters
unitsdict (optional)

If specified, this controls the units that the samples are converted to before packing into a single array.

nameslist (optional)

The order of names to pack into.

nonlinear_onlybool (optional)

Only pack the data for the nonlinear parameters into the returned array.

Returns
packed_samplesnumpy.ndarray

The samples data packed into a single numpy array with no units.

unitsOrderedDict

The units of the packed sample data.

classmethod read(filename, path=None)[source]

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
filenamestr, h5py.File, h5py.Group

The output filename or HDF5 group.

std()[source]

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

classmethod unpack(packed_samples, units, **kwargs)[source]

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

Parameters
packed_samplesarray_like
unitsOrderedDict, 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., t0, n_offsets, poly_trend)

Returns
samplesJokerSamples

The unpacked samples.

wrap_K()[source]

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

write(output, overwrite=False, append=False)[source]

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
outputstr, h5py.File, h5py.Group

The output filename or h5py group.

overwritebool (optional)

Overwrite the existing file.

appendbool (optional)

Append the samples to an existing table in the specified filename.