Skip to content

Parallelized Function Proposal #737

Description

@kjugalde

Hello! @translunar suggested I file this. I want to propose adding support for parallelized Orbit constructors and lat/lon/alt extractors

Context

For ephemeris-scale Python workflows a typical caller around transform_many_to currently looks like this:

orbits_gcrf = []
for i in range(N):
	orbits_gcrf.append(Orbit.from_cartesian(
		pos_km[i, 0], pos_km[i, 1], pos_km[i, 2],
		0.0, 0.0, 0.0,
		epochs[i], Frames.GCRF,
	))
	
orbits_itrf93 = almanac.transform_many_to(orbits_gcrf, Frames.EARTH_ITRF93)

lons_rad = np.array([
	o.longitude_360_deg()
	for o in orbits_itrf93
])

Two Python for loops bracket the parallel call. These series of loops can prove slow for large enough ephemerides. The proposal below outlines some functions that might prove useful

API Surface

Batch Orbit constructors

@staticmethod
def from_cartesian_many(
	pos_vel: numpy.ndarray,     # shape (N, 6), units km / (km/s)
	epochs: list[Epoch],        # length N
	frame: Frame,
) -> list[Orbit]: ...

Mirrors the existing from_cartesian_npy precedent with _many suffix matching transform_many, solar_eclipsing_many, azimuth_elevation_range_sez_many.

@staticmethod
def from_position(
	x_km: float, y_km: float, z_km: float
	epochs: list[Epoch],      
	frame: Frame,
) -> Orbit: ...

@staticmethod(
	positions: numpy.ndarray,   # shape (N, 3), units km
	epochs: list[Epoch],        # length N
	frame: Frame,
) -> list[Orbit]: ...

Position-only constructors for callers whose state doesn't include velocity (typical when velocity is computed downstream from positions, or simply isn't needed for what's being measured). Velocity defaults to zero. Saves the zero-padding boilerplate at every position-only call site.

Batch lat/lon extractors on Orbit

@staticmethod
def longitude_360_deg_many(orbits: list[Orbit]) -> numpy.ndarray: ...

@staticmethod
def latitude_deg_many(orbits: list[Orbit]) -> numpy.ndarray: ...

@staticmethod
def latlongalt_many(orbits: list[Orbit]) -> numpy.ndarray: ...   # shape (N, 3)

latitude_deg_many is paired with longitude_360_deg_many so lat/lon extraction has the same vectorized shape; latlongalt_many mirrors the existing tuple-returning latlongalt() for callers that want all three components in one call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions