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:
In [4]:
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."
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.
In [5]:
from tessfpe.data.operating_parameters import operating_parameters
operating_parameters["heater_1_current"]
Out[5]:
fpe1.house_keeping["analogue"]["parameter_name"]
In [6]:
fpe1.house_keeping["analogue"]["heater_1_current"]
fpe1.house_keeping["analogue"]["ccd1_input_diode_high"]
Out[6]:
fpe1.ops.parameter_name = value fpe1.ops.send()
In [7]:
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()
In [7]:
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)
Out[7]:
In [8]:
operating_parameters["ccd1_output_drain_a_offset"]
#operating_parameters["ccd1_reset_drain"]
Out[8]:
In [ ]:
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"]
In [ ]:
#operating_parameters["ccd1_reset_high"]
operating_parameters['ccd1_reset_low_offset']
In [ ]:
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"]
In [9]:
fpe1.cmd_start_frames() # Starts frame generation.
Out[9]:
In [10]:
fpe1.cmd_stop_frames() # Stops frame generation.
Out[10]:
In [145]:
from tessfpe.data.housekeeping_channels import housekeeping_channels
In [146]:
from tessfpe.data.housekeeping_channels import housekeeping_channel_memory_map
In [ ]:
print fpe1.house_keeping
In [11]:
print fpe1.house_keeping["analogue"]
In [24]:
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])
In [ ]:
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
In [103]:
print sample_data
In [57]:
v = {}
for name in operating_parameters.keys():
v[name] = operating_parameters[name]
print v[name]["unit"]
print name
In [29]:
In [18]: