Skip to content

Commit

Permalink
Merge pull request #144 from punch-mission/use-units
Browse files Browse the repository at this point in the history
Use units everywhere!
  • Loading branch information
jmbhughes authored Aug 6, 2024
2 parents 250b25d + 24635f3 commit 8ad944f
Show file tree
Hide file tree
Showing 27 changed files with 1,459 additions and 1,455 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ jobs:
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
pip install -r ./docs/requirements.txt
pip install ".[test]"
pip install ".[docs, test]"
# Build the book
- name: Sphinx build
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ Please open a discussion or issue for help.
## Features Coming Soon
- [x] core transformation capability
- [x] clearer examples in the documentation
- [x] more comprehensive support for 4-polarizer systems
- [x] functions to deal with the IMAX effect in wide-field imagers
- [ ] quantification and propagation of error
- [ ] additional plotting utilities
- [ ] more comprehensive support for 4-polarizer systems
- [x] functions to deal with the IMAX effect in wide-field imagers


## Contributing
We encourage all contributions.
Expand Down
6 changes: 0 additions & 6 deletions docs/requirements.txt

This file was deleted.

26 changes: 13 additions & 13 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# -- Project information -----------------------------------------------------
from solpolpy import __version__

project = 'solpolpy'
copyright = '2023, PUNCH Science Operations Center'
author = 'PUNCH Science Operations Center'
project = "solpolpy"
copyright = "2023, PUNCH Science Operations Center"
author = "PUNCH Science Operations Center"

# The full version, including alpha/beta/rc tags
release = __version__
Expand All @@ -32,14 +32,14 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

extensions = ['autoapi.extension',
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'nbsphinx',
'IPython.sphinxext.ipython_console_highlighting']
extensions = ["autoapi.extension",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"nbsphinx",
"IPython.sphinxext.ipython_console_highlighting"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -54,7 +54,7 @@
#
html_theme = "pydata_sphinx_theme"
html_show_sourcelink = False
html_static_path = ['_static']
html_static_path = ["_static"]
html_theme_options = {
"use_edit_page_button": True,
"icon_links": [
Expand All @@ -63,10 +63,10 @@
"url": "https://github.com/punch-mission/solpolpy",
"icon": "fa-brands fa-github",
"type": "fontawesome",
}
},
],
"show_nav_level": 1,
"show_toc_level": 3
"show_toc_level": 3,
}
html_context = {
# "github_url": "https://github.com", # or your GitHub Enterprise site
Expand All @@ -77,4 +77,4 @@
}


autoapi_dirs = ['../../solpolpy']
autoapi_dirs = ["../../solpolpy"]
10 changes: 4 additions & 6 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ If you're contributing code, we recommend reading `our project-wide evelopment g

We recommend working in a virtual environment.
This can be created by running ``python -m venv venv``. Then, activate the environment with ``source venv/bin/activate``.
You can then install the required packages with ``pip install -r requirements_dev.txt``.
You can then install the required packages with ``pip install -e ".[dev]``.

If at any time you run into issues, please contact us by :doc:`following the guidelines here <help>`.

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 -r requirements_dev.txt`` but then requires you to activate them by
It gets installed when you do ``pip install -e ".[dev]"`` but then requires you to activate them by
running ``pre-commit install``. Now everytime you commit, our checks will run first.

Building the docs
------------------
The docs are built using ``sphinx``. First, you must install it and the other documentation requirements with ::

pip install -r ./docs/requirements.txt
pip install -r requirements.txt
The docs are built using ``sphinx``. First, you must install it and the other documentation requirements with
``pip install -e ".[dev]"``.

Then, navigate to the ``docs`` directory and run ``make html`` to build the docs.

Expand Down
179 changes: 75 additions & 104 deletions docs/source/example.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ The easiest way to interact with solpolpy is through the ``resolve`` method:
# to access the data, just access the appropriate cube
print(output_collection['B'].data)
``resolve`` takes two parameters: 1. the input data and 2. the desired output polarization system.
``resolve`` takes two (or more depending on the polarization systems) parameters:
1. the input data and 2. the desired output polarization system.
Valid polarization systems are described in the documentation.

.. autofunction:: solpolpy.resolve
Expand Down
20 changes: 18 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "solpolpy"
version = "0.2.0"
version = "0.3.0"
authors = [
{ name="J. Marcus Hughes", email="mhughes@boulder.swri.edu"},
{ name="Matthew J. West", email="mwest@boulder.swri.edu"},
Expand All @@ -11,7 +11,7 @@ authors = [
description = "Solar polarization resolver for any instrument"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.10"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand All @@ -33,6 +33,16 @@ test = [
'pytest-cov',
'ruff'
]
docs = [
"sphinx",
"pydata-sphinx-theme",
"sphinx-autoapi",
"nbsphinx",
"ipython",
"pandoc"
]

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

[build-system]
requires = ["setuptools>=61.0"]
Expand All @@ -44,6 +54,12 @@ packages = ['solpolpy']
[tool.ruff]
line-length = 120
ignore-init-module-imports = true
#lint.select = ["ALL"]
lint.ignore = ["F403"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402"]
"tests/*.py" = ['S101']

[tool.isort]
balanced_wrapping = true
Expand Down
3 changes: 2 additions & 1 deletion solpolpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from solpolpy.core import resolve
from solpolpy.instruments import load_data
from solpolpy.plotting import get_colormap_str, plot_collection
from solpolpy.transforms import System

__version__ = importlib.metadata.version("solpolpy")
__all__ = [resolve, load_data, get_colormap_str, plot_collection]
__all__ = [resolve, load_data, get_colormap_str, plot_collection, System]
11 changes: 6 additions & 5 deletions solpolpy/alpha.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
""" Functions related to constructing an alpha array for transformation"""
"""Functions related to constructing an alpha array for transformation."""

import astropy.units as u
import numpy as np


def radial_north(shape):
"""An alpha array oriented west
"""An alpha array oriented west.
Parameters
----------
Expand All @@ -18,11 +18,12 @@ def radial_north(shape):
alpha array used in calculations
Notes
------
-----
- assumes solar north is up
- assumes polarizer 0 is along solar north axis
- creates radial polarization map
- angles increase in counterclockwise direction
"""
x_size, y_size = shape
x = np.arange(-x_size // 2, x_size // 2)
Expand All @@ -31,5 +32,5 @@ def radial_north(shape):
return np.rot90(np.fliplr(np.arctan2(yy, xx)+np.pi), k=1)*u.radian


ALPHA_FUNCTIONS = {'radial_north': radial_north,
'zeros': np.zeros}
ALPHA_FUNCTIONS = {"radial_north": radial_north,
"zeros": np.zeros}
12 changes: 1 addition & 11 deletions solpolpy/constants.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
"""Constants used in code"""
"""Constants used in code."""
import astropy.units as u

VALID_KINDS = {"mzp": [["Bm", "Bz", "Bp", "alpha"], ["Bm", "Bz", "Bp"]],
"bpb": [["B", "pB", "alpha"], ["B", "pB"]],
"btbr": [["Bt", "Br", "alpha"], ["Bt", "Br"]],
"stokes": [["Bi", "Bq", "Bu"], ["Bi", "Bq", "Bu", "alpha"]],
"bp3": [["B", "pB", "pBp", "alpha"], ["B", "pB", "pBp"]],
"bthp": [["B", "theta", "p"]],
"fourpol": [["B0", "B90", "B45", "B135"]], # fourpol comes before npol to force it instead of npol
"npol": [["B*"]], # star indicates angle in degrees, as many as desired are supported
}

# offset angles come from https://www.sciencedirect.com/science/article/pii/S0019103515003620?via%3Dihub
STEREOA_OFFSET_ANGLE = 45.8 * u.degree
STEREOB_OFFSET_ANGLE = -18 * u.degree
Loading

0 comments on commit 8ad944f

Please sign in to comment.