MJD = windows.time.mjd
		
		""" Display the status of the reduction so far
		"""
		statusString = "\r%s MJD: %5.7f Frame: [%d/%d]"%(timeLeftString, MJD, trueFrameNumber, frameRange)
		sys.stdout.write(statusString)
		sys.stdout.flush()
			
		for windowIndex, w in enumerate(windows):
			image = w._data
			allWindows[windowIndex].setData(image)
			
		if arg.preview: 
			fullFrame = numpy.zeros((fullFrameysize, fullFramexsize))	
			for w in allWindows:
				boostedImage = ultracamutils.percentiles(w.data, 20, 99)
				xll = w.xll/w.xbin - xmin
				xsize = w.nx
				yll = w.yll/w.ybin - ymin
				ysize = w.ny
				fullFrame[yll:yll+ysize, xll:xll+xsize] = fullFrame[yll:yll+ysize, xll:xll+xsize] + boostedImage
					
			
			matplotlib.pyplot.imshow(fullFrame, cmap='gray_r')
			
			for a in apertures:
				(x, y) = a.position
				matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), a.radius, color='green', fill=False, linewidth=1.0))
				matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), a.skyInnerRadius, color='blue', fill=False, linewidth=1.0))
				matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), a.skyOuterRadius, color='blue', fill=False, linewidth=1.0))
			
		sys.stdout.write(statusString)
		sys.stdout.flush()
		
		windows = ccdFrame[0]
		for windowIndex, w in enumerate(windows):
			image = w._data		
			allWindows[windowIndex].setData(image)
		
		
		if arg.preview:
			ppgplot.pgslct(bitmapView['pgplotHandle']) 
			ppgplot.pgbbuf()
			fullFrame = numpy.zeros((fullFrameysize, fullFramexsize))	
			for w in allWindows:
				if (arg.stack):
					boostedImage = ultracamutils.percentiles(w.stackedData, 20, 99)
				else:
					boostedImage = ultracamutils.percentiles(w.data, 20, 99)
				xll = w.xll/w.xbin - xmin
				xsize = w.nx
				yll = w.yll/w.ybin - ymin
				ysize = w.ny
				fullFrame[yll:yll+ysize, xll:xll+xsize] = fullFrame[yll:yll+ysize, xll:xll+xsize] + boostedImage		
			
			rows, cols  = numpy.shape(fullFrame)
			
			# Draw the grayscale bitmap
			ppgplot.pggray(fullFrame, 0, cols-1 , 0, rows-1 , 0, 255, pgPlotTransform)
	
			# Draw the full reference aperture list
			ppgplot.pgsci(3)
				xll = frameInfo.getWindow(j).xll 
				yll = frameInfo.getWindow(j).yll 
				xsize = frameInfo.getWindow(j).xsize 
				ysize = frameInfo.getWindow(j).ysize 
				#print "windowImage.shape:", windowImage.shape
				#print "assembledChannelFrame.shape:", assembledChannelFrame.shape
			
				leftPixel = xll-1
				rightPixel = xll-1+xsize
				bottomPixel = yll-1
				topPixel = yll-1+ysize
				#print "leftPixel", leftPixel
				#print "rightPixel", rightPixel
				#print "bottomPixel", bottomPixel
				#print "topPixel", topPixel
				assembledChannelFrame[leftPixel:rightPixel, bottomPixel:topPixel] = assembledChannelFrame[leftPixel:rightPixel, bottomPixel:topPixel] + ultracamutils.percentiles(windowImage, 20, 98)
				#stackedFrame[xll:xll+xsize, yll:yll+ysize] = stackedFrame[xll:xll+xsize, yll:yll+ysize] + windowImage

				for o in newObjectsinWindow:
					(windowX, windowY) = ( o['y'], o['x'] )
					(absoluteX, absoluteY) = (windowX + xll - 1, windowY + yll - 1)
					o['absX'] = absoluteX
					o['absY'] = absoluteY
					newObjects.append(o)

			if len(newObjects)>0:
				updateCatalog(wholeFrame['MJD'], frameIndex, newObjects)

			frameData.setObjectCount(channel, len(newObjects))
		
			allObjects[channel] = masterObjectList
		ccdFrame = rdat()
		frameWindows = ccdFrame[0]
		
		for windowIndex, w in enumerate(frameWindows):
			image = w._data
			allWindows[windowIndex].addData(image)
			
		
	# Reconstruct a full frame from the windows	
	if (arg.keyimages):
		stackedFigure = matplotlib.pyplot.figure(figsize=(10, 10))
		matplotlib.pyplot.title("Initial 10 frame stacked image")
	boostedFullFrame = numpy.zeros((fullFrameysize, fullFramexsize))	
	fullFrame = numpy.zeros((fullFrameysize, fullFramexsize))	
	for w in allWindows:
		boostedImage = ultracamutils.percentiles(w.stackedData, 10, 99.8)
		image = w.stackedData
		xll = w.xll/w.xbin - xmin
		xsize = w.nx
		yll = w.yll/w.ybin - ymin
		ysize = w.ny
		boostedFullFrame[yll:yll+ysize, xll:xll+xsize] = fullFrame[yll:yll+ysize, xll:xll+xsize] + boostedImage
		fullFrame[yll:yll+ysize, xll:xll+xsize] = fullFrame[yll:yll+ysize, xll:xll+xsize] + image
		
		bkg_sigma = 1.48 * mad(image)
		sources = daofind(image, fwhm=4.0, threshold=3*bkg_sigma) 
		w.setSourcesAvoidBorders(sources)	
		
		
	# Get the source list from this image
	# Combine the sources from all of the windows
示例#5
0
				tmpFilename = ultracamutils.createFITS(trueFrameNumber, j, channel, windowImage)
				catFilename = ultracamutils.runSex(tmpFilename)
				newObjectsinWindow = ultracamutils.readSexObjects(catFilename)
			
				newObjectsinWindow = ultracamutils.rejectBadObjects(newObjectsinWindow)
			
				if config.KEEP_TMP_FILES!="1":
					ultracamutils.removeTMPFile(tmpFilename)
					ultracamutils.removeTMPFile(catFilename)

				xll = frameInfo.getWindow(j).xll 
				yll = frameInfo.getWindow(j).yll 
				xsize = frameInfo.getWindow(j).xsize 
				ysize = frameInfo.getWindow(j).ysize 
			
				assembledChannelFrame[xll:xll+xsize, yll:yll+ysize] = assembledChannelFrame[xll:xll+xsize, yll:yll+ysize] + ultracamutils.percentiles(windowImage, 20, 98)
				assembledChannelFrameUnequalised[xll:xll+xsize, yll:yll+ysize] = assembledChannelFrameUnequalised[xll:xll+xsize, yll:yll+ysize] + windowImage
				#stackedFrame[xll:xll+xsize, yll:yll+ysize] = stackedFrame[xll:xll+xsize, yll:yll+ysize] + windowImage

				for o in newObjectsinWindow:
					(windowX, windowY) = ( o['y'], o['x'] )
					(absoluteX, absoluteY) = (windowX + xll - 1, windowY + yll - 1)
					o['absX'] = absoluteX
					o['absY'] = absoluteY
					newObjects.append(o)

			if len(newObjects)>0:
				updateCatalog(wholeFrame['MJD'], frameIndex, newObjects)
		
			allObjects[channel] = masterObjectList
			channelTempCatalogs[channel] = prevCatalog
			yll = w.yll/w.ybin - ymin
			sources = w.getSources()
			newSources = [(x + xll, y + yll, flux) for (x, y, flux) in sources]
			allSources+=newSources
		sourceMap.updateMap(allSources)
		
		print allSources
		sortedSources = sorted(allSources, key= lambda tup: tup[2], reverse=True)
		for s in sortedSources:
			print s[2]," : ", s[0], s[1]	
			
		if arg.preview: 
			fullFrame = numpy.zeros((fullFrameysize, fullFramexsize))	
			for w in allWindows:
				if (arg.stack):
					boostedImage = ultracamutils.percentiles(w.stackedData, 20, 99)
				else:
					boostedImage = ultracamutils.percentiles(w.data, 20, 99)
				xll = w.xll/w.xbin - xmin
				xsize = w.nx
				yll = w.yll/w.ybin - ymin
				ysize = w.ny
				fullFrame[yll:yll+ysize, xll:xll+xsize] = fullFrame[yll:yll+ysize, xll:xll+xsize] + boostedImage
					
			
			matplotlib.pyplot.imshow(fullFrame, cmap='gray')
			
			for s in allSources:
				(x, y) = s
				matplotlib.pyplot.gca().add_artist(matplotlib.pyplot.Circle((x,y), 15, color='green', fill=False, linewidth=2.0))
			
示例#7
0
	imageData = hdulist[0].data
	hdulist.close()
	
	if arg.testimage:
		imageData = matplotlib.pyplot.imread("/Users/rashley/code/utils/lena.png")
		print imageData
	
	maximumValue = numpy.max(imageData)
	minimumValue = numpy.min(imageData)
	fullRange = maximumValue - minimumValue
	imageData = imageData/ fullRange * 255.0
	print imageData
	
	originalFigure = matplotlib.pyplot.figure(figsize=(10, 10))
	matplotlib.pyplot.title("Original image")
	boostedImageData = ultracamutils.percentiles(imageData, 10, 99.8)	
	
	imagePlot = matplotlib.pyplot.imshow(boostedImageData, cmap='gray')
	
	#matplotlib.pyplot.gca().invert_yaxis()			
	matplotlib.pyplot.show(block=False)
	
	freqData = fftpack.fft2(imageData)
	
	transformFigure = matplotlib.pyplot.figure(figsize=(10, 10))
	matplotlib.pyplot.title("FFT image")
	
	magnitudes = numpy.absolute(freqData)
	"""print freqData
	print magnitudes
	maximumValue = numpy.max(magnitudes)