def centroidFunc(): # Display the Object Image "Open the object image and display using DS9" numdisplay.display(objectImage) normalizedObject = modify(flatImage) image = noise(normalizedObject) # Bright Pixel "Get bright pixel location" xPos = input("Please enter the x value for the location of the bright pixel: ") yPos = input("Please enter the y value for the location of the bright pixel: ") print "The radius corresponds to the numer of points to be used in the calculation i.e. 1->9 and 3->49" radius = input("Please enter the radius for the location of the bright pixel: ") brightLoc = image[yPos - radius - 1 : yPos + radius, xPos - radius - 1 : xPos + radius] # Find Centroid "Call Centroid Function to locate the given centroid" centroidArray = calcCentroid(brightLoc) centroid = (xPos + centroidArray[0], yPos + centroidArray[1]) uncertainty = centroidArray[2] # Output print "The centroid of the object is: " + str(centroid) print "The uncertainty of the calculation is: " + str(uncertainty) "Give choice for a visual" choice = raw_input("Would you like to see a visual (Y/N)? ") if choice == "y" or choice == "Y" or choice == "Yes" or choice == "yes": visualFunc(brightLoc, centroidArray[0], centroidArray[1], uncertainty) else: print "Goodbye!"
def centroidFunc(): # -- Display the Object Image -- # #Open the object image and display using DS9 numdisplay.display(objectImage) image = noise(objectImage) choice = raw_input( "Would you like to create an output centroid file (Y/N)? ") outputChoice = False fileOut = None if choice == "y" or choice == "Y" or choice == "Yes" or choice == "yes": fileName3 = raw_input("Please enter file name of centroid outputs: ") fileOut = open(fileName3 + ".txt", "w") fileOut.write("Centroid Report\n\n") outputChoice = True choice2 = raw_input( "Would you like to import search data from a file (Y/N)? ") if choice2 == "y" or choice2 == "Y" or choice2 == "Yes" or choice2 == "yes": centroidProcess2(image, outputChoice, fileOut) else: centroidProcess1(image, outputChoice, fileOut, True) if outputChoice == True: fileOut.close()
def centroidFunc( ): # -- Display the Object Image -- # #Open the object image and display using DS9 numdisplay.display(objectImage) image = noise( objectImage ) choice = raw_input("Would you like to create an output centroid file (Y/N)? ") outputChoice = False fileOut = None if choice == "y" or choice == "Y" or choice == "Yes" or choice == "yes": fileName3 = raw_input("Please enter file name of centroid outputs: ") fileOut = open(fileName3 + ".txt", "w" ) fileOut.write( "Centroid Report\n\n" ) outputChoice = True choice2 = raw_input("Would you like to import search data from a file (Y/N)? ") if choice2 == "y" or choice2 == "Y" or choice2 == "Yes" or choice2 == "yes": centroidProcess2( image, outputChoice, fileOut ) else: centroidProcess1( image, outputChoice, fileOut, True ) if outputChoice == True: fileOut.close()
def array2ds9(array, frame=1, name=None, zscale=False): ds9frame = frame % 16 try: numdisplay.display(array.transpose(), z1=array.min(), z2=array.min(), name=name, frame=ds9frame, zscale=zscale, quiet=True) except IOError: import os, time os.system('ds9 &') while True: try: numdisplay.display(array.transpose(), z1=array.min(), z2=array.min(), name=name, frame=ds9frame, zscale=zscale, quiet=True) except IOError: time.sleep(0.5) else: break
def open_in_ds9(self, field, take_log=True): """ This will open a given field in DS9. This requires the *numdisplay* package, which is a simple download from STSci. Furthermore, it presupposed that it can connect to DS9 -- that is, that DS9 is already open. """ import numdisplay numdisplay.open() if take_log: data = na.log10(self[field]) else: data = self[field] numdisplay.display(data)
def process(obj,flat): #Normalize with respect to flat file obj_img=pyfits.getdata(obj) numdisplay.display(obj_img,z1=2000,z2=40000) flat_img=pyfits.getdata(flat) flat_img=flat_img/flat_img.mean() obj_img=obj_img/flat_img x_c=input("Enter x coordinate of asteroid: ") y_c=input("Enter y coordinate of asteroid: ") #Subtract background noise obj_img=obj_img-background_noise(obj_img,x_c,y_c) obj_img[where(obj_img<0)]=0 numdisplay.display(obj_img,z1=100,z2=400) #Computes centroid n=input("Radius of asteroid-field: ") center=centroid(obj_img[y_c-1-n:y_c-1+n+1,x_c-1-n:x_c-1+n+1]) obj_img*=0.1 x=round(x_c+center[0][0]) y=round(y_c+center[1][0]) obj_img[y-3:y+3,x-3:x+3]=20000 numdisplay.display(obj_img,z1=100,z2=10000) return [[x_c+center[0][0],center[0][1]],[y_c+center[1][0],center[1][1]]]
import pyfits import numdisplay from numpy import * filename = "file" xcentre = 500 ycentre = 500 radlimit = 50 imdata = pyfits.getdata(filename) y, x = indices(imdata.shape, dtype=float32) x = x - xcentre y = y - ycentre radius = sqrt(x**2 + y**2) mask = radius < radlimit flux = (mask*im).sum() numdisplay.display(mask*im)
if not os.path.isfile(file): print file,' is not a file.' exit(1) file = file if file.endswith('.ucm') else file + '.ucm' ucm = ucm.rucm(file) print 'read ucm file' if len(sys.argv) < 3 and len(ucm.data) > 1: nccd = int(raw_input('CCD number to display: ')) elif len(ucm.data) > 1: nccd = int(sys.argv[2]) else: nccd = 1 xbin = ucm.xbin ybin = ucm.ybin image = npy.zeros((ucm.nxtot//xbin,ucm.nytot//ybin)) for i in range(len(ucm.data[nccd-1])): win = ucm.data[nccd-1][i] (llx,lly) = ucm.off[nccd-1][i] x1 = (llx-1)/xbin+1 y1 = (lly-1)/ybin+1 image[y1:y1+win.shape[0],x1:x1+win.shape[1]] = win ndpy.display(image)
#!/usr/bin/env python import numdisplay, numpy import astropy.io.fits as pyfits fitsobj=pyfits.open('ned_test.fits',"readonly") pix=fitsobj[0].data numdisplay.display(pix,z1=5.,z2=25.)
def flatten(obj_img,flat_img): numdisplay.display(obj_img,z1=0,z2=400) flat_img=flat_img/flat_img.mean() obj_img=obj_img/flat_img return obj_img
def display(*args, **kwargs): numdisplay.display(*args, **kwargs)