eyepiece
Plotting and animation primitives for astronomical imaging simulations.
What eyepiece is
eyepiece provides ax-first, stateless figure functions for the plots that
recur across direct-imaging work: log-scaled and diverging image displays,
side-by-side and A/B comparison panels, radial profiles and contrast curves,
corner plots, orbit and sky-track scenes, optical-train schematics, and a
multi-sink animation recorder that grabs frames once and writes them to any
combination of gif, mp4, and html. Every primitive takes plain arrays in and
returns a small result object holding the axes and the artists it drew, so
callers can update or extend a figure without re-deriving which line or
image object came from where.
Figure style (color, colormaps, and mode) is resolved through
hwostyle at call
time, not at import time. import eyepiece never activates a style or
touches matplotlib's rcParams. Without an active hwostyle mode, primitives
fall back to a fixed light-mode palette, so eyepiece also works as a
standalone plotting library.
What eyepiece is not
- Not a simulation library. eyepiece takes arrays and returns figures; it never imports a simulation, orbit, or optics package.
- Not a style engine. Color, colormap, and mode definitions live in hwostyle; eyepiece only reads them at call time.
- Not a data pipeline. Aggregating or transforming simulation output before plotting is the caller's job.
What is in it
Every name below is importable straight from eyepiece; the submodules that
implement them are internal organization.
- Images.
imshow_log(log scale clipped to a floor, so a zero-valued pixel cannot break the norm),imshow_diverging(symmetric norm about zero),show_field(amplitude and phase panels of a complex field),compare_row(several images sharing one norm and colorbar), andtriptych(A, B, and a ratio or residual comparison panel, side by side). - Distributions.
corner,corner_overlay(a second sample set laid over an existing triangle plot),hist_vs_pdf, andcov_ellipse. - Profiles.
plot_radial(a precomputed radial profile line),plot_contrast_curve(a contrast curve with inner/outer working angle shading and reference floor curves, drawn once per axes even across repeated calls, with each curve taking the next palette color so two calls on one axes are distinguishable), andradial_profile_plot(computes the profile viahwoutilsand plots it in one call, under the[hwo]extra). - Scenes.
trail(a 2D or 3D trajectory with depth-cued markers),sky_fan(weighted candidate sky tracks with an inner-working-angle disk), andfading_track. - Schematics.
rail(an optical-train diagram built from a plain(label, glyph)element list, over theGLYPHSvocabulary), andschematic, a preset wrapper overrailfor the imager and coronagraph trains that come up constantly. - Layout. Pixel-edge extent helpers (
extent_lod,extent_arcsec,extent_au, ...) with matching axis labelers, plusFrameandSourceStylesfor keeping several panels of one scene consistent. - Output.
save_figfor a styled write to disk,record(a context manager that opens every sink at once and takes frames from a loop the caller drives) andanimate(which binds a figure, a draw function, and a frame source into the publicAnimationtype it returns), andPRESETSof measured fps/dpi pairs.
Usage
import eyepiece as ep
result = ep.imshow_log(psf, extent=ep.extent_lod_from_pixels(psf.shape[0], 0.5))
ep.label_lod(result.ax)
ep.save_fig(result.fig, "psf")
Every primitive returns a small result object carrying the axes it drew on
and the artists it made (keyed by the ARTIST_KEYS vocabulary), so a caller
can keep working on the figure without hunting for the objects again. An
image primitive also returns an .update that redraws with new data through
the same transform, which is what makes animation a few lines:
frames = [cube[k] for k in range(len(cube))]
result = ep.imshow_log(frames[0])
def draw(fig, k):
result.update(frames[k])
ep.animate(result.fig, draw, len(frames), fps=10).save("run.mp4", "run.gif")
rail draws a miniature optical-train diagram from a plain element list, so
a physics panel can sit beside a reminder of which plane it shows:
import eyepiece as ep
result = ep.rail(
[("Pupil", "pupil"), ("FPM", "fpm"), ("Lyot", "lyot"), ("Focal", "focal")],
highlight="FPM",
)
ep.save_fig(result.fig, "coronagraph_rail")
Status
eyepiece is young: the primitives above are implemented and tested, and the public API may still shift before 1.0.
Installation
pip install eyepiece
Unit conversions used by a small number of layout helpers (arcsecond and AU
extents) and radial_profile_plot's profile computation are optional and
pull in hwoutils:
pip install eyepiece[hwo]
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eyepiece-0.1.0.tar.gz.
File metadata
- Download URL: eyepiece-0.1.0.tar.gz
- Upload date:
- Size: 49.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
004941bc92f13a55d947081746da3ba32a4f857b1c316c20bad34756aa6625f7
|
|
| MD5 |
4ba86bd7195c2164e75a27f3577e7faa
|
|
| BLAKE2b-256 |
b367d14ce8eab3f7e66c03912462d4957f52254970c86b77e787f9dcb74cb95c
|
Provenance
The following attestation bundles were made for eyepiece-0.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on CoreySpohn/eyepiece
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eyepiece-0.1.0.tar.gz -
Subject digest:
004941bc92f13a55d947081746da3ba32a4f857b1c316c20bad34756aa6625f7 - Sigstore transparency entry: 2430106485
- Sigstore integration time:
-
Permalink:
CoreySpohn/eyepiece@7743af8cf676928554ad45e6aab41c05d2001889 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/CoreySpohn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@7743af8cf676928554ad45e6aab41c05d2001889 -
Trigger Event:
push
-
Statement type:
File details
Details for the file eyepiece-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eyepiece-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
941fae14eb2330b077c4cf61880bbc6e55c948bb14007e0cd2a6f742964f835d
|
|
| MD5 |
c5f0f59621f712099c659739c2d96fc6
|
|
| BLAKE2b-256 |
6a196dd9be904c5232640a22f8df0ba39cb7e984784248fcb5e925193fa70f95
|
Provenance
The following attestation bundles were made for eyepiece-0.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on CoreySpohn/eyepiece
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eyepiece-0.1.0-py3-none-any.whl -
Subject digest:
941fae14eb2330b077c4cf61880bbc6e55c948bb14007e0cd2a6f742964f835d - Sigstore transparency entry: 2430106544
- Sigstore integration time:
-
Permalink:
CoreySpohn/eyepiece@7743af8cf676928554ad45e6aab41c05d2001889 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/CoreySpohn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@7743af8cf676928554ad45e6aab41c05d2001889 -
Trigger Event:
push
-
Statement type: