Exemple #1
0
    def initCommands(self):
        """Recreate the objects that hold the state of the various commands."""

        sopState = myGlobals.actorState

        sopState.doApogeeScience = CmdState.DoApogeeScienceCmd()
        sopState.doApogeeSkyFlats = CmdState.DoApogeeSkyFlatsCmd()
        sopState.gotoGangChange = CmdState.GotoGangChangeCmd()
        sopState.gotoPosition = CmdState.GotoPositionCmd()
        sopState.doApogeeDomeFlat = CmdState.DoApogeeDomeFlatCmd()

        self.updateCartridge(-1, 'UNKNOWN', 'None')
        sopState.guiderState.setLoadedNewCartridgeCallback(
            self.updateCartridge)
Exemple #2
0
 def test_do_boss_calibs_one_of_each(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nBias = 1
     cmdState.nDark = 1
     cmdState.nFlat = 1
     cmdState.nArc = 1
     self._do_boss_calibs(16,82,0,0,cmdState)
Exemple #3
0
 def test_do_boss_calibs_two_of_each(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nBias = 2
     cmdState.nDark = 2
     cmdState.nFlat = 2
     cmdState.nArc = 2
     self._do_boss_calibs(29,148,0,0,cmdState)
Exemple #4
0
    def hartmann(self, cmd, finish=True):
        """
        Take two arc exposures, one with the Hartmann left screen in
        and one with the right one in.

        If the flat field screens are initially open they are closed,
        and the Ne/HgCd lamps are turned on. You may specify using
        only one spectrograph with sp1 or sp2; the default is both.
        The exposure time is set by expTime

        When the sequence is finished the Hartmann screens are moved
        out of the beam, the lamps turned off, and the flat field
        screens returned to their initial state.
        """
        sopState = myGlobals.actorState
        cmdState = sopState.hartmann

        if self.doing_science(sopState):
            cmd.fail(
                "text='A science exposure sequence is running -- will not start a hartmann sequence!"
            )
            return

        cmdState.reinitialize(cmd, output=False)

        expTime = float(cmd.cmd.keywords["expTime"].values[0]) \
                  if "expTime" in cmd.cmd.keywords else CmdState.getDefaultArcTime(sopActor.BOSS)
        cmdState.expTime = expTime

        sopState.queues[sopActor.MASTER].put(Msg.HARTMANN,
                                             cmd,
                                             replyQueue=self.replyQueue,
                                             actorState=sopState,
                                             cmdState=cmdState)
Exemple #5
0
    def initCommands(self):
        """Recreate the objects that hold the state of the various commands."""

        sopState = myGlobals.actorState

        sopState.gotoField = CmdState.GotoFieldLCOCmd()

        super(SopCmd_LCO, self).initCommands()
Exemple #6
0
 def test_do_boss_calibs_one_arc_coobserve(self):
     """coobserving carts should close the apogee shutter first."""
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nArc = 1
     sopTester.updateModel('guider',TestHelper.guiderState['apogeemangaDitherLoaded'])
     sopTester.updateModel('mcp',TestHelper.mcpState['apogee_parked'])
     sopTester.updateModel('apogee',TestHelper.apogeeState['B_open'])
     self._do_boss_calibs(8,38,0,0,cmdState)
Exemple #7
0
    def initCommands(self):
        """Recreate the objects that hold the state of the various commands."""

        sopState = myGlobals.actorState

        sopState.gotoField = CmdState.GotoFieldCmd()
        sopState.doBossCalibs = CmdState.DoBossCalibsCmd()
        sopState.doBossScience = CmdState.DoBossScienceCmd()
        sopState.doMangaDither = CmdState.DoMangaDitherCmd()
        sopState.doMangaSequence = CmdState.DoMangaSequenceCmd()
        sopState.doApogeeMangaDither = CmdState.DoApogeeMangaDitherCmd()
        sopState.doApogeeMangaSequence = CmdState.DoApogeeMangaSequenceCmd()
        sopState.hartmann = CmdState.HartmannCmd()
        sopState.collimateBoss = CmdState.CollimateBossCmd()

        super(SopCmd_APO, self).initCommands()
Exemple #8
0
 def test_do_boss_calibs_one_flat_coobserve_gangPodium(self):
     """
     Coobserving carts should not bother with the apogee shutter when the
     gang connector is not at the cart.
     """
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nFlat = 1
     sopTester.updateModel('guider',TestHelper.guiderState['apogeemangaDitherLoaded'])
     sopTester.updateModel('mcp',TestHelper.mcpState['all_off'])
     sopTester.updateModel('apogee',TestHelper.apogeeState['B_open'])
     self._do_boss_calibs(7,30,0,0,cmdState)
Exemple #9
0
    def gotoField(self, cmd):
        """Slew to the current cartridge/pointing

        Slew to the position of the currently loaded cartridge. At the
        beginning of the slew all the lamps are turned on and the flat
        field screen petals are closed.  When you arrive at the field,
        all the lamps are turned off again and the flat field petals
        are opened if you specified openFFS.
        """

        sopState = myGlobals.actorState
        survey = sopState.survey
        cmdState = sopState.gotoField
        keywords = cmd.cmd.keywords

        if self.doing_science(sopState):
            cmd.fail(
                "text='A science exposure sequence is running -- will not go to field!"
            )
            return

        if "abort" in keywords:
            self.stop_cmd(cmd, cmdState, sopState, 'gotoField')
            return

        # Modify running gotoField command
        if self.modifiable(cmd, cmdState):
            cmdState.doSlew = True if "noSlew" not in keywords else False
            cmdState.doGuider = True if "noGuider" not in keywords else False
            cmdState.doHartmann = True if "noHartmann" not in keywords else False

            # NOTE: TBD: Need a full set of test cases for this...

            dropCalibs = False
            if "noCalibs" in keywords:
                if cmdState.didFlat or cmdState.didArc:
                    cmd.warn(
                        'text="Some cals have been taken; it\'s too late to disable them."'
                    )
                else:
                    dropCalibs = True
            if "arcTime" in keywords:
                if cmdState.didArc:
                    cmd.warn(
                        'text="Arcs are taken; it\'s too late to modify arcTime"'
                    )
                else:
                    cmdState.arcTime = float(keywords["arcTime"].values[0])
            if "flatTime" in keywords:
                if cmdState.didFlat:
                    cmd.warn(
                        'text="Flats are taken; it\'s too late to modify flatTime"'
                    )
                else:
                    cmdState.flatTime = float(keywords["flatTime"].values[0])
            if "guiderFlatTime" in keywords:
                cmdState.guiderFlatTime = float(
                    keywords["guiderFlatTime"].values[0])
            if "guiderTime" in keywords:
                cmdState.guiderTime = float(keywords["guiderTime"].values[0])

            # * TBD: WARNING! This does not keep track of what's already been done,
            # * except for the dropCalibs bit above.
            cmdState.doCalibs = not dropCalibs
            cmdState.setStageState("slew",
                                   "pending" if cmdState.doSlew else "off")
            cmdState.setStageState("hartmann",
                                   "pending" if cmdState.doHartmann else "off")
            cmdState.setStageState("calibs",
                                   "pending" if not dropCalibs else "off")
            cmdState.setStageState("guider",
                                   "pending" if cmdState.doGuider else "off")

            self.status(cmd,
                        threads=False,
                        finish=True,
                        oneCommand="gotoField")
            return

        cmdState.reinitialize(cmd, output=False)

        cmdState.doSlew = "noSlew" not in keywords
        cmdState.doGuider = "noGuider" not in keywords
        cmdState.doCalibs = ("noCalibs" not in keywords
                             and survey != sopActor.APOGEE)
        cmdState.doHartmann = ("noHartmann" not in keywords
                               and survey != sopActor.APOGEE)
        if cmdState.doCalibs:
            if "arcTime" in keywords:
                cmdState.arcTime = float(keywords["arcTime"].values[0])
            else:
                cmdState.arcTime = CmdState.getDefaultArcTime(survey)
            if "flatTime" in keywords:
                cmdState.flatTime = float(keywords["flatTime"].values[0])
            else:
                cmdState.flatTime = CmdState.getDefaultFlatTime(survey)
            if cmdState.arcTime <= 0:
                cmd.warn(
                    'text="GotoField arcTime is not a positive number: are you sure you want that?"'
                )
            if cmdState.flatTime <= 0:
                cmd.warn(
                    'text="GotoField flatTime is not a positive number: are you sure you want that?"'
                )
        if cmdState.doGuider:
            cmdState.guiderFlatTime = float(keywords["guiderFlatTime"].values[0]) \
                                      if "guiderFlatTime" in keywords else 0.5
            cmdState.guiderTime = float(keywords["guiderTime"].values[0]) \
                                  if "guiderTime" in keywords else 5
            cmdState.doGuiderFlat = cmdState.guiderFlatTime > 0
            cmdState.keepOffsets = "keepOffsets" in keywords
        else:
            cmdState.doGuiderFlat = False

        if survey == sopActor.UNKNOWN:
            cmd.warn(
                'text="No cartridge is known to be loaded; disabling guider"')
            cmdState.doGuider = False
            cmdState.doGuiderFlat = False

        if cmdState.doSlew:
            pointingInfo = sopState.models["platedb"].keyVarDict[
                "pointingInfo"]
            cmdState.ra = pointingInfo[3]
            cmdState.dec = pointingInfo[4]
            cmdState.rotang = 0.0  # Rotator angle; should always be 0.0

        if myGlobals.bypass.get(name='slewToField'):
            fakeSkyPos = SopCmd.obs2Sky(cmd, cmdState.fakeAz, cmdState.fakeAlt,
                                        cmdState.fakeRotOffset)
            cmdState.ra = fakeSkyPos[0]
            cmdState.dec = fakeSkyPos[1]
            cmdState.rotang = fakeSkyPos[2]
            cmd.warn(
                'text="Bypass slewToField is FAKING RA DEC:  %g, %g /rotang=%g"'
                % (cmdState.ra, cmdState.dec, cmdState.rotang))

        # Junk!! Must keep this in one place! Adjustment will be ugly otherwise.
        activeStages = []
        if cmdState.doSlew: activeStages.append("slew")
        if cmdState.doHartmann: activeStages.append("hartmann")
        if cmdState.doCalibs: activeStages.append("calibs")
        if cmdState.doGuider: activeStages.append("guider")
        activeStages.append('cleanup')  # we always may have to cleanup...
        cmdState.setupCommand(cmd, activeStages)

        sopState.queues[sopActor.MASTER].put(Msg.GOTO_FIELD,
                                             cmd,
                                             replyQueue=self.replyQueue,
                                             actorState=sopState,
                                             cmdState=cmdState)
Exemple #10
0
    def doBossCalibs(self, cmd):
        """Take a set of calibration frames.

        CmdArgs:
          nbias=N     - the number of biases to take. Taken first. [0]
          ndark=N     - the number of darks to take. Taken after any biases. [0]
          nflat=N     - the number of flats to take. Taken after any darks or biases. [0]
          narc=N      - the number of arcs to take. Taken after any flats, darks, or biases. [0]

          darkTime=S  - override the default dark exposure time. Default depends on survey.
          flatTime=S  - override the default flat exposure time. Default depends on survey.
          arcTime=S   - override the default arc exposure time. Default depends on survey.
          guiderFlatTime=S   - override the default guider flat exposure time.

          """

        sopState = myGlobals.actorState
        cmdState = sopState.doBossCalibs
        keywords = cmd.cmd.keywords
        if self.doing_science(sopState):
            cmd.fail(
                "text='A science exposure sequence is running -- will not take calibration frames!"
            )
            return

        if "abort" in keywords:
            self.stop_cmd(cmd, cmdState, sopState, 'doBossCalibs')
            return

        # Modify running doBossCalibs command
        if self.modifiable(cmd, cmdState):
            if "nbias" in keywords:
                cmdState.nBias = int(keywords["nbias"].values[0])
            if "ndark" in keywords:
                cmdState.nDark = int(keywords["ndark"].values[0])
            if "nflat" in keywords:
                cmdState.nFlat = int(keywords["nflat"].values[0])
            if "narc" in keywords:
                cmdState.nArc = int(keywords["narc"].values[0])

            if "darkTime" in keywords:
                cmdState.darkTime = float(keywords["darkTime"].values[0])
            if "flatTime" in keywords:
                cmdState.flatTime = float(keywords["flatTime"].values[0])
            if "guiderFlatTime" in keywords:
                cmdState.guiderFlatTime = float(
                    keywords["guiderFlatTime"].values[0])
            if "arcTime" in keywords:
                cmdState.arcTime = float(keywords["arcTime"].values[0])

            self.status(cmd,
                        threads=False,
                        finish=True,
                        oneCommand='doBossCalibs')
            return

        # Lookup the current cartridge
        survey = sopState.survey
        if survey == sopActor.APOGEE:
            cmd.fail(
                'text="current cartridge is not for BOSS or MaNGA; use bypass if you want to force calibrations"'
            )
            return

        cmdState.reinitialize(cmd)
        if 'nbias' in keywords:
            cmdState.nBias = keywords["nbias"].values[0]
        if 'ndark' in keywords:
            cmdState.nDark = keywords["ndark"].values[0]
        if 'nflat' in keywords:
            cmdState.nFlat = keywords["nflat"].values[0]
        if 'narc' in keywords:
            cmdState.nArc = keywords["narc"].values[0]

        cmdState.arcTime = keywords["arcTime"].values[0] \
                                    if "arcTime" in keywords else CmdState.getDefaultArcTime(survey)
        if 'darkTime' in keywords:
            cmdState.darkTime = keywords["darkTime"].values[0]
        cmdState.flatTime = keywords["flatTime"].values[0] \
                                     if "flatTime" in keywords else CmdState.getDefaultFlatTime(survey)
        if 'guiderFlatTime' in keywords:
            cmdState.guiderFlatTime = keywords["guiderFlatTime"].values[0]

        if cmdState.nArc + cmdState.nBias + cmdState.nDark + cmdState.nFlat == 0:
            cmd.fail(
                'text="You must take at least one arc, bias, dark, or flat exposure"'
            )
            return

        if cmdState.nDark and cmdState.darkTime <= 0:
            cmd.fail('text="darkTime must have a non-zero length"')
            return

        if cmdState.nFlat > 0 and cmdState.guiderFlatTime > 0:
            if sopState.cartridge < 0:
                cmd.warn(
                    'text="No cartridge is known to be loaded; not taking guider flats"'
                )
                cmdState.guiderFlatTime = 0

        activeStages = []
        if cmdState.nBias: activeStages.append('bias')
        if cmdState.nDark: activeStages.append('dark')
        if cmdState.nFlat: activeStages.append('flat')
        if cmdState.nArc: activeStages.append('arc')
        activeStages.append('cleanup')  # we always may have to cleanup...
        cmdState.setupCommand(cmd, activeStages)

        sopState.queues[sopActor.MASTER].put(Msg.DO_BOSS_CALIBS,
                                             cmd,
                                             replyQueue=self.replyQueue,
                                             actorState=sopState,
                                             cmdState=cmdState)
Exemple #11
0
 def test_do_boss_calibs_one_dark(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nDark = 1
     self._do_boss_calibs(4,24,0,0,cmdState)
Exemple #12
0
 def test_do_boss_calibs_two_dark(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nDark = 2
     self._do_boss_calibs(5,38,0,0,cmdState)
Exemple #13
0
 def test_do_boss_calibs_two_arc_fail_on_second_exposure(self):
     cmdState = CmdState.DoBossCalibsCmd()
     self.cmd.failOn = "boss exposure arc itime=4 noreadout"
     self.cmd.failOnCount = 2
     cmdState.nArc = 2
     self._do_boss_calibs(9,48,0,1,cmdState,didFail=True)
Exemple #14
0
 def test_do_boss_calibs_two_flat_fail_on_readout(self):
     cmdState = CmdState.DoBossCalibsCmd()
     self.cmd.failOn = "boss exposure   readout"
     cmdState.nFlat = 2
     self._do_boss_calibs(7,38,0,1,cmdState,didFail=True)
Exemple #15
0
 def test_do_boss_calibs_flat_arc_fail_on_hgcd(self):
     cmdState = CmdState.DoBossCalibsCmd()
     self.cmd.failOn = "mcp hgcd.on"
     cmdState.nFlat = 1
     cmdState.nArc = 1
     self._do_boss_calibs(7,38,0,1,cmdState,didFail=True)
Exemple #16
0
 def test_do_boss_calibs_one_dark_ffs_open(self):
     """For #371, not closing FFS for bias/dark."""
     sopTester.updateModel('mcp',TestHelper.mcpState['boss_science'])
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nDark = 1
     self._do_boss_calibs(4,24,0,0,cmdState)
Exemple #17
0
 def test_do_boss_calibs_one_flat(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nFlat = 1
     self._do_boss_calibs(7,30,0,0,cmdState)
Exemple #18
0
 def test_do_boss_calibs_two_bias(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nBias = 2
     self._do_boss_calibs(5,38,0,0,cmdState)
Exemple #19
0
 def test_do_boss_calibs_two_flat(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nFlat = 2
     self._do_boss_calibs(13,50,0,0,cmdState)
Exemple #20
0
 def test_do_boss_calibs_two_arc(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nArc = 2
     self._do_boss_calibs(12,49,0,0,cmdState)
Exemple #21
0
 def test_do_boss_calibs_one_arc(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nArc = 1
     self._do_boss_calibs(7,31,0,0,cmdState)
Exemple #22
0
 def test_do_boss_calibs_one_arc_ffs_open(self):
     sopTester.updateModel('mcp',TestHelper.mcpState['boss_science'])
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nArc = 1
     self._do_boss_calibs(9,31,0,0,cmdState)
Exemple #23
0
 def test_do_boss_calibs_one_bias(self):
     cmdState = CmdState.DoBossCalibsCmd()
     cmdState.nBias = 1
     self._do_boss_calibs(4,24,0,0,cmdState)