ConfigureForScience

Bases: KPFFunction

Script which configures the instrument for Science observations.

  • Sets octagon / simulcal source
  • Sets source select shutters
  • Set triggered detectors
Parameters:
  • observation (dict) –

    A observation OB component in dictionary format (e.g. using the output of the .to_dict() method of a kpf.ObservingBlocks.Observation.Observation instance).

KTL Keywords Used:

  • kpfexpose.EXPOSE

Functions Called:

  • kpf.calbench.SetSimulCalSource
  • kpf.guider.ConfirmGuiding
  • kpf.spectrograph.SetSourceSelectShutters
  • kpf.spectrograph.SetTriggeredDetectors
  • kpf.spectrograph.WaitForReady
  • kpf.telescope.EastNorth
Source code in kpf/scripts/ConfigureForScience.py
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
86
87
88
89
90
91
92
93
94
95
96
class ConfigureForScience(KPFFunction):
    '''Script which configures the instrument for Science observations.

    - Sets octagon / simulcal source
    - Sets source select shutters
    - Set triggered detectors

    Args:
        observation (dict): A observation OB component in dictionary format (e.g.
                            using the output of the `.to_dict()` method of a
                            `kpf.ObservingBlocks.Observation.Observation` instance).

    KTL Keywords Used:

    - `kpfexpose.EXPOSE`

    Functions Called:

    - `kpf.calbench.SetSimulCalSource`
    - `kpf.guider.ConfirmGuiding`
    - `kpf.spectrograph.SetSourceSelectShutters`
    - `kpf.spectrograph.SetTriggeredDetectors`
    - `kpf.spectrograph.WaitForReady`
    - `kpf.telescope.EastNorth`
    '''
    @classmethod
    def pre_condition(cls, observation):
        pass

    @classmethod
    def perform(cls, observation):
        log.info('-------------------------')
        log.info(f"Running {cls.__name__}")
        log.info('-------------------------')

        # Offset if requested
#         NodN = observation.get('NodN', 0)
#         NodE = observation.get('NodE', 0)
#         if abs(NodN) > 0.01 or abs(NodE) > 0.01:
#             EastNorth.execute(observation)

        check_scriptstop()

        # Confirm guiding
        ConfirmGuiding.execute(observation)

        check_scriptstop()

        # Set Octagon
        SetSimulCalSource.execute({})

        check_scriptstop()

        # Set source select shutters
        exposestatus = ktl.cache('kpfexpose', 'EXPOSE')
        if exposestatus.read() != 'Ready':
            log.info(f"Waiting for kpfexpose to be Ready")
            WaitForReady.execute({})
            log.debug(f"kpfexpose is Ready")
        log.info(f"Set Source Select Shutters")
        SetSourceSelectShutters.execute({'OpenScienceShutter': True,
                                         'OpenSkyShutter': not observation.get('BlockSky', False),
                                         'OpenSoCalSciShutter': False,
                                         'OpenSoCalCalShutter': False,
                                         'OpenCalSciSkyShutter': False})

        # Set Triggered Detectors
        observation['TriggerGuide'] = True
        SetTriggeredDetectors.execute(observation)

        check_scriptstop()

    @classmethod
    def post_condition(cls, observation):
        pass