@@ -159,3 +159,112 @@ identifying some spectral lines in the data.
159159 row = lines[0 ]
160160 linename = fmt.format(** dict (zip (row.colnames,row.data)))
161161 vcube.write(' M83_ALMA_{linename} .fits' .format(linename = linename))
162+
163+ Example 7
164+ +++++++++
165+ Find ALMA pointings that have been observed toward M83, then overplot the
166+ various fields-of view on a 2MASS image retrieved from SkyView. See
167+ http://nbviewer.ipython.org/gist/keflavich/19175791176e8d1fb204 for the
168+ notebook.
169+
170+ .. code-block :: python
171+
172+ # coding: utf-8
173+
174+ # Querying ALMA archive for M83 pointings and plotting them on a 2MASS image
175+
176+ # In[1]:
177+
178+ from astroquery.alma import Alma
179+ from astroquery.skyview import SkyView
180+ import string
181+ from astropy import units as u
182+ import pylab as pl
183+ import aplpy
184+
185+
186+ # Retrieve M83 2MASS K-band image:
187+
188+ # In[2]:
189+
190+ m83_images = SkyView.get_images(position = ' M83' , survey = [' 2MASS-K' ], pixels = 1500 )
191+
192+
193+ # Retrieve ALMA archive information *including* private data and non-science fields:
194+ #
195+
196+ # In[3]:
197+
198+ m83 = Alma.query_object(' M83' , public = False , science = False )
199+
200+
201+ # In[4]:
202+
203+ m83
204+
205+
206+ # Parse components of the ALMA data. Specifically, find the frequency support - the frequency range covered - and convert that into a central frequency for beam radius estimation.
207+
208+ # In[5]:
209+
210+ def parse_frequency_support (frequency_support_str ):
211+ supports = frequency_support_str.split(" U" )
212+ freq_ranges = [(float (sup.strip(' [] ' ).split(" .." )[0 ]),
213+ float (sup.strip(' [] ' ).split(" .." )[1 ].split(' ,' )[0 ].strip(string.letters)))
214+ * u.Unit(sup.strip(' [] ' ).split(" .." )[1 ].split(' ,' )[0 ].strip(string.punctuation+ string.digits))
215+ for sup in supports]
216+ return u.Quantity(freq_ranges)
217+
218+ def approximate_primary_beam_sizes (frequency_support_str ):
219+ freq_ranges = parse_frequency_support(frequency_support_str)
220+ beam_sizes = [(1.22 * fr.mean().to(u.m, u.spectral())/ (12 * u.m)).to(u.arcsec,
221+ u.dimensionless_angles())
222+ for fr in freq_ranges]
223+ return u.Quantity(beam_sizes)
224+
225+
226+ # In[6]:
227+
228+ primary_beam_radii = [approximate_primary_beam_sizes(row[' Frequency_support' ]) for row in m83]
229+
230+
231+ # Compute primary beam parameters for the public and private components of the data for plotting below
232+
233+ # In[7]:
234+
235+ private_circle_parameters = [(row[' RA' ],row[' Dec' ],np.mean(rad).to(u.deg).value)
236+ for row,rad in zip (m83, primary_beam_radii)
237+ if row[' Release_date' ]!= ' ' ]
238+ public_circle_parameters = [(row[' RA' ],row[' Dec' ],np.mean(rad).to(u.deg).value)
239+ for row,rad in zip (m83, primary_beam_radii)
240+ if row[' Release_date' ]== ' ' ]
241+ unique_private_circle_parameters = np.array(list (set (private_circle_parameters)))
242+ unique_public_circle_parameters = np.array(list (set (public_circle_parameters)))
243+
244+ print (" PUBLIC: Number of rows: {0} . Unique pointings: {1} " .format(len (m83), len (unique_public_circle_parameters)))
245+ print (" PRIVATE: Number of rows: {0} . Unique pointings: {1} " .format(len (m83), len (unique_private_circle_parameters)))
246+
247+
248+ # Show all of the private observation pointings that have been acquired
249+
250+ # In[8]:
251+
252+ fig = aplpy.FITSFigure(m83_images[0 ])
253+ fig.show_grayscale(stretch = ' arcsinh' )
254+ fig.show_circles(unique_private_circle_parameters[:,0 ],
255+ unique_private_circle_parameters[:,1 ],
256+ unique_private_circle_parameters[:,2 ],
257+ color = ' r' , alpha = 0.2 )
258+
259+
260+ # In principle, all of the pointings shown below should be downloadable from the archive:
261+
262+ # In[9]:
263+
264+ fig = aplpy.FITSFigure(m83_images[0 ])
265+ fig.show_grayscale(stretch = ' arcsinh' )
266+ fig.show_circles(unique_public_circle_parameters[:,0 ],
267+ unique_public_circle_parameters[:,1 ],
268+ unique_public_circle_parameters[:,2 ],
269+ color = ' b' , alpha = 0.2 )
270+
0 commit comments