cogwheel.likelihood.marginalization.skydict.SkyDictionary

class cogwheel.likelihood.marginalization.skydict.SkyDictionary(detector_names, *, f_sampling: int = 8192, nsky: int = 1000000, seed=0)

Bases: JSONMixin

Given a network of detectors, this class generates a set of samples covering the sky location isotropically in Earth-fixed coordinates (lat, lon).

The samples are assigned to bins based on the arrival-time delays between detectors. This information is accessible as dictionaries delays2inds_map, delays2genind_map. Antenna coefficients F+, Fx (psi=0) and detector time delays from geocenter are computed and stored for all samples.

Attributes:
detector_namestuple

E.g. ('H', 'L', 'V').

nskyint

Number of sky-location samples.

f_samplingfloat

Inverse of the time bin size at each detector (Hz).

seed

Sets the initial random state.

sky_samplesdict

Contains entries for ‘lat’ and ‘lon’ (rad) of the sky samples.

fplus_fcross_0(nsky, n_det, 2) float array

Antenna coefficients at the sky samples for psi=0.

geocenter_delay_first_det(nsky,) float array

Time delay (s) from geocenter to the first detector (per .detector_names) for each sky sample.

delays(n_det - 1, nsky) float array

Time delay (s) from the first detector (per .detector_names) to the remaining detectors, for each sky sample.

delays2inds_mapdict

Each key is a tuple of (n_det-1) ints, corresponding to discretized delays from the first detector to the remaining detectors. Each value is a list of ints, corresponding to indices of sky-samples that have the correct delay (to the resolution given by f_sampling).

Methods

apply_tdet_prior

Change t_arrival_lnprob inplace to account for the astrophysical prior for time delays.

choose_f_sampling

Return closest frequency to the default f_sampling that still makes it an integer multiple of the sampling frequency corresponding to f_nyquist (Hz).

get_init_dict

Return dictionary with keyword arguments to __init__.

get_module_name

Name of the module that defines the instance's class.

get_sky_inds_and_prior

reinstantiate

Return a new instance of the class, possibly updating init_kwargs.

resample_timeseries

Resample a timeseries to match the SkyDict's sampling frequency.

set_generators

Set attribute self._ind_generators, this method can be called after instantiation to make the method .get_sky_inds_and_prior have reproducible output.

to_json

Write class instance to json file.

Attributes

DEFAULT_F_SAMPLING

subclass_registry

apply_tdet_prior(t_arrival_lnprob)

Change t_arrival_lnprob inplace to account for the astrophysical prior for time delays.

Parameters:
t_arrival_lnprob(n_det, n_times) float array

Incoherent proposal for log probability of arrival times at each detector.

classmethod choose_f_sampling(f_nyquist: int) int

Return closest frequency to the default f_sampling that still makes it an integer multiple of the sampling frequency corresponding to f_nyquist (Hz).

The output of this function can be used as f_sampling parameter in __init__.

get_init_dict(**kwargs)

Return dictionary with keyword arguments to __init__.

Only works if the class stores its init parameters as attributes with the same names. Otherwise, the subclass should override this method.

Parameters:
**kwargs

Allows to manually override some keys. The remaining ones will be read from the instance’s attributes. All keywords must be in the __init__ signature. It’s mostly here to facilitate overriding by subclasses.

get_module_name()

Name of the module that defines the instance’s class.

get_sky_inds_and_prior(delays)
Parameters:
delaysint array of shape (n_det-1, n_samples)

Time-of-arrival delays in units of 1 / self.f_sampling

Returns:
sky_indstuple of ints of length n_physical

Indices of self.sky_samples with the correct time delays.

sky_priorfloat array of length n_physical

Prior probability density for the time-delays (s).

physical_maskboolean array of length n_samples

Some choices of time of arrival at detectors may not correspond to any physical sky location, these are flagged False in this array. Unphysical samples are discarded.

reinstantiate(**new_init_kwargs)

Return a new instance of the class, possibly updating init_kwargs.

Values not passed will be taken from the current instance.

resample_timeseries(timeseries, times, axis=-1)

Resample a timeseries to match the SkyDict’s sampling frequency.

The sampling frequencies of the SkyDict and timeseries must be multiples (or ValueError is raised). The data are smoothed at the edges to make them periodic.

Parameters:
timeseriesarray_like

The data to resample.

timesarray_like

Equally-spaced sample positions associated with the signal data in timeseries.

axisint

The axis of timeseries that is resampled. Default is -1.

Returns:
resampled_timeseries, resampled_times

A tuple containing the resampled array and the corresponding resampled positions.

set_generators()

Set attribute self._ind_generators, this method can be called after instantiation to make the method .get_sky_inds_and_prior have reproducible output.

to_json(dirname, basename=None, *, dir_permissions=493, file_permissions=420, overwrite=False)

Write class instance to json file.

It can then be loaded with read_json.