Skip to content

Commit a556178

Browse files
committed
Merge remote-tracking branch 'upstream/master' into alma_api_update
Conflicts: astroquery/alma/core.py
2 parents 84fd4b7 + 6c5b91e commit a556178

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
@@ -875,3 +875,40 @@ def unique(seq):
875875
def filter_printable(s):
876876
""" extract printable characters from a string """
877877
return filter(lambda x: x in string.printable, s)
878+
879+
def parse_frequency_support(frequency_support_str):
880+
"""
881+
ALMA "Frequency Support" strings have the form:
882+
[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]
883+
at least, as far as we have seen. The "U" is meant to be the Union symbol.
884+
This function will parse such a string into a list of pairs of astropy
885+
Quantities representing the frequency range. It will ignore the resolution
886+
and polarizations.
887+
"""
888+
supports = frequency_support_str.split("U")
889+
freq_ranges = [(float(sup.strip('[] ').split("..")[0]),
890+
float(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.letters)))
891+
*u.Unit(sup.strip('[] ').split("..")[1].split(',')[0].strip(string.punctuation+string.digits))
892+
for sup in supports]
893+
return freq_ranges
894+
895+
def approximate_primary_beam_sizes(frequency_support_str, dish_diameter=12*u.m, first_null=1.220):
896+
"""
897+
Using parse_frequency_support, determine the mean primary beam size in each
898+
observed band
899+
900+
Parameters
901+
----------
902+
frequency_support_str : str
903+
The frequency support string, see `parse_frequency_support`
904+
dish_diameter : `~astropy.units.Quantity`
905+
Meter-equivalent unit. The diameter of the dish.
906+
first_null : float
907+
The position of the first null of an Airy. Used to compute resolution
908+
as :math:`R = 1.22 \lambda/D`
909+
"""
910+
freq_ranges = parse_frequency_support(frequency_support_str)
911+
beam_sizes = [(first_null*fr.mean().to(u.m, u.spectral())/(dish_diameter)).to(u.arcsec,
912+
u.dimensionless_angles())
913+
for fr in freq_ranges]
914+
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)