Projectile#

The Projectile class is an operations class defining the interface for generating projectile velocities, angles, and densities for a given target body.

Available Implementations#

Class

Argument name

Example Usage

AsteroidProjectiles

“asteroids”

asteroids = Projectile.maker(“asteroids”)

CometProjectiles

“comets”

comets = Projectile.maker(“comets”)

GenericProjectiles

“generic”

generic = Projectile.maker(“generic”,sample=True,mean_velocity=20e3,density=1500.0)

class cratermaker.components.projectile.Projectile(sample=True, mean_velocity=None, velocity=None, density=None, angle=None, direction=None, location=None, target=None, rng=None, rng_seed=None, rng_state=None, **kwargs)[source]#

Bases: ComponentBase

An abstract base class for all projectile models. It defines the interface for generating projectile velocities, angles, and densities for a given target body.

classmethod maker(projectile=None, mean_velocity=None, density=None, sample=True, angle=None, velocity=None, direction=None, location=None, target=None, rng=None, rng_seed=None, rng_state=None, **kwargs)[source]#

Initialize a Projectile model with the given name or instance.

Parameters:
  • projectile (Projectile or str) – The projectile model to initialize. Can be a class or a string representing the model name.

  • mean_velocity (float) – The mean velocity of the projectile in m/s.

  • density (float) – The density of the projectile in kg/m³.

  • sample (bool) – Flag that determines whether to sample impact velocities, angles, and directions from distributions. If set to False, impact velocities will be set to the mean velocity, impact angles will be set to 90 degrees (vertical impact), and directions will be 0.

  • angle (float) – The impact angle in degrees.

  • velocity (float | None) – The impact velocity in m/s. If None, the velocity will be sampled from a distribution.

  • direction (float | None) – The impact direction in degrees. If None, the direction will be sampled from a distribution.

  • location (tuple[float, float]) – The location of the projectile on the target body in (lon, lat) coordinates. If None, the location willb e sampled from a distribution

  • target (Target or str.) – The name of the target body for the impact. Default is “Moon”

  • rng (numpy.random.Generator | None) – A numpy random number generator. If None, a new generator is created using the rng_seed if it is provided.

  • rng_seed (Any type allowed by the rng_seed argument of numpy.random.Generator, optional) – The rng_seed for the RNG. If None, a new RNG is created.

  • rng_state (dict, optional) – The state of the random number generator. If None, a new state is created.

  • **kwargs (Any) – Additional keyword arguments that are either ignored or passed to internal functions as needed.

Returns:

Projectile – The initialized projectile model.

Raises:
  • KeyError – If the specified projectile model is not found in the registry.

  • TypeError – If the specified projectile model is not a string or a subclass of Projectile.

Available models:

  • asteroids

  • comets

  • generic

new_projectile(velocity=None, angle=None, direction=None, location=None, density=None, **kwargs)[source]#

Returns a new projectile instance with updated sampled or default values, based on the original instance.

Parameters:
  • velocity (float | None) – The impact velocity in m/s. If None, the velocity will be sampled from a distribution if sample is True, otherwise it will be set to the value of mean_velocity.

  • angle (float, optional) – The impact angle in degrees. Default is 90.0 degrees (vertical impact) if sample is False.

  • direction (float | None) – The impact direction in degrees. Default is 0.0 degrees (due North) if sample is False.

  • location (tuple[float, float] | None) – The location of the projectile on the target body in (lon, lat) coordinates. If None, the location will be sampled from a distribution.

  • density (float | None) – The density of the projectile in kg/m³. If None, the density will be the default for this Projectile type.

  • **kwargs (Any) – Additional keyword arguments that are either ignored or passed to internal functions as needed.

Returns:

Projectile – A new Projectile instance with updated properties.

property sample#

Flag that determines whether to sample velocities, angles, and directions from distributions. If set to False, impact velocities will be set to the mean velocity, impact angles will be set to 90 degrees (vertical impact), and directions will be 0.

Returns:

bool

property mean_velocity#

The mean velocity of the projectile in m/s.

Returns:

float

property angle#

The impact angle relative to horizontal in degrees.

property direction#

The impact direction measured clockwise from North in degrees.

property location#

The location of the projectile (longitude, latitude) in degrees on the target body.

property velocity#

The impact velocity in m/s.

property density#

The bulk density of the projectile in kg/m³.

property vertical_velocity#

The vertical component of the impact velocity in m/s.

property population#

The name of the population of the projectile model.

property target#

The Target object associated with theprojectile model.

property catalogue#

A string representation of the projectile catalogue for the target body.

AsteroidProjectiles#

See Projectile for inherited methods and attributes.

class cratermaker.components.projectile.asteroids.AsteroidProjectiles(sample=True, density=None, angle=None, direction=None, location=None, target=None, rng=None, rng_seed=None, rng_state=None, **kwargs)[source]#

Bases: Projectile

Usage example#

1 from cratermaker import Projectile
2 asteroids = Projectile.maker("asteroids")

CometProjectiles#

See Projectile for inherited methods and attributes.

class cratermaker.components.projectile.comets.CometProjectiles(sample=True, density=None, angle=None, direction=None, location=None, target=None, rng=None, rng_seed=None, rng_state=None, **kwargs)[source]#

Bases: Projectile

Usage example#

1 from cratermaker import Projectile
2 comets = Projectile.maker("comets")

GenericProjectiles#

See Projectile for inherited methods and attributes.

class cratermaker.components.projectile.generic.GenericProjectiles(sample=True, mean_velocity=None, velocity=None, density=None, angle=None, direction=None, location=None, target=None, rng=None, rng_seed=None, rng_state=None, **kwargs)[source]#

Bases: Projectile

Usage example#

1 from cratermaker import Projectile
2 generic = Projectile.maker("generic", sample=True, mean_velocity=20e3, density=1500.0)