Ejemplo n.º 1
0
	def writeSelf(self, configData):
		""" Writes itself to a JSON file in the web folder 
		"""
		filename = ultracamutils.addPaths(configData.SITE_PATH, self.runDate)
		filename = ultracamutils.addPaths(filename, self.runID)
		if self.version!='primary': filename+= "_" + str(self.version);
		filename+= "_info.json"
		print "Updating runinfo in file: ", filename
		
		outputObject = {}
		outputObject["target"] = self.target
		outputObject["date"] = self.runDate
		outputObject["runID"] = self.runID
		outputObject["comment"] = self.comment
		outputObject["ra"] = self.ra
		outputObject["dec"] = self.dec
		outputObject["expose"] = self.expose
		outputObject["objectID"] = self.objectID
		outputObject["dataProcessed"] = self.dataProcessed
		outputObject['numWindows'] = self.numWindows
		outputObject['maxExtents'] = self.maxExtents
		
		if hasattr(self, 'sexMagnitude'):
			outputObject['sexMagnitude'] = self.sexMagnitude
			
		if hasattr(self, 'sexOptions'):
			outputObject['sexOptions'] = self.sexOptions
		
		JSONfile = open(filename, 'w')
		json.dump(outputObject, JSONfile)
		JSONfile.close()
Ejemplo n.º 2
0
	def checkForComments(self, rawDataPath):
		""" Does a check for comments in the DDDD-MM-YY.dat file in the raw data path
		"""
		filename = ultracamutils.addPaths(rawDataPath, self.runDate)
		filename = ultracamutils.addPaths(filename, self.runDate) + '.dat'
		dataFile = open(filename, 'r')
		
		for line in dataFile:
			runIdentifier = line[:6]
			if (runIdentifier==self.runID):
				self.comment = line[7:]
Ejemplo n.º 3
0
	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'
Ejemplo n.º 4
0
	def loadFromXML(self, rawDataDirectory):
		""" This method is called upon if the loadFromJSON method fails to return any data
		"""
		print "Trying to load run info from the XML file"
		XMLFilename = ultracamutils.addPaths(rawDataDirectory, self.runPath) + ".xml"
		print XMLFilename
		try:
			tree = ElementTree.parse(XMLFilename)
		except IOError as e:
			print "Could not get read the run's XML file."
			return False
		
		root = tree.getroot()
		user = root.find('user')
		target = user.find('target').text
		PI = user.find('PI').text
		ID = user.find('ID').text
		observers = user.find('Observers').text
		raStr = user.find('RA').text
		decStr = user.find('Dec').text
		ra, dec = ultracamutils.fromSexagesimal(raStr, decStr)
		print "Target:", target
		print "PI: %s Observers: %s  Programme: %s"%(PI, observers, ID)
		print "(ra, dec): (%f, %f)"%(ra, dec)
		
		self.ra = ra
		self.dec = dec
		self.target = target
		
		return True
Ejemplo n.º 5
0
	def loadSelf(self, configData):
		""" Checks to see if a saved file exists that contains info for this run. Loads it into this object.
		"""
		filename = ultracamutils.addPaths(configData.SITE_PATH, self.runDate)
		filename = ultracamutils.addPaths(filename, self.runID)
		if (self.version!='primary'): filename+= "_" + str(self.version)
		filename+= "_info.json"
		print "Trying to load myself from a file.", filename
		if os.path.exists(filename):
			JSONfile = open(filename, "r")
			wholeFileString = JSONfile.read()
			parsedObject = json.loads(wholeFileString)
			for key in parsedObject.keys():
				print "Setting property:", key, parsedObject[key]
				setattr(self,key,parsedObject[key])
		else: 
			print "Not found... falling back to ultra.json"
			self.mergeULTRAJSON(configData.RUNINFO)
	debug = classes.debugObject(config.DEBUG)
	debug.toggleTimeLog()
	if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel);
	debug.write(arg, level = 2)
	debug.write("Astropy version %s"%(astropy.__version__), level = 3)
	
	
	runInfo = ultraspecClasses.runInfo(arg.runname)
	found = runInfo.loadFromJSON(config.RUNINFO)
	if not found:
		debug.write("Could not get info for this run from the ultra.json file.", level = 1)
		xmlRead = runInfo.loadFromXML(config.ULTRASPECRAW)
		
	debug.write(runInfo, 2)
		
	runFilename = ultracamutils.addPaths(config.ULTRASPECRAW, arg.runname)

	debug.write("Opening the Ultraspec raw file at: " + runFilename, level = 2)
	
	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)
	ultracamutils.createFolder(workingFolder)
	
	startFrame = arg.startframe
	if startFrame<1:
		debug.error("startframe cannot be less than 1")
Ejemplo n.º 7
0
	
	channels = ['r', 'g', 'b']
	channelDescriptions = {'r':'Red', 'g':'Green', 'b':'Blue'}
	
		
	""" Read info about the run to get the starting RA and DEC coordinates
	"""
	debug.write("Getting run info from the file:" + config.RUNINFO, level = 2)
	runInfo = ultracamutils.getRunInfo(config.RUNINFO, arg.runname)
	
	debug.write("Run Info:\n----------------------", level = 2)
	debug.write(runInfo, level = 2)
	debug.write("----------------------", level = 2)

	
	jsonFilename = ultracamutils.addPaths(config.SITE_PATH, arg.runname) + "_objects.json"
	
	JSONfile = open(jsonFilename, "r")

	wholeFileString = JSONfile.read()

	allObjectsJSON = json.loads(wholeFileString)

	objects = []

	for i in allObjectsJSON:
		ob = json.loads(i)
		object = {}
		object['id'] = ob['id']
		colourIDs = ob['colourID']
		object['colourID'] = colourIDs
Ejemplo n.º 8
0
	runInfo.loadSelf(config)
	# runInfo = ultracamutils.getRunInfo(config.RUNINFO, arg.runname)
	
	debug.write("Run Info:\n----------------------", level = 2)
	debug.write(runInfo, level = 2)
	debug.write("----------------------", level = 2)

	channels = ['r', 'g', 'b']
	channelDescriptions = {'r': "Red", 'g': "Green", 'b': "Blue"}
	allObjects = {'r': [], 'g':[], 'b':[]}
	pixelMatch = False      # This is set to True if we don't have a WCS solution and need to use pixel locations for matching
	colours = ['r', 'g', 'b']
	
	""" Load the information about the frames
	"""
	jsonFilename = ultracamutils.addPaths(config.SITE_PATH, runName) + "_frameInfo.json"
	if (arg.version!='primary'):
		jsonFilename = ultracamutils.addPaths(config.SITE_PATH, runName) + "_" + str(arg.version) + "_frameInfo.json"

	debug.write("Loading frame info from %s"%(jsonFilename), level = 2)
	jsonFile = open(jsonFilename, 'r')
	jsonObjects = json.loads(jsonFile.read())
	
	frameData = []
	
	for j in jsonObjects:
		object = json.loads(j)
		frame = ucamObjectClass.frameObject()
		frame.setFromObject(object)
		frameData.append(frame)
Ejemplo n.º 9
0
			yll = frameInfo.getWindow(j).yll 
			xsize = frameInfo.getWindow(j).xsize 
			ysize = frameInfo.getWindow(j).ysize 
			fullImage[xll:xll+xsize, yll:yll+ysize] = fullImage[xll:xll+xsize, yll:yll+ysize] + ultracamutils.percentiles(windowImage, 20, 98)
			
		fullImage = numpy.fliplr(fullImage)
		imgData = fullImage
		imgSize = numpy.shape(imgData)
		imgLength = imgSize[0] * imgSize[1]
		testData = numpy.reshape(imgData, imgLength, order="F")
		img = Image.new("L", imgSize)
		img.putdata(testData)
		rgbImage[channel] = img

	colourImage = Image.merge("RGB", (rgbImage['r'],rgbImage['g'],rgbImage['b']))	
	imageFilename = ultracamutils.addPaths(config.SITE_PATH,runIdent) + "_colour.png"
	debug.write("Writing PNG file: " + imageFilename) 
	colourImage.save(imageFilename, "PNG")

	""" Write the normalised stacked images to individual FITS files.
	"""
	for channel in channelNames:
		runIdent = arg.runname
		imageFilename = utils.addPaths(config.SITE_PATH,runIdent) + "_" + channel + "_n.fits"
		stackedImage = stackedImages[channel]
		fullImage =  numpy.zeros((frameInfo.nxmax, frameInfo.nymax))
		for j in range(frameInfo.numWindows):
			windowImage = stackedImage.getWindow(j)
			xll = frameInfo.getWindow(j).xll 
			yll = frameInfo.getWindow(j).yll 
			xsize = frameInfo.getWindow(j).xsize 
Ejemplo n.º 10
0
	debug.write("Getting run info from the file:" + config.RUNINFO, level = 2)
	runInfo = ultracamutils.getRunInfo(config.RUNINFO, arg.runname)
	
	debug.write("Run Info:\n----------------------", level = 2)
	debug.write(runInfo, level = 2)
	debug.write("----------------------", level = 2)

	channels = ['r', 'g', 'b']
	channelDescriptions = {'r': "Red", 'g': "Green", 'b': "Blue"}
	allObjects = {'r': [], 'g':[], 'b':[]}
	pixelMatch = False      # This is set to True if we don't have a WCS solution and need to use pixel locations for matching
	
	""" Load the objects from the .json files.... channel by channel (r, g, b)
	"""
	for c in channels:
		jsonFilename = ultracamutils.addPaths(config.SITE_PATH, runName) + "_" + c + ".json"	
		debug.write("Loading the json file for the %s objects from path: %s"%(channelDescriptions[c], jsonFilename), level = 2)
		objects = ultracamutils.buildObjectsFromJSON(jsonFilename)
		allObjects[c] = objects
		debug.write("%d %s objects loaded."%(len(allObjects[c]), channelDescriptions[c]), level = 2)
		
	""" Look for and load WCS solutions for each colour (if they exist)
	"""
	for c in channels:
		wcsSolutionFilename = ultracamutils.addPaths(config.WORKINGDIR, runName) + "_" + c + ".wcs"
		if os.path.exists(wcsSolutionFilename):
			debug.write("There is a WCS solution for channel: %s"%(channelDescriptions[c]), level = 2)
			wcsParametersFile = astropy.io.fits.open(wcsSolutionFilename)
			header = wcsParametersFile[0].header
			wcs = wcsclasses.wcsSolution()
			
Ejemplo n.º 11
0
	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')
	parser.add_argument('-t', '--sleep', default=0, type=int, help='Sleep time (in seconds) between frames. \'0\' is the default')
	parser.add_argument('-o', default = 0, type=int, help = "Only plot photometry for the top [o] objects.")
	
	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 = ultracamutils.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)
	
	""" Load the apertures from an existing aperture file
Ejemplo n.º 12
0
	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()
		
	""" 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
	if startFrame<1:
		debug.error("startframe cannot be less than 1")
		sys.exit()

	rdat  = ultracam.Rdata(runFilename, startFrame, server=False)

	maximumFrames = rdat.ntotal()
	if startFrame>maximumFrames:
		debug.error("startframe " + str(startFrame) + ", is beyond the end of the run, which has only " + str(maximumFrames) + " frames in it.")
		sys.exit()
Ejemplo n.º 13
0
	debug.write("----------------------", level = 2)
	
	runDuration = ultracamutils.writeFriendlyTimeMinutes(runInfo.expose)
	debug.write("Approx run time: %s"%(runDuration), level =2)
	
	# Read the template file using the environment object.
	# This also constructs our Template object.
	template = templateEnv.get_template(config.RUNTEMPLATE)
	
	# Specify any input variables to the template as a dictionary.
	templateVars = { 	"runName" : runID, 
						"date" : date, 
						"comments" : runInfo.comment,
						"object" : runInfo.target,
						"duration" : runDuration,
						"version" : runInfo.version }
	
	outputFilename = ultracamutils.addPaths(config.SITE_PATH, arg.runname)
	if arg.version!='primary':
		outputFilename+="_" + str(arg.version)
	outputFilename+= ".html"
	
	debug.write("Writing HTML file to: %s"%(outputFilename))
	
	outFile = open(outputFilename, "w")
	outFile.write(template.render(templateVars))
	outFile.close()
	
	
	
Ejemplo n.º 14
0
	channelDescriptions = {'r':'Red', 'g':'Green', 'b':'Blue'}
	
		
	""" Read info about the run to get the starting RA and DEC coordinates
	"""
	debug.write("Getting run info from the file:" + config.RUNINFO, level = 2)
	runInfo = ultracamutils.getRunInfo(config.RUNINFO, arg.runname)
	
	debug.write("Run Info:\n----------------------", level = 2)
	debug.write(runInfo, level = 2)
	debug.write("----------------------", level = 2)

	solved = [False, False, False]
	for n,c in enumerate(channels):
		# Check that there is a solution for each channel
		solvedFileMarker = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + '_' + c + ".solved"
		if os.path.exists(solvedFileMarker):
			solved[n] = True
	print solved
	if solved[0] & solved[1] & solved[2]:
		print "All solved!"

	
	""" Load the fits files of the wcs solutions
	"""
	wcsSolutions = {'r': None, 'g': None, 'b': None }
	for n,c in enumerate(channels):
		if solved[n]:
			wcsFilename = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + '_' + c + ".wcs"
			wcsJSONFilename = ultracamutils.addPaths(config.SITE_PATH, arg.runname) + '_' + c + "_wcs.json"
			wcsFile = astropy.io.fits.open(wcsFilename)
Ejemplo n.º 15
0
	runInfo.version = arg.version
	runInfo.loadSelf(config)
	
	debug.write("Run Info:\n----------------------", level = 2)
	debug.write(runInfo, level = 2)
	debug.write("----------------------", level = 2)

	channels = ['r', 'g', 'b']
	channelDescriptions = {'r': "Red", 'g': "Green", 'b': "Blue"}
	allObjects = {'r': [], 'g':[], 'b':[]}
	
	""" Load the objects from the .json files.... channel by channel (r, g, b)
	"""
	for c in channels:
		debug.write("Loading the json file for the %s objects."%(channelDescriptions[c]), level = 2)
		jsonFilename = ultracamutils.addPaths(config.WORKINGDIR, runName) + "_" + c + "_raw.json"
		if (arg.version!='primary'):
			jsonFilename = ultracamutils.addPaths(config.WORKINGDIR, runName) + "_" + c + "_" + str(arg.version) + "_raw.json"
				
		objects = ultracamutils.buildObjectsFromJSON(jsonFilename)
		allObjects[c] = objects
		debug.write("%d %s objects loaded."%(len(allObjects[c]), channelDescriptions[c]), level = 2)
	
	
	""" Do some filtering of the objects
	"""
	for c in channels:
			objects = allObjects[c]
			beforeCount = len(objects)
			objects = ultracamutils.filterOutCosmicRays(objects)
			allObjects[c] = objects
Ejemplo n.º 16
0
	parser.add_argument('-f', '--forcesolve', action='store_true', help='Force a "solve" even if we already have a solution')
	parser.add_argument('-p', '--preview', action='store_true', help='Show a preview of the check plots.')
	parser.add_argument('-v', '--version', default='primary', help="Optional version string.")

	arg = parser.parse_args()

	config = ultracamutils.readConfigFile(arg.configfile)
	debug = classes.debugObject(config.DEBUG)
	debug.toggleTimeLog()
	if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel);

	""" First check if a directory is made for the output files in the working director folder. and create one. 
	"""
	runDate, runNumber = ultracamutils.separateRunNameAndDate(arg.runname)
	
	outputDirectory = ultracamutils.addPaths(config.WORKINGDIR, runDate)
	
	if not os.path.exists(outputDirectory):
		debug.write("Creating the directory: " + outputDirectory, level = 2)
		os.mkdir(outputDirectory)

	
	""" Produce a 'preview plot' of the catalogs and the png files 
	"""
	channels = ['r', 'g', 'b']
	channelDescriptions = {'r':'Red', 'g':'Green', 'b':'Blue'}
	for c in channels:
		pngFile = ultracamutils.addPaths(config.SITE_PATH, arg.runname) + '_' + c + ".png"
		xylsFile = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + '_' + c + ".xyls"
		checkplotFile = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + '_' + c + "_preview.png"
Ejemplo n.º 17
0
    def loadFromXML(self, rawDataDirectory):
        """ This method is called upon if the loadFromJSON method fails to return any data
		"""
        XMLFilename = ultracamutils.addPaths(rawDataDirectory, self.runPath) + ".xml"
        try:
            tree = ElementTree.parse(XMLFilename)
        except IOError as e:
            print "Could not get read the run's XML file at:", XMLFilename
            return False

        root = tree.getroot()
        # Read the window sizes and binning, etc
        filesave = root.find("filesave_status")
        instrument = filesave.find("instrument_status")
        detector = instrument.find("detector_status")

        powerToDetector = detector.attrib["power"]
        if powerToDetector == "OFF":
            self.powerCycle = True
            return True

        parameter = instrument.findall("parameter_status")
        parameters = {}
        for param in parameter:
            parameters[param.attrib["name"]] = param.attrib["value"]
        if parameters.has_key("COM_TAB_START"):
            self.powerCycle = True
            return True

        windows = []
        xbin = int(parameters["X_BIN"])
        ybin = int(parameters["Y_BIN"])
        for number in range(1, 5):
            try:
                xStartStr = "X%d_START" % number
                xStart = int(parameters[xStartStr])
                yStartStr = "Y%d_START" % number
                yStart = int(parameters[yStartStr])
                xSizeStr = "X%d_SIZE" % number
                xSize = int(parameters[xSizeStr])
                ySizeStr = "Y%d_SIZE" % number
                ySize = int(parameters[ySizeStr])
            except KeyError:
                continue
            if xSize != 0 and ySize != 0:
                # Add this to the list of windows
                windowDict = {}
                windowDict["xll"] = xStart
                windowDict["nx"] = xSize
                windowDict["yll"] = yStart
                windowDict["ny"] = ySize
                windowDict["xbin"] = xbin
                windowDict["ybin"] = ybin
                windows.append(windowDict)
        self.windowInfo = windows

        # Get the observation meta-data
        user = root.find("user")
        target = user.find("target").text
        flags = user.find("flags").text
        PI = user.find("PI").text
        ID = user.find("ID").text
        observers = user.find("Observers").text
        try:
            raStr = user.find("RA").text
            decStr = user.find("Dec").text
            ra, dec = ultracamutils.fromSexagesimal(raStr, decStr)
        except AttributeError:
            ra, dec = (0, 0)
            # print "Target:", target
            # print "PI: %s Observers: %s  Programme: %s"%(PI, observers, ID)
            # print "(ra, dec): (%f, %f)"%(ra, dec)

        self.ra = ra
        self.dec = dec
        self.target = target
        self.flags = flags

        return True
Ejemplo n.º 18
0
	runInfo = ultraspecClasses.runInfo(arg.runname)
	runInfo.loadFromJSON(config.RUNINFO)
	
	debug.write(runInfo, 2)
	
	coordinates = (runInfo.ra, runInfo.dec)
	debug.write(coordinates, 2)
	debug.write(ultracamutils.toSexagesimal(coordinates), 2)
		
	runDate, runID = ultracamutils.separateRunNameAndDate(arg.runname)
	
	""" Check that the stacked image is available
	"""
	(runDate, runNumber) = ultracamutils.separateRunNameAndDate(arg.runname)
	
	workingFolder = ultracamutils.addPaths(config.WORKINGDIR, runDate)
	
	stackedImageFilename = workingFolder + '/' + runNumber + ".png"
	if os.path.isfile(stackedImageFilename):
		print "Found - ", stackedImageFilename 
	else: 
		print "No stacked image found at:", stackedImageFilename
		
	solutionOutputFile = workingFolder + '/' + runNumber + "_wcs_solution.fits"
	FITSSolutionOutputFile = workingFolder + '/' + runNumber + "_wcs_solved_image.fits"
	# Run astrometryClient
	astrometryCommand = ['astrometryClient.py']
	astrometryCommand.append("-kpadlqljoevlogqik")
	astrometryCommand.append("-u" + stackedImageFilename)
	astrometryCommand.append("--wcs=" + solutionOutputFile)
	astrometryCommand.append("--wcsfits=" + FITSSolutionOutputFile)
Ejemplo n.º 19
0
    arg = parser.parse_args()

    config = ultracamutils.readConfigFile(arg.configfile)
    debug = classes.debugObject(config.DEBUG)
    debug.toggleTimeLog()
    if arg.debuglevel != None:
        debug.setLevel(arg.debuglevel)

    if arg.numframes != None:
        numFrames = arg.numframes

    """ First check if a directory is made for the output files in the ucamsite folder. and create one. 
	"""
    runDate, runNumber = ultracamutils.separateRunNameAndDate(arg.runname)

    outputDirectory = ultracamutils.addPaths(config.SITE_PATH, runDate)

    if not os.path.exists(outputDirectory):
        debug.write("Creating the directory: " + outputDirectory)
        os.mkdir(outputDirectory)

    print arg

    # Run OBJECTDBCREATOR
    objectdbcreatorCommand = ["objectdbcreator.py"]
    objectdbcreatorCommand.append(arg.runname)
    dString = "-d" + str(arg.debuglevel)
    objectdbcreatorCommand.append(dString)
    if arg.numframes != None:
        objectdbcreatorCommand.append("-n" + str(arg.numframes))
    if arg.version != "primary":
Ejemplo n.º 20
0
	parser.add_argument('-r', '--buildruns', action='store_true', help='Build the run output for each run (if no existing output found)')
	parser.add_argument('-f', '--forcebuildruns', action='store_true', help='Force build of each run (even if existing data is found)')
	arg = parser.parse_args()

	config = ultracamutils.readConfigFile(arg.configfile)
	debug = classes.debugObject(config.DEBUG)
	debug.toggleTimeLog()
	if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel);

	if arg.numframes!=None:
		numFrames = arg.numframes

	""" First check if a directory for the output files exists in the ucamsite folder and if not, create one. 
	"""
	
	outputDirectory = ultracamutils.addPaths(config.SITE_PATH, arg.date)
	
	if not os.path.exists(outputDirectory):
		debug.write("Creating the directory: " + outputDirectory)
		os.mkdir(outputDirectory)
		
	debug.write("Arguments: " + str(arg))

	""" Get a list of all of the .dat files in the folder. This is going to be our list of 'runs'
	"""
	
	path = ultracamutils.addPaths(config.ULTRACAMRAW, arg.date)

	filer = subprocess.Popen(["ls", str(path)], stdout = subprocess.PIPE)

	fileList = filer.communicate()[0].split('\n')
Ejemplo n.º 21
0
	innerSkyRadius = float(config.INNER_SKY)
	outerSkyRadius = float(config.OUTER_SKY)
	apertureRadius = float(config.APERTURE_RADIUS)
	polynomialDegree = int(config.POLY_DEGREE)
	numReferenceApertures = int(config.REF_APERTURES)
	if arg.apertures!=None: numReferenceApertures = arg.apertures
	applyShift = True
	if (arg.noshift):
		applyShift = False
	debug = classes.debugObject(config.DEBUG)
	debug.toggleTimeLog()
	if (arg.debuglevel!=None): debug.setLevel(arg.debuglevel);
	debug.write(arg, level = 2)
	debug.write("Astropy version %s"%(astropy.__version__), level = 3)
	
	sourcesFilename = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + "_sources.csv"
	debug.write("Loading source list from: " + sourcesFilename, 2)	
	sourceList = ultraspecClasses.sourceList()
	success = sourceList.loadFromCSV(sourcesFilename)
	if (not success):
		debug.error("Unable to open the list of sources. Have you run uspecCreateSourceMap yet?")
		sys.exit()
	else:
		debug.write("Loaded %d sources from the CSV file."%sourceList.getNumSources(), 2)
	referenceApertures = ultraspecClasses.referenceApertures()
	referenceApertures.initFromSourceList(sourceList, max=numReferenceApertures)
	debug.write("Number of reference apertures we are going to use is %d."%len(referenceApertures.sources), 2)
	
	margins = 10
	
	runInfo = ultraspecClasses.runInfo(arg.runname)
Ejemplo n.º 22
0
	print "sourceMap mean:", numpy.mean(smoothedSourceMap)
	print "sourceMap max:", numpy.max(smoothedSourceMap)
	threshold = frameRange/100.
	print "threshold:", threshold
	apertureSources = daofind(smoothedSourceMap, fwhm=4.0, threshold=threshold)   
	
	# Draw the source map 
	sourceMapImage = matplotlib.pyplot.figure(figsize=(10, 10))
	matplotlib.pyplot.title("Source map")
	matplotlib.pyplot.imshow(smoothedSourceMap, cmap='hot')
	for s in apertureSources:
		x, y = s['xcentroid'], s['ycentroid']
		matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), 10, color='green', fill=False, linewidth=1.0))
	matplotlib.pyplot.gca().invert_yaxis()			
	#matplotlib.pyplot.show(block=False)
	outputFilename = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + "_sourcemap.png"
	matplotlib.pyplot.savefig(outputFilename)

	# Draw the source map with no apertures
	sourceMapImage = matplotlib.pyplot.figure(figsize=(10, 10))
	matplotlib.pyplot.title("Source map")
	matplotlib.pyplot.imshow(smoothedSourceMap, cmap='hot')
	matplotlib.pyplot.gca().invert_yaxis()
	outputFilename = ultracamutils.addPaths(config.WORKINGDIR, arg.runname) + "_sourcemap_clean.png"
	matplotlib.pyplot.savefig(outputFilename)


	# Write the XYLS FITS file
	if (arg.xyls):
		IDs = []
		x_values = []