Module for downsampling accross a path in multi-dimensional space.

Let a d-dimensional parametric curve in of the form:

x_1 = x_1(t) x_2 = x_2(t) … x_d = x_d(t)

sampled at N time steps, t_1, t_2, …, t_N. It is possible to select a subset of the time steps - essentially defining a downsampled version of the curve - so that the original curve can be reconstructed with minimum error.

The provided class TrackDownsampler performs the downsampling. It requires two input arrays. The first is the “independent” variable, t, which does not have to be temporal (e.g., spatial), but must be strictly increasing. The 2nd array is the track, in which the different columns correspond to the different dimensions:

— parameters —>

x_1(t_1) x_2(t_1) … x_d(t_1)
time x_1(t_2) x_2(t_2) … x_d(t_2)

or . . … . any . . … .

. . … .

V x_1(t_N) x_2(t_N) … x_d(t_N)

TD = TrackDownsample(t, X) t_new, X_new = TD.downsample(max_err=0.001)

class posydon.grids.downsampling.TrackDownsampler(independent, dependent, verbose=False)[source]

Bases: object

Class performing downsampling of multi-dimensional paths.

Get, reduce and rescale data.

downsample(max_err=None, scale_back=True, max_interval=None)[source]

Perform the downsampling and return the result.

extract_downsample(scale_back=True)[source]

Extract the downsampled array.

find_downsample(max_err=None, max_interval=None)[source]

Find the rows of the data that constitute the “down-sample”.

Note: if max_interval is negative, it’s value is the relative ratio

between maximum allowed dm and total star mass.

rescale()[source]

Rescale the parameter space from 0 to 1.

say(message)[source]

Speak to the standard output, only if .verbose is False.

posydon.grids.downsampling.rescale_from_0_to_1(array, return_minmax=False)[source]

Rescale a matrix so that all dimensions span from 0 to 1.