Skip to content

Commit 6c5b91e

Browse files
committed
Merge pull request #498 from keflavich/alma_fov_example
Add new Gallery example and utilities for ALMA
2 parents 48bc89c + 3fc082a commit 6c5b91e

File tree

2 files changed

+146
-0
lines changed

2 files changed

+146
-0
lines changed

astroquery/alma/core.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,3 +832,40 @@ def unique(seq):
832832
seen = set()
833833
seen_add = seen.add
834834
return [x for x in seq if not (x in seen or seen_add(x))]
835+
836+
def parse_frequency_support(frequency_support_str):
837+
"""
838+
ALMA "Frequency Support" strings have the form:
839+
[100.63..101.57GHz,488.28kHz, XX YY] U [102.43..103.37GHz,488.28kHz, XX YY] U [112.74..113.68GHz,488.28kHz, XX YY] U [114.45..115.38GHz,488.28kHz, XX YY]
840+
at least, as far as we have seen. The "U" is meant to be the Union symbol.
841+
This function will parse such a string into a list of pairs of astropy
842+
Quantities representing the frequency range. It will ignore the resolution
843+
and polarizations.
844+
"""
845+
supports = frequency_support_str.split("U")
846+
freq_ranges = [(float(sup.strip('[] ').split("..")[0]),
847+
float(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.letters)))
848+
*u.Unit(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.punctuation+string.digits))
849+
for sup in supports]
850+
return freq_ranges
851+
852+
def approximate_primary_beam_sizes(frequency_support_str, dish_diameter=12*u.m, first_null=1.220):
853+
"""
854+
Using parse_frequency_support, determine the mean primary beam size in each
855+
observed band
856+
857+
Parameters
858+
----------
859+
frequency_support_str : str
860+
The frequency support string, see `parse_frequency_support`
861+
dish_diameter : `~astropy.units.Quantity`
862+
Meter-equivalent unit. The diameter of the dish.
863+
first_null : float
864+
The position of the first null of an Airy. Used to compute resolution
865+
as :math:`R = 1.22 \lambda/D`
866+
"""
867+
freq_ranges = parse_frequency_support(frequency_support_str)
868+
beam_sizes = [(first_null*fr.mean().to(u.m, u.spectral())/(dish_diameter)).to(u.arcsec,
869+
u.dimensionless_angles())
870+
for fr in freq_ranges]
871+
return beam_sizes

docs/gallery.rst

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)