def plotfind(findata, ftype="pdf"): """ plot just the data from the stellar locations file """ outfile = findata + "." + ftype #read the ascii table into an astropy.table reader = ascii.Daophot() photfile = reader.read(findata) #remove the points that had issues noerror = np.where(photfile[:]['PERROR'] == 'NoError') goodphot = photfile[good[0][:]] indef = np.where(goodphot["MAG"] != "INDEF") phot = goodphot[indef[0][:]] plt.figure(figsize=(8, 10)) #this is in inches plt.title('Total Stars Detected %i' % (len(phot))) mag = phot["MAG"].astype(np.float) merr = phot["MERR"].astype(np.float) #plots from the finder program #sharpness histogram from the detection file plt.subplot(222) plt.xlabel('Sharpness') plt.ylabel('Number') hist, bins, p = plt.hist(sharp, 10, normed=False) plt.title('Detection Types', {'fontsize': 10}) #plt.legend(['Stars','Blends','Blemish'],loc='upper left') delta = max(hist) / len(bins) yy = max(hist) - delta plt.text(bins[0], yy, 'Stars at zero', {'color': 'black', 'fontsize': 10}) plt.text(bins[0], yy - delta * 1.5, 'Blends Positive', { 'color': 'black', 'fontsize': 10 }) plt.text(bins[0], yy - delta * 2.5, 'Blemish Negative', { 'color': 'black', 'fontsize': 10 }) #chi relation plt.subplot(224) plt.xlabel('chi') plt.ylabel('mag') #plt.hist(chi<2,10,normed=False) u = np.where(sharp < 1.5) uu = np.where(sharp[u] > 0.5) schi = chi[uu] smag = mag[uu] plt.plot(schi, smag, 'bx') plt.xlim(0, 2) plt.title('CHI-ball for stars (0.5<sharp>1.5)', {'fontsize': 10}) plt.savefig(outfile) return ofile
def plotphot(photdata, ftype="pdf"): """ neato phot plots from the output files use the astropy library to read the input files make sure you have astropy0.2 or later installed or it might fail to read correctly """ print photdata outfile = photdata + "." + ftype #read the ascii table into an astropy.table reader = ascii.Daophot() photfile = reader.read(photdata) #remove the points that had issues noerror = np.where(photfile[:]['PERROR'] == 'NoError') goodphot = photfile[noerror[0][:]] indef = np.where(goodphot["MAG"] != "INDEF") phot = goodphot[indef[0][:]] plt.ioff() #turn off interactive so plots dont pop up plt.figure(figsize=(8, 10)) #this is in inches mag = phot["MAG"].astype(np.float) merr = phot["MERR"].astype(np.float) #mag vs merr plt.subplot(221) plt.xlabel('MAG') plt.ylabel('MERR') plt.plot(mag, merr, 'bx') plt.title(photdata, {'fontsize': 10}) #magnitude histogram plt.subplot(222) plt.xlabel('mag') plt.ylabel('Number') plt.hist(mag, 10) plt.xlim(19, 29) #overplot the cummulative curve normHist, bins, patches = plt.hist(mag, bins=10, normed=False) plt.title('Mag distribution', {'fontsize': 10}) xsh = phot["XSHIFT"].astype(np.float) ysh = phot["YSHIFT"].astype(np.float) #xshift and yshifts, just to see plt.subplot(223) plt.xlabel('XSHIFT') plt.ylabel('YSHIFT') plt.plot(xsh, ysh, 'bx') plt.title('Xshift vs Yshift of centers', {'fontsize': 10}) #a quick reference plot of the image and starlocations x = phot["XCENTER"].astype(np.float) y = phot["YCENTER"].astype(np.float) imname = phot["IMAGE"][0].split("[")[ 0] #assume all from 1 image, and remove extension (careful here) image = pyfits.getdata(imname) plt.subplot(224) plt.xlabel('X') plt.ylabel('Y') plt.plot(x, y, 'ko', mfc="None") zero = np.where(image <= 0) image[zero] = 0.999 plt.imshow(np.log10(image), cmap=plt.cm.gray) plt.title('Total Non-error Stars: %i' % (len(phot)), {'fontsize': 10}) plt.tight_layout() plt.savefig(outfile) print "saved output figure to %s" % (outfile)