Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full rewrite for speed and logical simplicity #209

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .codespellignore
Empty file.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ jobs:
- name: Lint with ruff
run: |
ruff check .
- name: Run codespell on source code
uses: codespell-project/actions-codespell@v2
with:
skip: '*.fits'
ignore_words_file: .codespellignore
path: punchbowl
- name: Run codespell on documentation
uses: codespell-project/actions-codespell@v2
with:
skip: '*.fits'
ignore_words_file: .codespellignore
path: docs/source
- name: Test with pytest
run: |
coverage run -m pytest
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ jobs:

- name: Install dependencies
run: |
pip install -r ./docs/requirements.txt
pip install ".[test]"
python setup.py build_ext --inplace
pip install ".[docs]"

# Build the book
- name: Sphinx build
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ repos:
hooks:
- id: isort
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|sunpy/extern)$"
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
files: ^.*\.(py|c|h|md|rst|yml)$
args: [ "--ignore-words", ".codespellignore" ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand Down
29 changes: 29 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"


# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ authors:
given-names: "Daniel"
orcid: "https://orcid.org/0000-0002-0494-2025"
title: "regularizepsf"
version: 0.4.0
version: 1.0.0
doi: 10.5281/zenodo.7392170
date-released: 2024-08-18
date-released: 2024-09-09
url: "https://github.com/punch-mission/regularizepsf"
16 changes: 15 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
numpy
h5py
sep-pjw
astropy
scipy
scikit-image
matplotlib
pytest
pytest-cov
hypothesis
coverage
ruff
pytest-mpl
pre-commit
sphinx
pydata-sphinx-theme
sphinx-autoapi
sphinx-autoapi
10 changes: 5 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import os
import sys

import regularizepsf

sys.path.insert(0, os.path.abspath("../.."))


project = "regularizepsf"
copyright = "2023, J. Marcus Hughes and the PUNCH Science Operations Center"
author = "J. Marcus Hughes and the PUNCH Science Operations Center"
release = "0.4.0"
copyright = "2024, J. Marcus Hughes and the PUNCH Science Operations Center"
author = "J. Marcus Hughes, PUNCH Science Operations Center, and collaborators"
release = regularizepsf.__version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -27,7 +29,6 @@
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

Expand All @@ -48,7 +49,6 @@
"show_toc_level": 3,
}
html_context = {
# "github_url": "https://github.com", # or your GitHub Enterprise site
"github_user": "punch-mission",
"github_repo": "regularizepsf",
"github_version": "main",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Setting up pre-commit

The first time you develop code, you'll need to install the pre-commit. This checks that our style is consistent.
It gets installed when you do ``pip install ".[test]"`` but then requires you to activate them by
running ``pre-commit install``. Now everytime you commit, our checks will run first.
running ``pre-commit install``. Now every time you commit, our checks will run first.

Building the docs
------------------
Expand Down
22 changes: 4 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
[build-system]
requires = ["setuptools", "wheel", "numpy", "Cython>=0.29.21"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["regularizepsf"]

[project]
name = "regularizepsf"
version = "0.4.0"
version = "1.0.0"
requires-python = ">3.10"
description = "Point spread function modeling and regularization"
dependencies = [
"numpy",
"dill",
"h5py",
"lmfit",
"sep-pjw",
"cython",
"astropy",
"scipy",
"scikit-image",
Expand All @@ -43,15 +33,11 @@ docs = [

dev = ["regularizepsf[test, docs]", "pre-commit"]


[tool.ruff]
exclude = ['tests/*']
exclude = ['tests/*', 'docs/*']
line-length = 120
# lint.select = ["ALL"]
lint.ignore = [ "FBT001", "FBT002", "ANN401"]

#[tool.ruff.lint]
#select = ["NPY201"]
lint.select = ["ALL"]
lint.ignore = [ "FBT001", "FBT002", "ANN101", "ANN102", "ANN401", "FIX002", "TD", "PD011", "I001"]

[tool.isort]
balanced_wrapping = true
Expand Down
14 changes: 5 additions & 9 deletions regularizepsf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from regularizepsf.corrector import ArrayCorrector # noqa: F401
from regularizepsf.corrector import FunctionalCorrector # noqa: F401
from regularizepsf.corrector import calculate_covering # noqa: F401
from regularizepsf.fitter import CoordinatePatchCollection # noqa: F401
from regularizepsf.psf import simple_psf # noqa: F401
from regularizepsf.psf import varied_psf # noqa: F401
from regularizepsf.visualize import visualize_patch_counts # noqa: F401
from regularizepsf.visualize import visualize_PSFs # noqa: F401
from regularizepsf.visualize import visualize_transfer_kernels # noqa: F401
"""Global init."""

import importlib.metadata

__version__ = importlib.metadata.version("regularizepsf")
27 changes: 27 additions & 0 deletions regularizepsf/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Functions for building PSF models from images."""

import pathlib

from regularizepsf.psf import ArrayPSF


class ArrayPSFBuilder:
"""A builder that will take a series of images and construct an ArrayPSF to represent their implicit PSF."""

def __init__(self) -> None:
"""Initialize an ArrayPSFBuilder."""

def build(self, image_paths: list[pathlib.Path]) -> ArrayPSF:
"""Build the PSF model.

Parameters
----------
image_paths : list[pathlib.Path]
paths of images to use

Returns
-------
ArrayPSF
an array PSF

"""
Loading
Loading