def greyscale(self, array2d, **kwargs): """ greyscale(array2d, **kwargs): Plot a 2D array as a greyscale image using the same scalings as in prepfold. """ # Use the same scaling as in prepfold_plot.c global_max = Num.maximum.reduce(Num.maximum.reduce(array2d)) min_parts = Num.minimum.reduce(array2d, 1) array2d = (array2d-min_parts[:,Num.newaxis])/Num.fabs(global_max) Pgplot.plot2d(array2d, image='antigrey', **kwargs)
def greyscale(self, array2d, **kwargs): """ greyscale(array2d, **kwargs): Plot a 2D array as a greyscale image using the same scalings as in prepfold. """ # Use the same scaling as in prepfold_plot.c global_max = Num.maximum.reduce(Num.maximum.reduce(array2d)) min_parts = Num.minimum.reduce(array2d, 1) array2d = (array2d-min_parts[:,Num.newaxis])/global_max Pgplot.plot2d(array2d, image='antigrey', **kwargs)
def show_ffdot_plane(data, r, z, dr=0.125, dz=0.5, numr=300, numz=300, T=None, contours=None, title=None, image="astro", device="/XWIN", norm=1.0): """ show_ffdot_plane(data, r, z): Show a color plot of the F-Fdot plane centered on the point 'r', 'z'. """ ffdp = ffdot_plane(data, r, dr, numr, z, dz, numz) ffdpow = spectralpower(ffdp.ravel()) ffdpow.shape = (numz, numr) startbin = int(r - (numr * dr) / 2) startz = int(z - (numz * dz) / 2) x = Num.arange(numr, dtype="d") * dr + startbin y = Num.arange(numz, dtype="d") * dz + startz highpt = Num.argmax(ffdpow.ravel()) hir = highpt % numr hiz = highpt / numr print "" print "Fourier Freqs from ", min(x), "to", max(x), "." print "Fourier Fdots from ", min(y), "to", max(y), "." print "Maximum normalized power is ", ffdpow[hiz][hir] print "The max value is located at: r =", startbin + hir * dr, \ " z =", startz + hiz * dz print "" if not T: Pgplot.plot2d(ffdpow, x, y, labx = "Fourier Frequency (bins)", \ laby = "Fourier Frequency Derivative", \ title = title, image = image, \ contours = contours, device = device) else: Pgplot.plot2d(ffdpow, x/T, y/(T**2.0), labx = "Frequency (hz)", \ laby = "Frequency Derivative (Hz/sec)", \ rangex2 = [x[0], x[-1]], rangey2 = [y[0], y[-1]], \ labx2 = "Fourier Frequency", \ laby2 = "Fourier Frequency Derivative", \ title = title, image = image, \ contours = contours, device = device)
def show_ffdot_plane(data, r, z, dr = 0.125, dz = 0.5, numr = 300, numz = 300, T = None, contours = None, title = None, image = "astro", device = "/XWIN", norm = 1.0): """ show_ffdot_plane(data, r, z): Show a color plot of the F-Fdot plane centered on the point 'r', 'z'. """ ffdp = ffdot_plane(data, r, dr, numr, z, dz, numz) ffdpow = spectralpower(ffdp.ravel()) ffdpow.shape = (numz, numr) startbin = int(r - (numr * dr) / 2) startz = int(z - (numz * dz) / 2) x = np.arange(numr, dtype="d") * dr + startbin y = np.arange(numz, dtype="d") * dz + startz highpt = np.argmax(ffdpow.ravel()) hir = highpt % numr hiz = highpt / numr print "" print "Fourier Freqs from ", min(x), "to", max(x), "." print "Fourier Fdots from ", min(y), "to", max(y), "." print "Maximum normalized power is ", ffdpow[hiz][hir] print "The max value is located at: r =", startbin + hir * dr, \ " z =", startz + hiz * dz print "" if not T: Pgplot.plot2d(ffdpow, x, y, labx = "Fourier Frequency (bins)", \ laby = "Fourier Frequency Derivative", \ title = title, image = image, \ contours = contours, device = device) else: Pgplot.plot2d(ffdpow, x/T, y/(T**2.0), labx = "Frequency (hz)", \ laby = "Frequency Derivative (Hz/sec)", \ rangex2 = [x[0], x[-1]], rangey2 = [y[0], y[-1]], \ labx2 = "Fourier Frequency", \ laby2 = "Fourier Frequency Derivative", \ title = title, image = image, \ contours = contours, device = device)
maxarg = argmax(spectralpower(ffd.flat)) rind = maxarg % numr zind = maxarg / numr peakr = (rind * dr + int(tryr - (numr * dr) / 2.0)) peakz = (zind * dz + tryz - (numz * dz) / 2.0) peakpow = ffd[zind][rind].real**2 + \ ffd[zind][rind].imag**2 if showplots: xvals = arange(numr, typecode="d") * dr + \ int(tryr - (numr * dr) / 2.0) yvals = arange(numz, typecode="d") * dz + \ tryz - (numz * dz) / 2.0 ffdpow = spectralpower(ffd.flat) ffdpow.shape = (numz, numr) Pgplot.plot2d(ffdpow, xvals, yvals, \ labx="Fourier Freq (bins)", \ laby="Fourier Freq Deriv", \ image="astro") Pgplot.closeplot() if debugout: print 'peakr = %11.5f peakz = %11.5f' % \ (peakr, peakz) if (peakpow < 0.2): pows[ct] = peakpow rmax = peakr zmax = peakz else: [pows[ct], rmax, zmax, rd] = \ maximize_rz(data, peakr, peakz, \ norm=1.0) if debugout: print 'max_r = %11.5f max_z = %11.5f' % \
maxarg = argmax(spectralpower(ffd.flat)) rind = maxarg % numr zind = maxarg / numr peakr = (rind * dr + int(tryr - (numr * dr) / 2.0)) peakz = (zind * dz + tryz - (numz * dz) / 2.0) peakpow = ffd[zind][rind].real**2 + \ ffd[zind][rind].imag**2 if showplots: xvals = arange(numr, typecode="d") * dr + \ int(tryr - (numr * dr) / 2.0) yvals = arange(numz, typecode="d") * dz + \ tryz - (numz * dz) / 2.0 ffdpow = spectralpower(ffd.flat) ffdpow.shape = (numz, numr) Pgplot.plot2d(ffdpow, xvals, yvals, \ labx="Fourier Freq (bins)", \ laby="Fourier Freq Deriv", \ image="astro") Pgplot.closeplot() if debugout: print 'peakr = %11.5f peakz = %11.5f' % \ (peakr, peakz) if (peakpow < 0.2): pows[ct] = peakpow rmax = peakr zmax = peakz else: [pows[ct], rmax, zmax, rd] = \ maximize_rz(data, peakr, peakz, \ norm=1.0) if debugout: print 'max_r = %11.5f max_z = %11.5f' % \