batcamp
batcamp reconstructs traversable octrees from BATSRUS-like outputs, and supports both spherical and cartesian data.
What it does
- Rebuilds a usable octree from simulation output, and
- provides fast, octree-aware resampling to e.g. planes, spheres, and rays.
Why
Some numerical codes provide leaf-cell values without storing the octree data. batcamp rebuilds that structure, permitting rapid interpolation and resampling.
Installation
Install the package with pip:
pip install batcamp
Quick start
The octree interpolator interface is made to resemble the scipy LinearNDInterpolator. The following code plots a two-dimensional density slice.
# Read an example dataset using the batread library
from batread import Dataset
ds = Dataset.from_file("MY_FILE")
print(ds)
# Build the octree from the dataset points and corners.
from batcamp import Octree
octree = Octree(
points=ds[["X [R]", "Y [R]", "Z [R]"]],
corners=ds.corners)
print(octree)
# Build the interpolator object from the octree and data values
from batcamp import OctreeInterpolator
octree_interpolator = OctreeInterpolator(octree, values=ds["Rho [g/cm^3]", "ti [K]"])
print(octree_interpolator)
# Create a regular grid of points, interpolate the data
# onto them, and display the result with matplotlib
import numpy as np
import matplotlib.pyplot as plt
X, Y = np.meshgrid(np.linspace(-24, 24, 512), np.linspace(-24, 24, 512))
Z = np.zeros_like(X)
rho_and_ti = octree_interpolator(X, Y, Z)
plt.pcolormesh(X, Y, rho_and_ti[..., 0], norm="log")
plt.title("Equatorial slice")
plt.colorbar()
plt.show()
See examples/quick_start.ipynb for a larger example.
Synthetic images
batcamp also provides a specialised ray tracer, which can be used e.g. to create synthetic images.
ds = Dataset.from_file("MY_FILE")
tree = Octree.from_ds(ds)
interp = OctreeInterpolator(tree, ds["Rho [g/cm^3]"])
from batcamp import OctreeRayTracer
octree_ray_tracer = OctreeRayTracer(tree)
print(octree_ray_tracer)
# Create rays that will form the image
x, z = np.meshgrid(
np.linspace(-4, 4, 512),
np.linspace(-4, 4, 512),
indexing="xy")
y = -24 * np.ones_like(x)
origins_xyz = np.stack((x, y, z), axis=-1)
direction = np.array([0.0, 1.0, 0.0])
# Create the image and show it
image, _ = octree_ray_tracer.trilinear_image(interp, origins_xyz, direction)
plt.pcolormesh(x, z, image, norm="log")
plt.colorbar()
plt.title("Synthetic image")
plt.show()
A raytracing example using a larger, more realistic data set can be seen in examples/ray_image.ipynb.
Metadata
Release files for batcamp 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| batcamp-0.3.1.tar.gz | 112.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| batcamp-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 174.6 kB
Release files / batcamp-0.3.1.tar.gz
| Download URL | batcamp-0.3.1.tar.gz |
|---|---|
| Size | 112.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20b097f56483f43ea6a329d8298d12471f73b588e96c0ef62311d494a750ec5b
|
|
BLAKE2b-256 checksum How to use checksums |
7459179068ef739091dad1dca14d8e86f8a7f4902ed0c18413342e11ffa7fd22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / batcamp-0.3.1-py3-none-any.whl
| Download URL | batcamp-0.3.1-py3-none-any.whl |
|---|---|
| Size | 62.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47cf31ad5ee8a5ae0a2f42dff34684d1312876ffb286b34df11693cbbf775c7d
|
|
BLAKE2b-256 checksum How to use checksums |
84d97eaa7a21a2dc1b1105de894844446eb01138a468a7228f86d1672d83aa06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for batcamp 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.