Skip to content

Commit ee3f93f

Browse files
committed
Swapping out more direct requests and BytesIO
1 parent 171dc26 commit ee3f93f

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

tutorials/euclid_access/4_Euclid_intro_PHZ_catalog.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ If you have questions about this notebook, please contact the [IRSA helpdesk](ht
5151

5252
```{code-cell} ipython3
5353
# Uncomment the next line to install dependencies if needed.
54-
# !pip install requests matplotlib pandas 'astropy>=5.3' 'astroquery>=0.4.10' fsspec firefly_client
54+
# !pip install matplotlib pandas 'astropy>=5.3' 'astroquery>=0.4.10' fsspec firefly_client
5555
```
5656

5757
```{code-cell} ipython3
58-
from io import BytesIO
5958
import os
6059
import re
60+
import urllib
6161
62-
import requests
6362
import matplotlib.pyplot as plt
6463
6564
from astropy.coordinates import SkyCoord
@@ -324,20 +323,15 @@ df2=result2.to_table().to_pandas()
324323
df2
325324
```
326325

327-
```{code-cell} ipython3
328-
## Create the full filename/url
329-
irsa_url='https://irsa.ipac.caltech.edu/'
326+
Pull out the file name from the ``result`` table:
330327

331-
file_url=irsa_url+df2['uri'].iloc[0]
332-
file_url
328+
```{code-cell} ipython3
329+
file_uri = urllib.parse.urljoin(Irsa.tap_url, result2['uri'][0])
330+
file_uri
333331
```
334332

335333
```{code-cell} ipython3
336-
## Open the large FITS file without loading it entirely into memory
337-
## pulling out just the extension we want for the 1D spectra of our object
338-
response = requests.get(file_url)
339-
340-
with fits.open(BytesIO(response.content), memmap=True) as hdul:
334+
with fits.open(file_uri) as hdul:
341335
hdu = hdul[df2['hdu'].iloc[0]]
342336
dat = Table.read(hdu, format='fits', hdu=1)
343337
df_obj_irsa = dat.to_pandas()

tutorials/euclid_access/5_Euclid_intro_SPE_catalog.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ If you have questions about this notebook, please contact the [IRSA helpdesk](ht
5454
```
5555

5656
```{code-cell} ipython3
57-
from io import BytesIO
5857
import re
58+
import urllib
5959
6060
import matplotlib.pyplot as plt
6161
import numpy as np
6262
import pandas as pd
63-
import requests
6463
6564
from astropy.coordinates import SkyCoord
6665
from astropy.io import fits
@@ -213,14 +212,12 @@ df2
213212
This involves reading in the spectrum without readin in the full FITS file, just pulling the extension we want.
214213

215214
```{code-cell} ipython3
216-
irsa_url = 'https://irsa.ipac.caltech.edu/'
217-
218-
file_url = irsa_url + df2['uri'].iloc[0]
219-
file_url
220-
221-
response = requests.get(file_url)
215+
file_uri = urllib.parse.urljoin(Irsa.tap_url, result2['uri'][0])
216+
file_uri
217+
```
222218

223-
with fits.open(BytesIO(response.content), memmap=True) as hdul:
219+
```{code-cell} ipython3
220+
with fits.open(file_uri) as hdul:
224221
hdu = hdul[df2['hdu'].iloc[0]]
225222
dat = Table.read(hdu, format='fits', hdu=1)
226223
df_obj_irsa = dat.to_pandas()

0 commit comments

Comments
 (0)