<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Manual Commands Workbook
This notebook is a workbook for testing hardware with manual FPE commands, and general empirical testing.  It turns out that it's also a handy command reference.
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
Step1:  Useful Commands
Step2:  Reading a housekeeping value has this form
Step3:  Setting an operating parameter has this form
Step4:  Setting all the operating parameters to the default values
Step7:  Workspace
<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: Manual Commands Workbook
This notebook is a workbook for testing hardware with manual FPE commands, and general empirical testing.  It turns out that it's also a handy command reference.
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
from tessfpe.data.operating_parameters import operating_parameters
operating_parameters["heater_1_current"]
Explanation: Useful Commands:
ping()
fpe1.cmd_start_frames() # Starts frame generation.
fpe1.cmd_stop_frames() # Stops frame generation.
fpe1.cmd_camrst # Don't know how to work this. As-is, it fails.
fpe1.cmd_cam_status() # Returns the camera status register values.
fpe1.cmd_version() # Returns ObsSim version info.
fpe1.house_keeping # Returns a set of HK data in alphabetical order, in engineering units, without frames running. This includes all the FPGA digital housekeeping values.
fpe1.house_keeping["analogue"] #Returns only the analog values of the housekeeping set.
{fpe1.cmd_cam_hsk() # Returns raw, un-parsed housekeeping data, two samples per word (decimal), mostly useless here.}
check_house_keeping_voltages(fpe1, tolerance=0.05) # Returns True if standard set of supply voltages are in tolerance.
If you plan on setting operating parameters (DACs), run this cell:
End of explanation
fpe1.house_keeping["analogue"]["heater_1_current"]
fpe1.house_keeping["analogue"]["ccd1_input_diode_high"]
Explanation: Reading a housekeeping value has this form:
fpe1.house_keeping["analogue"]["parameter_name"]
Here's a couple of sample reads of housekeeping values:
End of explanation
fpe1.ops.heater_1_current = fpe1.ops.heater_1_current.low
fpe1.ops.heater_2_current = fpe1.ops.heater_2_current.low
fpe1.ops.heater_3_current = fpe1.ops.heater_3_current.low
fpe1.ops.send()
Explanation: Setting an operating parameter has this form:
fpe1.ops.parameter_name = value
fpe1.ops.send()
Setting the 3 trim heaters to their minimum values looks like this:
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: Setting all the operating parameters to the default values:
End of explanation
operating_parameters["ccd1_output_drain_a_offset"]
#operating_parameters["ccd1_reset_drain"]
fpe1.ops.ccd1_reset_drain = 15
fpe1.ops.ccd1_output_drain_a_offset = 10
fpe1.ops.send()
fpe1.house_keeping["analogue"]["ccd1_output_drain_a"]
#operating_parameters["ccd1_reset_high"]
operating_parameters['ccd1_reset_low_offset']
fpe1.ops.ccd1_reset_high = -10.3
fpe1.ops.ccd1_reset_low_offset = -9.9
fpe1.ops.send()
fpe1.house_keeping["analogue"]["ccd1_reset_low"]
fpe1.cmd_start_frames() # Starts frame generation.
fpe1.cmd_stop_frames() # Stops frame generation.
from tessfpe.data.housekeeping_channels import housekeeping_channels
from tessfpe.data.housekeeping_channels import housekeeping_channel_memory_map
print fpe1.house_keeping
print fpe1.house_keeping["analogue"]
from numpy import var
samples=100
from tessfpe.data.housekeeping_channels import housekeeping_channels
# 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 = {}
    
#my_dict["new key"] = "New value"
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 = house_keeping_values.keys()
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 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] = var(signal_data[name])
    # print name, str(variance_values[name])
    print '{0}      {1:<5}'.format(name, variance_values[name])
data = []
for i in range(10):
    set_values = {}
    for k in range(len(fpe1.ops.address)):
        if fpe1.ops.address[k] is None:
            continue
        low = fpe1.ops.address[k].low
        high = fpe1.ops.address[k].high
        name = fpe1.ops.address[k].name
        set_values[name] = fpe1.ops.address[k].value = low + i / 100. * (high - low)
    fpe1.ops.send()
    data.append({"set values": set_values,"measured values": fpe1.house_keeping["analogue"]})
    print data
print sample_data
v = {}
for name in operating_parameters.keys():
    v[name] = operating_parameters[name]
    print v[name]["unit"]
    print name
Explanation: Workspace:
End of explanation
<END_TASK>