Maelstrom¶
-
class
maelstrom.maelstrom.
Maelstrom
(time, flux, freq=None, name='', model=None, **kwargs)[source]¶ Bases:
maelstrom.maelstrom.BaseOrbitModel
The real deal. This class provides an orbit model for an arbitrarily sized binary system, where each frequency freq is assigned a separate lighttime (asini). The time delays are forward-modelled directly onto the light curve time and flux data.
- Parameters
time (array) – Time values of the light curve
flux (array) – Flux values of the light curve
freq (array, optional) – Frequencies on which to model the time
If none are supplied, Maelstrom will attempt to find the (delay.) –
optimal frequencies. Defaults to None. (most) –
name (str, optional) – Model name. Defaults to ‘’.
-
pin_orbit_model
(opt=None)[source]¶ Pins the orbit model to attribute the frequencies to the correct stars. In doing so, the lighttimes are collapsed into a single value for each star.
- Parameters
opt (dict) – Results of the optimize function for the model. If none is supplied, Maelstrom will optimize first.
- Returns
- Return type
PB2Model or PB1Model, both instances of a PyMC3.model.Model
-
setup_orbit_model
(period=None, eccen=None)[source]¶ Generates an unpinned orbit model for the system. Each frequency in the model will be assigned a lighttime (asini). Optimizing this model will reveal which frequencies, if any, are associated with which stars. In general, this model should not be sampled.
- Parameters
period (float) – Initial period of the orbital system. If none is supplied (default), Maelstrom will attempt to find a suitable period by directly examining the time delays.
eccen (float) – Initial eccentricity of the system, defaults to 0.5 if None supplied.
-
class
maelstrom.maelstrom.
BaseOrbitModel
(time, flux, freq=None, name='', model=None, **kwargs)[source]¶ Bases:
pymc3.model.Model
-
first_look
(segment_size=None, save_path=None, **kwargs)[source]¶ Shows the light curve, its amplitude spectrum, the time delay signal, and the periodogram of the time delay signal in one convenient function. This is useful if you want to check whether a star may be a PM binary. However, sometimes only the strongest peak in the star will show a TD signal.
- Args: segment_size (float, optional): Segment size in which to
subdivide the light curve, in units of time. Defaults to None. save_path (str, optional): If you want to save the output of the axis, pass a save path. Defaults to None.
Returns: array: Array of matplotlib axes.
-
get_period_estimate
(**kwargs)[source]¶ Estimates the period from the segmented time delay
- Returns
period – Estimate of the period from extracted time delays.
- Return type
float
-
get_time_delay
(segment_size=None)[source]¶ Calculates the time delay signal, splitting the light curve into chunks of width segment_size. A smaller segment size will increase the scatter of the time delay signal, especially for low frequencies.
- Parameters
segment_size (float) – Segment size in which to separate the light curve, in units of the light curve time. For example, the default segment size of 10 will separate a 1000 d long light curve in 100 segments of 10 d each.
- Returns
time_midpoint (numpy.ndarray) – Midpoints of time for each segment in the light curve
time_delay (numpy.ndarray) – Values of the extracted time delay in each segment.
-
get_weights
(norm=True)[source]¶ Calculates the amplitudes of each frequency, returning an array of amplitudes. This is useful for calculating the weighted average time delay.
- Returns
(potentially) normalised amplitudes of each frequency
- Return type
weights
-
period_search
(periods=None)[source]¶ Optimizes a model over a grid of periods
- Parameters
periods (Array-like, optional) – Grid of periods over which to optimize, by default None
-
plot_periodogram
(ax=None)[source]¶ Plots the periodogram of the light curve with the model frequencies overlaid.
- Parameters
ax (matplotlib axis, optional) – do you want an axis or not, by default None
- Returns
this is also an axis.
- Return type
ax
-
plot_time_delay
(ax=None, show_weighted=True, **kwargs)[source]¶ Plots the time delay. **kwargs go into get_time_delay.
-
plot_time_delay_periodogram
(ax=None, **kwargs)[source]¶ Plots the time delay periodogram (i.e. the amplitude spectrum of the time delay signal)
- Parameters
ax (matplotlib axis, optional) – Axis on which to plot. If None is
a new one will be generated. Defaults to None. (supplied,) –
- Returns
Axis on which the periodogram is plotted.
- Return type
matplotlib axis
-
plot_time_delay_periodogram_period
(min_period=None, max_period=None, ax=None, annotate=True, return_res=False, **kwargs)[source]¶ Plots the time delay periodogram
-
profile
()[source]¶ Profiles the current model, returning the runtime of each node in your Theano graph
- Returns
[description]
- Return type
[type]
-
sample
(tune=3000, draws=3000, start=None, target_accept=0.9, **kwargs)[source]¶ Samples the model using the exoplanet PyMC3 sampler. By default, this will sample from 2 chains over 2 cores simultaneously.
- Parameters
tune (float, optional) – Number of tuning steps for the sampler (default 3000)
draws (float, optional) – Number of samples from which to populate the trace (default 3000)
start (dict, optional) – Starting location of the sampler. If none is supplied, the sampler will first optimize the model.
target_accept (float, optional) – The target acceptance ratio of the NUTS sampler (default 0.9).
**kwargs – Keyword arguments to pass to sample.tune and sample.sample
- Returns
trace
- Return type
pm trace object?
-