SetupAOforKPF

Bases: KPFFunction

Set up AO in the safe mode for KPF operation

  • Set AO roator in Manual mode
  • Set AO rotator to 0 deg
  • Turn off HEPA
  • Set AO in DCS sim mode
  • Home PCU
  • Move PCU to the KPF position
  • Open AO hatch

KTL Keywords Used:

  • ao.PCSFNAME

Functions Called:

  • kpf.ao.SetAORotatorManual
  • kpf.ao.SetAORotator
  • kpf.ao.TurnHepaOff
  • kpf.ao.SetAODCStoSIM
  • kpf.ao.TurnLightSourceOff
  • kpf.ao.SendPCUtoHome
  • kpf.ao.SendPCUtoKPF
Source code in kpf/ao/SetupAOforKPF.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class SetupAOforKPF(KPFFunction):
    '''Set up AO in the safe mode for KPF operation

    - Set AO roator in Manual mode
    - Set AO rotator to 0 deg
    - Turn off HEPA
    - Set AO in DCS sim mode
    - Home PCU
    - Move PCU to the KPF position
    - Open AO hatch

    KTL Keywords Used:

    - `ao.PCSFNAME`

    Functions Called:

    - `kpf.ao.SetAORotatorManual`
    - `kpf.ao.SetAORotator`
    - `kpf.ao.TurnHepaOff`
    - `kpf.ao.SetAODCStoSIM`
    - `kpf.ao.TurnLightSourceOff`
    - `kpf.ao.SendPCUtoHome`
    - `kpf.ao.SendPCUtoKPF`
    '''
    @classmethod
    def pre_condition(cls, args):
        pass

    @classmethod
    def perform(cls, args):

        try:
            log.info('Set AO rotator to Manual')
            SetAORotatorManual.execute({})

            log.info('Set AO rotator to 0 deg')
            SetAORotator.execute({'dest': 0})

            log.info('Turn off HEPA')
            TurnHepaOff.execute({})

            log.info('Set AO in DCS sim mode')
            SetAODCStoSIM.execute({})

            log.info('Turn K1 AO light source off')
            TurnLightSourceOff.execute({})

            PCSstagekw = ktl.cache('ao', 'PCSFNAME')
            if PCSstagekw.read() != 'kpf':
                log.info('Move PCU to KPF')
                SendPCUtoKPF.execute({})
        except Exception as e:
            log.warning('SetupAOforKPF failed.')
            log.warning(e)
            log.warning(f'SSHing to k1obsao@k1aoserver-new to run kpfStart.csh')
            ssh_cmds = ['ssh -X k1obsao@k1aoserver-new kpfStart.csh',
                        f'echo "Done!"',
                        f'sleep 30']
            ssh_cmd = ' ; '.join(ssh_cmds)
            cmd = ['xterm', '-title', 'SetupAOforKPF', '-name', 'SetupAOforKPF',
                   '-fn', '10x20', '-bg', 'black', '-fg', 'white',
                   '-e', f'{ssh_cmd}']
            proc = subprocess.Popen(cmd)

    @classmethod
    def post_condition(cls, args):
        pass