Last active
February 25, 2017 21:03
-
-
Save astro313/201bc07661a7246b953eca2ed8f3b348 to your computer and use it in GitHub Desktop.
for zsearch project -- show the spectral coverage for different SGs to identify overlapping ones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| show the spectral coverage for different SGs to identify overlapping ones... | |
| Last mod: 25 Feb 2017 | |
| ''' | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import matplotlib.patches as patches | |
| plot_5 = False | |
| plot_combined = True | |
| visList = ['../member.uid___A001_X879_X45e/DaisyCalMS/science_calibrated.ms', | |
| '../member.uid___A001_X879_X462/DaisyCalMS/science_calibrated.ms', | |
| '../member.uid___A001_X879_X466/DaisyCalMS/science_calibrated.ms', | |
| '../member.uid___A001_X879_X46a/DaisyCalMS/science_calibrated.ms', | |
| '../member.uid___A001_X879_X46e/DaisyCalMS/science_calibrated.ms'] | |
| combinedMS = 'ADFS_allTunings.LSRK.ms' | |
| if plot_5: | |
| fig5 = plt.figure() | |
| ax5 = fig5.add_subplot(111) | |
| for i, vv in enumerate(visList): | |
| tb.open(vv + "/SPECTRAL_WINDOW") | |
| freqs = np.squeeze(tb.getcol("CHAN_FREQ"))/1.e9 # GHz | |
| tb.close() | |
| for spw in range(freqs.shape[-1]): | |
| xlow = freqs[:, spw].min() | |
| xhi = freqs[:, spw].max() | |
| ylo, yhi = i/float(len(visList)), (i+1)/float(len(visList)) | |
| p = patches.Rectangle((xlow, ylo), abs(xhi - xlow) , abs(yhi - ylo), alpha=0.5) # xy, width, height | |
| ax5.annotate(str(spw), (freqs[:, spw].mean(), abs(yhi - ylo)/2+ylo)) | |
| ax5.add_patch(p) | |
| # plt.xlim(83, 116) | |
| # plt.show() | |
| # raw_input(" ") | |
| ax5.xaxis.set_minor_locator(plt.MultipleLocator(1.0)) | |
| ax5.tick_params(which='minor', length=3) | |
| plt.xlim(83, 116) | |
| plt.title(" Spectral Coverage for ADFS sources") | |
| plt.xlabel("observed freq [GHz]") | |
| ylabel = ax5.get_yticks().tolist() | |
| ylabel = [jj[ jj.find('_X4')+1 : jj.find('/D') ] for jj in visList] | |
| ax5.set_yticklabels(ylabel) | |
| plt.ylabel("SG file") | |
| plt.show() | |
| # fig1 = plt.gcf() | |
| User_input = raw_input('Save figure? (Y/N): ') | |
| if User_input == 'Y': | |
| filename = "spectral_coverage.png" | |
| Plotpath = './' | |
| fig5.savefig(Plotpath + filename, dpi=100, format='png', | |
| bbox_inches="tight", pad_inches=0.1) | |
| print "-- Saved figure as : %s --" % (Plotpath + filename) | |
| if plot_combined: | |
| visList = [combinedMS] | |
| fig3 = plt.figure() | |
| ax3 = fig3.add_subplot(111) | |
| for i, vv in enumerate(visList): | |
| tb.open(vv + "/SPECTRAL_WINDOW") | |
| freqs = np.squeeze(tb.getcol("CHAN_FREQ"))/1.e9 # GHz | |
| tb.close() | |
| for spw in range(freqs.shape[-1]): | |
| xlow = freqs[:, spw].min() | |
| xhi = freqs[:, spw].max() | |
| ylo, yhi = i/float(len(visList)), (i+1)/float(len(visList)) | |
| p = patches.Rectangle((xlow, ylo), abs(xhi - xlow) , abs(yhi - ylo) , alpha=0.3) # xy, width, height | |
| ax3.annotate(str(spw), (freqs[:, spw].mean(), abs(yhi - ylo)/2+ylo)) | |
| ax3.add_patch(p) | |
| ax3.xaxis.set_minor_locator(plt.MultipleLocator(1.0)) | |
| ax3.tick_params(which='minor', length=3) | |
| plt.xlim(83, 116) | |
| plt.title(" Spectral Coverage for ADFS sources, single MS combined all tunings") | |
| plt.xlabel("observed freq [GHz]") | |
| plt.show() | |
| # fig1 = plt.gcf() | |
| User_input = raw_input('Save figure? (Y/N): ') | |
| if User_input == 'Y': | |
| filename = "spectral_coverage_combinedTunings.png" | |
| Plotpath = './' | |
| fig3.savefig(Plotpath + filename, dpi=100, format='png', | |
| bbox_inches="tight", pad_inches=0.1) | |
| print "-- Saved figure as : %s --" % (Plotpath + filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment