Allow configuration centralizion in HDF5 files.
authorW. Trevor King <wking@tremily.us>
Wed, 13 Jun 2012 17:54:42 +0000 (13:54 -0400)
committerW. Trevor King <wking@tremily.us>
Wed, 13 Jun 2012 18:00:45 +0000 (14:00 -0400)
Before this commit, each bump/temperature/vibration measurement needed
it's own local copy of the configuration.  This is good, because it
allow you to store experiments where the configuration changes between
measurements (e.g. one bump with push depth of 200 nm, followed by
others with a push depth of 300 nm).  However, such per-measurement
changes should be a rare occurrence, so this commit allows you to
specify the measurement configuration in a central location.  For
example:

  /bump/0/config/bump/...
  /bump/1/config/bump/...
  /bump/2/config/bump/...
  ...

can now be consolidated to

  /config/bump/...

If you want, you can still override the central config for a
particular measurement by placing the config in the old location.

calibcant/analyze.py

index 625ae4caec931ac0578faa0d1069e821fb776ee6..38f9f15bf94519ff548aa888fdba84294a2d7eaf 100644 (file)
@@ -242,7 +242,7 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5,
             bumps_changed = True
         for i,bump in enumerate(raw_data['bump']):
             data['bump'][i],changed = check_bump(
-                index=i, bump=bump, z_axis_config=axis_config,
+                index=i, bump=bump, config=config, z_axis_config=axis_config,
                 deflection_channel_config=input_config, plot=plot,
                 maximum_relative_error=maximum_relative_error)
             if changed and not dry_run:
@@ -254,7 +254,7 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5,
             temperatures_changed = True
         for i,temperature in enumerate(raw_data['temperature']):
             data['temperature'][i],changed = check_temperature(
-                index=i, temperature=temperature,
+                index=i, temperature=temperature, config=config,
                 maximum_relative_error=maximum_relative_error)
             if changed and not dry_run:
                 temperatures_changed = True
@@ -267,7 +267,7 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5,
             vibrations_changed = True
         for i,vibration in enumerate(raw_data['vibration']):
             data['vibration'][i],changed = check_vibration(
-                    index=i, vibration=vibration,
+                    index=i, vibration=vibration, config=config,
                     deflection_channel_config=input_config, plot=plot,
                     maximum_relative_error=maximum_relative_error)
             if changed and not dry_run:
@@ -322,10 +322,14 @@ def analyze_all(config, data, raw_data, maximum_relative_error=1e-5,
              vibrations=data['raw']['vibration'])
     return (k, k_s)
 
-def check_bump(index, bump, maximum_relative_error, **kwargs):
+def check_bump(index, bump, config=None, maximum_relative_error=0, **kwargs):
     changed = False
+    try:
+        bump_config = bump['config']['bump']
+    except KeyError:
+        bump_config = config['bump']
     sensitivity = _bump_analyze(
-        config=bump['config']['bump'], data=bump['raw'], **kwargs)
+        config=bump_config, data=bump['raw'], **kwargs)
     if bump.get('processed', None) is None:
         changed = True            
         _LOG.warn('new analysis for bump {}: {}'.format(index, sensitivity))
@@ -339,10 +343,15 @@ def check_bump(index, bump, maximum_relative_error, **kwargs):
                     sensitivity-bump['processed'], rel_error))
     return (sensitivity, changed)
 
-def check_temperature(index, temperature, maximum_relative_error, **kwargs):
+def check_temperature(index, temperature, config=None,
+                      maximum_relative_error=0, **kwargs):
     changed = False
+    try:
+        temp_config = temperature['config']['temperature']
+    except KeyError:
+        temp_config = config['temperature']
     temp = _temperature_analyze(
-        config=temperature['config']['temperature'],
+        config=temp_config,
         temperature=temperature['raw'], **kwargs)
     if temperature.get('processed', None) is None:
         changed = True            
@@ -359,11 +368,15 @@ def check_temperature(index, temperature, maximum_relative_error, **kwargs):
                     temp-temperature['processed'], rel_error))
     return (temp, changed)
 
-def check_vibration(index, vibration, maximum_relative_error, **kwargs):
+def check_vibration(index, vibration, config=None, maximum_relative_error=0,
+                    **kwargs):
     changed = False
+    try:
+        vib_config = vibration['config']['vibration']
+    except KeyError:
+        vib_config = config['vibration']
     variance = _vibration_analyze(
-        config=vibration['config']['vibration'],
-        deflection=vibration['raw'], **kwargs)
+        config=vib_config, deflection=vibration['raw'], **kwargs)
     if vibration.get('processed', None) is None:
         changed = True
         _LOG.warn('new analysis for temperature {}: {}'.format(