Bases: KPFTranslatorFunction
Sets the exposure time for the science detectors in the kpfexpose
keyword service.
ARGS:
:ExpTime: float
The exposure time in seconds
Source code in kpf/spectrograph/SetExpTime.py
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 | class SetExpTime(KPFTranslatorFunction):
'''Sets the exposure time for the science detectors in the kpfexpose
keyword service.
ARGS:
=====
:ExpTime: `float` The exposure time in seconds
'''
@classmethod
def pre_condition(cls, args, logger, cfg):
check_input(args, 'ExpTime', allowed_types=[int, float])
@classmethod
def perform(cls, args, logger, cfg):
kpfexpose = ktl.cache('kpfexpose')
exptime = args.get('ExpTime')
log.debug(f"Setting exposure time to {exptime:.3f}")
kpfexpose['EXPOSURE'].write(exptime)
@classmethod
def post_condition(cls, args, logger, cfg):
log.debug("Checking for success")
exptime = args.get('ExpTime')
tol = cfg.getfloat('tolerances', 'kpfexpose_exptime_tolerance', fallback=0.01)
timeout = cfg.getfloat('times', 'kpfexpose_response_time', fallback=1)
expr = (f"($kpfexpose.EXPOSURE >= {exptime-tol}) and "
f"($kpfexpose.EXPOSURE <= {exptime+tol})")
log.debug(expr)
success = ktl.waitFor(expr, timeout=timeout)
if success is not True:
exposure = ktl.cache('kpfexpose', 'EXPOSURE')
raise FailedToReachDestination(exposure.read(), exptime)
@classmethod
def add_cmdline_args(cls, parser, cfg=None):
parser.add_argument('ExpTime', type=float,
help='The exposure time in seconds')
return super().add_cmdline_args(parser, cfg)
|