diff --git a/changelog/250.deprecation.rst b/changelog/250.deprecation.rst new file mode 100644 index 00000000..dfc16c7c --- /dev/null +++ b/changelog/250.deprecation.rst @@ -0,0 +1 @@ +Deprecate the `sunkit_spex.legacy` module. diff --git a/changelog/250.doc.rst b/changelog/250.doc.rst new file mode 100644 index 00000000..7346289e --- /dev/null +++ b/changelog/250.doc.rst @@ -0,0 +1 @@ +Split the gallery into `Examples` and `Legacy Examples` sections. diff --git a/docs/conf.py b/docs/conf.py index 6ca63212..6a92d41c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,7 +5,7 @@ # http://www.sphinx-doc.org/en/master/config import datetime -import pathlib +from pathlib import Path from packaging.version import Version @@ -76,10 +76,10 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { "python": ("https://docs.python.org/3/", (None, "http://data.astropy.org/intersphinx/python3.inv")), - "numpy": ("https://docs.scipy.org/doc/numpy/", (None, "http://data.astropy.org/intersphinx/numpy.inv")), - "scipy": ("https://docs.scipy.org/doc/scipy/reference/", (None, "http://data.astropy.org/intersphinx/scipy.inv")), - "matplotlib": ("https://matplotlib.org/", (None, "http://data.astropy.org/intersphinx/matplotlib.inv")), - "astropy": ("http://docs.astropy.org/en/stable/", None), + "numpy": ("https://docs.scipy.org/doc/numpy/", (None, "https://numpy.org/doc/stable/objects.inv")), + "scipy": ("https://docs.scipy.org/doc/scipy/reference/", (None, "https://docs.scipy.org/doc/scipy/objects.inv")), + "matplotlib": ("https://matplotlib.org/", (None, "https://matplotlib.org/stable/objects.inv")), + "astropy": ("http://docs.astropy.org/en/stable/", (None, "https://docs.astropy.org/en/stable/objects.inv")), "sunpy": ("https://docs.sunpy.org/en/stable/", None), } @@ -117,18 +117,15 @@ # -- Options for the Sphinx gallery ------------------------------------------- -path = pathlib.Path.cwd() -example_dir = path.parent.joinpath("examples") sphinx_gallery_conf = { - "backreferences_dir": str(path.joinpath("generated", "modules")), + "backreferences_dir": str(Path("generated") / "modules"), "filename_pattern": "^((?!skip_).)*$", - "examples_dirs": example_dir, - "gallery_dirs": path.joinpath("generated", "gallery"), + "examples_dirs": str(Path("..") / "examples"), + "gallery_dirs": str(Path("generated") / "gallery"), "abort_on_example_error": False, - "plot_gallery": "True", "remove_config_comments": True, "only_warn_on_example_error": True, - 'pypandoc': True + "parallel": True, } # -- Other options ---------------------------------------------------------- diff --git a/docs/how_to/index.rst b/docs/how_to/index.rst index 57f6abef..e4864e0d 100644 --- a/docs/how_to/index.rst +++ b/docs/how_to/index.rst @@ -11,3 +11,8 @@ you quickly accomplish common tasks. :maxdepth: 1 ../generated/gallery/index +.. toctree:: + :maxdepth: 1 + :hidden: + + ../generated/gallery/legacy/index diff --git a/docs/reference/legacy.rst b/docs/reference/legacy.rst index 733fc562..349686c6 100644 --- a/docs/reference/legacy.rst +++ b/docs/reference/legacy.rst @@ -2,7 +2,7 @@ Legacy (`sunkit_spex.legacy`) ***************************** .. warning:: - The legacy module contains legacy code which will no longer be maintained and will be removed in the near future. + The legacy module has been deprecated since version 0.4 and will be removed in a future version. .. automodapi:: sunkit_spex.legacy .. automodapi:: sunkit_spex.legacy.thermal diff --git a/examples/legacy/README.txt b/examples/legacy/README.txt new file mode 100644 index 00000000..e87267db --- /dev/null +++ b/examples/legacy/README.txt @@ -0,0 +1,5 @@ +Legacy Examples +--------------- + +.. warning:: + The legacy module has been deprecated since version 0.4 and will be removed in a future version. diff --git a/examples/fitting_NuSTAR_spectra-duncan2021.py b/examples/legacy/fitting_NuSTAR_spectra-duncan2021.py similarity index 98% rename from examples/fitting_NuSTAR_spectra-duncan2021.py rename to examples/legacy/fitting_NuSTAR_spectra-duncan2021.py index 79001549..81607aef 100644 --- a/examples/fitting_NuSTAR_spectra-duncan2021.py +++ b/examples/legacy/fitting_NuSTAR_spectra-duncan2021.py @@ -57,7 +57,7 @@ ] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./nustar/Duncan2021/") + dl.enqueue_file(base_url + fname, path="../../nustar/Duncan2021/") files = dl.download() @@ -65,7 +65,7 @@ # # First, load in your data files, here we load in 2 spectra -_dir = "./nustar/Duncan2021/" +_dir = "../../nustar/Duncan2021/" spec = Fitter(pha_file=[_dir + "nu80410201001A06_1618_p_chu2_N_sr.pha", _dir + "nu80410201001B06_1618_p_chu2_N_sr.pha"]) ##################################################### diff --git a/examples/fitting_NuSTAR_spectra-general.py b/examples/legacy/fitting_NuSTAR_spectra-general.py similarity index 98% rename from examples/fitting_NuSTAR_spectra-general.py rename to examples/legacy/fitting_NuSTAR_spectra-general.py index 94d51d37..72afc03e 100644 --- a/examples/fitting_NuSTAR_spectra-general.py +++ b/examples/legacy/fitting_NuSTAR_spectra-general.py @@ -47,7 +47,7 @@ ] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./nustar/m3_time2628/") + dl.enqueue_file(base_url + fname, path="../../nustar/m3_time2628/") files = dl.download() ##################################################### @@ -56,7 +56,7 @@ # First, load in your data files, here we load in 1 spectrum -_dir = "./nustar/m3_time2628/" +_dir = "../../nustar/m3_time2628/" spec = Fitter(pha_file=[_dir + "nu80414202001A06_chu23_S_cl_grade0_sr.pha"]) ##################################################### diff --git a/examples/fitting_NuSTAR_spectra-glesener2020.py b/examples/legacy/fitting_NuSTAR_spectra-glesener2020.py similarity index 98% rename from examples/fitting_NuSTAR_spectra-glesener2020.py rename to examples/legacy/fitting_NuSTAR_spectra-glesener2020.py index 72d9656f..e61a0837 100644 --- a/examples/fitting_NuSTAR_spectra-glesener2020.py +++ b/examples/legacy/fitting_NuSTAR_spectra-glesener2020.py @@ -62,14 +62,14 @@ ] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./nustar/Glesener2020/") + dl.enqueue_file(base_url + fname, path="../../nustar/Glesener2020/") files = dl.download() ##################################################### # # First, load in your data files, here we load in 2 spectra -_dir = "./nustar/Glesener2020/" +_dir = "../../nustar/Glesener2020/" # In the files here, the ARF and RMF file have different names to the PHA files so cannot use the PHA file name to help find the others so... spec = Fitter( pha_file=_dir + "nu20312001001B06_cl_grade0_sr_grp.pha", @@ -141,7 +141,7 @@ # In the original Figure 3(c), a broken power law is used as the cold thick target does not exist ins XPSEC. # # First, load in your data files, here we load in 2 spectra -_dir = "./nustar/Glesener2020/" +_dir = "../../nustar/Glesener2020/" spec = Fitter( pha_file=[_dir + "nu20312001001A06_cl_grade0_sr_grp.pha", _dir + "nu20312001001B06_cl_grade0_sr_grp.pha"], arf_file=[_dir + "nu20312001001A06_cl_grade0_sr.arf", _dir + "nu20312001001B06_cl_grade0_sr.arf"], @@ -227,7 +227,7 @@ # # First, load in your data files, here we load in 1 spectrum -_dir = "./nustar/Glesener2020/" +_dir = "../../nustar/Glesener2020/" spec = Fitter( pha_file=_dir + "nu20312001001B06_cl_grade0_sr_grp.pha", arf_file=_dir + "nu20312001001B06_cl_grade0_sr.arf", @@ -286,7 +286,7 @@ # # First, load in your data files, here we load in 2 spectra -_dir = "./nustar/Glesener2020/" +_dir = "../../nustar/Glesener2020/" spec = Fitter( pha_file=[_dir + "nu20312001001A06_cl_grade0_sr_grp.pha", _dir + "nu20312001001B06_cl_grade0_sr_grp.pha"], arf_file=[_dir + "nu20312001001A06_cl_grade0_sr.arf", _dir + "nu20312001001B06_cl_grade0_sr.arf"], diff --git a/examples/fitting_NuSTAR_spectra-simultaneously.py b/examples/legacy/fitting_NuSTAR_spectra-simultaneously.py similarity index 99% rename from examples/fitting_NuSTAR_spectra-simultaneously.py rename to examples/legacy/fitting_NuSTAR_spectra-simultaneously.py index b903a5df..432a357e 100644 --- a/examples/fitting_NuSTAR_spectra-simultaneously.py +++ b/examples/legacy/fitting_NuSTAR_spectra-simultaneously.py @@ -50,14 +50,14 @@ ] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./nustar/m10_1616_1620/") + dl.enqueue_file(base_url + fname, path="../../nustar/m10_1616_1620/") files = dl.download() ##################################################### # # Load in your data files, here we load in 2 spectra -_dir = "./nustar/m10_1616_1620/" +_dir = "../../nustar/m10_1616_1620/" spec = Fitter( pha_file=[_dir + "nu80415202001A06_chu13_N_cl_grade0_sr.pha", _dir + "nu80415202001B06_chu13_N_cl_grade0_sr.pha"] ) diff --git a/examples/fitting_RHESSI_spectra.py b/examples/legacy/fitting_RHESSI_spectra.py similarity index 98% rename from examples/fitting_RHESSI_spectra.py rename to examples/legacy/fitting_RHESSI_spectra.py index 841c0e9f..9b07db36 100644 --- a/examples/fitting_RHESSI_spectra.py +++ b/examples/legacy/fitting_RHESSI_spectra.py @@ -43,7 +43,7 @@ file_names = ["20021005_103800_spec.fits", "20021005_103800_srm.fits"] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./rhessi/") + dl.enqueue_file(base_url + fname, path="../../rhessi/") files = dl.download() ##################################################### @@ -61,7 +61,9 @@ # # Load in the data... -rhess_spec = RhessiLoader(spectrum_fn="./rhessi/20021005_103800_spec.fits", srm_fn="./rhessi/20021005_103800_srm.fits") +rhess_spec = RhessiLoader( + spectrum_fn="../../rhessi/20021005_103800_spec.fits", srm_fn="../../rhessi/20021005_103800_srm.fits" +) ##################################################### # @@ -358,7 +360,7 @@ # ---------------- # -save_filename = "./sunxspexRhessiSpectralFitting.pickle" +save_filename = "../sunxspexRhessiSpectralFitting.pickle" fitter.save(save_filename) ##################################################### diff --git a/examples/fitting_STIX_spectra.py b/examples/legacy/fitting_STIX_spectra.py similarity index 97% rename from examples/fitting_STIX_spectra.py rename to examples/legacy/fitting_STIX_spectra.py index b19b8df7..33c4a6fc 100644 --- a/examples/fitting_STIX_spectra.py +++ b/examples/legacy/fitting_STIX_spectra.py @@ -62,7 +62,7 @@ ] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./stix/") + dl.enqueue_file(base_url + fname, path="../../stix/") files = dl.download() ##################################################### @@ -83,7 +83,7 @@ # Load in the data... stix_spec = STIXLoader( - spectrum_file="./stix/stx_spectrum_2410019944_IM.fits", srm_file="./stix/stx_srm_2410019944_IM.fits" + spectrum_file="../../stix/stx_spectrum_2410019944_IM.fits", srm_file="../../stix/stx_srm_2410019944_IM.fits" ) ##################################################### @@ -202,7 +202,7 @@ # ---------------- # -save_filename = "./stix/sunkitspexSTIXpectralFitting.pickle" +save_filename = "../../stix/sunkitspexSTIXpectralFitting.pickle" fitter.save(save_filename) ##################################################### @@ -266,8 +266,8 @@ # ======================================================== # Loading the data into the fitter loader # -spec_bg, srm_bg = "./stix/stx_spectrum_2410019944_BKG.fits", "./stix/stx_srm_2410019944_BKG.fits" -spec_im, srm_im = "./stix/stx_spectrum_2410019944_IM.fits", "./stix/stx_srm_2410019944_IM.fits" +spec_bg, srm_bg = "../../stix/stx_spectrum_2410019944_BKG.fits", "../../stix/stx_srm_2410019944_BKG.fits" +spec_im, srm_im = "../../stix/stx_spectrum_2410019944_IM.fits", "../../stix/stx_srm_2410019944_IM.fits" spec_joint = Fitter(pha_file=[spec_bg, spec_im], srm_file=[srm_bg, srm_im]) diff --git a/examples/fitting_attenuated_RHESSI_spectra.py b/examples/legacy/fitting_attenuated_RHESSI_spectra.py similarity index 95% rename from examples/fitting_attenuated_RHESSI_spectra.py rename to examples/legacy/fitting_attenuated_RHESSI_spectra.py index f4e74665..2afb3df3 100644 --- a/examples/fitting_attenuated_RHESSI_spectra.py +++ b/examples/legacy/fitting_attenuated_RHESSI_spectra.py @@ -33,7 +33,7 @@ file_names = ["rhessi-2011-jul-stixbins-spec.fits", "rhessi-2011-jul-stixbins-srm.fits"] for fname in file_names: - dl.enqueue_file(base_url + fname, path="./rhessi/") + dl.enqueue_file(base_url + fname, path="../../rhessi/") files = dl.download() @@ -42,7 +42,8 @@ # Load in the spectrum and SRM, notice the warning about attenuator changes! rl = rhessi.RhessiLoader( - spectrum_fn="./rhessi/rhessi-2011-jul-stixbins-spec.fits", srm_fn="./rhessi/rhessi-2011-jul-stixbins-srm.fits" + spectrum_fn="../../rhessi/rhessi-2011-jul-stixbins-spec.fits", + srm_fn="../../rhessi/rhessi-2011-jul-stixbins-srm.fits", ) ##################################################### diff --git a/examples/fitting_custom_spectra.py b/examples/legacy/fitting_custom_spectra.py similarity index 100% rename from examples/fitting_custom_spectra.py rename to examples/legacy/fitting_custom_spectra.py diff --git a/pyproject.toml b/pyproject.toml index e8f44c46..ee90bf32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ docs = [ "packaging", "sphinx-changelog", "sphinx-gallery", - "pypandoc" + "joblib", # for sphinx-gallery parallel ] dev = [ "sunkit-spex[docs,tests]", diff --git a/pytest.ini b/pytest.ini index 4f886703..7dcb1b70 100644 --- a/pytest.ini +++ b/pytest.ini @@ -42,5 +42,6 @@ filterwarnings = ignore:Please use `convolve1d` from the `scipy.ndimage` namespace, the `scipy.ndimage.filters` namespace is deprecated.:DeprecationWarning ignore::FutureWarning:arviz.* ignore:The isiterable function.*:astropy.utils.exceptions.AstropyDeprecationWarning + ignore:The legacy module.*:sunpy.util.exceptions.SunpyDeprecationWarning ignore:'datfix' made the change:astropy.wcs.wcs.FITSFixedWarning ignore::pyparsing.warnings.PyparsingDeprecationWarning diff --git a/sunkit_spex/legacy/__init__.py b/sunkit_spex/legacy/__init__.py index e69de29b..ff071aef 100644 --- a/sunkit_spex/legacy/__init__.py +++ b/sunkit_spex/legacy/__init__.py @@ -0,0 +1,9 @@ +import warnings + +from sunpy.util.exceptions import SunpyDeprecationWarning + +warnings.warn( + "The legacy module has been deprecated since version 0.4 and will be removed in a future version.", + SunpyDeprecationWarning, + stacklevel=2, +)