Skip to content

Instantly share code, notes, and snippets.

@fredvol
Created December 23, 2025 11:09
Show Gist options
  • Select an option

  • Save fredvol/913cdd58892e7c310df68aa6cfbd3570 to your computer and use it in GitHub Desktop.

Select an option

Save fredvol/913cdd58892e7c310df68aa6cfbd3570 to your computer and use it in GitHub Desktop.
Toolbox for sic computation
def g_from_sic(sic_value: float, window_ms: float = 15.0) -> float:
"""
Compute the constant acceleration level (in g) that would produce
a given SIC value over a fully filled window of length window_ms.
Assumes:
SIC = a^2 * Δt (full overlap case)
Parameters
----------
sic_value : float
SIC value (units: g^2 * s).
window_ms : float, optional
SIC time window in milliseconds (default 15 ms).
Returns
-------
float
Constant acceleration level in g.
"""
if window_ms <= 0:
raise ValueError("window_ms must be positive.")
if sic_value <= 0:
return 0.0
dt = window_ms / 1000.0 # convert ms to s
return math.sqrt(sic_value / dt)
g_from_sic(10)
#%%
def triangle_from_sic(
sic_value: float,
sic_window_calculation_ms: float = 15.0,
pulse_duration_ms: float | None = None,
):
"""
Symmetric triangular model:
SIC = a_max^2 * T^2 / (4 * W), with T <= W
"""
if sic_window_calculation_ms <= 0:
raise ValueError("sic_window_calculation_ms must be positive.")
if sic_value <= 0:
return 0.0, 0.0
W = sic_window_calculation_ms / 1000.0 # s
if pulse_duration_ms is None:
T = W
a_max_g = 2.0 * math.sqrt(sic_value / W)
return a_max_g, sic_window_calculation_ms
if pulse_duration_ms <= 0:
raise ValueError("pulse_duration_ms must be positive.")
T = pulse_duration_ms / 1000.0 # s
if T > W:
raise ValueError(
"pulse_duration_ms must be <= sic_window_calculation_ms for this triangular model."
)
a_max_g = 2.0 * math.sqrt(sic_value * W) / T
return a_max_g, pulse_duration_ms
triangle_from_sic(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment