summarylogtreecommitdiffstats
path: root/use_local_doc_fits_offline.patch
blob: a8761cefd32b60e9f8b2effe367db1d81388a9de (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
--- a/docs/index.rst	2023-03-28 02:13:36.000000000 +0800
+++ b/docs/index.rst	2023-04-07 15:02:28.220494471 +0800
@@ -52,9 +52,13 @@
     Now we load the dataset from its canonical source:
 
     >>> filename = 'https://data.sdss.org/sas/dr16/sdss/spectro/redux/26/spectra/1323/spec-1323-52797-0012.fits'
-    >>> # The spectrum is in the second HDU of this file.
-    >>> with fits.open(filename) as f:  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
-    ...     specdata = f[1].data  # doctest: +REMOTE_DATA
+    >>> # The spectrum is in the second HDU of this file. Use local fits if no network when doc building.
+    >>> try: 
+    ...     with fits.open(filename) as f:  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
+    ...         specdata = f[1].data  # doctest: +REMOTE_DATA
+    >>> except Exception:
+    ...     with fits.open('spec-1323-52797-0012.fits') as f:  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
+    ...         specdata = f[1].data  # doctest: +REMOTE_DATA
 
     Then we re-format this dataset into astropy quantities, and create a
     `~specutils.Spectrum1D` object:
--- a/docs/manipulation.rst	2023-03-18 03:59:09.000000000 +0800
+++ b/docs/manipulation.rst	2023-04-07 15:02:42.363989130 +0800
@@ -181,9 +181,13 @@
     >>> quantity_support()  # for getting units on the axes below  # doctest: +IGNORE_OUTPUT
 
     >>> filename = 'https://data.sdss.org/sas/dr16/sdss/spectro/redux/26/spectra/1323/spec-1323-52797-0012.fits'
-    >>> # The spectrum is in the second HDU of this file.
-    >>> with fits.open(filename) as f:  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
-    ...     specdata = f[1].data[1020:1250]  # doctest: +REMOTE_DATA
+    >>> # The spectrum is in the second HDU of this file. Use local fits if no network when doc building.
+    >>> try:
+    ...     with fits.open(filename) as f:  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
+    ...         specdata = f[1].data[1020:1250]  # doctest: +REMOTE_DATA
+    >>> except Exception:
+    ...     with fits.open('spec-1323-52797-0012.fits') as f:  # doctest: +IGNORE_OUTPUT +REMOTE_DATA
+    ...         specdata = f[1].data[1020:1250]  # doctest: +REMOTE_DATA
 
     Then we re-format this dataset into astropy quantities, and create a
     `~specutils.Spectrum1D` object:
--- a/docs/spectral_cube.rst	2023-03-28 02:13:36.000000000 +0800
+++ b/docs/spectral_cube.rst	2023-04-07 14:50:15.832279576 +0800
@@ -180,7 +180,8 @@
     from specutils.manipulation import spectral_slab
 
     filename = "https://stsci.box.com/shared/static/28a88k1qfipo4yxc4p4d40v4axtlal8y.fits"
-    fn = download_file(filename, cache=True)
+    try: fn = download_file(filename, cache=True)
+    except Exception: fn = "28a88k1qfipo4yxc4p4d40v4axtlal8y.fits"  # use local fits if not network when doc building
     spec1d = Spectrum1D.read(fn)
 
     # Extract H-alpha sub-cube for moment maps using spectral_slab