def __init__(self, date, runName): self.runID = runName self.runDate = date config = utils.readConfigFile() runPath = utils.addPaths(config.ULTRACAMRAW, date) runPath = ultracamutils.addPaths(runPath, runName) self.totalTime = 0 runMetaData = trm.ultracam.Rhead(runPath, server=False) self.mode = runMetaData.mode #self.userData = runMetaData.user try: self.nblue = runMetaData.nblue except AttributeError: self.nblue = 1 if (self.mode != "PONOFF"): runData = trm.ultracam.Rdata(runPath, 1, server=False) self.numFrames = runData.ntotal() else: self.numFrames = 0 self.runClass = 0 self.comment = "" self.ra = 0 self.dec = 0 self.objectID = "?" self.target = "?" self.expose = 0 try: self.exposeTime = runMetaData.exposeTime except: self.exposeTime = -1 self.num = 0 self.dataProcessed = False self.numWindows = 0 self.maxExtents = [0, 0, 0, 0] self.version = 'primary'
def loadAllComments(date): """ Returns dictionary of run names and comments for a particular date """ comments = {} commentsFilename = utils.addPaths(config.ULTRACAMRAW, date) commentsFilename+= "/" + date + ".dat" commentsFile = open(commentsFilename, "r") runname_re = re.compile(r"run[0-9][0-9][0-9]") for line in commentsFile: run = line.split(' ')[0] r = runname_re.search(run) if r: comment = line[7:] comments[run] = comment commentsFile.close() return comments
arg = parser.parse_args() channelNames = [] for channelRequested in arg.channels: channelNames.append(channelRequested) colourMaps = {'r': 'Reds', 'g':'Greens', 'b':'Blues'} allObjects = { 'r': [], 'g': [], 'b':[]} config = ultracamutils.readConfigFile(arg.configfile) debug = classes.debugObject(config.DEBUG) debug.toggleTimeLog() if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel); runFilename = utils.addPaths(config.ULTRACAMRAW, arg.runname) debug.write("Opening the Ultracam raw file at: " + runFilename, level = 3) runDate, runID = ultracamutils.separateRunNameAndDate(arg.runname) runInfo = classes.runObject(runDate, runID) runInfo.version = arg.version runInfo.loadSelf(config) debug.write("Run Info:\n----------------------", level = 2) debug.write(runInfo, level = 2) debug.write("----------------------", level = 2) if arg.preview: matplotlib.pyplot.ion() fig = matplotlib.pyplot.gcf()
parser.add_argument('-C', '--channels', default='rgb', type=str, help='Which channels to run the extraction on \'rgb\'') arg = parser.parse_args() channelNames = [] for channelRequested in arg.channels: channelNames.append(channelRequested) colourMaps = {'r': 'Reds', 'g':'Greens', 'b':'Blues'} allObjects = { 'r': [], 'g': [], 'b':[]} config = ultracamutils.readConfigFile(arg.configfile) debug = classes.debugObject(config.DEBUG) debug.toggleTimeLog() if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel); runFilename = utils.addPaths(config.ULTRACAMRAW, arg.runname) debug.write("Opening the Ultracam raw file at: " + runFilename, level = 3) debug.write("Getting run info from the file:" + config.RUNINFO, level = 1) runInfo = ultracamutils.getRunInfo(config.RUNINFO, arg.runname) debug.write("Run Info:\n----------------------", level = 2) debug.write(runInfo, level = 2) debug.write("----------------------", level = 2) if arg.preview: matplotlib.pyplot.ion() fig = matplotlib.pyplot.gcf()
if (not objectRecognised): newIDNumber = utils.getUniqueID(masterObjectList) debug.write("New object detected... assigning a new ID number: %d"%newIDNumber) newObject = classes.ObservedObject(newIDNumber) newObject.addExposureByObject(ob, frameMJD) masterObjectList.append(newObject) config = utils.readConfigFile() debug = classes.debugObject(config.DEBUG) if (len(sys.argv) < 2): print "Please give me a run name." sys.exit() runName = sys.argv[1] runFilename = utils.addPaths(config.ULTRACAMRAW, runName) channel = 'r' startFrame = 1 requestedNumFrames = 10 keepTmpFiles = False frameInfo = classes.FrameObject() for i in sys.argv[2:]: if i[:2]=="-n": print "number of frames:", i[2:] framesStr = i[2:] requestedNumFrames = int(framesStr) if i[:2]=="-s": print "starting at frame:", i[2:]
# For debugging purposes, we run over a sample set of the dates, just 5 or so (sample_size) sample_size = 40 sample_start = int(random.random()*len(dates)-sample_size) sample_size = len(dates) sample_start = 0 totalRuns = 0 totalFileSize = 0 runs_re = re.compile(r'run[0-9][0-9][0-9].xml') for index in range(sample_start, sample_start+sample_size): d = dates[index] debug.write("%d/%d Processing: %s"%(index-sample_start+1, sample_size, d.date), level = 1) files = os.listdir(utils.addPaths(config.ULTRACAMRAW,d.date)) commentsList = loadAllComments(d.date) for f in files: debug.write("file: " + f) r = runs_re.search(f) if (r): runname = r.group(0)[:6] # Get the filesize (.dat) of this run runPath = utils.addPaths(config.ULTRACAMRAW,d.date) runPath = utils.addPaths(runPath, runname) runPath+= ".dat" try: totalFileSize+= os.path.getsize(runPath) except: pass # Get the observer's comments (if they exist)
for i in frameB._data: frameWindows.append(i.data) return frameWindows config = utils.readConfigFile() debug = classes.debugObject(1) debug.toggleTimeLog() if len(sys.argv) < 2: print "Please give me a run name." sys.exit() runName = sys.argv[1] runFilename = utils.addPaths(config.ULTRACAMRAW, runName) startFrame = 1 requestedNumFrames = -1 CCDside = 0 keepTmpFiles = False frameInfo = classes.FrameObject() tmpMoviePath = config.MOVIE_TMP_PATH movieFilename = utils.addPaths(config.SITE_PATH, runName) movieFilename += "movie.mp4" for i in sys.argv[2:]: if i[:2] == "-n": debug.write("command line: number of frames:" + i[2:]) framesStr = i[2:] requestedNumFrames = int(framesStr)
parser.add_argument('-p', '--preview', action='store_true', help='Show image previews with Matplotlib') parser.add_argument('-s', '--stack', action='store_true', help='Stack the images in the preview window') parser.add_argument('-c', '--configfile', default='ucambuilder.conf', help='The config file, usually ucambuilder.conf') parser.add_argument('-d', '--debuglevel', type=int, help='Debug level: 3 - verbose, 2 - normal, 1 - warnings only') parser.add_argument('--startframe', default=1, type=int, help='Start frame. \'1\' is the default') parser.add_argument('-n', '--numframes', type=int, help='Number of frames. No parameter means all frames, or from startframe to the end of the run') arg = parser.parse_args() config = ultracamutils.readConfigFile(arg.configfile) debug = classes.debugObject(config.DEBUG) debug.toggleTimeLog() if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel); runFilename = utils.addPaths(config.ULTRASPECRAW, arg.runname) debug.write("Opening the Ultraspec raw file at: " + runFilename, level = 3) runDate, runID = ultracamutils.separateRunNameAndDate(arg.runname) """ Check that the working folders and the output folders are there """ (runDate, runNumber) = ultracamutils.separateRunNameAndDate(arg.runname) workingFolder = ultracamutils.addPaths(config.WORKINGDIR, runDate) outputFolder = ultracamutils.addPaths(config.SITE_PATH, runDate) ultracamutils.createFolder(workingFolder) ultracamutils.createFolder(outputFolder) startFrame = arg.startframe
import rashley_utils as utils import sys, subprocess, re import classes config = utils.readConfigFile() if (len(sys.argv) < 2): print "Please give me a run name." sys.exit() requestedNumFrames = -1 for i in sys.argv[2:]: if i[:2]=="-n": print "number of frames:", i[2:] framesStr = i[2:] requestedNumFrames = int(framesStr) runname = sys.argv[1] runFilename = utils.addPaths(config.ULTRACAMRAW, runname) print runname, runFilename channel = ['r','g','b'] for i in channel: channelParam = "-c" + str(i) subprocess.call(["objecttracker.py", runname, "-n" + str(requestedNumFrames), channelParam])