Created
February 25, 2019 05:55
-
-
Save tony-johnson/1f214e69c7bc7af0827ef3b8d04d5539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ccs-script | |
# | |
# A simple script for taking data with the ATS. | |
# | |
from org.lsst.ccs.scripting import * | |
from org.lsst.ccs.bus.states import AlertState | |
from optparse import OptionParser | |
from org.lsst.ccs.subsystem.rafts.fpga.compiler import FPGA2ModelBuilder | |
from java.io import File | |
import time | |
from org.lsst.ccs.utilities.image.samp import SampUtils | |
from java.io import File | |
CCS.setThrowExceptions(True) | |
# Directory where output will be written | |
dataDir = "/data/ats" | |
# Connect to subsystems | |
raftsub = CCS.attachSubsystem("ats-wreb") | |
powersub = CCS.attachSubsystem("ats-power") | |
bonnsub = CCS.attachSubsystem("bonn-shutter") | |
# Sanity checks | |
biasOn = raftsub.sendSynchCommand("isBackBiasOn") | |
if not biasOn: | |
print "WARNING: Back bias is not on for WREB" | |
alerts = raftsub.sendSynchCommand("getRaisedAlertSummary") | |
if alerts.alertState!=AlertState.NOMINAL: | |
print "WARNING: WREB subsystem is in alarm state %s" % alerts.alertState | |
print "Clearing CCD " | |
raftsub.sendSynchCommand("setSequencerStart","Clear") | |
raftsub.sendSynchCommand("startSequencer") | |
raftsub.sendSynchCommand("waitSequencerDone",30000) | |
preCols = raftsub.sendSynchCommand("getSequencerParameter","PreCols")[0] | |
readCols = raftsub.sendSynchCommand("getSequencerParameter","ReadCols")[0] | |
postCols = raftsub.sendSynchCommand("getSequencerParameter","PostCols")[0] | |
preRows = raftsub.sendSynchCommand("getSequencerParameter","PreRows")[0] | |
readRows = raftsub.sendSynchCommand("getSequencerParameter","ReadRows")[0] | |
postRows = raftsub.sendSynchCommand("getSequencerParameter","PostRows")[0] | |
scanMode = raftsub.sendSynchCommand("WREB getRegister 0x330000 1") | |
#clampMode = raftsub.sendSynchCommand("WREB getRegister 0x330001 1") | |
print "Initial sequencer parameters" | |
print "preCols=%d" % preCols | |
print "readCols=%d" % readCols | |
print "postCols=%d" % postCols | |
print "preRows=%d" % preRows | |
print "readRows=%d" % readRows | |
print "postRows=%d" % postRows | |
print "scanMode=%s" % scanMode | |
#print "clampMode=%d" % clampMode | |
# set up scan mode | |
raftsub.sendSynchCommand("setSequencerParameter","PreCols" ,155) | |
raftsub.sendSynchCommand("setSequencerParameter","ReadCols",256) | |
raftsub.sendSynchCommand("setSequencerParameter","PostCols",165) # Must add up to 576 | |
raftsub.sendSynchCommand("setSequencerParameter","PreRows" ,2) | |
raftsub.sendSynchCommand("setSequencerParameter","ReadRows",1000) | |
raftsub.sendSynchCommand("setSequencerParameter","PostRows",1046) | |
scanMode = raftsub.sendSynchCommand("WREB setRegister 0x330000 [1]") | |
# Take scan mode image | |
fname = "${imageName}_scan_mode.fits" | |
raftsub.sendSynchCommand("setFitsFileNamePattern",fname) | |
time.sleep(1.0) | |
print "Reading out" | |
raftsub.sendSynchCommand("setSequencerStart","ReadFrame") | |
imageName = raftsub.sendSynchCommand("acquireLSSTImage") | |
rc = raftsub.sendSynchCommand("waitForImage",60000) | |
if rc == 0: | |
raise Exception,"Timeout waiting for image" | |
actualDir = dataDir+"/"+imageName.getDateString() | |
result = raftsub.sendSynchCommand("saveFitsImage", actualDir) | |
print "Saved FITS image to %s/%s" % (actualDir, result[0]) | |
# Restore settings | |
raftsub.sendSynchCommand("setSequencerParameter","PreCols" ,preCols) | |
raftsub.sendSynchCommand("setSequencerParameter","ReadCols",readCols) | |
raftsub.sendSynchCommand("setSequencerParameter","PostCols",postCols) | |
raftsub.sendSynchCommand("setSequencerParameter","PreRows" ,preRows) | |
raftsub.sendSynchCommand("setSequencerParameter","ReadRows",readRows) | |
raftsub.sendSynchCommand("setSequencerParameter","PostRows",postRows) | |
scanMode = raftsub.sendSynchCommand("WREB setRegister 0x330000 [0]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment