summarylogtreecommitdiffstats
path: root/datasets-use-local.patch
blob: 67f64adca19bb4552038e5945cb4608769215e03 (plain)
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	2024-10-15 02:27:03.000000000 +0800
+++ b/photutils/datasets/load.py	2024-10-15 10:30:36.770782046 +0800
@@ -98,8 +98,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)
 
     with fits.open(path) as hdulist:
         data = hdulist[0].data
@@ -145,8 +149,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)
     return Table.read(path)
 
 
@@ -210,7 +218,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)
     with fits.open(path) as hdulist:
         data = hdulist[0].data
         header = hdulist[0].header
@@ -250,8 +261,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)
     with fits.open(path) as hdulist:
         data = hdulist[0].data
         header = hdulist[0].header
@@ -287,9 +302,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)
     with fits.open(path) as hdulist:
         data = hdulist[0].data
         header = hdulist[0].header