Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. '''
  2.  
  3. show the spectral coverage for different SGs to identify overlapping ones...
  4.  
  5. Last mod: 25 Feb 2017
  6.  
  7.  
  8. '''
  9.  
  10. import numpy as np
  11. import matplotlib.pyplot as plt
  12. import matplotlib.patches as patches
  13.  
  14. visList = ['../member.uid___A001_X879_X45e/DaisyCalMS/science_calibrated.ms',
  15. '../member.uid___A001_X879_X462/DaisyCalMS/science_calibrated.ms',
  16. '../member.uid___A001_X879_X466/DaisyCalMS/science_calibrated.ms',
  17. '../member.uid___A001_X879_X46a/DaisyCalMS/science_calibrated.ms',
  18. '../member.uid___A001_X879_X46e/DaisyCalMS/science_calibrated.ms']
  19.  
  20.  
  21. fig5 = plt.figure()
  22. ax5 = fig5.add_subplot(111)
  23.  
  24. for i, vv in enumerate(visList):
  25.  
  26. tb.open(vv + "/SPECTRAL_WINDOW")
  27. freqs = np.squeeze(tb.getcol("CHAN_FREQ"))/1.e9 # GHz
  28. tb.close()
  29.  
  30. for spw in range(freqs.shape[-1]):
  31. xlow = freqs[:, spw].min()
  32. xhi = freqs[:, spw].max()
  33. ylo, yhi = i/float(len(visList)), (i+1)/float(len(visList))
  34. p = patches.Rectangle((xlow, ylo), abs(xhi - xlow) , abs(yhi - ylo), alpha=0.5) # xy, width, height
  35. ax5.annotate(str(spw), (freqs[:, spw].mean(), abs(yhi - ylo)/2+ylo))
  36. ax5.add_patch(p)
  37. # plt.xlim(83, 116)
  38. # plt.show()
  39. # raw_input(" ")
  40.  
  41. plt.xlim(83, 116)
  42. plt.title(" Spectral Coverage for ADFS sources")
  43. plt.xlabel("observed freq [GHz]")
  44. ylabel = ax5.get_yticks().tolist()
  45. ylabel = [jj[ jj.find('_X4')+1 : jj.find('/D') ] for jj in visList]
  46. ax5.set_yticklabels(ylabel)
  47. plt.ylabel("SG file")
  48. plt.show()
  49.  
  50. # fig1 = plt.gcf()
  51. User_input = raw_input('Save figure? (Y/N): ')
  52. if User_input == 'Y':
  53. filename = "spectral_coverage.png"
  54. Plotpath = './'
  55. fig5.savefig(Plotpath + filename, dpi=100, format='png',
  56. bbox_inches="tight", pad_inches=0.1)
  57. print "-- Saved figure as : %s --" % (Plotpath + filename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement