chronpy.psd#

class Lightcurve(t: NDArray, counts: NDArray, tbins: NDArray = None, exposure: NDArray = None)[source]#

Bases: object

Attributes

counts

dt

evenly_sampled

exposure

rate

t

tbins

property t: ndarray#
property counts: ndarray#
property rate: ndarray#
property tbins: ndarray | None#
property exposure: ndarray#
property dt: float | None#
property evenly_sampled: bool#
class PSD(freq_bins: ndarray, power: ndarray, dof: ndarray, dt: float, df: float)[source]#

Bases: object

Attributes

bins_width

density

derr

df

dof

dt

freq

freq_bins

perr

power

Methods

from_lc

abstract classmethod from_lc(lc: Lightcurve | list[Lightcurve], norm: str = 'leahy')[source]#
property freq: ndarray#
property power: ndarray#
abstract property perr: ndarray#
property density: ndarray#
property derr: ndarray#
property freq_bins: ndarray#
property bins_width: ndarray#
property df: float#
property dt: float#
property dof: ndarray#
class Periodogram(freq_bins: ndarray, power: ndarray, dof: ndarray, dt: float, df: float)[source]#

Bases: PSD

Attributes

bins_width

density

derr

df

dof

dt

freq

freq_bins

perr

power

Methods

from_lc

rebin_log

rebin_significance

classmethod from_lc(lc: Lightcurve | list[Lightcurve], norm: str = 'leahy')[source]#
rebin_log(f: float = 0.01) PSD[source]#
rebin_significance(s: float = 3.0) PSD[source]#
property perr: ndarray#
class PowerDist(dof, s)[source]#

Bases: Gamma

The probability density function of the power spectrum.

We know that if X ~ Chi_v^2, then cX ~ Gamma(alpha=v/2, scale=c/2).

For the power spectrum, we know that vI/S ~ Chi_v^2, where I is the observed power, v is the dof of I, and S is the true power. Then the underlying distribution of I is Gamma(alpha=v/2, scale=2S/v).

If I is obtained by summing over the power of m adjacent frequency bins, I = sum_{m} I_m, then there is no analytical expression for the distribution of I, since the Gamma dist’s scale of each I_m is different. If we assume that the expected powers of I_m are the same, then the distribution of I is Gamma(alpha=sum_{m} v_m/2, scale=2S/(sum_{m} v_m)). However, this is usually not the case for the observed powers of I_m, and this assumption may underestimate the variance of I, thus leading to a deviance that is systematically larger than the fit dof, i.e., number of data points minus number of parameters.

Averaging the powers of l different power spectrum is valid, and the distribution of the average power I_j is Gamma(alpha=l*v_j/2, scale=2S/(l*v_j)).

Attributes

batch_shape

Returns the shape over which the distribution parameters are batched.

event_dim

event_shape

Returns the shape of a single sample from the distribution without batching.

mean

Mean of the distribution.

variance

Variance of the distribution.

has_rsample

is_discrete

Methods

__call__(*args, **kwargs)

Call self as a function.

cdf(x)

The cumulative distribution function of this distribution.

entropy()

Returns the entropy of the distribution.

enumerate_support([expand])

Returns an array with shape len(support) x batch_shape containing all values in the support.

expand(batch_shape)

Returns a new ExpandedDistribution instance with batch dimensions expanded to batch_shape.

expand_by(sample_shape)

Expands a distribution by adding sample_shape to the left side of its batch_shape.

get_args()

Get arguments of the distribution.

icdf(q)

The inverse cumulative distribution function of this distribution.

infer_shapes(*args, **kwargs)

Infers batch_shape and event_shape given shapes of args to __init__().

mask(mask)

Masks a distribution by a boolean or boolean-valued array that is broadcastable to the distributions Distribution.batch_shape .

sample(key[, sample_shape])

Returns a sample from the distribution having shape given by sample_shape + batch_shape + event_shape.

sample_with_intermediates(key[, sample_shape])

Same as sample except that any intermediate computations are returned (useful for TransformedDistribution).

shape([sample_shape])

The tensor shape of samples from this distribution.

to_event([reinterpreted_batch_ndims])

Interpret the rightmost reinterpreted_batch_ndims batch dimensions as dependent event dimensions.

validate_args([strict])

Validate the arguments of the distribution.

gather_pytree_aux_fields

gather_pytree_data_fields

log_prob

rsample

set_default_validate_args

support

tree_flatten

tree_unflatten

log_prob(*args, **kwargs)#

Evaluates the log probability density for a batch of samples given by value.

Parameters:

value – A batch of samples from the distribution.

Returns:

an array with shape value.shape[:-self.event_shape]

Return type:

numpy.ndarray

class Fit(psd: PSD, model: Model)[source]#

Bases: object

Attributes

loss

ndata

nparam

numpyro_model

params_names

transform

Methods

batch_fit

mle

mle_lm

run_nuts

simulate

property ndata#
property nparam#
property numpyro_model#
run_nuts(num_warmup=2000, num_samples=2000, num_chains=4, init=None, chain_method='parallel', progress=True, seed=42)[source]#
property loss#
property params_names#
property transform#
mle_lm(init=None)[source]#
mle(init=None)[source]#
simulate(params, n=1, seed=42)[source]#
batch_fit(data, init=None, parallel: bool = True, n_parallel: int | None = None, progress: bool = True, update_rate: int = 50, run_str: str = 'Fitting', seed=42)[source]#
init_bacth_fit(fit)[source]#