v2_m = vibrations.mean() # average voltage variance
v2_s = vibrations.std()
+ if ps_m == 0:
+ raise ValueError('invalid bumps: {}'.format(bumps))
+ if T_m == 0:
+ raise ValueError('invalid temperatures: {}'.format(temperatures))
+ if v2_m == 0:
+ raise ValueError('invalid vibrations: {}'.format(vibrations))
+
# Vphoto / photo_sensitivity = x
# k = kB T / <x**2> = kB T photo_sensitivity**2 / Vphoto_var
#
input_config = config['afm']['piezo'].select_config(
setting_name='inputs', attribute_value='deflection')
bumps_changed = temperatures_changed = vibrations_changed = False
+ calibration_group = None
if not isinstance(group, _h5py.Group) and not dry_run:
f = _h5py.File(filename, mode='a')
group = _h5_create_group(f, group)
group, 'vibration/{}'.format(i))
_vibration_save(
group=vibration_group, processed=data['vibration'])
- k,k_s,changed = check_calibration(
- k=data.get('processed/spring_constant', None),
- k_s=data.get('processed/spring_constant_deviation', None),
- bumps=data['bump'],
- temperatures=data['temperature'], vibrations=data['vibration'],
- maximum_relative_error=maximum_relative_error)
- if (changed or bumps_changed or temperatures_changed or
- vibrations_changed) and not dry_run:
+ if (bumps_changed or temperatures_changed or vibrations_changed
+ ) and not dry_run:
calibration_group = _h5_create_group(group, 'calibration')
if bumps_changed:
save_results(
if vibrations_changed:
save_results(
group=calibration_group, vibration=data['vibration'])
- if changed:
- save_results(
- group=calibration_group,
- spring_constant=k, spring_constant_deviation=k_s)
+ if len(raw_data['bump']) != len(data['bump']):
+ raise ValueError(
+ 'not enough raw bump data: {} of {}'.format(
+ len(raw_data['bump']), len(data['bump'])))
+ if len(raw_data['temperature']) != len(data['temperature']):
+ raise ValueError(
+ 'not enough raw temperature data: {} of {}'.format(
+ len(raw_data['temperature']), len(data['temperature'])))
+ if len(raw_data['vibration']) != len(data['vibration']):
+ raise ValueError(
+ 'not enough raw vibration data: {} of {}'.format(
+ len(raw_data['vibration']), len(data['vibration'])))
+ k,k_s,changed = check_calibration(
+ k=data.get('processed/spring_constant', None),
+ k_s=data.get('processed/spring_constant_deviation', None),
+ bumps=data['bump'],
+ temperatures=data['temperature'], vibrations=data['vibration'],
+ maximum_relative_error=maximum_relative_error)
+ if changed and not dry_run:
+ if calibration_group is None:
+ calibration_group = _h5_create_group(group, 'calibration')
+ save_results(
+ group=calibration_group,
+ spring_constant=k, spring_constant_deviation=k_s)
finally:
if f:
f.close()