Fix error when reference-only data given

This commit is contained in:
linarphy 2024-06-18 17:53:49 +02:00
parent 35ae306712
commit d49ca3e39f
No known key found for this signature in database
GPG key ID: E61920135EFF2295
2 changed files with 31 additions and 21 deletions

View file

@ -21,33 +21,40 @@ def show_projection(
ylabel,
)
excited = experiment.data.excited.sensibility.psd().sqrt()
reference = experiment.data.reference.sensibility.psd().sqrt()
loglog(
experiment.projection_excited.x,
experiment.projection_excited.y,
label=_("projection with excitation"),
) # type: ignore[ReportUnusedCallResult]
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(
excited.x,
excited.y,
label=_("detected sensibility with excitation"),
) # type: ignore[ReportUnusedCallResult]
loglog(
reference.x,
reference.y,
label=_("detected sensibility without 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]
legend() # type: ignore[ReportUnusedCallResult]
title(experiment.bench) #  type: ignore[ReportUnusedCallResult]
xlabel(_("frequency (Hz)")) # type: ignore[ReportUnusedCallResult]

View file

@ -203,7 +203,7 @@ class Experiment:
self.calibrations,
vibration_frequency,
)
except ValueError:
except AttributeError:
pass
logger.debug(_("movement processed"))
@ -255,12 +255,15 @@ class Experiment:
)
self.factors = self.fit_factors()
self.projection_excited = self.compute_projection(
AcquisitionType.EXCITED,
)
self.projection_reference = self.compute_projection(
AcquisitionType.REFERENCE,
)
try:
self.projection_excited = self.compute_projection(
AcquisitionType.EXCITED,
)
except Exception:
pass
logger.debug(_("end of experiment initialisation"))
def get_factors(
@ -294,7 +297,7 @@ class Experiment:
)
raise Exception(
_(
"no excited signal given, cannot get facotrs "
"no excited signal given, cannot get factors "
+ "of the excited signal"
)
)