1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
--- a/photutils/datasets/load.py 2022-07-13 11:03:16.000000000 +0800
+++ b/photutils/datasets/load.py 2022-07-13 15:21:23.655360328 +0800
@@ -105,8 +105,12 @@
hdu = load_spitzer_image()
plt.imshow(hdu.data, origin='lower', vmax=50)
"""
- path = get_path('spitzer_example_image.fits', location='remote',
- show_progress=show_progress)
+ try:
+ path = get_path('spitzer_example_image.fits', location='remote',
+ show_progress=show_progress)
+ except (URLError, HTTPError): # timeout or not found
+ path = get_path('spitzer_example_image.fits', location='local',
+ show_progress=show_progress)
hdu = fits.open(path)[0]
return hdu
@@ -149,8 +153,12 @@
plt.xlim(18.39, 18.05)
plt.ylim(0.13, 0.30)
"""
- path = get_path('spitzer_example_catalog.xml', location='remote',
- show_progress=show_progress)
+ try:
+ path = get_path('spitzer_example_catalog.xml', location='remote',
+ show_progress=show_progress)
+ except Exception: # timeout or not found
+ path = get_path('spitzer_example_catalog.xml', location='local',
+ show_progress=show_progress)
table = Table.read(path)
return table
@@ -216,7 +224,10 @@
raise ValueError('channel must be 1, 2, 3, or 4')
filepath = f'irac_ch{channel}_flight.fits'
- path = get_path(filepath, location='remote', show_progress=show_progress)
+ try:
+ path = get_path(filepath, location='remote', show_progress=show_progress)
+ except Exception: # timeout or not found
+ path = get_path(filepath, location='local', show_progress=show_progress)
hdu = fits.open(path)[0]
return hdu
@@ -287,8 +298,12 @@
hdu = load_star_image()
plt.imshow(hdu.data, origin='lower', interpolation='nearest')
"""
- path = get_path('M6707HH.fits', location='remote',
- show_progress=show_progress)
+ try:
+ path = get_path('M6707HH.fits', location='remote',
+ show_progress=show_progress)
+ except Exception: # timeout or not found
+ path = get_path('M6707HH.fits', location='local',
+ show_progress=show_progress)
hdu = fits.open(path)[0]
return hdu
@@ -322,9 +337,14 @@
hdu = load_simulated_hst_star_image()
plt.imshow(hdu.data, origin='lower', interpolation='nearest')
"""
- path = get_path('hst_wfc3ir_f160w_simulated_starfield.fits',
- location='photutils-datasets',
- show_progress=show_progress)
+ try:
+ path = get_path('hst_wfc3ir_f160w_simulated_starfield.fits',
+ location='photutils-datasets',
+ show_progress=show_progress)
+ except Exception: # timeout or not found
+ path = get_path('hst_wfc3ir_f160w_simulated_starfield.fits',
+ location='local',
+ show_progress=show_progress)
hdu = fits.open(path)[0]
return hdu
|