JaiWillems / celest

Satellite dynamics Python library for orbital calculations and mission planning.

Home Page:https://pypi.org/project/Celest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array Indices Corresponding to the Start and Ends of Encounter Windows

itchono opened this issue · comments

Is your feature request related to a problem? Please describe.
I would like to have a good way of determining the mission elapsed time at which encounters start and end.

I usually begin with an array of timesteps, and I would like to know which array indices correspond to the starts and ends of encounter windows.

Describe the solution you'd like
Define a new attribute/module, encounter_indices, which returns two lists defining the indices of the starts and ends in the time array.

Describe alternatives you've considered
Manually creating arrays to find np.where(alt > 30) and then breaking the arrays at discontinuities to find the starts and ends.

Additional context
My workaround code:

from celest import Satellite, GroundPosition

UTCTimeData = observation_times.utc.value.astype(str)
ECIvec = propagated_positions[:].xyz.T

toronto = GroundPosition(name="Toronto", coor=(43.662300, -79.394530))
torontoCoords = Satellite()

torontoECI = torontoCoords.getECI(posData=toronto.ECEFpos[np.newaxis, :], timeData = UTCTimeData)


finch = Satellite()
NdrAng = finch.getNdrAng(groundPos=toronto, posData=ECIvec, timeData=UTCTimeData)
# Get nadir angles of the spacecraft
Alt, _ = finch.getAltAz(groundPos=toronto, posData=ECIvec, timeData=UTCTimeData)
# Get Alt Az angles

altok = np.where(Alt > 0)
ndrok = np.where(NdrAng < 30)
IOI = np.intersect1d(altok, ndrok)

encounter_segments = np.split(IOI, np.where(np.diff(IOI) > 1)[0]+1)
encounter_segments

The Encounter class's _special_interp() method implements a very similar process as you outlined but is internal to the method. For the next release (i.e. Celest 0.2.0), I can incorporate a public method which can be used both in the _special_interp() method and for public access.

With the 0.2.0 release, the encounter indices functionality has been incorporated into the programs window generation workflow to allow for position and time interpolation before windows are generated. This approach uses a modified version of the _special_interp() method and only interpolates around regions where encounters are possible.

For making public the attitudes() function, the encounter indices problem will be addressed internally to prevent the need for user to juggle such information.

With this considered, raw encounter indices can be attained through the celest.encounter._analytical_math_utils._analytical_encounter_ind function, and processed encounter indices (considering lighting and solar constraint angle considerations) can be attained through the celest.encounter._window_utils._window_encounter_ind function.