def updateCatalog(MJD, frameNumber, newObjects): global prevCatalog debug.write("Frame number: %d"%(frameNumber)) debug.write("Number of objects in this frame: %d"%(len(newObjects))) if len(prevCatalog)==0: #This is probably the first frame and there are currently no objects to compare to ... add them all to the catalog x = [] y = [] for o in newObjects: x.append(o['absX']) # Use the x, y values that include the Window offset y.append(o['absY']) prevCatalog = numpy.array(zip(x, y)) updateMasterCatalog(newObjects, (0, 0)) return # Create a new catalog x = [] y = [] for o in newObjects: x.append(o['absX']) y.append(o['absY']) newCatalog = numpy.array(zip(x, y)) psize = 0.5 fwhm = 4. dmax = 30. mmax = 30. (gaussImage, xp, yp, xr, yr) = ultracam_shift.vimage(prevCatalog, newCatalog, dmax, psize, fwhm) (nmatch, inds) = ultracam_shift.match(prevCatalog, newCatalog, xp, yp, mmax) prevCatalog = newCatalog offsetMag = numpy.sqrt(xr*xr + yr*yr) debug.write("Channel: " + channel + " -> Matched objects: %d Offset distance: %f"%(nmatch, offsetMag)) updateMasterCatalog(newObjects, (xr, yr)) #print inds if arg.preview: matplotlib.pyplot.figure(channel+"_gauss", figsize=(4,4)) gaussPlot = matplotlib.pyplot.imshow(gaussImage, cmap=colourMaps[channel], interpolation='nearest')
allSources = sorted(allSources, key=lambda object: object[2], reverse = True) # Remove the flux column from the source list. We don't need it anymore. tempSources = [ (x, y) for (x, y, flux) in allSources] allSources = tempSources if (applyShift): oldCatalog = numpy.array(masterApertureList) newCatalog = numpy.array(allSources) psize = 0.1 fwhm = 4. dmax = 10. mmax = 10. (gaussImage, xp, yp, xr, yr) = ultracam_shift.vimage(oldCatalog, newCatalog, dmax, psize, fwhm) debug.write("Applying offset: (%2.2f, %2.2f)"%(xr, yr), level = 3) for windowIndex, w in enumerate(windows): image = w._data allWindows[windowIndex].setData(image) if (applyShift): image = ndimage.interpolation.shift(image, (-1.0*yr, -1.0*xr), order = 4 ) allWindows[windowIndex].addToStack(image) 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)