Skip to content

dm-dt API

light_curve.DmDt

dm-dt map producer

Each pair of observations is mapped to dm-dt plane bringing unity value. dmdt-map is a rectangle on this plane consisted of dt_size x dm_size cells, and limited by [min_dt; max_dt) and [min_dm; max_dm) intervals. .points*() methods assigns unity value of each observation to a single cell, while .gausses*() methods smears this unity value over all cells with given dt value using normal distribution N(m2 - m1, sigma1^2 + sigma2^2), where (t1, m1, sigma1) and (t2, m2, sigma2) are a pair of observations including uncertainties. Optionally, after the map is built, normalisation is performed ("norm" parameter): "dt" means divide each dt = const column by the total number of all observations corresponded to given dt (in this case gausses() output can be interpreted as conditional probability p(dm|dt)); "max" means divide all values by the maximum value; both options can be combined, then "max" is performed after "dt".

Parameters:

Name Type Description Default
dt np.array of float64

Ascending array of dt grid edges

required
dm np.array of float64

Ascending array of dm grid edges

required
dt_type str

Type of dt grid, one of: - 'auto' (default) means check if grid is linear or logarithmic one, which allows some speed-up - 'linear' says to build a linear grid from the first and last values of dt, using the same number of edges - 'log' is the same as 'linear' but for building logarithmic grid - 'asis' means using the given array as a grid

required
dm_type str

Type of dm grid, see dt_type for details

required
norm list of str

Types of normalisation, cab be any combination of "dt" and "max", default is an empty list [] which means no normalisation

required
n_jobs int

Number of parallel threads to run bulk methods such as points_many() or gausses_batches() default is -1 which means to use as many threads as CPU cores

required
approx_erf bool

Use approximation normal CDF in gausses* methods, reduces accuracy, but has better performance, default is False

required

Attributes:

Name Type Description
n_jobs int
shape (int, int)

Shape of a single dmdt map, (dt_size, dm_size)

dt_grid np.array of float64
min_dt float
max_dt float
dm_grid np.array of float64
min_dm float
max_dm float

Methods:

Name Description
from_borders

Construct DmDt with logarithmic dt grid [10^min_lgdt, 10^max_lgdt) and linear dm grid [-max_abs_dm, max_abs_dm), kwargs are passed to __new__()

points

Produces dmdt-maps from light curve

gausses

Produces smeared dmdt-map from noisy light curve

count_dt

Total number of observations per each dt interval

points_many

Produces dmdt-maps from a list of light curves

gausses_many

Produces smeared dmdt-maps from a list of light curves

count_dt_many

Number of observations in each dt for a list of arrays

points_batches

Gives a reusable iterable which yields dmdt-maps

gausses_batches

Gives a reusable iterable which yields smeared dmdt-maps

dm_grid property

dt_grid property

max_dm property

max_dt property

min_dm property

min_dt property

n_jobs property

shape property

count_dt method descriptor

Total number of observations per each dt interval

Output takes into account all observation pairs within [min_dt; max_dt), even if they are not in [min_dm; max_dm)

Parameters:

Name Type Description Default
t 1d-ndarray of float

Time moments, must be sorted

required
sorted bool or None

True guarantees that t is sorted

None
cast bool

If False allow np.ndarray input only, True allows casting. Casting provides more flexibility with input types at the cost of

False
Returns
required

count_dt_many method descriptor

Total number of observations per each dt interval

Output takes into account all observation pairs within [min_dt; max_dt), even if they are not in [min_dm; max_dm)

Parameters:

Name Type Description Default
t_ list of 1d-ndarray of float

List of arrays, each represents time moments, must be sorted

required
sorted bool or None

True guarantees that t is sorted

None
Returns
required

gausses method descriptor

Produces smeared dmdt-map from light curve

Parameters:

Name Type Description Default
t 1d-ndarray of float

Time moments, must be sorted

required
m 1d-ndarray of float

Magnitudes

required
sigma 1d-ndarray of float

Uncertainties

required
sorted bool or None

True guarantees that the light curve is sorted

None
cast bool

If False allow np.ndarray input only, True allows casting. Casting provides more flexibility with input types at the cost of

False

Returns:

Type Description
2d-array of float

gausses_batches method descriptor

Reusable iterable yielding dmdt-maps

The dmdt-maps are produced in parallel using n_jobs threads, batches are being generated in background, so the next batch is started to generate just after the previous one is yielded. Note that light curves data are copied, so from the performance point of view it is better to use gausses_many if you don't need observation dropping

Parameters:

Name Type Description Default
lcs list of (ndarray, ndarray, ndarray)

List or tuple of tuple pairs (t, m, sigma) represented individual light curves. All arrays must have the same dtype

required
sorted bool or None

True guarantees that all light curves is sorted, default is None

None
batch_size int

The number of dmdt-maps to yield. The last batch can be smaller. Default is 1

1
yield_index bool

Yield a tuple of (indexes, maps) instead of just maps. Could be useful when shuffle is True. Default is False

False
shuffle bool

If True, shuffle light curves (not individual observations) on each creating of new iterator. Default is False

False
drop_nobs int or float

Drop observations from every light curve. If it is a positive integer, it is a number of observations to drop. If it is a floating point between 0 and 1, it is a part of observation to drop. Default is 0, which means usage of the original data

0
random_seed int or None

Random seed for shuffling and dropping. Default is None which means random seed

None

gausses_many method descriptor

Produces smeared dmdt-map from a collection of light curves

The method is performed in parallel using n_jobs threads

Parameters:

Name Type Description Default
lcs list of (ndarray, ndarray, ndarray)

List or tuple of tuple pairs (t, m, sigma) represented individual light curves. All arrays must have the same dtype

required
sorted bool or None

True guarantees that all light curves are sorted

None

Returns:

Type Description
3d-ndarray of float

points method descriptor

Produces dmdt-map from light curve

Parameters:

Name Type Description Default
t 1d-ndarray of float

Time moments, must be sorted

required
m 1d-ndarray of float

Magnitudes

required
sorted bool or None

True guarantees that the light curve is sorted

None
cast bool

If False allow np.ndarray input only, True allows casting. Casting provides more flexibility with input types at the cost of

False

Returns:

Type Description
2d-ndarray of float

points_batches method descriptor

Reusable iterable yielding dmdt-maps

The dmdt-maps are produced in parallel using n_jobs threads, batches are being generated in background, so the next batch is started to generate just after the previous one is yielded. Note that light curves data are copied, so from the performance point of view it is better to use points_many if you don't need observation dropping

Parameters:

Name Type Description Default
lcs list of (ndarray, ndarray)

List or tuple of tuple pairs (t, m) represented individual light curves. All arrays must have the same dtype

required
sorted bool or None

True guarantees that all light curves is sorted, default is None

None
batch_size int

The number of dmdt-maps to yield. The last batch can be smaller. Default is 1

1
yield_index bool

Yield a tuple of (indexes, maps) instead of just maps. Could be useful when shuffle is True. Default is False

False
shuffle bool

If True, shuffle light curves (not individual observations) on each creating of new iterator. Default is False

False
drop_nobs int or float

Drop observations from every light curve. If it is a positive integer, it is a number of observations to drop. If it is a floating point between 0 and 1, it is a part of observation to drop. Default is 0, which means usage of the original data

0
random_seed int or None

Random seed for shuffling and dropping. Default is None which means random seed

None

Returns:

Type Description
Iterable of 3d-ndarray or (1d-ndarray, 3d-ndarray)

points_many method descriptor

Produces dmdt-map from a collection of light curves

The method is performed in parallel using n_jobs threads

Parameters:

Name Type Description Default
lcs list of (ndarray, ndarray)

List or tuple of tuple pairs (t, m) represented individual light curves. All arrays must have the same dtype

required
sorted bool or None

True guarantees that all light curves is sorted

None

Returns:

Type Description
3d-ndarray of float