from .temperature_analyze import save as _temperature_save
from .vibration_analyze import analyze as _vibration_analyze
from .vibration_analyze import save as _vibration_save
+from .util import SaveSpec as _SaveSpec
+from .util import save as _save
def analyze(bumps, temperatures, vibrations):
return figure
_plot = plot # alternative name for use inside analyze_all()
+def save_results(filename=None, group='/', bump=None,
+ temperature=None, vibration=None, spring_constant=None,
+ spring_constant_deviation=None):
+ specs = [
+ _SaveSpec(item=bump, relpath='raw/photodiode-sensitivity',
+ array=True, units='V/m'),
+ _SaveSpec(item=temperature, relpath='raw/temperature',
+ array=True, units='K'),
+ _SaveSpec(item=vibration, relpath='raw/vibration',
+ array=True, units='V^2/Hz'),
+ _SaveSpec(item=spring_constant, relpath='processed/spring-constant',
+ units='N/m', deviation=spring_constant_deviation),
+ ]
+ _save(filename=filename, group=group, specs=specs)
def analyze_all(config, data, raw_data, maximum_relative_error=1e-5,
filename=None, group=None, plot=False, dry_run=False):
vibrations_changed) and not dry_run:
calibration_group = _h5_create_group(group, 'calibration')
if bumps_changed:
- calib_save(group=calibration_group, bump=data['bump'])
+ save_results(
+ group=calibration_group, bump=data['bump'])
if temperatures_changed:
- calib_save(
+ save_results(
group=calibration_group, temperature=data['temperature'])
if vibrations_changed:
- calib_save(
+ save_results(
group=calibration_group, vibration=data['vibration'])
if changed:
- calib_save(group=calibration_group, k=k, k_s=k_s)
+ save_results(
+ group=calibration_group,
+ spring_constant=k, spring_constant_deviation=k_s)
finally:
if f:
f.close()
else:
rel_error = abs(new_k-k)/k
if rel_error > maximum_relative_error:
+ changed = True
_LOG.warn(("new analysis doesn't match for the spring constant: "
"{} != {} (difference: {}, relative error: {})").format(
new_k, k, new_k-k, rel_error))
_LOG.warn('new analysis for the spring constant deviation: {}'.format(
new_k_s))
else:
- rel_error = abs(new_k-k)/k
+ rel_error = abs(new_k_s-k_s)/k_s
if rel_error > maximum_relative_error:
+ changed = True
_LOG.warn(
("new analysis doesn't match for the spring constant deviation"
": {} != {} (difference: {}, relative error: {})").format(
from .vibration import run as _vibration
from .vibration_analyze import load as _vibration_load
from .analyze import analyze as _analyze
+from .analyze import save_results as _save_results
from .util import SaveSpec as _SaveSpec
-from .util import save as _save
from .util import load as _load
storage = _HDF5_Storage(filename=filename, group=group)
storage.save(config=self.config)
- @staticmethod
- def save_results(filename=None, group='/', bump=None,
- temperature=None, vibration=None, spring_constant=None,
- spring_constant_deviation=None):
- specs = [
- _SaveSpec(item=bump, relpath='raw/photodiode-sensitivity',
- array=True, units='V/m'),
- _SaveSpec(item=temperature, relpath='raw/temperature',
- array=True, units='K'),
- _SaveSpec(item=vibration, relpath='raw/vibration',
- array=True, units='V^2/Hz'),
- _SaveSpec(item=spring_constant, relpath='processed/spring-constant',
- units='N/m', deviation=spring_constant_deviation),
- ]
- _save(filename=filename, group=group, specs=specs)
-
@staticmethod
def load_results(filename, group='/'):
"""Load results saved with `.save_results()`."""
else:
data[name].append(loader(group=cwg))
return data
+
+Calibrator.save_results = _save_results