https://github.com/ravenexp/pyplanetarium

Python bindings for Planetarium sub-pixel precision light spot rendering library

https://github.com/ravenexp/pyplanetarium

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.3%) to scientific vocabulary

Keywords

astronomy graphics-library python science simulation-modeling
Last synced: 6 months ago · JSON representation

Repository

Python bindings for Planetarium sub-pixel precision light spot rendering library

Basic Info
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
astronomy graphics-library python science simulation-modeling
Created over 4 years ago · Last pushed almost 3 years ago
Metadata Files
Readme Changelog License

README.md

PyPlanetarium

Python bindings for Planetarium sub-pixel precision light spot rendering library for astronomy and video tracking applications.

Sample image

Sample

Example usage

```python from pyplanetarium import Canvas, SpotShape

Draw on a square 256x256 pixel canvas.

c = Canvas.new(256, 256)

Define a round spot shape with diffraction radius of 2.5 pixels.

shape = SpotShape().scale(2.5)

Add some spots at random positions with varying shape size

and peak intensity.

spot1 = c.addspot((100.3, 130.8), shape, 0.5) spot2 = c.addspot((80.6, 200.2), shape.scale(0.5), 0.9)

Note: Out of range position coordinates and peak intensities are fine.

The resulting spot image is clipped into the canvas rectangle.

Peak intensity > 1.0 leads to saturation to the maximum pixel value.

spot3 = c.add_spot((256.1, 3.5), shape.scale(10.0), 1.1)

Set the canvas background pixel value.

c.setbackground(int(0.05 * Canvas.PIXELMAX))

Clear the canvas and paint the light spots.

c.draw()

Get image dimensions.

imagewidth, imageheight = c.dimensions() ```

Light spot parameters adjustment

Some of the light spot parameters like coordinates and peak intensity can be adjusted after the spot has been added to the canvas.

The spot position coordinates can be changed by adding an offset vector and the peak intensity can be adjusted by multiplying with a spot illumination factor.

It is possible to define a custom world coordinates to canvas coordinates transformation, which affects all light spots.

```python from pyplanetarium import Canvas, SpotShape, Transform

Draw on a square 256x256 pixel canvas.

c = Canvas.new(256, 256)

Define an elliptic spot shape with diffraction radii of 2.5 x 1.5 pixels

rotated by 45 degrees counter-clockwise.

shape1 = SpotShape().stretch(2.5, 1.5).rotate(45.0)

Define an elliptic spot shape by a 2x2 linear transform matrix.

shape2 = SpotShape([[2.0, -0.5], [1.5, 3.0]])

Add some spots at random positions with varying shape size

and peak intensity.

spot1 = c.addspot((100.3, 130.8), shape1, 0.5) spot2 = c.addspot((80.6, 200.2), shape2, 0.9)

Shift the rendered spot positions by applying the relative offset vectors.

The intrinsic spot position coordinates are immutable.

c.setspotoffset(spot1, (-34.2, 12.6)) c.setspotoffset(spot2, (114.2, -73.3))

Adjust the rendered spot peak intensity by applying the spot illumination factors.

The intrinsic spot intensities are immutable.

c.setspotillumination(spot1, 1.2) c.setspotillumination(spot2, 0.7)

Query the resulting spot coordinates on the canvas.

pos1 = c.spotposition(spot1) pos2 = c.spotposition(spot2)

Query the resulting peak spot intensities.

int1 = c.spotintensity(spot1) int2 = c.spotintensity(spot2)

Apply a custom world coordinates to canvas coordinates transformation.

c.setviewtransform(Transform().translate((13.7, -20.3)))

Query the resulting spot coordinates on the canvas after

the view coordinate transformation.

pos1x = c.spotposition(spot1) pos2x = c.spotposition(spot2) ```

Canvas image export

The Canvas object supports image export to RAW and PNG file formats. Both 8-bit and 16-bit PNG sample formats are supported. Export to PNG formats requires the default png feature to be enabled.

Example image export code

```python from pyplanetarium import Canvas, ImageFormat

c = Canvas.new(256, 256)

c.set_background(1000) c.clear()

Export to a 8-bit gamma-compressed grayscale RAW image.

raw8bppbytes = c.export_image(ImageFormat.RawGamma8Bpp)

Export to a 10-bit linear light grayscale little-endian RAW image.

raw10bppbytes = c.export_image(ImageFormat.RawLinear10BppLE)

Export to a 12-bit gamma-compressed grayscale little-endian RAW image.

raw12bppbytes = c.export_image(ImageFormat.RawLinear12BppLE)

Export to a 8-bit gamma-compressed grayscale PNG image.

png8bppbytes = c.export_image(ImageFormat.PngGamma8Bpp)

Export to a 16-bit linear light grayscale PNG image.

png16bppbytes = c.export_image(ImageFormat.PngLinear16Bpp) ```

Window image export

The Canvas object additionally supports windowed image export.

A single rectangular window represents a region of interest (ROI) on the canvas image. Window rectangle coordinates are represented by the public Window structure.

Example window image export code

```python from pyplanetarium import Canvas, ImageFormat, Window

c = Canvas.new(256, 256)

Create a 64x32 pixels window with origin at (90, 120).

wnd = Window.new(64, 32).at(90, 120)

fmt = ImageFormat.RawGamma8Bpp

Export to the canvas window image bytes.

rawwindowbytes = c.exportwindowimage(wnd, fmt) ```

Subsampled image export

The Canvas object additionally supports subsampled image export with independent row and column subsampling factors.

Only whole canvas images can be exported with subsampling.

Example subsampled image export code

```python from pyplanetarium import Canvas, ImageFormat

c = Canvas.new(256, 256)

fmt = ImageFormat.RawLinear10BppLE

Column (X) and row (Y) subsampling factors

factors = (2, 2)

Export to the subsampled canvas image bytes.

rawsubbytes = c.exportsubsampledimage(factors, fmt) ```

Owner

  • Name: Sergey Kvachonok
  • Login: ravenexp
  • Kind: user

EE/SE/Undecided

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 days
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • Nimeriya778 (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cargo 6,674 total
    • pypi 22 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 15
  • Total maintainers: 2
pypi.org: pyplanetarium

Python bindings for Rust Planetarium rendering library

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 22 Last month
Rankings
Dependent packages count: 10.0%
Downloads: 20.9%
Average: 21.4%
Dependent repos count: 21.7%
Forks count: 22.6%
Stargazers count: 31.9%
Maintainers (1)
Last synced: 6 months ago
crates.io: pyplanetarium

Python bindings for Rust Planetarium rendering library

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 6,674 Total
Rankings
Dependent repos count: 29.3%
Dependent packages count: 33.8%
Forks count: 37.5%
Average: 41.1%
Stargazers count: 43.6%
Downloads: 61.3%
Maintainers (1)
Last synced: 6 months ago

Dependencies

Cargo.lock cargo
  • adler 1.0.2
  • adler32 1.2.0
  • autocfg 1.1.0
  • bitflags 1.3.2
  • cc 1.0.73
  • cfg-if 1.0.0
  • crc32fast 1.3.2
  • deflate 1.0.0
  • indoc 1.0.6
  • libc 0.2.125
  • libm 0.2.2
  • lock_api 0.4.7
  • miniz_oxide 0.5.1
  • once_cell 1.10.0
  • parking_lot 0.12.0
  • parking_lot_core 0.9.3
  • planetarium 0.1.5
  • png 0.17.5
  • proc-macro2 1.0.38
  • pyo3 0.16.4
  • pyo3-build-config 0.16.4
  • pyo3-ffi 0.16.4
  • pyo3-macros 0.16.4
  • pyo3-macros-backend 0.16.4
  • python3-dll-a 0.2.2
  • quote 1.0.18
  • redox_syscall 0.2.13
  • scopeguard 1.1.0
  • smallvec 1.8.0
  • syn 1.0.93
  • target-lexicon 0.12.3
  • unicode-xid 0.2.3
  • unindent 0.1.9
  • windows-sys 0.36.1
  • windows_aarch64_msvc 0.36.1
  • windows_i686_gnu 0.36.1
  • windows_i686_msvc 0.36.1
  • windows_x86_64_gnu 0.36.1
  • windows_x86_64_msvc 0.36.1
.github/workflows/publish.yml actions
  • actions/checkout v3 composite
  • dawidd6/action-download-artifact v2 composite
.github/workflows/python.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/rust.yml actions
  • actions/checkout v3 composite
.github/workflows/wheels.yml actions
  • PyO3/maturin-action v1 composite
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
Cargo.toml cargo
pyproject.toml pypi