utu 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ name: Black
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ black:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ - uses: psf/black@stable
15
+ with:
16
+ options: "--check --verbose --diff"
17
+ src: "./utu"
@@ -0,0 +1,32 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Build and publish to PyPI
10
+ if: startsWith(github.ref, 'refs/tags')
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ - name: Install pypa/build
19
+ run: >-
20
+ python -m
21
+ pip install
22
+ build
23
+ --user
24
+ - name: Build a binary wheel and a source tarball
25
+ run: >-
26
+ python -m
27
+ build
28
+ --sdist
29
+ --wheel
30
+ --outdir dist/
31
+ - name: Publish to PyPI
32
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,14 @@
1
+ name: Ruff
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ ruff:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: chartboost/ruff-action@v1
@@ -0,0 +1,117 @@
1
+
2
+ name: tests
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os: [
17
+ ubuntu-latest,
18
+ windows-latest,
19
+ macOS-latest,
20
+ ]
21
+ python-version: ["3.12", "3.13"]
22
+ name: ${{ matrix.os }}, Python ${{ matrix.python-version }} tests
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - name: Set up Python ${{ matrix.python-version }}
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+ - name: Install package
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install setuptools wheel
33
+ pip install -e .[test]
34
+ # Coverage is measured in the `chianti` job below and nowhere else.
35
+ # These jobs skip every test which reads the atomic database, so their
36
+ # coverage is a subset of that one's, and Codecov decides a pull request
37
+ # on whichever reports have arrived when it is asked: the subset lands
38
+ # first and the answer is wrong until the superset catches up, which is
39
+ # too late to be reported. One report cannot race itself.
40
+ - name: Test with pytest
41
+ env:
42
+ MPLBACKEND: "agg"
43
+ run: pytest --doctest-modules --junitxml=junit/test-results.xml
44
+
45
+ # The tests which read the CHIANTI database, which is too large to fetch on
46
+ # every job of the matrix, so it is fetched once here and cached. Without
47
+ # this the whole of `utu.spectrum` skips, and CI reports success on code it
48
+ # never ran.
49
+ chianti:
50
+ runs-on: ubuntu-latest
51
+ name: ubuntu-latest, Python 3.13, CHIANTI tests
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+ - name: Set up Python
55
+ uses: actions/setup-python@v5
56
+ with:
57
+ python-version: "3.13"
58
+ - name: Install package
59
+ run: |
60
+ python -m pip install --upgrade pip
61
+ pip install -e .[test]
62
+ pip install pytest-cov
63
+ - name: Ask fiasco which database it wants
64
+ id: chianti
65
+ run: |
66
+ python -c "
67
+ from fiasco.util.setup_db import LATEST_VERSION
68
+ print(f'version={LATEST_VERSION}')
69
+ " >> $GITHUB_OUTPUT
70
+ - name: Restore the CHIANTI database
71
+ id: cache
72
+ uses: actions/cache@v4
73
+ with:
74
+ path: ~/.fiasco
75
+ key: chianti-${{ steps.chianti.outputs.version }}
76
+ - name: Download and build the CHIANTI database
77
+ if: steps.cache.outputs.cache-hit != 'true'
78
+ run: |
79
+ python -c "
80
+ import fiasco
81
+ from fiasco.util import check_database
82
+ check_database(
83
+ hdf5_dbase_root=fiasco.defaults['hdf5_dbase_root'],
84
+ ascii_dbase_root=fiasco.defaults['ascii_dbase_root'],
85
+ ask_before=False,
86
+ )
87
+ "
88
+ - name: Test with pytest
89
+ env:
90
+ MPLBACKEND: "agg"
91
+ run: pytest --cov=. --cov-report=xml
92
+ - name: Upload coverage to Codecov
93
+ uses: codecov/codecov-action@v7
94
+ with:
95
+ token: ${{ secrets.CODECOV_TOKEN }}
96
+ files: coverage.xml
97
+ name: codecov-umbrella
98
+
99
+ # A single check for the whole matrix to report through, so that the branch
100
+ # ruleset never has to name an operating system or a version of Python.
101
+ # Naming them means that changing the matrix silently blocks every pull
102
+ # request: a required check which no longer runs is one which never reports,
103
+ # and a pull request waits on it forever.
104
+ tests:
105
+ if: always()
106
+ needs: [build, chianti]
107
+ runs-on: ubuntu-latest
108
+ steps:
109
+ - name: Check whether every job in the matrix succeeded
110
+ run: |
111
+ for result in "${{ needs.build.result }}" "${{ needs.chianti.result }}"; do
112
+ if [ "$result" != "success" ]; then
113
+ echo "a job reported '$result'"
114
+ exit 1
115
+ fi
116
+ done
117
+ echo "every job in the matrix succeeded"
utu-0.1.0/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ build/
6
+ dist/
7
+ docs/_build/
8
+ docs/_autosummary/
9
+ docs/jupyter_execute/
10
+ .coverage
11
+ coverage.xml
@@ -0,0 +1,18 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-lts-latest
5
+ tools:
6
+ python: "3.12"
7
+ apt_packages:
8
+ - graphviz
9
+
10
+ sphinx:
11
+ configuration: docs/conf.py
12
+
13
+ python:
14
+ install:
15
+ - method: pip
16
+ path: .
17
+ extra_requirements:
18
+ - doc
utu-0.1.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Roy T. Smart
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
utu-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: utu
3
+ Version: 0.1.0
4
+ Summary: A Python library of solar physics utilities built on named arrays
5
+ Author-email: "Roy T. Smart" <roytsmart@gmail.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/sun-data/utu
8
+ Project-URL: Documentation, https://utu.readthedocs.io
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: numpy
14
+ Requires-Dist: astropy
15
+ Requires-Dist: matplotlib
16
+ Requires-Dist: adjustText
17
+ Requires-Dist: named-arrays~=2.8
18
+ Requires-Dist: fiasco~=0.8.2
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest; extra == "test"
21
+ Requires-Dist: pytest-doctestplus; extra == "test"
22
+ Provides-Extra: doc
23
+ Requires-Dist: matplotlib; extra == "doc"
24
+ Requires-Dist: graphviz; extra == "doc"
25
+ Requires-Dist: pydata-sphinx-theme; extra == "doc"
26
+ Requires-Dist: ipykernel; extra == "doc"
27
+ Requires-Dist: jupyter-sphinx; extra == "doc"
28
+ Requires-Dist: sphinx-favicon; extra == "doc"
29
+ Requires-Dist: sphinx-codeautolink; extra == "doc"
30
+ Dynamic: license-file
31
+
32
+ # utu
33
+
34
+ [![tests](https://github.com/sun-data/utu/actions/workflows/tests.yml/badge.svg)](https://github.com/sun-data/utu/actions/workflows/tests.yml)
35
+ [![Black](https://github.com/sun-data/utu/actions/workflows/black.yml/badge.svg)](https://github.com/sun-data/utu/actions/workflows/black.yml)
36
+ [![Ruff](https://github.com/sun-data/utu/actions/workflows/ruff.yml/badge.svg)](https://github.com/sun-data/utu/actions/workflows/ruff.yml)
37
+ [![Documentation Status](https://readthedocs.org/projects/utu/badge/?version=latest)](https://utu.readthedocs.io/en/latest/?badge=latest)
38
+
39
+ A Python library of solar physics utilities built on
40
+ [named arrays](https://github.com/sun-data/named-arrays).
41
+
42
+ Named for the Sumerian god of the sun.
43
+
44
+ ## Documentation
45
+
46
+ The documentation is at [utu.readthedocs.io](https://utu.readthedocs.io/en/latest/).
47
+
48
+ ## `utu.spectrum`
49
+
50
+ The emission lines of an optically thin plasma, computed from the CHIANTI
51
+ atomic database through [fiasco](https://github.com/wtbarnes/fiasco), and
52
+ returned as named arrays.
utu-0.1.0/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # utu
2
+
3
+ [![tests](https://github.com/sun-data/utu/actions/workflows/tests.yml/badge.svg)](https://github.com/sun-data/utu/actions/workflows/tests.yml)
4
+ [![Black](https://github.com/sun-data/utu/actions/workflows/black.yml/badge.svg)](https://github.com/sun-data/utu/actions/workflows/black.yml)
5
+ [![Ruff](https://github.com/sun-data/utu/actions/workflows/ruff.yml/badge.svg)](https://github.com/sun-data/utu/actions/workflows/ruff.yml)
6
+ [![Documentation Status](https://readthedocs.org/projects/utu/badge/?version=latest)](https://utu.readthedocs.io/en/latest/?badge=latest)
7
+
8
+ A Python library of solar physics utilities built on
9
+ [named arrays](https://github.com/sun-data/named-arrays).
10
+
11
+ Named for the Sumerian god of the sun.
12
+
13
+ ## Documentation
14
+
15
+ The documentation is at [utu.readthedocs.io](https://utu.readthedocs.io/en/latest/).
16
+
17
+ ## `utu.spectrum`
18
+
19
+ The emission lines of an optically thin plasma, computed from the CHIANTI
20
+ atomic database through [fiasco](https://github.com/wtbarnes/fiasco), and
21
+ returned as named arrays.
@@ -0,0 +1,69 @@
1
+ {{ name | escape | underline}}
2
+
3
+ .. automodule:: {{ fullname }}
4
+
5
+ {% block attributes %}
6
+ {% if attributes %}
7
+ .. rubric:: Module Attributes
8
+
9
+ .. autosummary::
10
+ :toctree:
11
+ {% for item in attributes %}
12
+ {{ item }}
13
+ {%- endfor %}
14
+ {% endif %}
15
+ {% endblock %}
16
+
17
+ {% block functions %}
18
+ {% if functions %}
19
+ .. rubric:: {{ _('Functions') }}
20
+
21
+ .. autosummary::
22
+ :toctree:
23
+ :template: function_custom.rst
24
+ {% for item in functions %}
25
+ {{ item }}
26
+ {%- endfor %}
27
+ {% endif %}
28
+ {% endblock %}
29
+
30
+ {% block classes %}
31
+ {% if classes %}
32
+ .. rubric:: {{ _('Classes') }}
33
+
34
+ .. autosummary::
35
+ :toctree:
36
+ :template: class_custom.rst
37
+ {% for item in classes %}
38
+ {{ item }}
39
+ {%- endfor %}
40
+ {% endif %}
41
+ {% endblock %}
42
+
43
+ {% block exceptions %}
44
+ {% if exceptions %}
45
+ .. rubric:: {{ _('Exceptions') }}
46
+
47
+ .. autosummary::
48
+ :toctree:
49
+ {% for item in exceptions %}
50
+ {{ item }}
51
+ {%- endfor %}
52
+ {% endif %}
53
+ {% endblock %}
54
+
55
+ {% block modules %}
56
+ {% if modules %}
57
+ .. rubric:: Modules
58
+
59
+ .. autosummary::
60
+ :toctree:
61
+ :template: module_custom.rst
62
+ :recursive:
63
+ {% for item in modules %}
64
+ {{ item }}
65
+ {%- endfor %}
66
+ {% endif %}
67
+ {% endblock %}
68
+
69
+
utu-0.1.0/docs/conf.py ADDED
@@ -0,0 +1,139 @@
1
+ """Configuration for the Sphinx documentation builder."""
2
+
3
+ import os
4
+ import pathlib
5
+ import sys
6
+
7
+ sys.path.insert(0, str(pathlib.Path("..").resolve()))
8
+
9
+ project = "utu"
10
+ copyright = "2026, Roy T. Smart"
11
+ author = "Roy T. Smart"
12
+
13
+ extensions = [
14
+ "sphinx.ext.napoleon",
15
+ "sphinx.ext.autodoc",
16
+ "sphinx.ext.autosummary",
17
+ "sphinx.ext.intersphinx",
18
+ "sphinx.ext.viewcode",
19
+ "jupyter_sphinx",
20
+ "sphinx_codeautolink",
21
+ "sphinx_favicon",
22
+ ]
23
+
24
+ autosummary_generate = True
25
+ autosummary_imported_members = True
26
+ autosummary_ignore_module_all = False
27
+ autodoc_typehints = "description"
28
+
29
+ templates_path = ["_templates"]
30
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
31
+
32
+ html_theme = "pydata_sphinx_theme"
33
+ html_static_path = ["_static"]
34
+ html_theme_options = {
35
+ "icon_links": [
36
+ {
37
+ "name": "GitHub",
38
+ "url": "https://github.com/sun-data/utu",
39
+ "icon": "fa-brands fa-github",
40
+ "type": "fontawesome",
41
+ },
42
+ {
43
+ "name": "PyPI",
44
+ "url": "https://pypi.org/project/utu/",
45
+ "icon": "fa-brands fa-python",
46
+ },
47
+ ],
48
+ }
49
+
50
+ # https://github.com/readthedocs/readthedocs.org/issues/2569
51
+ master_doc = "index"
52
+
53
+ intersphinx_mapping = {
54
+ "python": ("https://docs.python.org/3", None),
55
+ "numpy": ("https://numpy.org/doc/stable", None),
56
+ "astropy": ("https://docs.astropy.org/en/stable", None),
57
+ "named_arrays": ("https://named-arrays.readthedocs.io/en/stable", None),
58
+ "fiasco": ("https://fiasco.readthedocs.io/en/stable", None),
59
+ }
60
+
61
+ codeautolink_custom_blocks = {"jupyter-execute": None}
62
+
63
+
64
+ # -- The atomic database ----------------------------------------------------
65
+
66
+ ions = [
67
+ "he_1",
68
+ "o_3",
69
+ "o_4",
70
+ "o_5",
71
+ "ne_7",
72
+ "mg_10",
73
+ "si_11",
74
+ ]
75
+ """
76
+ The ions the examples on these pages compute with.
77
+
78
+ Every page which reads the CHIANTI database is written against these ions,
79
+ and the database built below describes only these, so that a page can be
80
+ built in a minute rather than in twenty. The whole database is 1.6 GB of
81
+ text, almost all of it the collision strengths of iron, and turning it into
82
+ the form :mod:`fiasco` reads takes about as long as Read the Docs allows a
83
+ build to run in total.
84
+ """
85
+
86
+ extension = [
87
+ "auto",
88
+ "cilvl",
89
+ "diparams",
90
+ "drparams",
91
+ "easplom",
92
+ "easplups",
93
+ "elvlc",
94
+ "fblvl",
95
+ "psplups",
96
+ "reclvl",
97
+ "rrlvl",
98
+ "rrparams",
99
+ "scups",
100
+ "trparams",
101
+ "wgfa",
102
+ ]
103
+ """
104
+ The kinds of file an ion can have.
105
+
106
+ Not every ion has every one of them; the ones an ion does not have are
107
+ skipped as the database is built.
108
+ """
109
+
110
+ if os.environ.get("READTHEDOCS") == "True": # pragma: no cover
111
+ import fiasco
112
+ from fiasco.util import get_chianti_catalog
113
+ from fiasco.util.setup_db import (
114
+ _get_chianti_dbase_url,
115
+ build_hdf5_dbase,
116
+ download_dbase,
117
+ )
118
+
119
+ ascii_dbase_root = pathlib.Path(fiasco.defaults["ascii_dbase_root"])
120
+ hdf5_dbase_root = pathlib.Path(fiasco.defaults["hdf5_dbase_root"])
121
+
122
+ if not (ascii_dbase_root / "VERSION").is_file():
123
+ # which version to fetch is asked of `fiasco` rather than written
124
+ # down here, since the two are not the same question: the URL of a
125
+ # version is not something one can guess from its number
126
+ download_dbase(_get_chianti_dbase_url(), ascii_dbase_root)
127
+
128
+ if not hdf5_dbase_root.is_file():
129
+ catalog = get_chianti_catalog(ascii_dbase_root)
130
+ files = [f"{ion}.{ext}" for ion in ions for ext in extension]
131
+ files += catalog["abundance_files"]
132
+ files += catalog["ioneq_files"]
133
+ files += catalog["ip_files"]
134
+ build_hdf5_dbase(
135
+ ascii_dbase_root,
136
+ hdf5_dbase_root,
137
+ files=files,
138
+ show_progress=False,
139
+ )
@@ -0,0 +1,38 @@
1
+ utu
2
+ ===
3
+
4
+ :mod:`utu` is a library of solar physics utilities built on
5
+ :mod:`named_arrays`, named for the Sumerian god of the sun.
6
+
7
+ Installation
8
+ ============
9
+
10
+ :mod:`utu` is available on PyPI and can be installed using pip::
11
+
12
+ pip install utu
13
+
14
+ Tutorials
15
+ =========
16
+
17
+ .. toctree::
18
+ :maxdepth: 1
19
+
20
+ tutorials/spectrum
21
+
22
+
23
+ API Reference
24
+ =============
25
+
26
+ .. autosummary::
27
+ :toctree: _autosummary
28
+ :template: module_custom.rst
29
+ :recursive:
30
+
31
+ utu
32
+
33
+ Indices and tables
34
+ ==================
35
+
36
+ * :ref:`genindex`
37
+ * :ref:`modindex`
38
+ * :ref:`search`