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

View file

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