Skip to content

Commit

Permalink
Merge pull request #36 from samaloney/docs-example-gallery
Browse files Browse the repository at this point in the history
Add doc gallery and paper figure example
  • Loading branch information
samaloney authored Jan 23, 2025
2 parents 084e607 + b0e1fad commit 71fa218
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 17 deletions.
16 changes: 16 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[settings]
balanced_wrapping = true
skip =
docs/conf.py
chimerapy/__init__.py
default_section = THIRDPARTY
include_trailing_comma = true
known_astropy = astropy, asdf
known_chimerapy = chimerapy
known_first_party = chimerapy
length_sort = false
length_sort_sections = stdlib
line_length = 110
multi_line_output = 3
no_lines_before = LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, CHIMERAPY, FIRSTPARTY, LOCALFOLDER
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.8"
rev: "v0.6.1"
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -27,3 +27,7 @@ repos:
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"

ci:
autofix_prs: false
autoupdate_schedule: "quarterly"
15 changes: 8 additions & 7 deletions chimerapy/chimera.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
""" """

import glob
import sys
import glob

import astropy.units as u
import cv2
import mahotas
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate
import sunpy.map
from scipy.interpolate import RectBivariateSpline
from skimage.util import img_as_ubyte

import astropy.units as u
from astropy import wcs
from astropy.io import fits
from astropy.modeling.models import Gaussian2D
from skimage.util import img_as_ubyte


def chimera_legacy():
Expand Down Expand Up @@ -46,15 +47,15 @@ def chimera(im171, im193, im211, imhmi):
hdu_number = 0
heda = fits.getheader(im171[0], hdu_number)
data = fits.getdata(im171[0], ext=0) / (heda["EXPTIME"])
dn = scipy.interpolate.interp2d(x, x, data)
dn = RectBivariateSpline(x, x, data, kx=1, ky=1)
data = dn(np.arange(0, 4096), np.arange(0, 4096))
hedb = fits.getheader(im193[0], hdu_number)
datb = fits.getdata(im193[0], ext=0) / (hedb["EXPTIME"])
dn = scipy.interpolate.interp2d(x, x, datb)
dn = RectBivariateSpline(x, x, datb, kx=1, ky=1)
datb = dn(np.arange(0, 4096), np.arange(0, 4096))
hedc = fits.getheader(im211[0], hdu_number)
datc = fits.getdata(im211[0], ext=0) / (hedc["EXPTIME"])
dn = scipy.interpolate.interp2d(x, x, datc)
dn = RectBivariateSpline(x, x, datc, kx=1, ky=1)
datc = dn(np.arange(0, 4096), np.arange(0, 4096))
hedm = fits.getheader(imhmi[0], hdu_number)
datm = fits.getdata(imhmi[0], ext=0)
Expand Down
27 changes: 21 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

import pathlib

# -- Project information -----------------------------------------------------

Expand All @@ -24,16 +24,17 @@
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.doctest",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
"sphinx_gallery.gen_gallery",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -75,3 +76,17 @@
# the docs. For more options, see:
# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autoclass_content
autoclass_content = "both"

# -- 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")),
"filename_pattern": "^((?!skip_).)*$",
"examples_dirs": example_dir,
"gallery_dirs": path.joinpath("generated", "gallery"),
"abort_on_example_error": False,
"plot_gallery": "True",
"remove_config_comments": True,
"only_warn_on_example_error": True,
}
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ CHIMERApy Documentation
This is the documentation for CHIMERApy.

.. toctree::
:maxdepth: 2
:caption: Contents:

../generated/gallery/index

Indices and tables
==================
Expand Down
2 changes: 2 additions & 0 deletions examples/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gallery
=======
Loading

0 comments on commit 71fa218

Please sign in to comment.