pyRTX.classes.Spacecraft

Classes

Spacecraft([name, base_frame, ...])

Represents a spacecraft, including its geometry, materials, and orientation.

class pyRTX.classes.Spacecraft.Spacecraft(name=None, base_frame=None, spacecraft_model=None, units='m', mass=0.0)[source]

Represents a spacecraft, including its geometry, materials, and orientation.

This class manages the different components of a spacecraft, their transformations, and material properties. It can load geometry from OBJ files and uses SPICE kernels to determine the orientation of each component.

__init__(name=None, base_frame=None, spacecraft_model=None, units='m', mass=0.0)[source]

Initializes the Spacecraft object.

Parameters:
  • name (str, optional) – The name of the spacecraft.

  • base_frame (str, optional) – The SPICE reference frame for the spacecraft’s body.

  • spacecraft_model (dict, optional) –

    A dictionary defining the spacecraft’s components. Each key is the component name, and the value is another dictionary with the following keys:

    • ’file’ (str): Path to the OBJ file for the component.

    • ’frame_type’ (str): ‘Spice’ or ‘UD’ (User Defined).

    • ’frame_name’ (str): The name of the SPICE or UD frame.

    • ’center’ (list): The position of the component’s origin in the base frame.

    • ’specular’ (float): The specular reflection coefficient.

    • ’diffuse’ (float): The diffuse reflection coefficient.

    • ’UD_rotation’ (trimesh.transformations.Transform, optional): A user-defined rotation matrix.

  • units (str, default 'm') – The units for the spacecraft model’s dimensions (‘m’ for meters, ‘km’ for kilometers, etc.).

  • mass (float or xarray.Dataset, default 0.) – The spacecraft’s mass. Can be a constant float or an xarray Dataset with time-varying mass.

add_parts(spacecraft_model=None)[source]

Adds new parts to the spacecraft model.

Parameters:

spacecraft_model (dict) – A dictionary describing the new components to add, in the same format as the spacecraft_model parameter of the __init__ method.

Raises:

Exception – If a part with the same name already exists in the model.

subset(elem_names)[source]

Creates a new Spacecraft instance containing only a subset of the

components of the current instance.

Parameters:

elem_names (list of str) – A list of the names of the components to include in the new instance.

Returns:

A new Spacecraft instance with only the specified components.

Return type:

Spacecraft

remove_part(name)[source]

Removes a part from the spacecraft model.

Parameters:

name (str) – The name of the part to remove.

apply_transforms(epoch)[source]

Applies the rotations and translations to each component for a given

epoch.

Parameters:

epoch (float) – The epoch (in SPICE ephemeris time) at which to apply the transformations.

materials()[source]

Returns the material properties dictionary for the spacecraft.

Returns:

A dictionary containing the material properties of each component.

Return type:

dict

dump(epoch=None, split=False)[source]

Returns the combined or individual meshes of the spacecraft’s components

at a specific epoch.

Parameters:
  • epoch (float, optional) – The epoch (in SPICE ephemeris time) for which to get the meshes. If None, the base meshes are used without transformation.

  • split (bool, default False) – If True, returns a list of individual meshes for each component. If False, returns a single combined mesh.

Returns:

The combined mesh or a list of individual component meshes.

Return type:

trimesh.Trimesh or list of trimesh.Trimesh

dump_materials()[source]

Generates and stores a dictionary of material properties for all

components.

info()[source]

Prints a summary of the spacecraft’s components.

__str__()[source]

Returns a string representation of the spacecraft’s information.

Returns:

A string containing the spacecraft’s summary.

Return type:

str