<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 HK Variance Test (Frames Running)
This notebook provides a test for the noise and stability of the housekeeping data captured by the FPE.  It evaluates the performance of the housekeeping system by taking a large number of samples, collecting the results for each signal channel, and evaluating the variance of the data for each channel.
In this version, we start frames running and repeat the taking of variance data on the housekeeping system.
Instructions
Step1:  Set all the operating parameters to the default values
Step3:  Start the frames
Step6:  Run the variance test
<ASSISTANT_TASK:>
Python Code:
from tessfpe.dhu.fpe import FPE
from tessfpe.dhu.unit_tests import check_house_keeping_voltages
fpe1 = FPE(1, debug=False, preload=True, FPE_Wrapper_version='6.1.1')
print fpe1.version
fpe1.cmd_start_frames()
fpe1.cmd_stop_frames()
if check_house_keeping_voltages(fpe1):
    print "Wrapper load complete. Interface voltages OK."
Explanation: HK Variance Test (Frames Running)
This notebook provides a test for the noise and stability of the housekeeping data captured by the FPE.  It evaluates the performance of the housekeeping system by taking a large number of samples, collecting the results for each signal channel, and evaluating the variance of the data for each channel.
In this version, we start frames running and repeat the taking of variance data on the housekeeping system.
Instructions:
Enter Your Name and today's date:
Ed Bokhour, 11/4/15
Enter the part numbers and serial numbers of the units under test:
SDPCB Interface 6.1, s/n 02. SDPCB 6.1 Driver s/n RPI15310002, SDPCB Video 6.1 s/n RPI15310001. Using wrapper 6.1.2 (San Diego).
When the test is complete, save this notebook as a new file, indicating the date, as "HK_Variance_Results_YYMMDD.ipynb".  Alternatively, export the notebook as a PDF file, then clear all entries and outputs.
Start the Observatory Simulator and Load the FPE FPGA
Remember that whenever you power-cycle the Observatory Simulator, you should set preload=True below.
When you are running this notebook and it has not been power cycled, you should set preload=False.
Run the following cell to get the FPE loaded:
End of explanation
def set_fpe_defaults(fpe):
    "Set the FPE to the default operating parameters and return a list of the default values"
    defaults = {}
    for k in range(len(fpe.ops.address)):
        if fpe.ops.address[k] is None:
            continue
        fpe.ops.address[k].value = fpe.ops.address[k].default
        defaults[fpe.ops.address[k].name] = fpe.ops.address[k].default
    return defaults
set_fpe_defaults(fpe1)
Explanation: Set all the operating parameters to the default values:
End of explanation
fpe1.cmd_start_frames()
subprocess.check_output(["pwd"])
    def capture_frames(self, n):
        Capture frames
        import subprocess
        import os.path
        self.cmd_start_frames()
        proc = subprocess.Popen(
            [os.path.join(self._dir, "..", "fits_capture", "tess_obssim", "tess_obssim"), '-n', str(n)],
            shell=False)
        proc.communicate()
        self.cmd_stop_frames()
Explanation: Start the frames
End of explanation
from numpy import var, sqrt
samples=5
#from tessfpe.data.housekeeping_channels import housekeeping_channels
fpe1.cmd_cam_status()
# We make sample_data a dictionary and each value will be a set of HK 
# data, with key = sample_name.
sample_data = {}
# For later:
signal_names = []
signal_values = []
signal_data = {}
variance_values = {}
#for i in range(samples):
    # Get a new set of HK values
#    house_keeping_values = fpe1.house_keeping["analogue"]
#    data_values = house_keeping_values.values()
    # Add the new HK values to the sample_data dictionary:
    sample_number = "sample_" + str(i)
    sample_data[sample_number] = data_values
# Get the signal names for use later
signal_names = housekeeping_channels.keys()
# Get list of units for later
units = {}
for name in housekeeping_channels:
    units[name] = housekeeping_channels[name]['unit']
    
Assign the set of all HK values of the same signal (e.g. substrate_1) 
to the dictionary 'signal_data'
for k in range(len(signal_names)):
    # Build the list 'signal_values' for this signal:
    for i in range(samples):
        sample_number = "sample_" + str(i)
        signal_values.append(sample_data[sample_number][k])
    # Add signal_values to the signal_data dictionary:
    signal_data[signal_names[k]] = signal_values
    signal_values = []
 Now get the square root of the variance of each of the 'signal_values' in the 
signal_data dictionary and put the result in the 'variance_values' 
dictionary.
for name in signal_data:
    variance_values[name] = sqrt(var(signal_data[name]))
    #print units[name]["unit"]
    #print signal_data
    #print units[name]
    print '{0:26}     {1:.3} {2}'.format(name, variance_values[name], units[name])
# Results will be displayed below, in engineering units (root-variance).  
# Watch ObsSim LEDs for activity.
Explanation: Run the variance test:
End of explanation
<END_TASK>