Skip to content

Commit d940421

Browse files
committed
integrated example:simbad + splatalogue + alma + spectral_cube
1 parent 8444e9f commit d940421

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

docs/gallery.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,48 @@ 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+
vcube = cube.with_spectral_unit(u.km/u.s,
150+
rest_value=lines['Freq-GHz'][0]*u.GHz,
151+
velocity_convention='radio')
152+
# Ugly, I know, but it's a clever python trick...
153+
linename = "{Species}{Resolved QNs}".format(**dict(zip(row.colnames,row.data)))
154+
vcube.write('M83_ALMA_{linename}.fits'.format(linename=linename))

0 commit comments

Comments
 (0)