From 5c72a9ab2ef1d38a9351370cf1b678a2e1caaba8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 11 May 2012 10:49:46 -0400 Subject: [PATCH] Adjust analyze_all to work with missing data['raw'] or data['processed']. This is especially useful for analyzing data where the initial analysis crashed for some reason, but and you want to re-analyze after you fixed the bug. --- calibcant/analyze.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/calibcant/analyze.py b/calibcant/analyze.py index ab3fbbb..0cfab7c 100644 --- a/calibcant/analyze.py +++ b/calibcant/analyze.py @@ -230,7 +230,7 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5, else: f = None try: - if len(data['raw']['bump']) != len(data['bump']): + if len(data.get('raw/bump', [])) != len(data['bump']): bumps_changed = True for i,bump in enumerate(raw_data['bump']): data['bump'][i],changed = check_bump( @@ -241,7 +241,7 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5, bumps_changed = True bump_group = _h5_create_group(group, 'bump/{}'.format(i)) _bump_save(group=bump_group, processed=data['bump'][i]) - if len(data['raw']['temperature']) != len(data['temperature']): + if len(data.get('raw/temperature', [])) != len(data['temperature']): temperatures_changed = True for i,temperature in enumerate(raw_data['temperature']): data['temperature'][i],changed = check_temperature( @@ -253,7 +253,7 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5, group, 'temperature/{}'.format(i)) _temperature_save( group=temerature_group, processed=data['temperature'][i]) - if len(data['raw']['vibration']) != len(data['vibration']): + if len(data.get('raw/vibration', [])) != len(data['vibration']): vibrations_changed = True for i,vibration in enumerate(raw_data['vibration']): data['vibration'][i],changed = check_vibration( @@ -267,8 +267,8 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5, _vibration_save( group=vibration_group, processed=data['vibration']) k,k_s,changed = check_calibration( - k=data['processed']['spring_constant'], - k_s=data['processed']['spring_constant_deviation'], + 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) -- 2.26.2