You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def gen_spin_table(start_time: datetime, end_time: datetime = None) -> Path:
"""
Generate a pointing table CSV covering one or more days.
Parameters
-----------
start_time : provides the starting day of year
end_time : optionally specify end day of year. If not provided default to one day
Returns
--------
Path to CSV file
Tim's prototype code:
# Spin table contains the following fields:
# (spin_number, spin_start_sec, spin_start_subsec, spin_period_sec, spin_period_valid, spin_phas_valid, spin_period_source, thruster_firing)
seconds_per_point = 24 * 60 * 60
# get the very first spin start sclk
_, start_sclk_sec, start_sclk_ticks = parse_sclk_str(spice.sce2s(SC_ID, cov[0]))
_, end_sclk_sec, end_sclk_ticks = parse_sclk_str(spice.sce2s(SC_ID, cov[-1]))
# fill the whole year worth of spin data with assuming ideal 15 seccond spins
spin_dict = dict()
spin_start_sec = np.arange(start_sclk_sec, end_sclk_sec, 15, dtype=np.uint64)
spin_dict["spin_number"] = np.arange(spin_start_sec.size, dtype=np.uint64)
spin_dict["spin_start_sec"] = spin_start_sec
spin_dict["spin_start_subsec"] = np.full(spin_dict["spin_start_sec"].size, start_sclk_ticks * TICKS_TO_MS, dtype=np.uint64)
spin_dict["spin_period_sec"] = np.full(spin_dict["spin_start_sec"].size, 15.0, dtype=np.float64)
spin_dict["spin_period_valid"] = np.ones(spin_dict["spin_start_sec"].size, dtype=np.uint8)
spin_dict["spin_period_phase"] = np.ones(spin_dict["spin_start_sec"].size, dtype=np.uint8)
spin_dict["spin_period_source"] = np.zeros(spin_dict["spin_start_sec"].size, dtype=np.uint8)
spin_dict["thruster_firing"] = np.zeros(spin_dict["spin_start_sec"].size, dtype=np.uint8)
spin_start_float = np.arange(cov[0], cov[-1], 15)
# Set thruster firing flag. Intervals here indicate time during repointing
for i_pointing, interval in enumerate(cov[1:-1].reshape((-1, 2))):
# set values where spin end time is greater than repoint start and spin start time is < repoint end
firing_mask = np.logical_and(
spin_start_float + spin_dict["spin_period_sec"] >= interval[0],
spin_start_float < interval[1]
)
spin_dict["thruster_firing"][firing_mask] = 1
spin_dict["spin_period_valid"][firing_mask] = 0
spin_df = pd.DataFrame.from_dict(spin_dict)
spin_df.to_csv("imap_2025_106_2026_105_v00.spin.csv", index=False)
The text was updated successfully, but these errors were encountered:
tech3371
changed the title
Spin phase query utils function - using spin start and spin rate data.
SPICE - Spin phase query utils function - using spin start and spin rate data.
Sep 4, 2024
For a given input time, this function will need to return spin phase angle of spacecraft.
Function signature
Could also add a function to get instrument spin phase (Put this in a new ticket?)
fixture function signature
Tim's prototype code:
The text was updated successfully, but these errors were encountered: