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)
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)
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)