Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alfalfa documentation clean up #1941

Merged
merged 3 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions astroquery/alfalfa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ def get_catalog(self):
return self.ALFALFACAT

result = requests.get(self.CATALOG_PREFIX)
iterable_lines = result.iter_lines()
iterable_lines = result.text.split('\n')

# Read header
cols = [col for col in next(iterable_lines).rstrip('\n').split(',')]
cols = iterable_lines[0].split(',')

catalog = {}
for col in cols:
catalog[col] = []

# Parse result
for line in iterable_lines:
for line in iterable_lines[1:]:
# skip blank lines or trailing newlines
if line == "":
continue
col_values = line.rstrip('\n').split(',')
col_values = line.split(',')
for i, col in enumerate(cols):
item = col_values[i].strip()
if item == '\"\"':
Expand Down
18 changes: 12 additions & 6 deletions docs/alfalfa/alfalfa.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.. doctest-skip-all

.. _astroquery.alfalfa:

ALFALFA Queries (`astroquery.alfalfa`)
Expand All @@ -12,12 +10,14 @@ This example shows how to perform an object cross-ID with ALFALFA. We'll start
with the position of a source that exists in another survey (same object we
used in the SDSS example).

.. code-block:: python
.. doctest-remote-data::

>>> from astroquery.alfalfa import Alfalfa
>>> from astropy import coordinates as coords
>>> pos = coords.SkyCoord('0h8m05.63s +14d50m23.3s')
>>> agc = Alfalfa.query_region(pos, optical_counterpart=True)
>>> agc
100051

This retrieves the AGC number of the object closest to the supplied ra and dec
(within search radius dr=3 arcminutes by default). The "optical_counterpart" keyword
Expand All @@ -27,19 +27,25 @@ determined by members of the ALFALFA team), rather than their radio centroids.
The AGC number is an identification number for objects in the ALFALFA survey,
and once we know it, we can download spectra (if they are available) easily,

.. code-block:: python
.. Remove the skip once #2403 is fixed
.. .. doctest-remote-data::
.. doctest-skip::

>>> sp = Alfalfa.get_spectrum(agc)

This returns a PyFITS HDUList object. If we want to have a look at the entire ALFALFA catalog, we can do that too:
This returns a `~astropy.io.fits.HDUList` object. If we want to have a look at the
entire ALFALFA catalog as a dictionary, we can do that too:

.. code-block:: python
.. doctest-remote-data::

>>> cat = Alfalfa.get_catalog()
>>> cat.keys()
dict_keys(['AGCNr', 'Name', 'RAdeg_HI', 'Decdeg_HI', 'RAdeg_OC', 'DECdeg_OC', 'Vhelio', 'W50', 'errW50', 'HIflux', 'errflux', 'SNR', 'RMS', 'Dist', 'logMsun', 'HIcode', 'OCcode', 'NoteFlag'])

which returns a dictionary containing HI measurements for nearly 16,000
objects.


Reference/API
-------------

Expand Down