70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
from backscattering_analyzer import logger
|
||
from backscattering_analyzer.experiment import Experiment
|
||
|
||
|
||
def show_projection(
|
||
experiment: Experiment,
|
||
start_frequency: float | None = None,
|
||
end_frequency: float | None = None,
|
||
) -> None:
|
||
"""
|
||
Show projection data with matplotlib
|
||
"""
|
||
logger.debug(_("showing experiment result"))
|
||
from matplotlib.pyplot import (
|
||
loglog,
|
||
show,
|
||
legend,
|
||
close,
|
||
title,
|
||
xlabel,
|
||
ylabel,
|
||
xlim,
|
||
ylim,
|
||
grid,
|
||
)
|
||
|
||
reference = experiment.data.reference.sensibility.psd().sqrt()
|
||
try:
|
||
excited = experiment.data.excited.sensibility.psd().sqrt()
|
||
loglog(
|
||
experiment.projection_excited.x,
|
||
experiment.projection_excited.y,
|
||
label=_("projection with excitation"),
|
||
) # type: ignore[ReportUnusedCallResult]
|
||
loglog(
|
||
excited.x,
|
||
excited.y,
|
||
label=_("detected sensibility with excitation"),
|
||
) # type: ignore[ReportUnusedCallResult]
|
||
loglog(
|
||
(experiment.projection_excited + reference).x,
|
||
(experiment.projection_excited + reference).y,
|
||
label=_(
|
||
"sum: no excitation and projection with excitation"
|
||
),
|
||
) # type: ignore[ReportUnusedCallResult]
|
||
except AttributeError:
|
||
logger.debug(
|
||
_("no excited signal, will only show reference signal")
|
||
)
|
||
loglog(
|
||
experiment.projection_reference.x,
|
||
experiment.projection_reference.y,
|
||
label=_("projection without excitation"),
|
||
) # type: ignore[ReportUnunsedCallResult]
|
||
loglog(
|
||
reference.x,
|
||
reference.y,
|
||
label=_("detected sensibility without excitation"),
|
||
) # type: ignore[ReportUnusedCallResult]
|
||
legend() # type: ignore[ReportUnusedCallResult]
|
||
title(experiment.bench) # type: ignore[ReportUnusedCallResult]
|
||
xlabel(_("frequencies (Hz)")) # type: ignore[ReportUnusedCallResult]
|
||
ylabel(_("sensibility ($\\frac{1} {\\sqrt {Hz}}$)")) # type: ignore[ReportUnusedCallResult]
|
||
xlim(5, 100) # type: ignore[ReportUnusedCallResult]
|
||
ylim(10e-28, 10e-18) # type: ignore[ReportUnusedCallResult]
|
||
grid(True, "both") # type: ignore[ReportUnusedCallResult]
|
||
show()
|
||
close()
|
||
logger.debug(_("experiment result showed"))
|