Last active
September 12, 2018 16:41
-
-
Save tony-johnson/651e480932c1107f25c2a7e50547a838 to your computer and use it in GitHub Desktop.
Focal Plane data taking script (Conceptual)
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
from org.lsst.ccs.scripting import * | |
from org.lsst.ccs.bus.states import AlertState | |
from datetime import date | |
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 | |
from java.time import Duration | |
CCS.setThrowExceptions(True) | |
dataDir = "/data/ats/"+str(date.today()) | |
# Parse command line options | |
parser=OptionParser() | |
parser.add_option("-e","--exp",dest="expose") | |
parser.add_option("-d","--dark",dest="dark") | |
parser.add_option("-s","--sequencer",dest="sequencer") | |
parser.add_option("-9","--ds9", action="store_true", dest="ds9") | |
(options, args) = parser.parse_args() | |
exposure = float(options.expose or 2) | |
dark = float(options.dark or 0) | |
if dark>0: | |
exposure = 0 | |
fp = CCS.attachSubsystem("focal-plane-sim") | |
#powersub = CCS.attachSubsystem("ts2r") | |
#botbench = CCS.attachSubsystem("bot-bench") | |
# Sanity checks | |
#biasOn = fp.sendSynchCommand("isBackBiasOn") | |
#if not biasOn: | |
# print "WARNING: Back bias is not on" | |
alerts = fp.sendSynchCommand("getRaisedAlertSummary") | |
if alerts.alertState!=AlertState.NOMINAL: | |
print "WARNING: fo0cal-plane subsystem is in alarm state %s" % alerts.alertState | |
print "Clearing CCDs " | |
fp.sendSynchCommand("clear",1) | |
#fp.sendSynchCommand("setExposureTime",exposure) | |
if exposure>0: | |
print "Exposing for %g seconds" % exposure | |
imageName = fp.sendSynchCommand("startIntegration") | |
print "Image name: %s" % imageName | |
# botbench.sendSynchCommand("openShutter", exposure) | |
if dark>0: | |
print "Dark for %g seconds" % dark | |
fp.sendSynchCommand("startIntegration") | |
time.sleep(dark) | |
fname = "ats_dark_%g_${timestamp}.fits" % dark | |
print "Reading out" | |
fp.sendSynchCommand("endIntegration") | |
result = fp.sendSynchCommand("waitForFitsFiles", Duration.ofSeconds(30)) | |
print "Saved FITS files to %s" % result | |
if options.ds9: | |
su = SampUtils("focal-plane",True) | |
file = File("%s/%s" % (dataDir,result[0])) | |
su.display(file) | |
# Kirk's favorite ds9 options | |
su.ds9Set("scale scope local", None, 1000) | |
su.ds9Set("scale zscale", None, 1000) | |
su.ds9Set("color b", None, 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment