Skip to content

hertzforge.core.rescale

rescale

Rescaling a time history: some or all of its channels times a factor.

The usual reason is a channel recorded with the wrong sensitivity. The acquisition divides volts by the sensitivity it was given, so a record taken with recorded mV per unit where the sensor is correct mV per unit is off by recorded / correct (sensitivity_factor). A gain entered on the wrong channel, or a sign, is the same operation with the factor typed directly.

The result keeps the record's clock, its channels and what is set on it (the averaging and shock windows, the filter and truncation settings, the sine extraction and the channel roles), so everything read or computed from the record reads the same way from the rescaled one.

Functions:

Name Description
sensitivity_factor

The factor that corrects data recorded with sensitivity recorded

chosen_records

The records a rescale applies to, sorted: all of them for None.

rescaled

The time history with records (all of them for None) multiplied

Functions:

sensitivity_factor

sensitivity_factor(recorded: float, correct: float) -> float

The factor that corrects data recorded with sensitivity recorded to what sensitivity correct gives, both in the same units (mV per engineering unit, say).

Engineering units are volts over the sensitivity, so the factor is recorded / correct: data taken with 100 mV/g on a 10 mV/g sensor reads a tenth of the true level and is multiplied by 10.

Parameters:

Name Type Description Default
recorded float

The sensitivity the data was recorded with and the sensor's correct one.

required
correct float

The sensitivity the data was recorded with and the sensor's correct one.

required

Returns:

Type Description
float

recorded / correct.

Raises:

Type Description
ValueError

When either sensitivity is not a finite number above zero.

chosen_records

chosen_records(data: Any, records: Sequence[int] | None) -> list[int]

The records a rescale applies to, sorted: all of them for None.

Parameters:

Name Type Description Default
data TimeHistory

The record.

required
records sequence of int or None

Which records, counting from zero.

required

Returns:

Type Description
list of int

The records, sorted, each once.

Raises:

Type Description
ValueError

For an empty list or a record the history does not have.

rescaled

rescaled(data: Any, factor: float, records: Sequence[int] | None = None) -> Any

The time history with records (all of them for None) multiplied by factor, the rest unchanged.

Parameters:

Name Type Description Default
data TimeHistory

The record.

required
factor float

Finite and not zero; negative flips the sign.

required
records sequence of int

Which records, counting from zero.

None

Returns:

Type Description
TimeHistory

The rescaled record, with the source's clock, channels and settings.

Raises:

Type Description
ValueError

When the factor is zero or not finite, or a record is not in the history.