Skip to content
Snippets Groups Projects
Commit 4d02725c authored by Danilo Ferreira de Lima's avatar Danilo Ferreira de Lima
Browse files

Fixes several points found by Cammille.

parent cc84e420
No related branches found
No related tags found
1 merge request!26Added example for SCS.
Pipeline #132020 passed
......@@ -43,7 +43,7 @@ class VSConfig(object):
"""
Receives an extra-data run and outputs the configuration.
"""
out = VSConfig()
out = cls()
if isinstance(runNumbers, int):
runNumbers = [runNumbers]
assert isinstance(runNumbers, list), "The run numbers must be a list or an integer."
......@@ -58,21 +58,21 @@ class VSConfig(object):
else:
run = run[0].union(*run[1:])
# get details on the run configuration
if VSConfig.pressure_source in run.all_sources:
pressure = run[VSConfig.pressure_source, "value"].ndarray()
if cls.pressure_source in run.all_sources:
pressure = run[cls.pressure_source, "value"].ndarray()
out.pressure = float(np.mean(pressure))
out.pressure_tol = float(np.std(pressure))
else:
raise ValueError(f"The input data does not contain the pressure source '{pressure_source}'.")
if VSConfig.voltage_source in run.all_sources:
for key in run[VSConfig.voltage_source].keys():
if cls.voltage_source in run.all_sources:
for key in run[cls.voltage_source].keys():
m = re.match("^(u[0-9]+).value$", key)
if m is not None and len(m.groups()) >= 1:
name = m.groups()[0]
out.voltage[name] = run[VSConfig.voltage_source, f"{name}.value"].ndarray().mean()
out.voltage_tol[name] = run[VSConfig.voltage_source, f"{name}.value"].ndarray().std()
out.voltage[name] = run[cls.voltage_source, f"{name}.value"].ndarray().mean()
out.voltage_tol[name] = run[cls.voltage_source, f"{name}.value"].ndarray().std()
for gas in VSConfig.gas_sources:
for gas in cls.gas_sources:
# check if this gas source is interlocked
if gas in run.all_sources and run[gas, "interlock.AActionState.value"].ndarray().sum() == 0:
# it is not, so this gas was used
......@@ -105,7 +105,7 @@ class VSConfig(object):
for k, v in self.voltage.items()}
diff.pressure = self.pressure - other.pressure
diff.voltage_tol = {k: np.sqrt(v**2 + other.voltage_tol[k]**2)
for k in self.voltage_tol.items()}
for k, v in self.voltage_tol.items()}
diff.pressure_tol = np.sqrt(self.pressure_tol**2 + other.pressure_tol**2)
diff.gas = set(self.gas).difference(set(other.gas))
return diff
......@@ -114,7 +114,7 @@ class VSConfig(object):
"""
Check if two configurations match.
"""
if not isinstance(other, VSConfig):
if not isinstance(other, self.__class__):
raise ValueError("I can only check equality with another VSConfig object.")
diff = self - other
for v in diff.voltage.values():
......@@ -161,13 +161,13 @@ class VSConfig(object):
"""
Build from dictionary.
"""
out = VSConfig()
out = cls()
out.gas = {data['gas']}
out.pressure = data['pressure']
out.voltage = {k: v for k, v in data.items()
if k not in ('gas', 'pressure')}
if tolerance is None:
tolerance = {k: 0.0 for k, v in data.items() if k != 'gas'}
tolerance = {k: 0.0 for k in data.keys() if k != 'gas'}
out.pressure_tol = tolerance['pressure']
out.voltage_tol = {k: v for k, v in tolerance.items()
if k not in ('gas', 'pressure')}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment