Skip to content

Commit 57700a2

Browse files
committed
Merge pull request #439 from keflavich/alma/docs
Add 'help' to ALMA docs
2 parents 76e8ef1 + 4d7d11d commit 57700a2

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

docs/alma/alma.rst

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,44 @@ Getting started
1212
`astroquery.alma` provides the astroquery interface to the ALMA archive. It
1313
supports object and region based querying and data staging and retrieval.
1414

15+
You can get interactive help to find out what keywords to query for:
16+
17+
.. code-block:: python
18+
19+
>>> from astroquery.alma import Alma
20+
>>> Alma.help()
21+
Valid ALMA keywords:
22+
23+
Position
24+
Source name (Sesame) : source_name_sesame
25+
Source name (ALMA) : source_name-asu
26+
RA Dec : raDecCoordinates
27+
28+
Energy
29+
Frequency : energy.frequency-asu
30+
Bandwidth : energy.bandwidth-asu
31+
Spectral resolution : energy.resolution-asu
32+
Band : band-asu
33+
34+
Time
35+
Observation date : start_date-asu
36+
Integration time : int_time-asu
37+
38+
Polarisation
39+
Polarisation type : energy.pol_num-asu
40+
41+
Observation
42+
Water vapour : pwv-asu
43+
44+
Project
45+
Project code : project_code-asu
46+
Project title : project.title-substr
47+
PI name : project.pi_name-substr
48+
49+
Options
50+
View: : viewFormat
51+
[x] public data only : publicFilterFlag = public
52+
[x] science observations only : scan_intent-asu = =%TARGET%
1553
1654
Authentication
1755
==============
@@ -111,7 +149,7 @@ UIDs):
111149
112150
You can then go on to download that data. The download will be cached so that repeat
113151
queries of the same file will not re-download the data. The default cache
114-
directory is `~/.astropy/cache/astroquery/Alma/`, but this can be changed by
152+
directory is ``~/.astropy/cache/astroquery/Alma/``, but this can be changed by
115153
changing the ``cache_location`` variable:
116154

117155
.. code-block:: python

docs/gallery.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,53 @@ Finding the mass of a specific planet:
107107
>>> print findvalue( kepler68b, 'mass')
108108
0.02105109
109109
110+
Example 6
111+
+++++++++
112+
113+
Grab some data from ALMA, then analyze it using the Spectral Cube package after
114+
identifying some spectral lines in the data.
115+
116+
.. code-block:: python
117+
118+
from astroquery.alma import Alma
119+
from astroquery.splatalogue import Splatalogue
120+
from astroquery.simbad import Simbad
121+
from astropy import units as u
122+
from astropy import constants
123+
from spectral_cube import SpectralCube
124+
125+
m83table = Alma.query_object('M83', public=True)
126+
m83urls = Alma.stage_data(m83table['Asdm_uid'])
127+
m83files = Alma.download_and_extract_files(m83urls['URL'])
128+
# Sometimes there can be duplicates
129+
m83files = list(set(m83files))
130+
131+
Simbad.add_votable_fields('rvel')
132+
m83simbad = Simbad.query_object('M83')
133+
rvel = m83simbad['RVel_Rvel'][0]*u.Unit(m83simbad['RVel_Rvel'].unit)
134+
135+
for fn in m83files:
136+
if 'line' in fn:
137+
cube = SpectralCube.read(fn)
138+
# Convert frequencies to their rest frequencies
139+
frange = u.Quantity([cube.spectral_axis.min(),
140+
cube.spectral_axis.max()]) * (1+rvel/constants.c)
141+
142+
# Query the top 20 most common species in the frequency range of the
143+
# cube with an upper energy state <= 50K
144+
lines = Splatalogue.query_lines(frange[0], frange[1], top20='top20',
145+
energy_max=50, energy_type='eu_k',
146+
only_NRAO_recommended=True)
147+
lines.pprint()
148+
149+
# Change the cube coordinate system to be in velocity with respect
150+
# to the rest frequency (in the M83 rest frame)
151+
rests_frequency = lines['Freq-GHz'][0]*u.GHz / (1+rvel/constants.c)
152+
vcube = cube.with_spectral_unit(u.km/u.s,
153+
rest_value=rest_frequency,
154+
velocity_convention='radio')
155+
156+
# Write the cube with the specified line name
157+
fmt = "{Species}{Resolved QNs}"
158+
linename = fmt.format(**dict(zip(row.colnames,row.data)))
159+
vcube.write('M83_ALMA_{linename}.fits'.format(linename=linename))

0 commit comments

Comments
 (0)