Hi all, I am quite new, this is my first question on here so hope I have provided enough detail!
I am writing a script for detecting lunar eclipses across a spacecraft, using various Astrodynamics julia packages (AstroTime.jl, SPICE.jl etc.). I created a custom struct Eclipse to store my individual eclipse events.
struct Eclipse
"Start time (UTC)"
Ti::UTCEpoch
"Finish time (UTC)"
Tf::UTCEpoch
"Duration - seconds"
dur::AstroTime.Period
"Type - penumbral or umbral"
type::Symbol
"Event number"
num::Int64
end
In the main I loop through the dates and at each time step detect the type of eclipse (or lack of eclipse). Now I want to store each eclipse as an instance of my struct Eclipse and save them to an array with the start and stop times. However, I can’t figure out how to do this in a general way (e.g. one that doesn’t rely on knowing a priori the order of eclipse types).
A MWE:
eclipses = []
for i in eachindex(dates)
# Check whether the spacecraft is in eclipse or not. Returns :none, :pen, or :umb.
eclipse_type = detect_eclipse(spacecraft_position[i], dates[i])
## DO some check conditions and identify the start and stop time of a single event (e.g. a series of uninterrupted :pen eclipse_types equates to one eclipse event).
# Once a full eclipse has been found, push this eclipse struct to the array.
push!(eclipses, Eclipse(t_i, t_f, t_f-t_i, eclipse_type, event_number))
end
One idea i had was to push to another array at each time step so I have something like this
Array{N, 1}[:none, :none, :pen, :pen, :pen, :umb, :umb, :umb, :none, :none, … ] where N = length(dates)
then check at which indices the value changes as this indicates the start/stop times of an eclipse. However, I am unsure how to implement this and it seems very inefficient. Any other ideas for distinguishing events would be very appreciated, thanks!