hertzforge.core.impact_windows¶
impact_windows
¶
The windows of an impact test's captured frames: the force window on the references and the exponential window on every channel.
Both are applied to a frame taken around a trigger, and only there: a
modal test's measurement estimated again (core.modal_test.reprocess).
They are not windows for averaged spectra of a continuous record, which
is why core.averaging.WINDOWS does not hold them.
The force window holds one over the leading part of the frame, the
pre-trigger and the pulse after the trigger (a width given as a fraction
of the block, counted from the trigger), then falls by a steep
half-cosine to zero and stays zero for the rest of the frame
(force_window). It keeps the force pulse and takes away what the force
channel holds after it (noise, and the ringing of the hammer's own
structure), which would otherwise be read as force over the whole frame.
It cures nothing about a second hit inside the frame: a double hit is a
second force the structure felt, and cutting it from the force channel
leaves it in every response.
The exponential window w(t) = exp(-t / tau), t = n / fs from the
frame's first sample, on the force and every response alike, makes a
response that has not died out by the end of the frame die out inside it
(exponential_window). Its tau is set from the value it reaches at the
frame's end, T = N / fs (exponential_tau).
It does that by adding damping: each mode's decay rate becomes its own
plus 1 / tau, so the damping ratio a fit reads is high by about
1 / (tau omega_n) (core.modal_test.window_damping).
tests/data/modal_test_windows.json holds both windows' samples, so
every implementation of them is checked against the same numbers.
References
- Fladung, W. A. (1997). "Windows Used for Impact Testing." Proceedings of IMAC XV. The force window (unity over the leading part of the record, a steep cosine taper to zero, zero for the remainder), and the exponential window applied to both the force and the response.
- Trethewey, M. W., & Cafeo, J. A. (1992). "Tutorial: Signal Processing Aspects of Structural Impact Testing." International Journal of Analytical and Experimental Modal Analysis 7(2), 129-149. The exponential window w(t) = exp(-t / tau) (equation 22).
Functions:
| Name | Description |
|---|---|
nearest_sample |
|
force_fall |
The fall a force window of |
force_width |
The force window's width in samples, counted after the trigger, from |
force_window |
The force window of a frame triggered at sample |
exponential_tau |
The time constant, in samples, of an exponential window whose value |
exponential_window |
The exponential window |
Functions:¶
nearest_sample
¶
value samples rounded to the nearest whole sample, a half rounded
up, never below zero: the one rounding these windows use, the same in
every language (Python's own round rounds a half to even).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Samples, finite. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|
force_fall
¶
The fall a force window of width samples takes when none is
given: FORCE_FALL of its width, at least one sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The pulse allowance after the trigger, samples. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|
force_width
¶
The force window's width in samples, counted after the trigger, from
the fraction of the block it is given as: nearest_sample(fraction *
block), as the control service resolves it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Above zero. |
required |
block
|
int
|
The frame's samples. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Samples, at least one. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a fraction that is not a finite number above zero, or one that rounds to no sample. |
force_window
¶
The force window of a frame triggered at sample pre: one over the
pre-trigger and width samples after the trigger, a half-cosine fall
over fall samples, zero after.
For sample n of a frame of block samples, with E = pre + width:
w[n] = 1 for n < E
w[n] = (1 + cos(pi (n - E) / F)) / 2 for E <= n < E + F
w[n] = 0 for n >= E + F
so the fall starts at one on sample E and would reach zero on sample E + F, the first zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
int
|
The frame's samples. |
required |
pre
|
int
|
The trigger's sample in the frame, the pre-trigger's length, zero or more. |
required |
width
|
int
|
The pulse allowance after the trigger, samples, above zero. |
required |
fall
|
int
|
The samples of the fall; |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
One value per sample. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a width that is not a whole number of samples above zero, a pre-trigger or fall below zero, or a window that runs past the block (it is refused, not cut short). |
exponential_tau
¶
The time constant, in samples, of an exponential window whose value
is end at the end of a frame of length samples, T = length / fs
(one sample past its last): length / -ln(end), infinite for an end
of one (no decay).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
end
|
float
|
The window's value at the frame's end, above 0 and at most 1. |
required |
length
|
int
|
The frame's samples. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Samples. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For an end outside (0, 1]. |
exponential_window
¶
The exponential window w[n] = exp(-n / tau), n from the frame's
first sample, tau in samples (a time constant tau_s seconds at a
rate fs is tau_s * fs samples).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
int
|
The frame's samples, at least one. |
required |
tau
|
float
|
The time constant, samples, above zero; infinite is no decay. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
One value per sample. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For a length under one or a time constant not above zero. |