import math, sys, md5 import matplotlib matplotlib.use("TkAgg") import matplotlib.pyplot as plt from matplotlib.lines import Line2D from matplotlib.text import Text from matplotlib.ticker import FuncFormatter from matplotlib.backends.backend_pdf import PdfPages import os def argsort(seq): return sorted(range(len(seq)), key=seq.__getitem__) # Database: # Band names: band = ['L','S','C','X','U','K','Ka','Q'] # Band coverage: fmin = [1.00,2.00,4.00,8.00,12.00,18.00,26.50,40.00] fmax = [2.00,4.00,8.00,12.00,18.00,26.50,40.00,50.00] # Band extreme limits: frn = [0.950,1.850,3.80,7.70,11.650,17.70,25.00,39.00] frx = [2.050,4.150,8.20,12.60,18.350,26.80,41.00,51.00] # No. of 128 MHz blocks for 8 bit and 3 bit samplers n128_8 = [8,8,8,8,8,8,8,8] n128_3 = [16,16,16,16,16,16,16,16,16,16] # Speed of light c = 299792.458 # Initialize some off the parameters samp = -1982 flex = -1982 nline = -1 k_l = -1 k_b = -1 velo = 0.0 rs = 0.0 fflag = 0 prints = [] prints1 = [] prints21 = [] prints22 = [] shift = 0.0 prints21.append('Inputs:') # Number of arguments value = int(len(sys.argv)) os.system("clear") print ' ' print ' ******************************************************************** ' print ' * Hello User * ' print ' * You are running "TUNE", a visual interactive tool * ' print ' * for VLA spectral line setup. * ' print ' * If you need any help, please contact Nirupam Roy * ' print ' ******************************************************************** ' print ' ' # Depending on arguments, read parameters, check values, assign defaults # If arguments/parameters are missing/incorrect, print error message and exit if value == 1: print 'Usage: python tune.py -s [3 or 8](-bit sampler) -f [0 or 1](flexible tuning N/Y) -n [Number](of spectral lines) -l [l1 l2 ...](line frequencies GHz) -b [b1 b2 ...](subband widths MHz) -v [velocity,optional](km/s) -z [redshift,optional] -i [input file,optional]' print ' ' print 'Example: python tune.py -s 8 -f 0 -n 4 -l 23.694 23.723 23.870 24.139 -b 4.0 4.0 4.0 4.0 -v 650.0 -z 0.1 -i input.txt' print ' ' print 'Received no inputs this time! Quitting now ...' sys.exit() else: for i in range(1,value-1): if sys.argv[i] == '-z': try: rs = float(sys.argv[i+1]) except ValueError: print 'Unrecognised -z flag for redshift! Quitting now ...' sys.exit() if sys.argv[i] == '-v': try: velo = float(sys.argv[i+1]) except ValueError: print 'Unrecognised -v flag for velocity! Quitting now ...' sys.exit() if sys.argv[i] == '-s': try: samp = int(sys.argv[i+1]) except ValueError: print 'Unrecognised -s flag for 3/8-bit sampler! Quitting now ...' sys.exit() if sys.argv[i] == '-f': try: flex = int(sys.argv[i+1]) except ValueError: print 'Unrecognised -f flag for flexible tuning! Quitting now ...' sys.exit() if sys.argv[i] == '-n': try: nline = int(sys.argv[i+1]) except ValueError: print 'Unrecognised -n flag for number of lines! Quitting now ...' sys.exit() if sys.argv[i] == '-l': k_l = i if sys.argv[i] == '-b': k_b = i if sys.argv[i] == '-i': try: f = open(str(sys.argv[i+1]), 'r') print 'Using input file for line frequency and subband width values.' print 'Ignoring all other -l and -b flags!' except IOError: print 'Can not open input file! Quitting now ...' sys.exit() nline = 0 fflag = 1 k_l = 0 k_b = 0 if nline == -1: print 'Number of line not specified! Quitting now ...' sys.exit() if k_l == -1: print 'No line frequencies specified! Quitting now ...' sys.exit() if k_b == -1: print 'No subband widths specified! Quitting now ...' sys.exit() if samp == -1982: print 'Sampler not specified, using default 8-bit'; samp = 8 if flex == -1982: print 'Flexible tuning option not specified, using default no flexible tuning'; flex = 0 bbbw = [] line = [] liner=[] linez=[] if fflag != 1: if samp == 3: print 'Using 3-bit sampler setting this time' print 'Ignoring any -f flag; No flexible tuning allowed in 3-bit' flex = 0 print 'Ignoring any -b flag; Using 128 MHz bandwidth for all subbands' print ' ' for i in range(1,nline+1): bbbw.append(128.00) try: temp = float(sys.argv[k_l+i]) except ValueError: print 'Problem with line number/frequency. Check inputs carefully!' sys.exit() liner.append(temp) linez.append(temp/(1.0+rs)) line.append(float(sys.argv[k_l+i])*(c/((c+velo)*(1.0+rs)))) print 'Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1]) prints21.append('Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1])) continue elif samp == 8: print 'Using 8-bit sampler setting this time' if flex == 1: print 'Using flexible tuning' print ' ' for i in range(1,nline+1): try: temp = float(sys.argv[k_l+i]) except ValueError: print 'Problem with line number/frequency. Check inputs carefully!' sys.exit() try: temp1 = float(sys.argv[k_b+i]) except ValueError: print 'Problem with subband number/width. Check inputs carefully!' sys.exit() bbbw.append(pow(2.00,round(math.log(float(sys.argv[k_b+i]),2.0)))) bbbw[i-1] = min(bbbw[i-1],128.00) bbbw[i-1] = max(bbbw[i-1],0.03125) liner.append(temp) linez.append(temp/(1.0+rs)) line.append(float(sys.argv[k_l+i])*(c/((c+velo)*(1.0+rs)))) print 'Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1]) prints21.append('Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1])) continue elif flex == 0: print ' ' for i in range(1,nline+1): try: temp = float(sys.argv[k_l+i]) except ValueError: print 'Problem with line number/frequency. Check inputs carefully!' sys.exit() try: temp1 = float(sys.argv[k_b+1]) except ValueError: print 'Problem with subband number/width. Check inputs carefully!' sys.exit() bbbw.append(pow(2.00,round(math.log(float(sys.argv[k_b+1]),2.0)))) bbbw[i-1] = min(bbbw[i-1],128.00) bbbw[i-1] = max(bbbw[i-1],0.03125) liner.append(temp) linez.append(temp/(1.0+rs)) line.append(float(sys.argv[k_l+i])*(c/((c+velo)*(1.0+rs)))) print 'Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1]) prints21.append('Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1])) continue print ' ' print 'Not using flexible tuning. Using %g MHz width for all subbands' % (bbbw[1]) else: print 'Use -f either 0 or 1 for flexible tuning option' sys.exit() else: print 'Use -s either 3 or 8 for 3 and 8 bit sampler respectively' sys.exit() else: farray1 = [] farray2 = [] for line in f: nline = nline+1 line = line.strip() sline = line.split() try: tt = float(sline[0]) except Exception: print 'Problem with input line frequency: Line %i in input file!' % (nline) print 'Check inputs carefully!' sys.exit() try: tt = float(sline[1]) except Exception: print 'Problem with subband width: Line %i in input file!' % (nline) print 'Check inputs carefully!' sys.exit() farray1.append(float(sline[0])) farray2.append(float(sline[1])) f.close() if fflag == 1: line=[] if samp == 3: print 'Using 3-bit sampler setting this time' print 'Ignoring any -f flag; No flexible tuning allowed in 3-bit' flex = 0 print 'Ignoring any -b flag; Using 128 MHz bandwidth for all subbands' print ' ' for i in range(1,nline+1): bbbw.append(128.00) temp = farray1[i-1] liner.append(temp) linez.append(temp/(1.0+rs)) line.append(temp*(c/((c+velo)*(1.0+rs)))) print 'Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1]) prints21.append('Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1])) continue elif samp == 8: print 'Using 8-bit sampler setting this time' if flex == 1: print 'Using flexible tuning' print ' ' for i in range(1,nline+1): temp = farray1[i-1] temp1 = farray2[i-1] bbbw.append(pow(2.00,round(math.log(temp1,2.0)))) bbbw[i-1] = min(bbbw[i-1],128.00) bbbw[i-1] = max(bbbw[i-1],0.03125) liner.append(temp) linez.append(temp/(1.0+rs)) line.append(temp*(c/((c+velo)*(1.0+rs)))) print 'Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1]) prints21.append('Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1])) continue elif flex == 0: print ' ' for i in range(1,nline+1): temp = farray1[i-1] temp1 = farray2[0] bbbw.append(pow(2.00,round(math.log(temp1,2.0)))) bbbw[i-1] = min(bbbw[i-1],128.00) bbbw[i-1] = max(bbbw[i-1],0.03125) liner.append(temp) linez.append(temp/(1.0+rs)) line.append(temp*(c/((c+velo)*(1.0+rs)))) print 'Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1]) prints21.append('Line freq.: %f GHz shifted to %f GHz, BW: %g MHz' % (temp, line[i-1], bbbw[i-1])) continue print ' ' print 'Not using flexible tuning. Using %g MHz width for all subbands' % (bbbw[1]) else: print 'Use -f either 0 or 1 for flexible tuning option' sys.exit() else: print 'Use -s either 3 or 8 for 3 and 8 bit sampler respectively' sys.exit() # At this point I have all the information from either user input or database # Assign band ID and check that all the lines fit in single baseband print ' ' cont = raw_input('Hit enter to continue:') os.system("clear") print ' ' band_id = -1 for i in range(8): if min(line) >= fmin[i] and max(line) <= fmax[i]: band_id = i if samp == 3: n_128 = n128_3[i] if samp == 8: n_128 = n128_8[i] else: continue if band_id == -1: print 'Lines do not fit in a single VLA band!' sys.exit() if max(line)-min(line) > n_128*0.12800: print 'Lines do not fit in a single baseband!' print 'Run TUNE separately for different basebands.' sys.exit() prints.append('') prints.append('Summary for this %s-band spectral line observation setup:' %band[band_id]) if flex == 0: prints.append('%i-bit sampler, no flexible tuning of subbands, extra shift %g MHz' %(samp, shift)) if flex == 1: prints.append('%i-bit sampler, flexible tuning of subbands, extra shift %g MHz' %(samp, shift)) prints.append('') nlinput = (len(prints21) % 32) if nlinput == 0: prints21.append('Output setup:') elif nlinput == 30: prints21.append(' ') prints21.append(' ') prints21.append('Output setup:') else: prints21.append(' ') prints21.append('Output setup:') # Find the best baseband setting ... #c_fr = (sum(line)/nline) c_fr = 0.5*(min(line)+max(line)) bb_ef = c_fr - (n_128*0.12800/2.00) mod128 = [] space128 = [] for i in range(nline): mod128.append((line[i]-bb_ef) % 0.12800) continue soin = argsort(mod128) mod128.sort() for i in range(nline-1): space128.append(mod128[i+1] - mod128[i]) continue space128.append(0.12800 + mod128[0] - mod128[nline-1]) defindx = argsort(space128) itix = 1 itixa = 1 while itix == 1: findx = defindx[nline-itixa] deltaf1 = space128[findx] deltaf2 = mod128[findx] deltaf = deltaf2 + (0.50*deltaf1) if deltaf > 0.06400: deltaf = deltaf - 0.128 c_fr = c_fr + deltaf if (c_fr-(n_128*0.12800/2.00)) < min(line) and (c_fr+(n_128*0.12800/2.00)) > max(line): itix = 0 else: c_fr = c_fr - deltaf itix = 1 itixa = itixa + 1 if samp == 8: if flex == 0: bb_ef = c_fr - (n_128*0.12800/2.00) mod128 = [] space128 = [] for i in range(nline): mod128.append((line[i]-bb_ef) % (bbbw[0]/1000.0)) continue soin = argsort(mod128) mod128.sort() for i in range(nline-1): space128.append(mod128[i+1] - mod128[i]) continue space128.append((bbbw[0]/1000.0) + mod128[0] - mod128[nline-1]) defindx = argsort(space128) itix = 1 itixa = 1 while itix == 1: findx = defindx[nline-itixa] deltaf1p = space128[findx] deltaf2p = mod128[findx] deltafp = deltaf2p + (0.50*deltaf1p) if deltafp > (bbbw[0]/2000.0): deltafp = deltafp - (bbbw[0]/1000.0) c_fr = c_fr + deltafp if (c_fr-(n_128*0.12800/2.00)) < min(line) and (c_fr+(n_128*0.12800/2.00)) > max(line): itix = 0 else: c_fr = c_fr - deltafp deltafp = deltafp + (bbbw[0]/1000.0) c_fr = c_fr + deltafp if (c_fr-(n_128*0.12800/2.00)) < min(line) and (c_fr+(n_128*0.12800/2.00)) > max(line): itix = 0 else: c_fr = c_fr - deltafp itix = 1 itixa = itixa + 1 while fmin[band_id] - (c_fr-(n_128*0.128/2.0)) > 0.128: c_fr = c_fr + 0.128 while (c_fr+(n_128*0.128/2.0)) - fmax[band_id] > 0.128: c_fr = c_fr - 0.128 if samp == 3: ms_128 = 1000.0*0.50*deltaf1 if samp == 8: if flex == 0: ms_128 = 1000.0*((0.50*deltaf1)+abs(deltafp)) if flex == 1: ms_128 = 1000.0*0.50*deltaf1 print 'Min. separation from "128 MHz edge" %g MHz' % (ms_128) prints1.append('Min. separation from "128 MHz edge" %g MHz' % (ms_128)) if ms_128 < 0.05*128.0: print '****************************************' print 'WARNING: Line(s) too close to "128 MHz edge"!!' prints1.append('WARNING: Line(s) too close to "128 MHz edge"!!') print '****************************************' print ' ' if samp == 8: if flex == 0: ms_BBBW = 1000.0*0.50*deltaf1p print 'Min. separation from subband edge %g MHz' % (ms_BBBW) prints1.append('Min. separation from subband edge %g MHz' % (ms_BBBW)) if ms_BBBW < (bbbw[0]/8.0): print '****************************************' print 'WARNING: Line(s) too close to subband edge"!!' prints1.append('WARNING: Line(s) too close to subband edge"!!') print '****************************************' print ' ' print 'BB freq. %f GHz, BW %g GHz, Freq. range %f - %f GHz' % (c_fr, n_128*0.128, c_fr-(n_128*0.128/2.0), c_fr+(n_128*0.128/2.0)) prints1.append('BB freq. %f GHz, BW %g GHz, Freq. range %f - %f GHz' % (c_fr, n_128*0.128, c_fr-(n_128*0.128/2.0), c_fr+(n_128*0.128/2.0))) print ' ' subbandx=[] subbandy=[] for i in range(nline): if flex == 1: f1 = c_fr + (((line[i]-c_fr)//0.128)*0.128) f2 = f1 + 0.128 if (f2 - line[i]) < (bbbw[i]/2000.0): off = line[i]-c_fr-((bbbw[i]/2000.0)-(f2 - line[i])) elif (line[i] - f1) < (bbbw[i]/2000.0): off = line[i]-c_fr + ((bbbw[i]/2000.0)-(line[i] - f1)) else: off = line[i]-c_fr if flex == 0: off = line[i]-c_fr - ((line[i]-c_fr) % (bbbw[0]/1000.0)) + (bbbw[0]/2000.0) range1 = c_fr + off - (bbbw[i]/2000.0) range2 = c_fr + off + (bbbw[i]/2000.0) subbandx.append(range1) subbandx.append(range1) subbandx.append(range2) subbandx.append(range2) subbandy.append(0.0) subbandy.append(0.905) subbandy.append(0.905) subbandy.append(0.0) print 'Line-%i %f GHz: Offset %g MHz, Sky range %f - %f GHz' %(i+1, line[i], off*1000, range1, range2) prints22.append('Line-%i %f GHz: Offset %g MHz, Sky range %f - %f GHz' %(i+1, line[i], off*1000, range1, range2)) print '' # Plots # Build the spectral lines linex = [] liney = [] for i in range(nline): linex.append(line[i]) linex.append(line[i]) linex.append(line[i]) liney.append(0.0) liney.append(0.735) liney.append(0.0) # Build the observing band bandy1 = [0.0,0.975,0.975,0.0,0.0] bandy2 = [0.0,0.95,0.95,0.0,0.0] bandx1 = [frn[band_id],frn[band_id],frx[band_id],frx[band_id],frn[band_id]] bandx2 = [fmin[band_id],fmin[band_id],fmax[band_id],fmax[band_id],fmin[band_id]] # Build the baseband bb_ef = c_fr - (n_128*0.12800/2.00) bb128x=[] bb128y=[] for i in range(n_128): bb128y.append(0.0) bb128y.append(0.935) bb128y.append(0.935) bb128y.append(0.0) bb128x.append(bb_ef+(i*0.12800)) bb128x.append(bb_ef+(i*0.12800)) bb128x.append(bb_ef+((i+1)*0.12800)) bb128x.append(bb_ef+((i+1)*0.12800)) plt.ion() j = 0 fig = plt.figure(facecolor='white') w, h = fig.get_size_inches() while (j < len(line)): plt.clf() # plt.subplot(311) sp1 = fig.add_subplot(311, frameon=False) sp1.get_xaxis().tick_bottom() sp1.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('Frequency (GHz)') xtxt1 = min(bandx1) + (0.05*(max(bandx1) - min(bandx1))) plt.text(xtxt1, 0.75, r'RF Band', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bandx1) > min(bb128x): xtxt0 = max(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if (max(bandx1) < max(bb128x)): xtxt0 = min(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp1.plot(bandx1,bandy1,'r--') sp1.plot(bandx2,bandy2,'g-.') sp1.plot(bb128x,bb128y,'b-') sp1.plot(subbandx,subbandy,'g-') sp1.plot(linex,liney,'r-') sp1.axis([min(bandx1)-0.030,max(bandx1)+0.030,0,1]) xmin, xmax = sp1.get_xaxis().get_view_interval() ymin, ymax = sp1.get_yaxis().get_view_interval() sp1.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) # plt.subplot(312) sp2 = fig.add_subplot(312, frameon=False) sp2.get_xaxis().tick_bottom() sp2.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') xtxt2 = min(bb128x) + (0.05*(max(bb128x) - min(bb128x))) plt.text(xtxt2, 0.75, r'Baseband', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bb128x) > min(linex): xtxt20 = max(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if max(bb128x) < max(linex): xtxt20 = min(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp2.plot(bb128x,bb128y,'b-') sp2.plot(subbandx,subbandy,'g-') sp2.plot(linex,liney,'r-') sp2.axis([min(bb128x)-0.006,max(bb128x)+0.006,0,1.2]) xmin, xmax = sp2.get_xaxis().get_view_interval() ymin, ymax = sp2.get_yaxis().get_view_interval() sp2.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) subbandxv=[] linexv=[] for i in range (len(subbandx)): subbandxv.append((linez[j]-subbandx[i])*c/subbandx[i]) for i in range (len(linex)): linexv.append((linez[j]-linex[i])*c/linex[i]) # plt.subplot(313) sp3 = fig.add_subplot(313, frameon=False) sp3.get_xaxis().tick_bottom() sp3.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('Velocity (km/s)') xtxt3 = subbandxv[3+(4*j)] + (0.05*(subbandxv[0+(4*j)] - subbandxv[3+(4*j)])) plt.text(xtxt3, 0.75, r'Subband', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if ((line[j] < min(bb128x)) or (line[j] > max(bb128x))): xtxt4 = subbandxv[3+(4*j)] + (0.5*(subbandxv[0+(4*j)] - subbandxv[3+(4*j)])) plt.text(xtxt4, 0.33, r'This line is outside the baseband!', ha='center', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp3.plot(subbandxv,subbandy,'g-') sp3.plot(linexv,liney,'r-', label='Line-%s' %(str(j+1))) plt.legend(loc='lower right') sp3.axis([subbandxv[3+(4*j)]-5.0,subbandxv[0+(4*j)]+5.0,0,1.1]) xmin, xmax = sp3.get_xaxis().get_view_interval() ymin, ymax = sp3.get_yaxis().get_view_interval() sp3.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) newax = sp3.twiny() fig.subplots_adjust(bottom=0.20) newax.set_frame_on(True) newax.patch.set_visible(False) newax.xaxis.set_ticks_position('bottom') newax.xaxis.set_label_position('bottom') newax.spines['bottom'].set_position(('outward', 40)) newax.spines['top'].set_position(('outward', 4000)) newax.spines['top'].set_color('white') newax.spines['left'].set_color('white') newax.spines['right'].set_color('white') newax.plot(linex,liney,'r:') newax.plot(subbandx,subbandy,'g:') newax.axis([(linez[j]*c/(c+subbandxv[3+(4*j)]-5.0)),(linez[j]*c/(c+subbandxv[0+(4*j)]+5.0)),0,1.1]) newax.set_xlabel('Frequency (GHz)') newax.xaxis.set_major_formatter(FuncFormatter(lambda x, pos: ('%.4f')%(x*1e0))) tt = raw_input('Enter n/p for next/previous subband, e for exit:') if tt.upper() == 'N': j = j+1 if j == len(line): j = j-1 elif tt.upper() == 'P': j = j-1 if j < 0: j = 0 elif tt == '': j = j+1 elif tt.upper() == 'E': j = len(line) else: continue ofname = 'baseband1_setup.pdf' saveyn = raw_input('Save summary pdf file? [y/n]:') if saveyn.upper() == 'Y': tename = raw_input('Enter filename to save summary [baseband1_setup.pdf]:') if tename == '': tename = 'baseband1_setup.pdf' mm = 0 while mm < 1: try: ntt = open(str(tename), 'r') ntt.close() owflg = raw_input('File already exist. Overwrite? [y/n]:') if owflg.upper() != 'Y': mm = 0 tename = raw_input('Enter filename to save summary [baseband1_setup.pdf]:') if tename == '': tename = 'baseband1_setup.pdf' else: mm = 1 ofname = str(tename) except Exception: try: ntt = open(str(tename), 'w') mm = 1 ofname = str(tename) ntt.close() except Exception: mm = 0 print 'Invalid input filename!' tename = raw_input('Enter filename to save summary [baseband1_setup.pdf]:') if tename == '': tename = 'baseband1_setup.pdf' pdfof = PdfPages(ofname) #remake subplot 313 fig.delaxes(sp3) fig.delaxes(newax) sp3 = fig.add_subplot(313, frameon=False) sp3.axes.get_xaxis().set_visible(False) sp3.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') sp3.plot(subbandx,subbandy,'w:') xmin, xmax = sp3.get_xaxis().get_view_interval() ymin, ymax = sp3.get_yaxis().get_view_interval() ytxt = ymax for l in range(len(prints)): ytxt = ymax - 0.125*(ymax-ymin)*(l+1) plt.text(xmin,ytxt,prints[l]) if len(prints1) > 9: prints1[8] = '... and more line(s) outside the baseband frequency coverage!' for l in range(min(9,len(prints1))): ytxt = ytxt - 0.125*(ymax-ymin) plt.text(xmin,ytxt,prints1[l]) plt.text(xmax,ytxt-0.125,'ID: %s' %(str(md5.new(file(str(sys.argv[0])).read()).hexdigest())), ha='right', color='0.85') fig.set_size_inches(11.00, 8.50) fig.savefig(pdfof, format='pdf') ############## PUT PAGE 2- here! fig.set_size_inches(w, h) prints2 = prints21 + prints22 k = 1 while k <= len(prints2): plt.clf() fig.set_size_inches(8.50, 11.00) p2 = fig.add_subplot(111, frameon=False) p2.axes.get_xaxis().set_visible(False) p2.axes.get_yaxis().set_visible(False) p2.plot(subbandx,subbandy,'w:') xmin, xmax = p2.get_xaxis().get_view_interval() ymin, ymax = p2.get_yaxis().get_view_interval() ytxt = ymax + 0.0375*(ymax-ymin) for l in range(32): k1 = k+l if k1 <= len(prints2): ytxt = ytxt - 0.0375*(ymax-ymin) plt.text(xmin,ytxt,prints2[k1-1]) else: break pdfof.savefig(fig) k = k1+1 ############# plt.clf() pdfof.close() fig.set_size_inches(w, h) #######################REPLOT # plt.subplot(311) sp1 = fig.add_subplot(311, frameon=False) sp1.get_xaxis().tick_bottom() sp1.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('Frequency (GHz)') xtxt1 = min(bandx1) + (0.05*(max(bandx1) - min(bandx1))) plt.text(xtxt1, 0.75, r'RF Band', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bandx1) > min(bb128x): xtxt0 = max(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if (max(bandx1) < max(bb128x)): xtxt0 = min(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp1.plot(bandx1,bandy1,'r--') sp1.plot(bandx2,bandy2,'g-.') sp1.plot(bb128x,bb128y,'b-') sp1.plot(subbandx,subbandy,'g-') sp1.plot(linex,liney,'r-') sp1.axis([min(bandx1)-0.030,max(bandx1)+0.030,0,1]) xmin, xmax = sp1.get_xaxis().get_view_interval() ymin, ymax = sp1.get_yaxis().get_view_interval() sp1.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) # plt.subplot(312) sp2 = fig.add_subplot(312, frameon=False) sp2.get_xaxis().tick_bottom() sp2.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') xtxt2 = min(bb128x) + (0.05*(max(bb128x) - min(bb128x))) plt.text(xtxt2, 0.75, r'Baseband', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bb128x) > min(linex): xtxt20 = max(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if max(bb128x) < max(linex): xtxt20 = min(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp2.plot(bb128x,bb128y,'b-') sp2.plot(subbandx,subbandy,'g-') sp2.plot(linex,liney,'r-') sp2.axis([min(bb128x)-0.006,max(bb128x)+0.006,0,1.2]) xmin, xmax = sp2.get_xaxis().get_view_interval() ymin, ymax = sp2.get_yaxis().get_view_interval() sp2.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) # plt.subplot(313) sp3 = fig.add_subplot(313, frameon=False) sp3.axes.get_xaxis().set_visible(False) sp3.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') sp3.plot(subbandx,subbandy,'w:') xmin, xmax = sp3.get_xaxis().get_view_interval() ymin, ymax = sp3.get_yaxis().get_view_interval() ytxt = ymax for l in range(len(prints)): ytxt = ymax - 0.125*(ymax-ymin)*(l+1) plt.text(xmin,ytxt,prints[l]) if len(prints1) > 9: prints1[8] = '... and more line(s) outside the baseband frequency coverage!' for l in range(min(9,len(prints1))): ytxt = ytxt - 0.125*(ymax-ymin) plt.text(xmin,ytxt,prints1[l]) plt.text(xmax,ytxt-0.125,'ID: %s' %(str(md5.new(file(str(sys.argv[0])).read()).hexdigest())), ha='right', color='0.85') ####################### prints = [] prints1 = [] prints22 = [] # Interactive bit ... print '****************************************' print 'Entering interactive ...' print '****************************************' i_flag=raw_input('Do you want to shift the baseband center freq.? [y/n]:') if i_flag.upper() != 'Y': plt.close() print 'We are done for now! Quitting tune ...' sys.exit() i=0 while (i < 1): shift=raw_input('Enter baseband freq. shift (MHz):') try: shift = float(shift) except ValueError: plt.close() print 'Problem with input. Check inputs carefully!' sys.exit() prints.append('') prints.append('Summary for this %s-band spectral line observation setup:' %band[band_id]) if flex == 0: prints.append('%i-bit sampler, no flexible tuning of subbands, extra shift %g MHz' %(samp, shift)) if flex == 1: prints.append('%i-bit sampler, flexible tuning of subbands, extra shift %g MHz' %(samp, shift)) prints.append('') os.system("clear") print ' ' c_fr = c_fr+(shift/1000.0) bb_ef = c_fr - (n_128*0.12800/2.00) mod128 = [] for i in range(nline): mod128.append((line[i]-bb_ef) % 0.12800) mod128.append(0.128 - ((line[i]-bb_ef) % 0.12800)) continue print 'Min. separation from "128 MHz edge" %g MHz' % ((min(mod128))*1000.0) prints1.append('Min. separation from "128 MHz edge" %g MHz' % ((min(mod128))*1000.0)) if (min(mod128))*1000.0 < 0.05*128.0: print '****************************************' print 'WARNING: Line(s) too close to "128 MHz edge"!!' prints1.append('WARNING: Line(s) too close to "128 MHz edge"!!') print '****************************************' print ' ' if samp == 8: if flex == 0: mod_bbbw=[] for i in range(nline): mod_bbbw.append((line[i]-bb_ef) % (bbbw[0]/1000.0)) mod_bbbw.append((bbbw[0]/1000.0) - ((line[i]-bb_ef) % (bbbw[0]/1000.0))) print 'Min. separation from subband edge %g MHz' % ((min(mod_bbbw))*1000.0) prints1.append('Min. separation from subband edge %g MHz' % ((min(mod_bbbw))*1000.0)) if (min(mod_bbbw))*1000.0 < (bbbw[0]/8.0): print '****************************************' print 'WARNING: Line(s) too close to subband edge"!!' prints1.append('WARNING: Line(s) too close to subband edge"!!') print '****************************************' print ' ' print 'BB freq. %f GHz, BW %g GHz, Freq. range %f - %f GHz' % (c_fr, n_128*0.128, c_fr-(n_128*0.128/2.0), c_fr+(n_128*0.128/2.0)) prints1.append('BB freq. %f GHz, BW %g GHz, Freq. range %f - %f GHz' % (c_fr, n_128*0.128, c_fr-(n_128*0.128/2.0), c_fr+(n_128*0.128/2.0))) print ' ' subbandx=[] subbandy=[] for i in range(nline): if line[i] >= c_fr-(n_128*0.128/2.0) and line[i] <= c_fr+(n_128*0.128/2.0): if flex == 1: f1 = c_fr + (((line[i]-c_fr)//0.128)*0.128) f2 = f1 + 0.128 if (f2 - line[i]) < (bbbw[i]/2000.0): off = line[i]-c_fr-((bbbw[i]/2000.0)-(f2 - line[i])) elif (line[i] - f1) < (bbbw[i]/2000.0): off = line[i]-c_fr + ((bbbw[i]/2000.0)-(line[i] - f1)) else: off = line[i]-c_fr if flex == 0: off = line[i]-c_fr - ((line[i]-c_fr) % (bbbw[0]/1000.0)) + (bbbw[0]/2000.0) range1 = c_fr + off - (bbbw[i]/2000.0) range2 = c_fr + off + (bbbw[i]/2000.0) subbandx.append(range1) subbandx.append(range1) subbandx.append(range2) subbandx.append(range2) subbandy.append(0.0) subbandy.append(0.905) subbandy.append(0.905) subbandy.append(0.0) print 'Line-%i %f GHz: Offset %g MHz, Sky range %f - %f GHz' %(i+1, line[i], off*1000, range1, range2) prints22.append('Line-%i %f GHz: Offset %g MHz, Sky range %f - %f GHz' %(i+1, line[i], off*1000, range1, range2)) else: range1 = line[i] - (bbbw[i]/2000.0) range2 = line[i] + (bbbw[i]/2000.0) subbandx.append(range1) subbandx.append(range1) subbandx.append(range2) subbandx.append(range2) subbandy.append(0.0) subbandy.append(0.905) subbandy.append(0.905) subbandy.append(0.0) print 'Line-%i %f GHz is outside the baseband frequency coverage!' %(i+1, line[i]) prints1.append('Line-%i %f GHz is outside the baseband frequency coverage!' %(i+1, line[i])) prints22.append('Line-%i %f GHz is outside the baseband freq. coverage!' %(i+1, line[i])) print '****************************************' print 'WARNING: Check if it is fine to exclude this line!!!' print '****************************************' print ' ' ## ## Build the baseband bb_ef = c_fr - (n_128*0.12800/2.00) bb128x=[] bb128y=[] for i in range(n_128): bb128y.append(0.0) bb128y.append(0.935) bb128y.append(0.935) bb128y.append(0.0) bb128x.append(bb_ef+(i*0.12800)) bb128x.append(bb_ef+(i*0.12800)) bb128x.append(bb_ef+((i+1)*0.12800)) bb128x.append(bb_ef+((i+1)*0.12800)) j = 0 while (j < len(line)): plt.clf() ## plt.subplot(311) sp1 = fig.add_subplot(311, frameon=False) sp1.get_xaxis().tick_bottom() sp1.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('Frequency (GHz)') xtxt1 = min(bandx1) + (0.05*(max(bandx1) - min(bandx1))) plt.text(xtxt1, 0.75, r'RF Band', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bandx1) > min(bb128x): xtxt0 = max(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if max(bandx1) < max(bb128x): xtxt0 = min(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp1.plot(bandx1,bandy1,'r--') sp1.plot(bandx2,bandy2,'g-.') sp1.plot(bb128x,bb128y,'b-') sp1.plot(subbandx,subbandy,'g-') sp1.plot(linex,liney,'r-') sp1.axis([min(bandx1)-0.030,max(bandx1)+0.030,0,1]) xmin, xmax = sp1.get_xaxis().get_view_interval() ymin, ymax = sp1.get_yaxis().get_view_interval() sp1.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) ## plt.subplot(312) sp2 = fig.add_subplot(312, frameon=False) sp2.get_xaxis().tick_bottom() sp2.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') xtxt2 = min(bb128x) + (0.05*(max(bb128x) - min(bb128x))) plt.text(xtxt2, 0.75, r'Baseband', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bb128x) > min(linex): xtxt20 = max(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if max(bb128x) < max(linex): xtxt20 = min(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp2.plot(bb128x,bb128y,'b-') sp2.plot(subbandx,subbandy,'g-') sp2.plot(linex,liney,'r-') sp2.axis([min(bb128x)-0.006,max(bb128x)+0.006,0,1.2]) xmin, xmax = sp2.get_xaxis().get_view_interval() ymin, ymax = sp2.get_yaxis().get_view_interval() sp2.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) subbandxv=[] linexv=[] for i in range (len(subbandx)): subbandxv.append((linez[j]-subbandx[i])*c/subbandx[i]) for i in range (len(linex)): linexv.append((linez[j]-linex[i])*c/linex[i]) ## plt.subplot(313) sp3 = fig.add_subplot(313, frameon=False) sp3.get_xaxis().tick_bottom() sp3.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('Velocity (km/s)') xtxt3 = subbandxv[3+(4*j)] + (0.05*(subbandxv[0+(4*j)] - subbandxv[3+(4*j)])) plt.text(xtxt3, 0.75, r'Subband', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if ((line[j] < min(bb128x)) or (line[j] > max(bb128x))): xtxt4 = subbandxv[3+(4*j)] + (0.5*(subbandxv[0+(4*j)] - subbandxv[3+(4*j)])) plt.text(xtxt4, 0.33, r'This line is outside the baseband!', ha='center', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp3.plot(subbandxv,subbandy,'g-') sp3.plot(linexv,liney,'r-', label='Line-%s' %(str(j+1))) plt.legend(loc='lower right') sp3.axis([subbandxv[3+(4*j)]-5.0,subbandxv[0+(4*j)]+5.0,0,1.1]) xmin, xmax = sp3.get_xaxis().get_view_interval() ymin, ymax = sp3.get_yaxis().get_view_interval() sp3.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) newax = sp3.twiny() fig.subplots_adjust(bottom=0.20) newax.set_frame_on(True) newax.patch.set_visible(False) newax.xaxis.set_ticks_position('bottom') newax.xaxis.set_label_position('bottom') newax.spines['bottom'].set_position(('outward', 40)) newax.spines['top'].set_position(('outward', 4000)) newax.spines['top'].set_color('white') newax.spines['left'].set_color('white') newax.spines['right'].set_color('white') newax.plot(linex,liney,'r:') newax.plot(subbandx,subbandy,'g:') newax.axis([(linez[j]*c/(c+subbandxv[3+(4*j)]-5.0)),(linez[j]*c/(c+subbandxv[0+(4*j)]+5.0)),0,1.1]) newax.set_xlabel('Frequency (GHz)') newax.xaxis.set_major_formatter(FuncFormatter(lambda x, pos: ('%.4f')%(x*1e0))) tt = raw_input('Enter n/p for next/previous subband, e for exit:') if tt.upper() == 'N': j = j+1 if j == len(line): j = j-1 elif tt.upper() == 'P': j = j-1 if j < 0: j = 0 elif tt == '': j = j+1 elif tt.upper() == 'E': j = len(line) else: continue saveyn = raw_input('Save summary pdf file? [y/n]:') if saveyn.upper() == 'Y': tename = raw_input('Enter filename to save summary [%s]:' %ofname) if tename == '': tename = ofname mm = 0 while mm < 1: try: ntt = open(str(tename), 'r') ntt.close() owflg = raw_input('File already exist. Overwrite? [y/n]:') if owflg.upper() != 'Y': mm = 0 tename = raw_input('Enter filename to save summary [%s]:' %ofname) if tename == '': tename = ofname else: mm = 1 ofname = str(tename) except Exception: try: ntt = open(str(tename), 'w') mm = 1 ofname = str(tename) ntt.close() except Exception: mm = 0 print 'Invalid input filename!' tename = raw_input('Enter filename to save summary [%s]:' %ofname) if tename == '': tename = ofname pdfof = PdfPages(ofname) ##remake subplot 313 fig.delaxes(sp3) fig.delaxes(newax) sp3 = fig.add_subplot(313, frameon=False) sp3.axes.get_xaxis().set_visible(False) sp3.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') sp3.plot(subbandx,subbandy,'w:') xmin, xmax = sp3.get_xaxis().get_view_interval() ymin, ymax = sp3.get_yaxis().get_view_interval() ytxt = ymax for l in range(len(prints)): ytxt = ymax - 0.125*(ymax-ymin)*(l+1) plt.text(xmin,ytxt,prints[l]) if len(prints1) > 9: prints1[8] = '... and more line(s) outside the baseband frequency coverage!' for l in range(min(9,len(prints1))): ytxt = ytxt - 0.125*(ymax-ymin) plt.text(xmin,ytxt,prints1[l]) plt.text(xmax,ytxt-0.125,'ID: %s' %(str(md5.new(file(str(sys.argv[0])).read()).hexdigest())), ha='right', color='0.85') fig.set_size_inches(11.00, 8.50) fig.savefig(pdfof, format='pdf') ############### PUT PAGE 2- here! fig.set_size_inches(w, h) prints2 = prints21 + prints22 k = 1 while k <= len(prints2): plt.clf() fig.set_size_inches(8.50, 11.00) p2 = fig.add_subplot(111, frameon=False) p2.axes.get_xaxis().set_visible(False) p2.axes.get_yaxis().set_visible(False) p2.plot(subbandx,subbandy,'w:') xmin, xmax = p2.get_xaxis().get_view_interval() ymin, ymax = p2.get_yaxis().get_view_interval() ytxt = ymax + 0.0375*(ymax-ymin) for l in range(32): k1 = k+l if k1 <= len(prints2): ytxt = ytxt - 0.0375*(ymax-ymin) plt.text(xmin,ytxt,prints2[k1-1]) else: break pdfof.savefig(fig) k = k1+1 ############## plt.clf() pdfof.close() fig.set_size_inches(w, h) #######################REPLOT # plt.subplot(311) sp1 = fig.add_subplot(311, frameon=False) sp1.get_xaxis().tick_bottom() sp1.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('Frequency (GHz)') xtxt1 = min(bandx1) + (0.05*(max(bandx1) - min(bandx1))) plt.text(xtxt1, 0.75, r'RF Band', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bandx1) > min(bb128x): xtxt0 = max(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if (max(bandx1) < max(bb128x)): xtxt0 = min(bandx1) plt.text(xtxt0, 0.33, r'Baseband (partly) outside observable RF band!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp1.plot(bandx1,bandy1,'r--') sp1.plot(bandx2,bandy2,'g-.') sp1.plot(bb128x,bb128y,'b-') sp1.plot(subbandx,subbandy,'g-') sp1.plot(linex,liney,'r-') sp1.axis([min(bandx1)-0.030,max(bandx1)+0.030,0,1]) xmin, xmax = sp1.get_xaxis().get_view_interval() ymin, ymax = sp1.get_yaxis().get_view_interval() sp1.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) # plt.subplot(312) sp2 = fig.add_subplot(312, frameon=False) sp2.get_xaxis().tick_bottom() sp2.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') xtxt2 = min(bb128x) + (0.05*(max(bb128x) - min(bb128x))) plt.text(xtxt2, 0.75, r'Baseband', color='blue', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if min(bb128x) > min(linex): xtxt20 = max(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='right', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) if max(bb128x) < max(linex): xtxt20 = min(bb128x) plt.text(xtxt20, 0.33, r'One or more line(s) outside the baseband!', ha='left', color='red', bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8),)) sp2.plot(bb128x,bb128y,'b-') sp2.plot(subbandx,subbandy,'g-') sp2.plot(linex,liney,'r-') sp2.axis([min(bb128x)-0.006,max(bb128x)+0.006,0,1.2]) xmin, xmax = sp2.get_xaxis().get_view_interval() ymin, ymax = sp2.get_yaxis().get_view_interval() sp2.add_artist(Line2D((xmin, xmax), (ymin, ymin), color='black', linewidth=2)) # plt.subplot(313) sp3 = fig.add_subplot(313, frameon=False) sp3.axes.get_xaxis().set_visible(False) sp3.axes.get_yaxis().set_visible(False) plt.ylabel('') plt.xlabel('') sp3.plot(subbandx,subbandy,'w:') xmin, xmax = sp3.get_xaxis().get_view_interval() ymin, ymax = sp3.get_yaxis().get_view_interval() ytxt = ymax for l in range(len(prints)): ytxt = ymax - 0.125*(ymax-ymin)*(l+1) plt.text(xmin,ytxt,prints[l]) if len(prints1) > 9: prints1[8] = '... and more line(s) outside the baseband frequency coverage!' for l in range(min(9,len(prints1))): ytxt = ytxt - 0.125*(ymax-ymin) plt.text(xmin,ytxt,prints1[l]) plt.text(xmax,ytxt-0.125,'ID: %s' %(str(md5.new(file(str(sys.argv[0])).read()).hexdigest())), ha='right', color='0.85') ####################### prints1 = [] prints22 = [] ## i_flag=raw_input('Do you want to further shift the baseband center freq.? [y/n]:') if i_flag.upper() != 'Y': plt.close() print 'We are done for now! Quitting tune ...' i=1 else: i=0