Skip to content

Commit 9b15295

Browse files
DOC: Include examples' documentation and sphinx-doc directory
1 parent 1df9f18 commit 9b15295

50 files changed

Lines changed: 2290 additions & 332 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ Icon?
133133
# ─────────────────────────────────────────────────────────────────────────────
134134
*-BAK
135135

136+
# ─────────────────────────────────────────────────────────────────────────────
137+
# LLM / AI tools
138+
# ─────────────────────────────────────────────────────────────────────────────
139+
.claude/
140+
.cursor/
141+
.aider*
142+
.copilot/
143+
*.cursorrules
144+
.windsurfrules
145+
CLAUDE.md
146+
136147
# ─────────────────────────────────────────────────────────────────────────────
137148
# Exclude Docs Assets
138149
# ─────────────────────────────────────────────────────────────────────────────

README.rst

Lines changed: 54 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,196 +1,62 @@
1-
========
2-
pyvisual
3-
========
1+
.. |psi| image:: https://predsci.com/doc/assets/static/psi_logo.png
2+
:target: https://predsci.com
3+
:alt: Predictive Science Inc.
4+
:width: 20px
45

5-
**3D solar-physics visualization for MHD datasets**
6+
.. |pypi| image:: https://img.shields.io/pypi/v/pyvisual?logo=pypi&logoColor=white
7+
:target: https://pypi.org/project/pyvisual
8+
:alt: PyPI
69

7-
.. image:: https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue
8-
:alt: Python versions
9-
10-
.. image:: https://img.shields.io/badge/license-Apache%202.0-green
10+
.. |license| image:: https://img.shields.io/pypi/l/pyvisual?logo=apache&logoColor=white
11+
:target: https://opensource.org/license/apache-2-0/
1112
:alt: License
1213

13-
.. image:: https://img.shields.io/badge/version-0.9.0-orange
14-
:alt: Version
15-
16-
**pyvisual** is developed and maintained by `Predictive Science Inc. (PSI)
17-
<https://www.predsci.com/>`_. It wraps `PyVista's
18-
<https://docs.pyvista.org/>`_ ``Plotter`` class with specialized capabilities
19-
for visualizing solar and magnetohydrodynamic (MHD) model output defined on
20-
spherical coordinate systems. The package is tightly coupled to the PSI data
21-
ecosystem and is tuned for use with **psi-io** and **mapflpy**.
22-
23-
----
24-
25-
Features
26-
--------
27-
28-
- **Spherical-coordinate rendering** — meshes and coordinate arrays in
29-
:math:`(r, \theta, \phi)` are converted to Cartesian automatically before
30-
being passed to the VTK render pipeline.
31-
- **Structured-grid slices** — add 1-D line slices, 2-D surface slices, and
32-
3-D volume slices directly from independent axis arrays.
33-
- **Fieldline rendering** — visualize open/closed magnetic fieldline topology
34-
with polarity coloring or random hue assignment.
35-
- **Observer controls** — set and query camera position, focal point,
36-
position angle, and line-of-sight field-of-view in spherical coordinates.
37-
- **Solar geometry primitives** — Sun sphere, concentric shells, planar discs,
38-
Thomson sphere, and lon/lat grid lines.
39-
- **Mesh arithmetic** — ``SphericalMesh`` and ``CartesianMesh`` support the
40-
full NumPy arithmetic operator suite and ``__array_ufunc__`` so expressions
41-
like ``np.log10(mesh)`` return a new mesh of the same type.
42-
- **PSI HDF support** — load model data directly from HDF4/HDF5 files written
43-
by the MAS code via ``psi-io``.
44-
45-
----
46-
47-
Installation
48-
------------
49-
50-
**Core dependencies** (NumPy, PyVista, psi-io, SunPy, Astropy) are installed
51-
automatically:
52-
53-
.. code-block:: bash
54-
55-
pip install pyvisual
56-
57-
**Optional extras:**
58-
59-
.. code-block:: bash
60-
61-
pip install "pyvisual[hdf4]" # HDF4 file support via pyhdf
62-
pip install "pyvisual[interp]" # scipy interpolation utilities
63-
pip install "pyvisual[tracing]" # mapflpy fieldline tracing
64-
pip install "pyvisual[data]" # pooch asset fetching + matplotlib
65-
pip install "pyvisual[all]" # everything
66-
67-
**Development install:**
68-
69-
.. code-block:: bash
70-
71-
git clone https://bitbucket.org/predsci/pyvisual.git
72-
cd pyvisual
73-
pip install -e ".[all]"
74-
75-
----
76-
77-
Quick Start
78-
-----------
79-
80-
.. code-block:: python
81-
82-
import pyvisual as pv
83-
import numpy as np
84-
85-
pl = pv.Plot3d()
86-
87-
# Add the Sun (radius 1 R☉, centred at the origin)
88-
pl.add_sun()
89-
90-
# Add a 2-D equatorial slice at r = [1, 5] R☉, θ = π/2
91-
r = np.linspace(1, 5, 50)
92-
t = np.array([np.pi / 2]) # fix colatitude at the equator
93-
p = np.linspace(0, 2 * np.pi, 200)
94-
pl.add_2d_slice(r, t, p)
95-
96-
# Add lon/lat grid lines just above the Sun's surface
97-
pl.add_longlat_lines(lat_deg=30, lon_deg=30, radius=1.01)
98-
99-
pl.show()
100-
101-
----
102-
103-
Architecture
104-
------------
105-
106-
``Plot3d`` extends ``pyvista.Plotter`` through four mixin classes:
107-
108-
+---------------------+--------------------------------------------------+
109-
| Mixin | Responsibility |
110-
+=====================+==================================================+
111-
| ``ObserverMixin`` | Camera position/orientation/FOV in spherical |
112-
| | coordinates; live camera-state readout |
113-
+---------------------+--------------------------------------------------+
114-
| ``GeometryMixin`` | Sun, shells, discs, Thomson sphere, |
115-
| | longitude/latitude grid lines |
116-
+---------------------+--------------------------------------------------+
117-
| ``GridMeshMixin`` | 1-D/2-D/3-D structured-grid slices and |
118-
| | isosurface contours |
119-
+---------------------+--------------------------------------------------+
120-
| ``StackMeshMixin`` | Points, splines, surfaces, and magnetic |
121-
| | fieldlines from stacked coordinate arrays |
122-
+---------------------+--------------------------------------------------+
123-
124-
Two structured-grid mesh classes carry PSI HDF data and plug directly into
125-
``Plot3d.add_mesh``:
126-
127-
- ``SphericalMesh`` (``pyvista.RectilinearGrid``) — stores data on an
128-
:math:`(r, \theta, \phi)` grid; axes are accessible as ``.r``, ``.t``,
129-
``.p``.
130-
- ``CartesianMesh`` (``pyvista.StructuredGrid``) — stores data on an
131-
:math:`(x, y, z)` grid; supports the same arithmetic interface.
132-
133-
----
134-
135-
Documentation
136-
-------------
137-
138-
Full API reference, gallery examples, and guides are published at:
139-
140-
https://predsci.com/doc/pyvisual/
141-
142-
To build the documentation locally:
143-
144-
.. code-block:: bash
145-
146-
pip install "pyvisual[docs]"
147-
cd docs && make html
148-
# output: docs/_build/html/index.html
149-
150-
----
151-
152-
Development
153-
-----------
14+
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pyvisual.svg?logo=python&label=python&logoColor=white
15+
:target: https://pypi.org/project/pyvisual
16+
:alt: Python Versions
15417

155-
.. code-block:: bash
18+
.. |deps| image:: https://img.shields.io/librariesio/github/predsci/pyvisual?logo=Libraries.io&logoColor=white
19+
:target: https://github.com/predsci/pyvisual/blob/main/pyproject.toml
20+
:alt: Libraries.io
15621

157-
# Linting
158-
ruff check .
22+
|pypi|
23+
|license|
24+
|pyversions|
25+
|deps|
15926

160-
# Type checking
161-
mypy .
27+
|psi| **PYVISUAL** | *3D Visualizations for Spherical Coordinate Systems*
28+
-------------------------------------------------------------------------
16229

163-
# Tests
164-
pytest
165-
pytest --cov # with coverage report
166-
167-
----
168-
169-
Data Conventions
170-
----------------
171-
172-
Solar model data is stored in HDF4 or HDF5 files written in Fortran-order
173-
array layout. The PSI conventions for these files are documented at:
174-
175-
- https://predsci.com/doc/psi-io/guide/index.html
176-
- https://predsci.com/doc/mapflpy/
177-
178-
Spherical coordinates follow the PSI :math:`(r, \theta, \phi)` convention —
179-
radius, **co**\latitude, longitude — which differs from the physics
180-
:math:`(r, \phi, \theta)` convention used in some other codes.
181-
182-
----
183-
184-
License
185-
-------
186-
187-
Apache License 2.0. See ``LICENSE.txt`` for details.
188-
189-
----
190-
191-
Authors
192-
-------
193-
194-
- Ryder Davidson — `Predictive Science Inc. <https://www.predsci.com/>`_
195-
- Cooper Downs — `Predictive Science Inc. <https://www.predsci.com/>`_
196-
- Andres Reyes — `Predictive Science Inc. <https://www.predsci.com/>`_
30+
**pyvisual** is developed and maintained by `Predictive Science Inc. (PSI)
31+
<https://www.predsci.com/>`_. Its principal concern is the visualization
32+
of solar and magnetohydrodynamic (MHD) model output defined on spherical
33+
coordinate systems. The package is tightly coupled to the PSI data ecosystem
34+
and is tuned for use with **psi-io** and **mapflpy** (although any model
35+
defined on a rectilinear grid in spherical coordinates is compatible with
36+
**pyvisual**'s API).
37+
38+
**pyvisual** is a thin wrapper around the **PyVista** package – a powerful and
39+
flexible (high-level) python interface for the Visualization Toolkit (VTK) library.
40+
It is **STRONGLY** recommended to visit the exhaustive
41+
`PyVista documentation <https://docs.pyvista.org/>`_ (along with
42+
their `examples <https://docs.pyvista.org/examples/index.html>`_) to get a better
43+
understanding of the underlying capabilities of the package. **pyvisual** is
44+
intentionally limited in scope – tailored for use with PSI's data ecosystem.
45+
For a more robust solar physics visualization package, consider using **SunPy**'s
46+
`sunkit-pyvista <https://docs.sunpy.org/projects/sunkit-pyvista/en/latest/index.html>`_
47+
subpackage *viz.* for coordinate-aware 3D visualizations.
48+
49+
To get started with **pyvisual**, visit the
50+
`User Guide <https://predsci.com/doc/pyvisual/guide/>`_ for installation instructions,
51+
an overview of features, and development/contribution guidelines; a gallery of
52+
`examples <https://predsci.com/doc/pyvisual/gallery/>`_ is also available, showcasing
53+
various use cases and functionalities of the package. Please direct any questions or
54+
issues to the `issue tracker <https://github.com/predsci/pyvisual/issues>`_,
55+
or `contact <https://www.predsci.com/portal/contact.php>`_ Predictive Science Inc. directly.
56+
57+
----
58+
59+
`Predictive Science Inc. <https://predsci.com>`_ |
60+
`Repository <https://github.com/predsci/pyvisual>`_ |
61+
`Documentation <https://predsci.com/doc/pyvisual>`_ |
62+
`Distribution <https://pypi.org/project/pyvisual>`_

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/_static/.gitkeep

Whitespace-only changes.

docs/source/_static/assets/.gitkeep

Whitespace-only changes.

docs/source/_static/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Primary navigation sidebar */
2+
.bd-sidebar-primary {
3+
width: max-content;
4+
flex-basis: max-content;
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ name | escape | underline}}
2+
3+
.. autodata:: {{ fullname }}

0 commit comments

Comments
 (0)