From 2d84a68a72aa8c048b8ba777d2eaa85a9da2966b Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Tue, 3 Feb 2026 21:18:11 +0000 Subject: [PATCH 1/7] Deprecate legacy and separate example galleries --- docs/conf.py | 21 ++++++++----------- docs/how_to/index.rst | 1 + docs/reference/legacy.rst | 2 +- examples/legacy/README.txt | 2 ++ .../fitting_NuSTAR_spectra-duncan2021.py | 4 ++-- .../fitting_NuSTAR_spectra-general.py | 4 ++-- .../fitting_NuSTAR_spectra-glesener2020.py | 10 ++++----- .../fitting_NuSTAR_spectra-simultaneously.py | 4 ++-- .../{ => legacy}/fitting_RHESSI_spectra.py | 8 ++++--- examples/{ => legacy}/fitting_STIX_spectra.py | 10 ++++----- .../fitting_attenuated_RHESSI_spectra.py | 5 +++-- .../{ => legacy}/fitting_custom_spectra.py | 0 pyproject.toml | 2 +- pytest.ini | 1 + sunkit_spex/legacy/__init__.py | 9 ++++++++ 15 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 examples/legacy/README.txt rename examples/{ => legacy}/fitting_NuSTAR_spectra-duncan2021.py (98%) rename examples/{ => legacy}/fitting_NuSTAR_spectra-general.py (98%) rename examples/{ => legacy}/fitting_NuSTAR_spectra-glesener2020.py (98%) rename examples/{ => legacy}/fitting_NuSTAR_spectra-simultaneously.py (99%) rename examples/{ => legacy}/fitting_RHESSI_spectra.py (98%) rename examples/{ => legacy}/fitting_STIX_spectra.py (97%) rename examples/{ => legacy}/fitting_attenuated_RHESSI_spectra.py (95%) rename examples/{ => legacy}/fitting_custom_spectra.py (100%) 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..46b4abb2 100644 --- a/docs/how_to/index.rst +++ b/docs/how_to/index.rst @@ -11,3 +11,4 @@ you quickly accomplish common tasks. :maxdepth: 1 ../generated/gallery/index + ../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..99156e39 --- /dev/null +++ b/examples/legacy/README.txt @@ -0,0 +1,2 @@ +Legacy Examples +--------------- 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 be250874..d6a11b35 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 7ec6ac41..fccb14b5 100644 --- a/pytest.ini +++ b/pytest.ini @@ -43,3 +43,4 @@ filterwarnings = ignore::pyparsing.warnings.PyparsingDeprecationWarning ignore::FutureWarning:arviz.* ignore:The isiterable function.*:astropy.utils.exceptions.AstropyDeprecationWarning + ignore:The legacy module.*:sunpy.utils.exceptions.SunpyDeprecationWarning 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, +) From acad7ce7d48001b91347c99bc457e0bb9148357a Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Tue, 3 Feb 2026 21:23:28 +0000 Subject: [PATCH 2/7] q --- examples/legacy/README.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/legacy/README.txt b/examples/legacy/README.txt index 99156e39..e87267db 100644 --- a/examples/legacy/README.txt +++ b/examples/legacy/README.txt @@ -1,2 +1,5 @@ Legacy Examples --------------- + +.. warning:: + The legacy module has been deprecated since version 0.4 and will be removed in a future version. From 087ea92910f9abc91ded21604bcfc575036bb262 Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Tue, 3 Feb 2026 21:28:32 +0000 Subject: [PATCH 3/7] Add changelogs --- changelog/250.deprecation.rst | 1 + changelog/250.doc.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 changelog/250.deprecation.rst create mode 100644 changelog/250.doc.rst diff --git a/changelog/250.deprecation.rst b/changelog/250.deprecation.rst new file mode 100644 index 00000000..64059229 --- /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. From 35ca8d7bd256614876c65983edf51f818940b3a7 Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Tue, 3 Feb 2026 21:31:56 +0000 Subject: [PATCH 4/7] Fix doc build --- pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index fccb14b5..189507ee 100644 --- a/pytest.ini +++ b/pytest.ini @@ -43,4 +43,4 @@ filterwarnings = ignore::pyparsing.warnings.PyparsingDeprecationWarning ignore::FutureWarning:arviz.* ignore:The isiterable function.*:astropy.utils.exceptions.AstropyDeprecationWarning - ignore:The legacy module.*:sunpy.utils.exceptions.SunpyDeprecationWarning + ignore:The legacy module.*:sunpy.util.exceptions.SunpyDeprecationWarning From 8f3d174d2570e2587f8260ab7a8612bb5eab42a1 Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Fri, 13 Feb 2026 15:46:03 +0000 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- changelog/250.deprecation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/250.deprecation.rst b/changelog/250.deprecation.rst index 64059229..dfc16c7c 100644 --- a/changelog/250.deprecation.rst +++ b/changelog/250.deprecation.rst @@ -1 +1 @@ -Deprecate the `sunkit-spex.legacy` module. +Deprecate the `sunkit_spex.legacy` module. From 4a725fe5772ea916c9d08598fc54d24be714fb0b Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Fri, 13 Feb 2026 16:08:04 +0000 Subject: [PATCH 6/7] Fix double of legacy gallery link --- docs/how_to/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/how_to/index.rst b/docs/how_to/index.rst index 46b4abb2..57f6abef 100644 --- a/docs/how_to/index.rst +++ b/docs/how_to/index.rst @@ -11,4 +11,3 @@ you quickly accomplish common tasks. :maxdepth: 1 ../generated/gallery/index - ../generated/gallery/legacy/index From d505b51d095e7cd7732999f73d6f36333419c894 Mon Sep 17 00:00:00 2001 From: Shane Maloney Date: Tue, 17 Feb 2026 14:05:45 +0000 Subject: [PATCH 7/7] Fix how the gallerys render in the sidebar and main page --- docs/how_to/index.rst | 5 +++++ 1 file changed, 5 insertions(+) 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