Skip to content
Snippets Groups Projects
Commit 9e038029 authored by Evan Goetz's avatar Evan Goetz
Browse files

Merge branch 'fix-epics-push' into 'master'

EPICS records push fix

Closes #124

See merge request !142
parents 7ab650e5 2cf980fc
No related branches found
No related tags found
1 merge request!142EPICS records push fix
Pipeline #462401 passed
......@@ -16,4 +16,4 @@ dependencies:
- python-nds2-client
- declarative
- dttxml
- ezca
- pyepics
\ No newline at end of file
......@@ -17,7 +17,7 @@
import numpy as np
from scipy import signal
from gwpy.time import tconvert, from_gps
import time
from epics import caget, caput
from .model import Model
from .sensing import SensingModel
......@@ -395,7 +395,8 @@ class DARMModel(Model):
Parameters
----------
IFO : str
'LHO' or 'LLO'
'H1', 'L1', or similar. This will be prepended to all channel names
as per CDS convention.
epics_output : `float`, dict
the output from compute_epics_records
filename : str
......@@ -405,40 +406,47 @@ class DARMModel(Model):
"""
with open(filename, 'w') as f:
for chan in sorted(epics_output.keys()):
chan_val = epics_output[chan]
for chname in sorted(epics_output.keys()):
chan_val = epics_output[chname]
# if value is complex then split operation into its
# corresponding channels ending in "_REAL" and
# "_IMAG"
if np.iscomplex(chan_val):
chan = [f"{IFO}:{chan}_REAL", f"{IFO}:{chan}_IMAG"]
chan = [f"{IFO}:{chname}_REAL", f"{IFO}:{chname}_IMAG"]
chan_val = [np.real(chan_val), np.imag(chan_val)]
else:
chan = [chan]
chan = [f"{IFO}:{chname}"]
chan_val = [chan_val]
for idx, ch in enumerate(chan):
f.write(f"{ch} {chan_val[idx]:0.16e}\n")
if push_to_epics:
from ezca import ezca
ezca = ezca.Ezca()
ezca[ch] = '{:0.16e}'.format(chan_val[idx])
f.close()
# using caput_many() would probably be better here
caput(ch, f'{chan_val[idx]:0.16e}', wait=True, timeout=1)
# Ensure there is a moment for the EPICS records to get written
time.sleep(1)
# check if values written to EPICS channels were transferred properly
# Note: This assumes there is no race condition to write to any of the
# relevant channels.
if push_to_epics:
with open(filename, 'r') as f:
for chan in sorted(epics_output.keys()):
chan_val = epics_output[chan]
for chname in sorted(epics_output.keys()):
chan_val = epics_output[chname]
# split channels if dealing with complex values, same as
# above.
if np.iscomplex(chan_val):
chan = [f"{IFO}:{chan}_REAL", f"{IFO}:{chan}_IMAG"]
chan = [f"{IFO}:{chname}_REAL", f"{IFO}:{chname}_IMAG"]
chan_val = [np.real(chan_val), np.imag(chan_val)]
else:
chan = [chan]
chan = [f"{IFO}:{chname}"]
chan_val = [chan_val]
for idx, ch in enumerate(chan):
readVal = ezca[ch]
ratio = readVal / chan_val[idx]
if abs(ratio[0] - 1) > 0.000001:
print('Eeeeek! We had an EPICS connection error on '+chan+'. Check it!!')
try:
readVal = caget(ch)
ratio = readVal / chan_val[idx]
if abs(ratio - 1) > 0.000001:
print(f"Eeeeek! We had an EPICS error on {ch}. Check it!!")
except TypeError:
print(f"Error: unable to validate record in channel {ch}.")
def compute_etas(self, frequencies, sensing_syserr=None,
actuation_syserr_dict=None):
......
......@@ -36,7 +36,7 @@ install_requires =
requests
scikit-learn >= 1.1.0
scipy
ezca
pyepics
include_package_data = true
[options.packages.find]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment