Small changes
This commit is contained in:
parent
1e4dc0975b
commit
0db64c03ab
3 changed files with 79 additions and 30 deletions
|
@ -16,7 +16,16 @@ def show_projection(
|
||||||
Show projection data with matplotlib
|
Show projection data with matplotlib
|
||||||
"""
|
"""
|
||||||
logger.debug(_("showing experiment result"))
|
logger.debug(_("showing experiment result"))
|
||||||
from matplotlib.pyplot import loglog, show, legend, close, vlines
|
from matplotlib.pyplot import (
|
||||||
|
loglog,
|
||||||
|
show,
|
||||||
|
legend,
|
||||||
|
close,
|
||||||
|
vlines,
|
||||||
|
title,
|
||||||
|
xlabel,
|
||||||
|
ylabel,
|
||||||
|
)
|
||||||
|
|
||||||
excited = experiment.signals["excited"].psd().sqrt()
|
excited = experiment.signals["excited"].psd().sqrt()
|
||||||
reference = experiment.signals["reference"].psd().sqrt()
|
reference = experiment.signals["reference"].psd().sqrt()
|
||||||
|
@ -25,13 +34,14 @@ def show_projection(
|
||||||
experiment.projection.y,
|
experiment.projection.y,
|
||||||
label="projection",
|
label="projection",
|
||||||
) # type: ignore[ReportUnusedCallResult]
|
) # type: ignore[ReportUnusedCallResult]
|
||||||
loglog(excited.x, excited.y, label="excited bench") # type: ignore[ReportUnusedCallResult]
|
loglog(excited.x, excited.y, label=_("excited bench")) # type: ignore[ReportUnusedCallResult]
|
||||||
loglog(reference.x, reference.y, label="reference bench") # type: ignore[ReportUnusedCallResult]
|
loglog(reference.x, reference.y, label=_("reference bench")) # type: ignore[ReportUnusedCallResult]
|
||||||
loglog(
|
loglog(
|
||||||
(experiment.projection + reference).x,
|
(experiment.projection + reference).x,
|
||||||
(experiment.projection + reference).y,
|
(experiment.projection + reference).y,
|
||||||
label="sum reference + excited",
|
label=_("sum reference + excited"),
|
||||||
) # type: ignore[ReportUnusedCallResult]
|
) # type: ignore[ReportUnusedCallResult]
|
||||||
|
"""
|
||||||
if start_frequency is not None:
|
if start_frequency is not None:
|
||||||
vlines(
|
vlines(
|
||||||
[
|
[
|
||||||
|
@ -39,8 +49,8 @@ def show_projection(
|
||||||
],
|
],
|
||||||
min(experiment.projection.y),
|
min(experiment.projection.y),
|
||||||
max(experiment.projection.y),
|
max(experiment.projection.y),
|
||||||
color = 'k',
|
color="k",
|
||||||
) # type: ignore[ReportUnusedCallResult]
|
) # type: ignore[ReportUnusedCallResult]
|
||||||
if end_frequency is not None:
|
if end_frequency is not None:
|
||||||
vlines(
|
vlines(
|
||||||
[
|
[
|
||||||
|
@ -48,9 +58,13 @@ def show_projection(
|
||||||
],
|
],
|
||||||
min(experiment.projection.y),
|
min(experiment.projection.y),
|
||||||
max(experiment.projection.y),
|
max(experiment.projection.y),
|
||||||
color = 'k',
|
color="k",
|
||||||
) # type: ignore[ReportUnusedCallResult]
|
) # type: ignore[ReportUnusedCallResult]
|
||||||
|
"""
|
||||||
legend() # type: ignore[ReportUnusedCallResult]
|
legend() # type: ignore[ReportUnusedCallResult]
|
||||||
|
title(experiment.bench) # type: ignore[ReportUnusedCallResult]
|
||||||
|
xlabel(_("frequency (Hz)")) # type: ignore[ReportUnusedCallResult]
|
||||||
|
ylabel(_("stray ($\\frac{1} {\\sqrt {Hz}}$)")) # type: ignore[ReportUnusedCallResult]
|
||||||
show()
|
show()
|
||||||
close()
|
close()
|
||||||
logger.debug(_("experiment result showed"))
|
logger.debug(_("experiment result showed"))
|
||||||
|
|
|
@ -90,6 +90,7 @@ def load_coupling(
|
||||||
date: str,
|
date: str,
|
||||||
file: str,
|
file: str,
|
||||||
powers: dict[str, float],
|
powers: dict[str, float],
|
||||||
|
model_powers: dict[str, float],
|
||||||
) -> list[Signal]:
|
) -> list[Signal]:
|
||||||
"""
|
"""
|
||||||
Load and correct coupling date from modelisation
|
Load and correct coupling date from modelisation
|
||||||
|
@ -141,21 +142,27 @@ def load_coupling(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if bench in ["SDB1", "SDB2"]:
|
if model_powers["laser"] != 0:
|
||||||
modelisation_signal[0] = (
|
if bench in ["SDB1", "SDB2"]:
|
||||||
modelisation_signal[0]
|
modelisation_signal[0] = (
|
||||||
* (powers["laser"] / 40)
|
modelisation_signal[0]
|
||||||
* (powers["dark_fringe"] / 5e-6) ** (1 / 2)
|
* (powers["laser"] / model_powers["laser"])
|
||||||
) # radiation
|
* (powers["dark_fringe"] / model_powers["dark_fringe"])
|
||||||
modelisation_signal[1] = modelisation_signal[1] * (
|
** (1 / 2)
|
||||||
powers["dark_fringe"] / 5e-6
|
) # radiation
|
||||||
) ** (1 / 2) # phase
|
modelisation_signal[1] = modelisation_signal[1] * (
|
||||||
elif bench in ["SWEB", "SNEB"]:
|
powers["dark_fringe"] / model_powers["dark_fringe"]
|
||||||
modelisation_signal[1] = (
|
) ** (1 / 2) # phase
|
||||||
modelisation_signal[1] * powers["laser"] / 40
|
elif bench in ["SWEB", "SNEB"]:
|
||||||
) # radiation
|
modelisation_signal[1] = (
|
||||||
elif bench in ["SIB2", "SPRB"]:
|
modelisation_signal[1]
|
||||||
logger.info(
|
* powers["laser"]
|
||||||
_("cannot fix projection power for SIB2 and SPRB coupling")
|
/ model_powers["laser"]
|
||||||
)
|
) # radiation
|
||||||
|
elif bench in ["SIB2", "SPRB"]:
|
||||||
|
logger.info(
|
||||||
|
_(
|
||||||
|
"cannot fix projection power for SIB2 and SPRB coupling"
|
||||||
|
)
|
||||||
|
)
|
||||||
return modelisation_signal
|
return modelisation_signal
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tomllib import load
|
from tomllib import load
|
||||||
|
|
||||||
from numpy import argmin, float64, pi, log10
|
from numpy import argmin, pi, log10
|
||||||
from numpy.core.function_base import logspace
|
from numpy.core.function_base import logspace
|
||||||
from numpy.core.multiarray import array
|
from numpy.core.multiarray import array
|
||||||
from numpy.typing import NDArray
|
|
||||||
from science_signal import interpolate
|
from science_signal import interpolate
|
||||||
from science_signal.signal import Signal
|
from science_signal.signal import Signal
|
||||||
from backscattering_analyzer import logger
|
from backscattering_analyzer import logger
|
||||||
|
@ -221,6 +220,36 @@ class Experiment:
|
||||||
)
|
)
|
||||||
logger.debug(_("movement processed"))
|
logger.debug(_("movement processed"))
|
||||||
|
|
||||||
|
try:
|
||||||
|
correct_power = bool(values["dates"][date]["correct-power"])
|
||||||
|
if correct_power:
|
||||||
|
model_powers = {
|
||||||
|
"laser": values["dates"][date]["coupling"]["laser"],
|
||||||
|
"dark_fringe": values["dates"][date]["coupling"][
|
||||||
|
"dark_fringe"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
model_powers = {
|
||||||
|
"laser": 0,
|
||||||
|
"dark_fringe": 0,
|
||||||
|
}
|
||||||
|
except KeyError as error:
|
||||||
|
print(error)
|
||||||
|
logger.warning(
|
||||||
|
_(
|
||||||
|
"cannot find if coupling values should be "
|
||||||
|
+ "corrected due to the diff between power used in "
|
||||||
|
+ "model and the real one. No correction will be "
|
||||||
|
+ "applied"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
correct_power = False
|
||||||
|
model_powers = {
|
||||||
|
"laser": 0,
|
||||||
|
"dark_fringe": 0,
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.coupling = load_coupling(
|
self.coupling = load_coupling(
|
||||||
data_folder,
|
data_folder,
|
||||||
|
@ -228,6 +257,7 @@ class Experiment:
|
||||||
date,
|
date,
|
||||||
self.modelisation_file,
|
self.modelisation_file,
|
||||||
self.powers,
|
self.powers,
|
||||||
|
model_powers,
|
||||||
)
|
)
|
||||||
logger.debug(_("coupling signals successfully loaded"))
|
logger.debug(_("coupling signals successfully loaded"))
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -316,9 +346,7 @@ class Experiment:
|
||||||
) = self.get_factors(start=start_frequency, end=end_frequency)
|
) = self.get_factors(start=start_frequency, end=end_frequency)
|
||||||
|
|
||||||
for index in range(precision):
|
for index in range(precision):
|
||||||
logger.debug(
|
logger.debug(_("search for a local minimum"))
|
||||||
_("search for a local minimum")
|
|
||||||
)
|
|
||||||
|
|
||||||
x = logspace(log10(scatter_min), log10(scatter_max), 1000)
|
x = logspace(log10(scatter_min), log10(scatter_max), 1000)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue