Skip to content
Snippets Groups Projects

Fix PCAL correction EPICS records

Merged Evan Goetz requested to merge evan-goetz/pydarm:calcs-pcal into master
All threads resolved!
Files
3
+ 43
18
@@ -882,19 +882,44 @@ class CALCSModel(DARMModel):
# Pcal corrections
# See T1700106
# We are reading the PCAL and DARM signals from the CALCS model, both
# of which have an implicit 1 16k clock cycle delay. The
# PCAL_LINE*_CORRECTION is being divided into the DARM/PCAL transfer
# function (both in CALCS). The compute_pcal_correction uses the
# "endstation" boolean to indicate that the PCAL channel read is in the
# CALCS model so it has been divided by a delay.
# The darm_advance is therefore necessary so that the CALCS DARM signal
# is properly treated as though it is coming from the OMC model, which
# is where DARM originates.
# (DARM / PCAL)_calcs * (1/PCAL_OVER_DARM_LINE*_CORRECTION) =
# (DARM_omc / PCAL_end)
# TODO: the front end and GDS needs to be fixed, and once it is fixed,
# then this math can be separate EPICS records and be more clear.
# Meaning, instead of dividing the (DARM/PCAL) transfer function in the
# front end by PCAL_OVER_DARM_LINE*_CORRECTION, we should multiply.
# Once that is fixed, then we should change this to be
# DARM_OVER_PCAL_LINE*_CORRECTION = darm_advance / pcal_correction
pcal_correction = self.pcal.compute_pcal_correction(freq, endstation)
PCAL_LINE1_CORRECTION = pcal_correction[0]
PCAL_LINE2_CORRECTION = pcal_correction[4]
PCAL_LINE3_CORRECTION = pcal_correction[5]
darm_advance = signal.dfreqresp(
digital_delay_filter(-1, 16384), 2*np.pi*freq/16384)[1]
PCAL_OVER_DARM_LINE1_CORRECTION = pcal_correction[0] / darm_advance[0]
PCAL_OVER_DARM_LINE2_CORRECTION = pcal_correction[4] / darm_advance[4]
PCAL_OVER_DARM_LINE3_CORRECTION = pcal_correction[5] / darm_advance[5]
# We divide out the pcal reference arm sign since we know which arm
# the next two values will be assigned to. This makes the next two
# values constant no matter what arm the PCal calibration lines are
# assigned to
PCAL_X_COMPARE_CORRECTION = (
pcal_correction[6] / self.pcal.ref_pcal_2_darm_act_sign)
PCAL_Y_COMPARE_CORRECTION = (
-1 * pcal_correction[7] / self.pcal.ref_pcal_2_darm_act_sign)
# assigned to.
# TODO: do these also need the same DARM advance divided out? We need
# to confirm because I don't know how these are being used
PCAL_OVER_DARM_X_COMPARE_CORRECTION = (
pcal_correction[6] /
self.pcal.ref_pcal_2_darm_act_sign /
darm_advance[6])
PCAL_OVER_DARM_Y_COMPARE_CORRECTION = (
-1 * pcal_correction[7] /
self.pcal.ref_pcal_2_darm_act_sign /
darm_advance[7])
# this does not include any OMC to SUS model jump delay
uim_actuation_epics = self.actuation.stage_super_actuator_drivealign(
@@ -952,8 +977,8 @@ class CALCSModel(DARMModel):
# Output - see T1700106
out = {
'CAL-CS_TDEP_PCAL_LINE1_CORRECTION_REAL': PCAL_LINE1_CORRECTION.real,
'CAL-CS_TDEP_PCAL_LINE1_CORRECTION_IMAG': PCAL_LINE1_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_LINE1_CORRECTION_REAL': PCAL_OVER_DARM_LINE1_CORRECTION.real,
'CAL-CS_TDEP_PCAL_LINE1_CORRECTION_IMAG': PCAL_OVER_DARM_LINE1_CORRECTION.imag,
'CAL-CS_TDEP_SUS_LINE3_REF_INVA_TST_RESPRATIO_REAL': SUS_LINE3_REF_INVA_TST_RESPRATIO.real, # noqa E501
'CAL-CS_TDEP_SUS_LINE3_REF_INVA_TST_RESPRATIO_IMAG': SUS_LINE3_REF_INVA_TST_RESPRATIO.imag, # noqa E501
'CAL-CS_TDEP_SUS_LINE2_REF_INVA_PUM_RESPRATIO_REAL': SUS_LINE2_REF_INVA_PUM_RESPRATIO.real, # noqa E501
@@ -970,8 +995,8 @@ class CALCSModel(DARMModel):
'CAL-CS_TDEP_PCAL_LINE2_REF_A_PUM_IMAG': PCAL_LINE2_REF_A_PUM.imag,
'CAL-CS_TDEP_PCAL_LINE2_REF_A_UIM_REAL': PCAL_LINE2_REF_A_UIM.real,
'CAL-CS_TDEP_PCAL_LINE2_REF_A_UIM_IMAG': PCAL_LINE2_REF_A_UIM.imag,
'CAL-CS_TDEP_PCAL_LINE2_CORRECTION_REAL': PCAL_LINE2_CORRECTION.real,
'CAL-CS_TDEP_PCAL_LINE2_CORRECTION_IMAG': PCAL_LINE2_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_LINE2_CORRECTION_REAL': PCAL_OVER_DARM_LINE2_CORRECTION.real,
'CAL-CS_TDEP_PCAL_LINE2_CORRECTION_IMAG': PCAL_OVER_DARM_LINE2_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_LINE1_REF_C_NOCAVPOLE_REAL': PCAL_LINE1_REF_C_NOCAVPOLE.real,
'CAL-CS_TDEP_PCAL_LINE1_REF_C_NOCAVPOLE_IMAG': PCAL_LINE1_REF_C_NOCAVPOLE.imag,
'CAL-CS_TDEP_PCAL_LINE1_REF_D_REAL': PCAL_LINE1_REF_D.real,
@@ -982,12 +1007,12 @@ class CALCSModel(DARMModel):
'CAL-CS_TDEP_PCAL_LINE1_REF_A_PUM_IMAG': PCAL_LINE1_REF_A_PUM.imag,
'CAL-CS_TDEP_PCAL_LINE1_REF_A_UIM_REAL': PCAL_LINE1_REF_A_UIM.real,
'CAL-CS_TDEP_PCAL_LINE1_REF_A_UIM_IMAG': PCAL_LINE1_REF_A_UIM.imag,
'CAL-CS_TDEP_PCAL_LINE3_CORRECTION_REAL': PCAL_LINE3_CORRECTION.real,
'CAL-CS_TDEP_PCAL_LINE3_CORRECTION_IMAG': PCAL_LINE3_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_X_COMPARE_CORRECTION_REAL': PCAL_X_COMPARE_CORRECTION.real,
'CAL-CS_TDEP_PCAL_X_COMPARE_CORRECTION_IMAG': PCAL_X_COMPARE_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_Y_COMPARE_CORRECTION_REAL': PCAL_Y_COMPARE_CORRECTION.real,
'CAL-CS_TDEP_PCAL_Y_COMPARE_CORRECTION_IMAG': PCAL_Y_COMPARE_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_LINE3_CORRECTION_REAL': PCAL_OVER_DARM_LINE3_CORRECTION.real,
'CAL-CS_TDEP_PCAL_LINE3_CORRECTION_IMAG': PCAL_OVER_DARM_LINE3_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_X_COMPARE_CORRECTION_REAL': PCAL_OVER_DARM_X_COMPARE_CORRECTION.real,
'CAL-CS_TDEP_PCAL_X_COMPARE_CORRECTION_IMAG': PCAL_OVER_DARM_X_COMPARE_CORRECTION.imag,
'CAL-CS_TDEP_PCAL_Y_COMPARE_CORRECTION_REAL': PCAL_OVER_DARM_Y_COMPARE_CORRECTION.real,
'CAL-CS_TDEP_PCAL_Y_COMPARE_CORRECTION_IMAG': PCAL_OVER_DARM_Y_COMPARE_CORRECTION.imag,
}
if exact:
Loading