Functions

A quick guide to using the functions included with axtools.

On this page, you'll learn:

  • To use the various functions included with axtools

  • How to turn dict objects representing bodies into real Body classes

Uncategorized Functions

import axinite.tools as axtools

# converting a time string into a Quantity
limit = axtools.interpret_time("1yr") # returns a Quantity of seconds in a year

# converting an array of dictionaries into an array of vectors
positions = axtools.array_to_vectors([
    {"x": 0, "y": 0, "z": 0},
    {"x": 1, "y": 1, "z": 1},
    {"x": 2, "y": 2, "z": 2},
    {"x": 3, "y": 3, "z": 3}
]) # returns an array of CartesianRepresentations

# turning a value into a np.float64
delta = axtools.to_float(1.0) # returns np.float64(1.0)
# this one is really just a shorthand

Dictionaries to Bodies

import axinite.tools as axtools
import astropy.units as u

axtools.data_to_body({
    "name": "example-name",
    "mass": 1 * u.kg,
    "r": {"x": 1, "y": 1, "z": 1},
    "v": {"x": 1, "y": 1, "z": 1},
})

You can add color, light, retain, and radius_multiplier should you choose to.

Last updated