Skip to main content

Octree reconstruction and interpolation utilities

Project description

batcamp logo batcamp

Tests PyPI version Codacy Badge Codacy Badge DOI

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.colorbar()
plt.show()

See examples/quick_start.ipynb for a larger example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

batcamp-0.2.1.tar.gz (48.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batcamp-0.2.1-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file batcamp-0.2.1.tar.gz.

File metadata

  • Download URL: batcamp-0.2.1.tar.gz
  • Upload date:
  • Size: 48.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for batcamp-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a157a2986f6bd0e9666afad59d512a20427ec2766f396f6043d44fce170767b1
MD5 4a0d3ec70e916dd89478da494dd303dd
BLAKE2b-256 a5a08f9226f9749feddb3e0b689c16960dee2ddcf59ba9e25ab55c5f23cb747b

See more details on using hashes here.

File details

Details for the file batcamp-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: batcamp-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for batcamp-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed998bb192cbbc9b983b888bf78d9939ba15b184ad4736b116a9a5f16bddcfcd
MD5 5bdf204fe88907ff8f325a422e2ea4f6
BLAKE2b-256 7e6f92bb083b91b38bcb55e66e5a8dab172ec8516841d1c899fde4f695d3e218

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page