sciview 0.3.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.
Files changed (96) hide show
  1. sciview-0.3.0/LICENSE +24 -0
  2. sciview-0.3.0/PKG-INFO +236 -0
  3. sciview-0.3.0/README.md +173 -0
  4. sciview-0.3.0/pyproject.toml +80 -0
  5. sciview-0.3.0/setup.cfg +4 -0
  6. sciview-0.3.0/src/sciview/__init__.py +33 -0
  7. sciview-0.3.0/src/sciview/__main__.py +6 -0
  8. sciview-0.3.0/src/sciview/agent/__init__.py +4 -0
  9. sciview-0.3.0/src/sciview/agent/mcp.py +202 -0
  10. sciview-0.3.0/src/sciview/agent/tools.py +434 -0
  11. sciview-0.3.0/src/sciview/cli.py +238 -0
  12. sciview-0.3.0/src/sciview/engine/__init__.py +8 -0
  13. sciview-0.3.0/src/sciview/engine/assets.py +503 -0
  14. sciview-0.3.0/src/sciview/engine/camera.py +86 -0
  15. sciview-0.3.0/src/sciview/engine/color.py +136 -0
  16. sciview-0.3.0/src/sciview/engine/easing.py +103 -0
  17. sciview-0.3.0/src/sciview/engine/mathexpr.py +82 -0
  18. sciview-0.3.0/src/sciview/engine/surface.py +660 -0
  19. sciview-0.3.0/src/sciview/engine/text.py +344 -0
  20. sciview-0.3.0/src/sciview/engine/units.py +68 -0
  21. sciview-0.3.0/src/sciview/export.py +292 -0
  22. sciview-0.3.0/src/sciview/figures.py +80 -0
  23. sciview-0.3.0/src/sciview/fonts/Inter-Bold.otf +0 -0
  24. sciview-0.3.0/src/sciview/fonts/Inter-Medium.otf +0 -0
  25. sciview-0.3.0/src/sciview/fonts/Inter-Regular.otf +0 -0
  26. sciview-0.3.0/src/sciview/fonts/OFL-Inter.txt +93 -0
  27. sciview-0.3.0/src/sciview/fonts/OFL-Poppins.txt +93 -0
  28. sciview-0.3.0/src/sciview/fonts/Poppins-Bold.ttf +0 -0
  29. sciview-0.3.0/src/sciview/fonts/Poppins-Light.ttf +0 -0
  30. sciview-0.3.0/src/sciview/fonts/Poppins-Medium.ttf +0 -0
  31. sciview-0.3.0/src/sciview/fonts/Poppins-Regular.ttf +0 -0
  32. sciview-0.3.0/src/sciview/gui/favicon.svg +1 -0
  33. sciview-0.3.0/src/sciview/gui/index.html +106 -0
  34. sciview-0.3.0/src/sciview/gui/js/actions.js +374 -0
  35. sciview-0.3.0/src/sciview/gui/js/api.js +53 -0
  36. sciview-0.3.0/src/sciview/gui/js/dialogs.js +288 -0
  37. sciview-0.3.0/src/sciview/gui/js/geom.js +133 -0
  38. sciview-0.3.0/src/sciview/gui/js/icons.js +98 -0
  39. sciview-0.3.0/src/sciview/gui/js/inspector.js +925 -0
  40. sciview-0.3.0/src/sciview/gui/js/main.js +338 -0
  41. sciview-0.3.0/src/sciview/gui/js/state.js +524 -0
  42. sciview-0.3.0/src/sciview/gui/js/timeline.js +391 -0
  43. sciview-0.3.0/src/sciview/gui/js/ui.js +124 -0
  44. sciview-0.3.0/src/sciview/gui/js/viewport.js +250 -0
  45. sciview-0.3.0/src/sciview/gui/style.css +380 -0
  46. sciview-0.3.0/src/sciview/model/__init__.py +16 -0
  47. sciview-0.3.0/src/sciview/model/base.py +607 -0
  48. sciview-0.3.0/src/sciview/model/charts.py +515 -0
  49. sciview-0.3.0/src/sciview/model/context.py +212 -0
  50. sciview-0.3.0/src/sciview/model/data.py +51 -0
  51. sciview-0.3.0/src/sciview/model/figure.py +75 -0
  52. sciview-0.3.0/src/sciview/model/group.py +35 -0
  53. sciview-0.3.0/src/sciview/model/molecule.py +250 -0
  54. sciview-0.3.0/src/sciview/model/objects2d.py +484 -0
  55. sciview-0.3.0/src/sciview/model/objects3d.py +774 -0
  56. sciview-0.3.0/src/sciview/model/optics.py +345 -0
  57. sciview-0.3.0/src/sciview/model/plots.py +973 -0
  58. sciview-0.3.0/src/sciview/model/project.py +532 -0
  59. sciview-0.3.0/src/sciview/model/science.py +816 -0
  60. sciview-0.3.0/src/sciview/render.py +443 -0
  61. sciview-0.3.0/src/sciview/science/__init__.py +4 -0
  62. sciview-0.3.0/src/sciview/science/tomo.py +134 -0
  63. sciview-0.3.0/src/sciview/server.py +692 -0
  64. sciview-0.3.0/src/sciview/templates/clusters/assets/slice_neutron.png +0 -0
  65. sciview-0.3.0/src/sciview/templates/clusters/assets/slice_xray.png +0 -0
  66. sciview-0.3.0/src/sciview/templates/clusters/assets/voxels.csv +1401 -0
  67. sciview-0.3.0/src/sciview/templates/clusters/project.sciview.json +530 -0
  68. sciview-0.3.0/src/sciview/templates/data_story/project.sciview.json +638 -0
  69. sciview-0.3.0/src/sciview/templates/lattice/assets/lattice.csv +65 -0
  70. sciview-0.3.0/src/sciview/templates/lattice/project.sciview.json +202 -0
  71. sciview-0.3.0/src/sciview/templates/neutron_imaging/assets/radiograph.png +0 -0
  72. sciview-0.3.0/src/sciview/templates/neutron_imaging/project.sciview.json +341 -0
  73. sciview-0.3.0/src/sciview/templates/optics/project.sciview.json +238 -0
  74. sciview-0.3.0/src/sciview/templates/title_card/project.sciview.json +193 -0
  75. sciview-0.3.0/src/sciview/templates/tomography/assets/sample.npy +0 -0
  76. sciview-0.3.0/src/sciview/templates/tomography/assets/slice.png +0 -0
  77. sciview-0.3.0/src/sciview/templates/tomography/project.sciview.json +415 -0
  78. sciview-0.3.0/src/sciview/templates/waves/project.sciview.json +245 -0
  79. sciview-0.3.0/src/sciview.egg-info/PKG-INFO +236 -0
  80. sciview-0.3.0/src/sciview.egg-info/SOURCES.txt +94 -0
  81. sciview-0.3.0/src/sciview.egg-info/dependency_links.txt +1 -0
  82. sciview-0.3.0/src/sciview.egg-info/entry_points.txt +2 -0
  83. sciview-0.3.0/src/sciview.egg-info/requires.txt +35 -0
  84. sciview-0.3.0/src/sciview.egg-info/top_level.txt +1 -0
  85. sciview-0.3.0/tests/test_cache.py +118 -0
  86. sciview-0.3.0/tests/test_data.py +227 -0
  87. sciview-0.3.0/tests/test_engine.py +182 -0
  88. sciview-0.3.0/tests/test_export_cli.py +83 -0
  89. sciview-0.3.0/tests/test_figures_agent.py +342 -0
  90. sciview-0.3.0/tests/test_groups.py +188 -0
  91. sciview-0.3.0/tests/test_gui.py +523 -0
  92. sciview-0.3.0/tests/test_model.py +150 -0
  93. sciview-0.3.0/tests/test_plots_optics.py +257 -0
  94. sciview-0.3.0/tests/test_render.py +124 -0
  95. sciview-0.3.0/tests/test_science.py +422 -0
  96. sciview-0.3.0/tests/test_server.py +208 -0
sciview-0.3.0/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oriol Sans Planell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ The fonts in src/sciview/fonts (Poppins and Inter) are licensed under the SIL
24
+ Open Font License 1.1; see the OFL-*.txt files in that folder.
sciview-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,236 @@
1
+ Metadata-Version: 2.4
2
+ Name: sciview
3
+ Version: 0.3.0
4
+ Summary: Make clear, beautiful scientific explainer videos with a visual editor or a few lines of Python.
5
+ Author: Oriol Sans Planell
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/OriolSansPlanell/SciView
8
+ Project-URL: Documentation, https://github.com/OriolSansPlanell/SciView/tree/main/docs
9
+ Project-URL: Issues, https://github.com/OriolSansPlanell/SciView/issues
10
+ Project-URL: Changelog, https://github.com/OriolSansPlanell/SciView/blob/main/CHANGELOG.md
11
+ Keywords: scientific visualization,animation,video,science communication,explainer,neutron imaging,tomography,MCP
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Operating System :: Microsoft :: Windows
24
+ Classifier: Operating System :: MacOS
25
+ Classifier: Operating System :: POSIX :: Linux
26
+ Classifier: Topic :: Multimedia :: Video
27
+ Classifier: Topic :: Scientific/Engineering :: Visualization
28
+ Requires-Python: >=3.10
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ License-File: src/sciview/fonts/OFL-Inter.txt
32
+ License-File: src/sciview/fonts/OFL-Poppins.txt
33
+ Requires-Dist: numpy>=1.22
34
+ Requires-Dist: opencv-python-headless>=4.6
35
+ Requires-Dist: pillow>=9.2
36
+ Requires-Dist: imageio-ffmpeg>=0.4.7
37
+ Provides-Extra: math
38
+ Requires-Dist: matplotlib>=3.5; extra == "math"
39
+ Provides-Extra: science
40
+ Requires-Dist: scikit-image>=0.19; extra == "science"
41
+ Requires-Dist: scipy>=1.8; extra == "science"
42
+ Requires-Dist: tifffile>=2021.1; extra == "science"
43
+ Requires-Dist: h5py>=3.6; extra == "science"
44
+ Provides-Extra: test
45
+ Requires-Dist: pytest>=7; extra == "test"
46
+ Requires-Dist: matplotlib>=3.5; extra == "test"
47
+ Requires-Dist: scikit-image>=0.19; extra == "test"
48
+ Requires-Dist: scipy>=1.8; extra == "test"
49
+ Requires-Dist: tifffile>=2021.1; extra == "test"
50
+ Requires-Dist: h5py>=3.6; extra == "test"
51
+ Provides-Extra: gui-test
52
+ Requires-Dist: playwright>=1.40; extra == "gui-test"
53
+ Provides-Extra: docs
54
+ Requires-Dist: mkdocs>=1.5; extra == "docs"
55
+ Requires-Dist: mkdocs-material>=9; extra == "docs"
56
+ Provides-Extra: all
57
+ Requires-Dist: matplotlib>=3.5; extra == "all"
58
+ Requires-Dist: scikit-image>=0.19; extra == "all"
59
+ Requires-Dist: scipy>=1.8; extra == "all"
60
+ Requires-Dist: tifffile>=2021.1; extra == "all"
61
+ Requires-Dist: h5py>=3.6; extra == "all"
62
+ Dynamic: license-file
63
+
64
+ <p align="center">
65
+ <img src="docs/images/beamline.gif" alt="A SciView film: a neutron beam crosses a sample and the radiograph builds up on the detector" width="640">
66
+ </p>
67
+
68
+ <h1 align="center">SciView</h1>
69
+
70
+ <p align="center">Make clear, beautiful scientific explainer videos, with a visual editor or a few lines of Python.</p>
71
+
72
+ <p align="center">
73
+ <a href="https://github.com/OriolSansPlanell/SciView/actions/workflows/ci.yml"><img src="https://github.com/OriolSansPlanell/SciView/actions/workflows/ci.yml/badge.svg" alt="Tests"></a>
74
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-4fd1c5" alt="MIT licence"></a>
75
+ <img src="https://img.shields.io/badge/python-3.10%E2%80%933.14-6cb4fc" alt="Python 3.10 to 3.14">
76
+ </p>
77
+
78
+ Most scientists explain their work with static slides, because animation tools are either made for
79
+ programmers (Manim), for 3D artists (Blender) or for marketing (After Effects). SciView sits in between: you
80
+ build a film from the things science talks about (beams, samples, detectors, curves, scatter plots,
81
+ equations, captions) and every one of them can be timed, keyframed and exported to a video you can drop
82
+ into a talk.
83
+
84
+ * **A visual editor** that runs in your browser: add objects, drag them in the preview, keyframe any value,
85
+ arrange clips on a timeline, export.
86
+ * **The same film in Python**: generate scenes from your own data with NumPy and render them from scripts or
87
+ notebooks.
88
+ * **Made for science**: particle beams with scattering, detector images that build up count by count,
89
+ tomography from sinogram to volume, molecules, ray optics, charts with error bars and fits whose axes,
90
+ curves and markers animate, LaTeX equations, sub- and superscripts everywhere (`H_2O`, `^6Li`, `\mu`),
91
+ subtitles exported for accessibility.
92
+ * **Easy to install**: pure Python on NumPy, OpenCV and Pillow. ffmpeg comes with the package. No LaTeX, no
93
+ Cairo, no GPU needed.
94
+
95
+ <p align="center"><img src="docs/images/editor.png" alt="The SciView editor: object library on the left, preview in the middle, properties on the right, timeline below" width="900"></p>
96
+
97
+ ## Install
98
+
99
+ ```bash
100
+ pip install "sciview[math] @ git+https://github.com/OriolSansPlanell/SciView"
101
+ ```
102
+
103
+ The `math` extra installs matplotlib, which renders the LaTeX equations; add `science` (`sciview[math,science]`)
104
+ for isosurfaces, TIFF stacks, HDF5 volumes and SciPy fits. SciView needs Python 3.10 or newer
105
+ and works on Windows, macOS and Linux.
106
+
107
+ ## Make your first film
108
+
109
+ ```bash
110
+ sciview edit
111
+ ```
112
+
113
+ Your browser opens the editor. Pick a template or an empty film, then:
114
+
115
+ 1. **Add** objects from the list on the left. They appear at the current time.
116
+ 2. **Place** them: drag objects in the preview, 2D and 3D alike (hold Shift to stay on one axis), or type
117
+ values in the panel on the right. Drag empty space to orbit the 3D camera and scroll to zoom. Shift-click
118
+ to select several objects, then align, distribute or group them (Ctrl+G) to move, scale, fade and time
119
+ them together.
120
+ 3. **Time** them: drag clips on the timeline to change when objects appear, and pick enter and exit effects
121
+ (fade, slide, pop, draw on, type on).
122
+ 4. **Animate** any value with the diamond next to it: set a value at one time, move the playhead, change it
123
+ again. Gold labels show what is animated; draw your own easing curve for any keyframe.
124
+ 5. **Export** an MP4 for slides, a WebM for the web, ProRes for video editors, a GIF or PNG frames.
125
+
126
+ Projects are saved as a readable `.sciview.json` file with an `assets` folder for your images and data.
127
+ The editor keeps unsaved changes next to the file every 30 seconds and offers them back if it stops before
128
+ you save. Press <kbd>?</kbd> in the editor for all shortcuts.
129
+
130
+ ## Or write it in Python
131
+
132
+ ```python
133
+ import numpy as np
134
+ import sciview as sv
135
+
136
+ film = sv.Project(title="Beer-Lambert", duration=8)
137
+
138
+ ax = film.add("axes", position=(260, 200), size=(1400, 620), x_range=(0, 5), y_range=(0, 1.05),
139
+ x_label="thickness d (cm)", y_label="transmission T")
140
+ film.add("curve", axes=ax, expression="exp(-1.2*x)", color="teal", start=0.5) # drawn on
141
+ dot = film.add("marker", axes=ax, x=0.0, follow="exp(-1.2*x)", label="T = {y:.2f}", start=2)
142
+ dot.key("x", 2.5, 0.0).key("x", 6.5, 4.0, ease="in_out") # slides along the curve
143
+
144
+ thickness = np.linspace(0.2, 4.8, 12)
145
+ film.add("scatter", axes=ax, x_values=thickness,
146
+ y_values=np.exp(-1.2 * thickness) + np.random.normal(0, 0.02, 12), color="gold", size=5, start=4)
147
+ film.add("title", text="Beer–Lambert law", subtitle="Transmission falls exponentially with thickness")
148
+ film.add("caption", text="Each centimetre removes the same fraction of the beam.", start=3, end=7.5)
149
+
150
+ film.save("beer_lambert.sciview.json") # open it later with: sciview edit beer_lambert.sciview.json
151
+ film.render("beer_lambert.mp4") # or film.still(4.0, "frame.png", scale=2) for a poster figure
152
+ ```
153
+
154
+ More in [examples/](examples/) and the [Python guide](docs/python-api.md).
155
+
156
+ ## Command line
157
+
158
+ ```bash
159
+ sciview edit film.sciview.json # open (or create) a film in the editor
160
+ sciview new talk.sciview.json --template waves # start from a template
161
+ sciview render film.sciview.json -o film.mp4 # render; --scale 2 for 4K, --start/--end for a part
162
+ sciview still film.sciview.json -t 4.5 --scale 2 # a 3840 px PNG of one moment, for papers and posters
163
+ sciview subtitles film.sciview.json # captions as an .srt file
164
+ sciview check film.sciview.json # missing files, broken references, bad expressions
165
+ sciview mcp film.sciview.json # let an AI assistant edit the film (MCP server)
166
+ ```
167
+
168
+ ## What you can put in a film
169
+
170
+ <p align="center"><img src="docs/images/templates.jpg" alt="Frames from the eight templates: imaging beamline, step-by-step analysis, tomography, scatter and thresholds, animated equations, lenses and mirrors, 3D structure, title card" width="900"></p>
171
+
172
+ | | Objects |
173
+ | --- | --- |
174
+ | **3D scene** | box, cylinder, sphere, screen/detector with an image, particle beam with scattering, 3D arrow, floor grid, point cloud from a table, STL/OBJ model, 3D label, volume (slices, maximum-intensity projection, isosurface) from `.npy`, TIFF stacks or HDF5, molecule from PDB/XYZ (ball-and-stick, space-filling, ribbon), 3D scale bar |
175
+ | **Text** | title, caption (also exported as subtitles), text with live counters and SI prefixes, LaTeX equation, legend |
176
+ | **Charts** | axes (linear or log, animatable ranges), curve from an expression or data, scatter, bars, histogram, marker that follows a curve, threshold line, heatmap with colour bar, error bars, uncertainty band, fitted curve, spectrum with labelled peaks, 2D histogram, vector field, streamlines, matplotlib figure redrawn per frame (from Python) |
177
+ | **Imaging** | sinogram recorded angle by angle, filtered back-projection that builds up the slice, scale bar from the pixel size, pixels that fly into a scatter plot or histogram bins |
178
+ | **Optics** | thin lenses, flat and curved mirrors, beam splitters, rays traced through them, wavefronts |
179
+ | **Shapes & media** | panel/card with numbered badge, rectangle, ellipse, arrow, image (PNG, 16-bit TIFF, NumPy arrays, with colormaps), group |
180
+
181
+ Curve expressions can use time: `sin(x - 2*t)` is a travelling wave. Any number can follow a column of a table
182
+ over time (a **data track**), and any file field can play a series of files, one per step: a stack of
183
+ radiographs, the outputs of a simulation. The full list of properties is in the
184
+ [object reference](docs/objects.md).
185
+
186
+ ## Let an AI assistant help
187
+
188
+ `sciview mcp film.sciview.json` lets an AI assistant (Claude Desktop, a local model in LM Studio, any
189
+ [MCP](https://modelcontextprotocol.io) client) read the film, add and animate objects and look at frames
190
+ through a small set of checked tools. It never runs code, keeps away from locked objects and can be limited
191
+ to a time window or a few objects. Pointed at the open editor, its changes appear live and Ctrl+Z takes
192
+ them back. See [AI assistants](docs/agent.md).
193
+
194
+ ## How it works
195
+
196
+ Every frame is a pure function of time: `frame(t)` builds the picture from the project and nothing is carried
197
+ over from the previous frame. That makes any moment reproducible on its own, lets the preview jump anywhere
198
+ instantly and lets exports render frames in parallel on all CPU cores. Objects that do not change between
199
+ frames are drawn once into cached layers, which never changes a pixel but saves work.
200
+
201
+ Objects draw anti-aliased geometry with OpenCV into a float canvas and send light into a separate glow
202
+ buffer, which is blurred at several scales and added back (the neon look). Particles are accumulated and
203
+ compressed with 1 − exp(−x), so dense beams glow instead of clipping to white. Text goes through Pillow with a
204
+ small markup for sub/superscripts and symbols, and falls back to a second font for missing glyphs. Frames are
205
+ piped straight into ffmpeg. The editor is a static web page served by a small local Python server; it sends
206
+ the project as JSON and shows the frames Python renders, so the preview and the export are pixel-identical.
207
+
208
+ The design started as the renderer behind two neutron imaging films for a conference talk, generalised so
209
+ that anyone can make films like them without writing a renderer.
210
+
211
+ ## Documentation
212
+
213
+ * [Getting started](docs/getting-started.md)
214
+ * [The editor](docs/editor.md)
215
+ * [Python guide](docs/python-api.md)
216
+ * [Object reference](docs/objects.md)
217
+ * [Rendering and sharing](docs/rendering.md)
218
+ * [AI assistants](docs/agent.md)
219
+ * [Project file format](docs/file-format.md)
220
+ * [Troubleshooting](docs/troubleshooting.md)
221
+
222
+ ## Citing SciView
223
+
224
+ If SciView helps you communicate your research, please cite it. GitHub's "Cite this repository" button gives
225
+ the reference from [CITATION.cff](CITATION.cff).
226
+
227
+ ## Contributing
228
+
229
+ Bug reports, templates and new object types are very welcome. See [CONTRIBUTING.md](CONTRIBUTING.md); a new
230
+ object type is one class with a list of properties and a `draw` method, and it appears in the editor
231
+ automatically.
232
+
233
+ ## Licence
234
+
235
+ SciView is released under the [MIT licence](LICENSE). The bundled Poppins and Inter fonts are under the SIL
236
+ Open Font License (see `src/sciview/fonts`).
@@ -0,0 +1,173 @@
1
+ <p align="center">
2
+ <img src="docs/images/beamline.gif" alt="A SciView film: a neutron beam crosses a sample and the radiograph builds up on the detector" width="640">
3
+ </p>
4
+
5
+ <h1 align="center">SciView</h1>
6
+
7
+ <p align="center">Make clear, beautiful scientific explainer videos, with a visual editor or a few lines of Python.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://github.com/OriolSansPlanell/SciView/actions/workflows/ci.yml"><img src="https://github.com/OriolSansPlanell/SciView/actions/workflows/ci.yml/badge.svg" alt="Tests"></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-4fd1c5" alt="MIT licence"></a>
12
+ <img src="https://img.shields.io/badge/python-3.10%E2%80%933.14-6cb4fc" alt="Python 3.10 to 3.14">
13
+ </p>
14
+
15
+ Most scientists explain their work with static slides, because animation tools are either made for
16
+ programmers (Manim), for 3D artists (Blender) or for marketing (After Effects). SciView sits in between: you
17
+ build a film from the things science talks about (beams, samples, detectors, curves, scatter plots,
18
+ equations, captions) and every one of them can be timed, keyframed and exported to a video you can drop
19
+ into a talk.
20
+
21
+ * **A visual editor** that runs in your browser: add objects, drag them in the preview, keyframe any value,
22
+ arrange clips on a timeline, export.
23
+ * **The same film in Python**: generate scenes from your own data with NumPy and render them from scripts or
24
+ notebooks.
25
+ * **Made for science**: particle beams with scattering, detector images that build up count by count,
26
+ tomography from sinogram to volume, molecules, ray optics, charts with error bars and fits whose axes,
27
+ curves and markers animate, LaTeX equations, sub- and superscripts everywhere (`H_2O`, `^6Li`, `\mu`),
28
+ subtitles exported for accessibility.
29
+ * **Easy to install**: pure Python on NumPy, OpenCV and Pillow. ffmpeg comes with the package. No LaTeX, no
30
+ Cairo, no GPU needed.
31
+
32
+ <p align="center"><img src="docs/images/editor.png" alt="The SciView editor: object library on the left, preview in the middle, properties on the right, timeline below" width="900"></p>
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install "sciview[math] @ git+https://github.com/OriolSansPlanell/SciView"
38
+ ```
39
+
40
+ The `math` extra installs matplotlib, which renders the LaTeX equations; add `science` (`sciview[math,science]`)
41
+ for isosurfaces, TIFF stacks, HDF5 volumes and SciPy fits. SciView needs Python 3.10 or newer
42
+ and works on Windows, macOS and Linux.
43
+
44
+ ## Make your first film
45
+
46
+ ```bash
47
+ sciview edit
48
+ ```
49
+
50
+ Your browser opens the editor. Pick a template or an empty film, then:
51
+
52
+ 1. **Add** objects from the list on the left. They appear at the current time.
53
+ 2. **Place** them: drag objects in the preview, 2D and 3D alike (hold Shift to stay on one axis), or type
54
+ values in the panel on the right. Drag empty space to orbit the 3D camera and scroll to zoom. Shift-click
55
+ to select several objects, then align, distribute or group them (Ctrl+G) to move, scale, fade and time
56
+ them together.
57
+ 3. **Time** them: drag clips on the timeline to change when objects appear, and pick enter and exit effects
58
+ (fade, slide, pop, draw on, type on).
59
+ 4. **Animate** any value with the diamond next to it: set a value at one time, move the playhead, change it
60
+ again. Gold labels show what is animated; draw your own easing curve for any keyframe.
61
+ 5. **Export** an MP4 for slides, a WebM for the web, ProRes for video editors, a GIF or PNG frames.
62
+
63
+ Projects are saved as a readable `.sciview.json` file with an `assets` folder for your images and data.
64
+ The editor keeps unsaved changes next to the file every 30 seconds and offers them back if it stops before
65
+ you save. Press <kbd>?</kbd> in the editor for all shortcuts.
66
+
67
+ ## Or write it in Python
68
+
69
+ ```python
70
+ import numpy as np
71
+ import sciview as sv
72
+
73
+ film = sv.Project(title="Beer-Lambert", duration=8)
74
+
75
+ ax = film.add("axes", position=(260, 200), size=(1400, 620), x_range=(0, 5), y_range=(0, 1.05),
76
+ x_label="thickness d (cm)", y_label="transmission T")
77
+ film.add("curve", axes=ax, expression="exp(-1.2*x)", color="teal", start=0.5) # drawn on
78
+ dot = film.add("marker", axes=ax, x=0.0, follow="exp(-1.2*x)", label="T = {y:.2f}", start=2)
79
+ dot.key("x", 2.5, 0.0).key("x", 6.5, 4.0, ease="in_out") # slides along the curve
80
+
81
+ thickness = np.linspace(0.2, 4.8, 12)
82
+ film.add("scatter", axes=ax, x_values=thickness,
83
+ y_values=np.exp(-1.2 * thickness) + np.random.normal(0, 0.02, 12), color="gold", size=5, start=4)
84
+ film.add("title", text="Beer–Lambert law", subtitle="Transmission falls exponentially with thickness")
85
+ film.add("caption", text="Each centimetre removes the same fraction of the beam.", start=3, end=7.5)
86
+
87
+ film.save("beer_lambert.sciview.json") # open it later with: sciview edit beer_lambert.sciview.json
88
+ film.render("beer_lambert.mp4") # or film.still(4.0, "frame.png", scale=2) for a poster figure
89
+ ```
90
+
91
+ More in [examples/](examples/) and the [Python guide](docs/python-api.md).
92
+
93
+ ## Command line
94
+
95
+ ```bash
96
+ sciview edit film.sciview.json # open (or create) a film in the editor
97
+ sciview new talk.sciview.json --template waves # start from a template
98
+ sciview render film.sciview.json -o film.mp4 # render; --scale 2 for 4K, --start/--end for a part
99
+ sciview still film.sciview.json -t 4.5 --scale 2 # a 3840 px PNG of one moment, for papers and posters
100
+ sciview subtitles film.sciview.json # captions as an .srt file
101
+ sciview check film.sciview.json # missing files, broken references, bad expressions
102
+ sciview mcp film.sciview.json # let an AI assistant edit the film (MCP server)
103
+ ```
104
+
105
+ ## What you can put in a film
106
+
107
+ <p align="center"><img src="docs/images/templates.jpg" alt="Frames from the eight templates: imaging beamline, step-by-step analysis, tomography, scatter and thresholds, animated equations, lenses and mirrors, 3D structure, title card" width="900"></p>
108
+
109
+ | | Objects |
110
+ | --- | --- |
111
+ | **3D scene** | box, cylinder, sphere, screen/detector with an image, particle beam with scattering, 3D arrow, floor grid, point cloud from a table, STL/OBJ model, 3D label, volume (slices, maximum-intensity projection, isosurface) from `.npy`, TIFF stacks or HDF5, molecule from PDB/XYZ (ball-and-stick, space-filling, ribbon), 3D scale bar |
112
+ | **Text** | title, caption (also exported as subtitles), text with live counters and SI prefixes, LaTeX equation, legend |
113
+ | **Charts** | axes (linear or log, animatable ranges), curve from an expression or data, scatter, bars, histogram, marker that follows a curve, threshold line, heatmap with colour bar, error bars, uncertainty band, fitted curve, spectrum with labelled peaks, 2D histogram, vector field, streamlines, matplotlib figure redrawn per frame (from Python) |
114
+ | **Imaging** | sinogram recorded angle by angle, filtered back-projection that builds up the slice, scale bar from the pixel size, pixels that fly into a scatter plot or histogram bins |
115
+ | **Optics** | thin lenses, flat and curved mirrors, beam splitters, rays traced through them, wavefronts |
116
+ | **Shapes & media** | panel/card with numbered badge, rectangle, ellipse, arrow, image (PNG, 16-bit TIFF, NumPy arrays, with colormaps), group |
117
+
118
+ Curve expressions can use time: `sin(x - 2*t)` is a travelling wave. Any number can follow a column of a table
119
+ over time (a **data track**), and any file field can play a series of files, one per step: a stack of
120
+ radiographs, the outputs of a simulation. The full list of properties is in the
121
+ [object reference](docs/objects.md).
122
+
123
+ ## Let an AI assistant help
124
+
125
+ `sciview mcp film.sciview.json` lets an AI assistant (Claude Desktop, a local model in LM Studio, any
126
+ [MCP](https://modelcontextprotocol.io) client) read the film, add and animate objects and look at frames
127
+ through a small set of checked tools. It never runs code, keeps away from locked objects and can be limited
128
+ to a time window or a few objects. Pointed at the open editor, its changes appear live and Ctrl+Z takes
129
+ them back. See [AI assistants](docs/agent.md).
130
+
131
+ ## How it works
132
+
133
+ Every frame is a pure function of time: `frame(t)` builds the picture from the project and nothing is carried
134
+ over from the previous frame. That makes any moment reproducible on its own, lets the preview jump anywhere
135
+ instantly and lets exports render frames in parallel on all CPU cores. Objects that do not change between
136
+ frames are drawn once into cached layers, which never changes a pixel but saves work.
137
+
138
+ Objects draw anti-aliased geometry with OpenCV into a float canvas and send light into a separate glow
139
+ buffer, which is blurred at several scales and added back (the neon look). Particles are accumulated and
140
+ compressed with 1 − exp(−x), so dense beams glow instead of clipping to white. Text goes through Pillow with a
141
+ small markup for sub/superscripts and symbols, and falls back to a second font for missing glyphs. Frames are
142
+ piped straight into ffmpeg. The editor is a static web page served by a small local Python server; it sends
143
+ the project as JSON and shows the frames Python renders, so the preview and the export are pixel-identical.
144
+
145
+ The design started as the renderer behind two neutron imaging films for a conference talk, generalised so
146
+ that anyone can make films like them without writing a renderer.
147
+
148
+ ## Documentation
149
+
150
+ * [Getting started](docs/getting-started.md)
151
+ * [The editor](docs/editor.md)
152
+ * [Python guide](docs/python-api.md)
153
+ * [Object reference](docs/objects.md)
154
+ * [Rendering and sharing](docs/rendering.md)
155
+ * [AI assistants](docs/agent.md)
156
+ * [Project file format](docs/file-format.md)
157
+ * [Troubleshooting](docs/troubleshooting.md)
158
+
159
+ ## Citing SciView
160
+
161
+ If SciView helps you communicate your research, please cite it. GitHub's "Cite this repository" button gives
162
+ the reference from [CITATION.cff](CITATION.cff).
163
+
164
+ ## Contributing
165
+
166
+ Bug reports, templates and new object types are very welcome. See [CONTRIBUTING.md](CONTRIBUTING.md); a new
167
+ object type is one class with a list of properties and a `draw` method, and it appears in the editor
168
+ automatically.
169
+
170
+ ## Licence
171
+
172
+ SciView is released under the [MIT licence](LICENSE). The bundled Poppins and Inter fonts are under the SIL
173
+ Open Font License (see `src/sciview/fonts`).
@@ -0,0 +1,80 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sciview"
7
+ version = "0.3.0"
8
+ description = "Make clear, beautiful scientific explainer videos with a visual editor or a few lines of Python."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE", "src/sciview/fonts/OFL-*.txt"]
12
+ authors = [{ name = "Oriol Sans Planell" }]
13
+ requires-python = ">=3.10"
14
+ keywords = ["scientific visualization", "animation", "video", "science communication", "explainer", "neutron imaging",
15
+ "tomography", "MCP"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Science/Research",
19
+ "Intended Audience :: Education",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
28
+ "Operating System :: Microsoft :: Windows",
29
+ "Operating System :: MacOS",
30
+ "Operating System :: POSIX :: Linux",
31
+ "Topic :: Multimedia :: Video",
32
+ "Topic :: Scientific/Engineering :: Visualization",
33
+ ]
34
+ dependencies = [
35
+ "numpy>=1.22",
36
+ "opencv-python-headless>=4.6",
37
+ "pillow>=9.2",
38
+ "imageio-ffmpeg>=0.4.7",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ math = ["matplotlib>=3.5"]
43
+ science = ["scikit-image>=0.19", "scipy>=1.8", "tifffile>=2021.1", "h5py>=3.6"]
44
+ test = ["pytest>=7", "matplotlib>=3.5", "scikit-image>=0.19", "scipy>=1.8", "tifffile>=2021.1", "h5py>=3.6"]
45
+ gui-test = ["playwright>=1.40"]
46
+ docs = ["mkdocs>=1.5", "mkdocs-material>=9"]
47
+ all = ["matplotlib>=3.5", "scikit-image>=0.19", "scipy>=1.8", "tifffile>=2021.1", "h5py>=3.6"]
48
+
49
+ [project.scripts]
50
+ sciview = "sciview.cli:main"
51
+
52
+ [project.urls]
53
+ Homepage = "https://github.com/OriolSansPlanell/SciView"
54
+ Documentation = "https://github.com/OriolSansPlanell/SciView/tree/main/docs"
55
+ Issues = "https://github.com/OriolSansPlanell/SciView/issues"
56
+ Changelog = "https://github.com/OriolSansPlanell/SciView/blob/main/CHANGELOG.md"
57
+
58
+ [tool.setuptools.packages.find]
59
+ where = ["src"]
60
+
61
+ [tool.setuptools.package-data]
62
+ sciview = [
63
+ "fonts/*",
64
+ "gui/*.html", "gui/*.css", "gui/*.svg", "gui/js/*.js",
65
+ "templates/*/*.json", "templates/*/assets/*",
66
+ ]
67
+
68
+ [tool.pytest.ini_options]
69
+ testpaths = ["tests"]
70
+ addopts = "-ra"
71
+ markers = ["gui: end-to-end editor tests in a headless browser (needs playwright)", "slow: renders video"]
72
+ filterwarnings = ["ignore::DeprecationWarning:skimage.*"]
73
+
74
+ [tool.ruff]
75
+ line-length = 120
76
+ target-version = "py310"
77
+
78
+ [tool.ruff.lint]
79
+ select = ["E", "F", "W", "I", "B", "UP"]
80
+ ignore = ["E501", "B008", "B905"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,33 @@
1
+ """SciView: make clear, beautiful scientific explainer videos.
2
+
3
+ Quick start::
4
+
5
+ import sciview as sv
6
+
7
+ film = sv.Project(duration=8, title="Neutron imaging")
8
+ src = film.add("box", name="Source", center=(-60, 0, 0), size=(14, 14, 14), edge_color="gold",
9
+ fill_color="gold", label="neutron source")
10
+ film.add("beam", source=(-53, 0, 0), target=(0, 0, 0), start=1.0)
11
+ film.add("title", text="Neutron imaging", subtitle="How a radiograph is made")
12
+ film.camera.key("azimuth", 0, -70).key("azimuth", 8, -40)
13
+ film.render("neutrons.mp4")
14
+
15
+ Open the graphical editor with ``sciview edit`` in a terminal.
16
+ """
17
+ from .model import REGISTRY, CameraRig, Project, Prop, SceneObject, all_schemas
18
+ from .render import Renderer
19
+
20
+ __version__ = "0.3.0"
21
+
22
+ __all__ = ["Project", "SceneObject", "Prop", "CameraRig", "Renderer", "REGISTRY", "all_schemas",
23
+ "object_types", "load", "__version__"]
24
+
25
+
26
+ def object_types() -> list[str]:
27
+ """Names of all object types that ``Project.add`` accepts."""
28
+ return sorted(REGISTRY)
29
+
30
+
31
+ def load(path) -> Project:
32
+ """Open a project file."""
33
+ return Project.load(path)
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())
@@ -0,0 +1,4 @@
1
+ """Let a language model build parts of a film: a checked tool API and an MCP server."""
2
+ from .tools import TOOLS, FilmTools, ToolError
3
+
4
+ __all__ = ["TOOLS", "FilmTools", "ToolError"]