Skip to content

Commit 9b29eeb

Browse files
tinuademargaretbsipocz
authored andcommitted
added remote data directive plus some debugging
1 parent b2bd214 commit 9b29eeb

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

astroquery/alfalfa/core.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_catalog(self):
4848
iterable_lines = result.iter_lines()
4949

5050
# Read header
51-
cols = [col for col in next(iterable_lines).rstrip('\n').split(',')]
51+
cols = [col for col in next(iterable_lines).rstrip(b'\n').split(b',')]
5252

5353
catalog = {}
5454
for col in cols:
@@ -59,14 +59,14 @@ def get_catalog(self):
5959
# skip blank lines or trailing newlines
6060
if line == "":
6161
continue
62-
col_values = line.rstrip('\n').split(',')
62+
col_values = line.rstrip(b'\n').split(b',')
6363
for i, col in enumerate(cols):
6464
item = col_values[i].strip()
6565
if item == '\"\"':
6666
catalog[col].append(self.PLACEHOLDER)
6767
elif item.isdigit():
6868
catalog[col].append(int(item))
69-
elif item.replace('.', '').isdigit():
69+
elif item.replace(b'.', b'').isdigit():
7070
catalog[col].append(float(item))
7171
else:
7272
catalog[col].append(item)
@@ -139,11 +139,11 @@ def query_region(self, coordinates, radius=3. * u.arcmin,
139139

140140
# Use RA and DEC to find appropriate AGC
141141
if optical_counterpart:
142-
ra_ref = cat['RAdeg_OC']
143-
dec_ref = cat['DECdeg_OC']
142+
ra_ref = cat[b'RAdeg_OC']
143+
dec_ref = cat[b'DECdeg_OC']
144144
else:
145-
ra_ref = cat['RAdeg_HI']
146-
dec_ref = cat['Decdeg_HI']
145+
ra_ref = cat[b'RAdeg_HI']
146+
dec_ref = cat[b'Decdeg_HI']
147147

148148
dra = np.abs(ra_ref - ra) \
149149
* np.cos(dec * np.pi / 180.)
@@ -155,7 +155,7 @@ def query_region(self, coordinates, radius=3. * u.arcmin,
155155

156156
# Matched object within our search radius?
157157
if minsep < dr:
158-
return cat['AGCNr'][i_minsep]
158+
return cat[b'AGCNr'][i_minsep]
159159
else:
160160
return None
161161

@@ -185,7 +185,7 @@ def get_spectrum_async(self, agc, show_progress=True):
185185
agc = str(agc).zfill(6)
186186

187187
link = "%s/A%s.fits" % (self.FITS_PREFIX, agc)
188-
result = commons.FileContainer(link, show_progress=show_progress)
188+
result = commons.FileContainer(link, show_progress=show_progress, encoding='binary')
189189
return result
190190

191191
@prepend_docstr_nosections(get_spectrum_async.__doc__)

astroquery/utils/commons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def get_fits(self):
382382
if len(filedata) == 0:
383383
raise TypeError("The file retrieved was empty.")
384384

385-
self._fits = fits.HDUList.fromstring(filedata)
385+
self._fits = fits.HDUList.fromstring(filedata, ignore_missing_end=True)
386386

387387
return self._fits
388388

docs/alfalfa/alfalfa.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. doctest-skip-all
2-
31
.. _astroquery.alfalfa:
42

53
ALFALFA Queries (`astroquery.alfalfa`)
@@ -13,12 +11,14 @@ with the position of a source that exists in another survey (same object we
1311
used in the SDSS example).
1412

1513
.. code-block:: python
14+
.. doctest-remote-data::
1615

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

21+
2222
This retrieves the AGC number of the object closest to the supplied ra and dec
2323
(within search radius dr=3 arcminutes by default). The "optical_counterpart" keyword
2424
argument above tells the crossID function to look for matches using the
@@ -29,13 +29,13 @@ and once we know it, we can download spectra (if they are available) easily,
2929

3030
.. code-block:: python
3131
32-
>>> sp = Alfalfa.get_spectrum(agc)
32+
>>> # sp = Alfalfa.get_spectrum(agc)
3333
3434
This returns a PyFITS HDUList object. If we want to have a look at the entire ALFALFA catalog, we can do that too:
3535

3636
.. code-block:: python
3737
38-
>>> cat = Alfalfa.get_catalog()
38+
>>> cat = Alfalfa.get_catalog() # doctest: +REMOTE_DATA
3939
4040
which returns a dictionary containing HI measurements for nearly 16,000
4141
objects.

0 commit comments

Comments
 (0)