API docs

Model

Annie’s internal clock

Annie’s internal clock

class annie.clock.Clock(spacecraft)

Controls the clock for an annie simulation.

tick()

Increments clock ticks by 1.

property start

Defines start time of the clock (astropy Quantity, secs).

property stop

Defines stop time of the clock (astropy Quantity, secs).

class annie.clock.ClockTime(value=0)

Converts input Time or DateTime object to annie’s clock time.

at_next(unit)

Return time at next integral value of unit time type.

Parameters

unit – time attribute like ‘mnf’, ‘frame’, ‘mnc’

Returns

annie.clock.ClockTime

ticks_mod(unit)

Return number of ticks within unit time type.

Parameters

unit – time attribute like ‘mnf’, ‘frame’, ‘mnc’

Returns

self.ticks % annie.clock.TICKS_PER [unit] (int)

property frame

Frame (1.025 sec).

property mjf

Major frame (32.8 sec).

property mnc

Minor cycle, which wraps at 64 (wraps each frame).

property mnf

Minor frame, which wraps at 128 (wraps each major frame).

property secs

Current annie’s clock time in secs.

property ticks

Current annie’s time in clock ticks (see annie.clock.TICKS_PER_FRAME).

property time

Current annie’s clock time (astropy Quantity, secs).

annie.clock.TICKS_PER_FRAME

Number of clock ticks per frame.

annie.clock.TICKS_PER

Dict of number of clock ticks per unit. The dict keys are the clock units: ‘mnc’, ‘mnf’, ‘mjf’, ‘frame’, ‘sec’.

Subsystem

Events and commands scheduling and processing

class annie.subsystem.SubSystem(spacecraft)

Subsystem with parent annie.annie.Spacecraft. The parent is used for access to other subsystems.

add_event(method, time, **kwargs)

Add command method(**kwargs) to annie.subsystem.SubSystem.events queue.

Subsystem will then execute those events at the specified time as part of subsystem command processing (annie.subsystem.SubSystem.process()).

Parameters
  • method – method name (str)

  • time – command time (absolute annie.clock.ClockTime)

  • kwargs – dict of kwargs for the command

add_task(func, clock_unit, ticks, **kwargs)

Add a recurring task to the subsystem.

Example:

def print_clock(self):
    print(self.clock)

sc = Spacecraft()
# Print clock on 2nd tick of each (1.025 sec) frame
sc.aca.add_task(print_clock, 'frame', 2)
Parameters
  • func – function to run

  • clock_unit – clock unit for ticks_mod (e.g. ‘frame’, ‘mnf’, ‘mjf’)

  • ticks – ticks within clock_unit

command(method, time=0, absolute=False, **kwargs)

Add command method(**kwargs) to annie.subsystem.SubSystem.commands queue.

Subsystem command processing will then handle those commands and actually schedule them in the annie.subsystem.SubSystem.pending_commands queue at some later time (annie.subsystem.SubSystem.process()). These commands are assumed to be asyncronous i.e. not initially syncronized with subsystem scheduling.

Parameters
  • time – command time (annie.clock.ClockTime compatible)

  • method – method name (str)

  • absolute – whether time is absolute or relative to current clock

  • kwargs – dict of kwargs for the command

execute_pending_commands()

Execute any pending commands and clear subsystem’s annie.subsystem.SubSystem.pending_commands list

process()

Generic processing for a subsystem that gets called every tick. First, check for commands scheduled at this time and put this into the annie.subsystem.SubSystem.pending_commands list. They will be executed later. Next, check for and execute regularly scheduled tasks. Finally, execute any events in annie.subsystem.SubSystem.events queue at this time.

command_sync_unit = 'frame'

Process commands at the beginning of each frame.

commands

Subsystem commands queue: dict of commands that will be executed at a particular time. The dict key is the time and the value is a list of commands to be executed in order at the time. The command values are a tuple of (method, kwargs). Commands are stored in commands queue until they are scheduled in the annie.subsystem.SubSystem.pending_commands queue (annie.subsystem.SubSystem.process()).

events

Subsystem events queue: dict of events that will be executed at a particular time. The dict key is the time and the value is a list of events to be executed in order at the time. (annie.subsystem.SubSystem.process()). The events values are a tuple of (method, kwargs).

property name

Name of the subsystem

pending_commands

Pending commands list. Pending commands are executed as part of main processing of each subsystem through annie.subsystem.SubSystem.execute_pending_commands() (e.g. annie.pcad.PCAD.main_processing()).

spacecraft

Spacecraft parent of the subsystem

annie.subsystem.event_logger(func)

Log call to subsystem event method.

Components

Sky subsystem

Sky subsystem

class annie.sky.Sky(spacecraft)

Sky subsystem for keeping track of available stars in the ACA FOV.

get_stars(yag_min=None, yag_max=None, zag_min=None, zag_max=None)

Get stars within the specified box in yag/zag

Parameters
  • yag_min – minimum ACA y-angle (arcsec, or None)

  • yag_max – maximum ACA y-angle (arcsec, or None)

  • zag_min – minimum ACA z-angle (arcsec, or None)

  • zag_max – maximum ACA z-angle (arcsec, or None)

Returns

structured array of stars in the box

get_stars_table_from_agasc()

Get stars from the AGASC

Returns

astropy table with columns ra, dec, yag, zag, mag, maxmag, id

get_stars_table_from_table()

Get stars from a table as specified in self.stars_data

The stars_data table should include these columns:

  • ‘yag’, ‘zag’ (arcsec) OR ‘yang’, ‘zang’ OR ‘ra’, ‘dec’ (deg): req’d; complementary pair is computed

  • ‘mag’ : required

  • ‘maxmag’ : optional, set to mag + 1.5 if not provided

Returns

Astropy table

update_stars()

Update the current set of stars if necessary.

This method can be called any time and only does an update if the current stars do not cover the current attitude to within 0.1 degrees in any axis.

att_sky = <Quat q1=0.00000000 q2=0.00000000 q3=0.00000000 q4=1.00000000>

Attitude

cone_radius = 1.2056629776875343

Cone radius in degrees = 512 pixels * 5 arsec/pix * sqrt(2) + extra 0.2 deg

stars = None

A numpy structured array for performance

stars_data = None

Astropy Table if stars_source='table' (see annie.sky.get_stars_table_from_table())

stars_source = 'agasc'

Source of stars (‘agasc’|’table’)

tasks = [('update_stars', 'frame', 0)]

Regularly scheduled tasks

ACA and CCD subsystems

ACA and CCD subsystems

class annie.aca.ACA(spacecraft)

Methods related to the ACA subsystem.

calc_bgd(sdr)

Redirects to the appropriate background calculation method depending on annie.aca.ACA.bgd_algorithm. The flight background is always computed and stored as sdr.bgd_avg, while sdr.bgd stores the computed background image or the custom background image provided as the input and derived in annie.ccd.shine(). Note that for background algorithm “FlightDynamicBgd” the execution of the relevant method is scheduled in annie.aca.main_processing().

Parameters

sdrannie.aca.StarDataRecord for a given slot

calc_flight_background(sdr)

Calculate average background (and rms and bgd status) using the current on-board algorithm.

Parameters

sdrannie.aca.StarDataRecord for a given slot

calc_flight_dynamic_background(sdr)

Implementation of dynamic background with basic data structure being a 5x16x16 numpy array. Make a 16x16 array centered on current row/col. Then dynamically adjust array row0/col0 as needed if 8x8 image goes outside the 16x16 array extent. Implement fast median filtering using numba.

Note: this is called after determining new row0, col0 but before shining a new image. Drag the bgd stack to the new row0, col0 location and update bgd_row0/col0, if needed. Update stack with the last image (with last_row0, last_col0; we do not have the new image yet). Compute bgd image with new row0/col0 using fast median filtering.

Parameters

sdrannie.aca.StarDataRecord for a given slot

find_star(sdr)

Find star (if possible) in sdr.

Parameters

sdrannie.aca.StarDataRecord for a given slot

Returns

sdr.mag < sdr.maxmag

idle(slot)

Idle a slot.

Parameters

slot – slot number

main_processing()

Perform main processing at start of each frame. Main processing consists of processing and setting up star data records, and a number of commands that currently cannot be executed unless the CCD is idle. CCD status ‘idle’ indicates that the CCD has completed the previous readout cycle. In this case events are scheduled for a CCD flush, integration, and readout, followed by ACA image processing (centroiding, search, image status etc).

monitor(slot, size=8, yag=0, zag=0, dark=None, t_ccd=None)

ACA monitor command.

Parameters
  • slot – slot

  • size – image readout window size (pixels, 4, 6, or 8)

  • yag – y angle (arcsec)

  • zag – z angle (arcsec)

search(slot, threshold=12.0, brightest=True, fid=False, halfwidth=20, end=False, size=8, yag_cat=0, zag_cat=0)

ACA search command.

Parameters
  • slot – slot

  • threshold – brightness threshold (mag)

  • brightest – take brightest star (closest to center if False)

  • fid – image is a fid

  • halfwidth – search box halfwidth (arcsec)

  • end – end of set of search commands (unused)

  • size – image readout window size (pixels, 4, 6, or 8)

  • yag_cat – catalog y angle (arcsec)

  • zag_cat – catalog z angle (arcsec)

star_data_record_prepare_read()

Predict/set row0, col0 for the next readout.

Note that these are the internal CCD readout windows which are always 8x8.

star_data_record_process_after_read()

ACA image processing (centroiding, search, image status etc.) executed if CCD is idle.

star_data_record_process_per_frame()

Processing that happens every frame regardless of integration status.

Currently the only action happening here is to increment the repeat_count counter (0|1) where 0 indicates new star data.

track(slot, threshold=12.0, fid=False, end=False, size=8, yag_cat=0, zag_cat=0)

Directly track a slot without waiting for a search command.

Parameters
  • slot – slot

  • threshold – brightness threshold (mag)

  • fid – image is a fid

  • end – end of set of search commands (unused)

  • size – image readout window size (pixels, 4, 6, or 8)

  • yag – y angle (arcsec)

  • zag – z angle (arcsec)

bgd_algorithm = 'FlightBgd'
tasks = [('main_processing', 'frame', 1)]
class annie.aca.CCD(spacecraft)

Methods related to the CCD.

Currently this does NOT maintain an actual full-frame CCD image for efficiency reasons (to support fast per-slot simulations), but one might later include an attribute like:

image = ACAImage(shape=(1024, 1024), row0=-512, col0=-512)

In this case the flush() method would zero image.

calc_mag(img_sum)

Calculate mag corresponding to img_sum.

Parameters

img_sum – sum of the image to be converted into mag

Returns

mag

calc_min_img_sum(maxmag)

Calculate image sum corresponding to maxmag below which the star is too faint for TRAK and ACA image function transitions from TRAK to RACQ.

Parameters

maxmag – catalog maxmag

Returns

min_img_sum

flush()

Flush (zero-out) the CCD.

No action happens in flush now, except of status change to ‘flush’, because everything is effectively handled in annie.aca.star_data_record_prepare_read() which creates a fresh (zero) ACAImage at the correct location and size for each readout.

integrate()

Integrate over the CCD.

No action happens in integrate now except of status change to ‘integrate’.

read()

Integrate over the CCD.

No action happens in read now except of status change to ‘idle’.

set_ccd_bgd_data(ccd_bgd_source='dcc_date', ccd_bgd_data=None, t_ccd=None, t_ccd_ref=None)

Set CCD background data (in e-/sec) based on CCD dark cal and CCD temperature or custom inputs.

Parameters
  • ccd_bgd_source

    source of CCD background data in e-/sec.

    • ’constant’ - constant background,

    • ’lists_8x8’ - dict of lists containing 8x8 custom bgd images (ndarrays), keyed by slot number,

    • ’custom_ACAImages’ - dict containing ACAImages with row0, col0 and shape defined so that they cover the desired CCD regions given the size of dither,

    • ’custom_1024x1024’ - custom 1024x1024 ACAImage, row0=-512, col0=-512, rescaled to t_ccd, if t_ccd and t_ccd_ref are not ‘None’,

    • ’dcc_date’ (default) - date, will fetch nearest ACA DCC map (in e-/sec) scaled with temperature if t_ccd is not ‘None’.

  • ccd_bgd_data – data corresponding to ccd_bgd_source

  • t_ccd – temperature of the CCD

  • t_ccd_ref – reference temperature, e.g. temperature at which a DCC was taken, or temperature for which a synthetic dark map was calculated

shine()

Shine simulated data or telemetry on CCD.

A correct shine method is chosen based on annie.ccd.image_source attribute (see annie.annie.track_stars_setup()). With current implementation it is possible to switch here between shine_simulation and shine_telemetry.

shine_simulation(sdr)

Shine the actual simulated ACA image data on CCD.

Parameters

sdrannie.aca.StarDataRecord for a given slot

shine_telemetry(sdr)

Shine real ACA image telemetry on CCD (useful for validation).

Parameters

sdrannie.aca.StarDataRecord for a given slot

ccd_bgd_source = 'dcc_date'
elec_per_DN = 5
property flicker
flight_plate_scale = True
flush_time = <Quantity 0.1 s>
image_source = 'simulation'
integ_time = <Quantity 1.696 s>
plate_scale = 5
psf_fwhm = 2.77
psf_sigma2 = 1.383706847404616
read_time = <Quantity 0.1 s>
status = 'idle'
t_ccd = None
tasks = []
class annie.aca.DictValuesIterate

Dictionary that which iterates over values instead of key. Used to construct dictionaries keyed by slot, such as e.g. annie.aca.StarDataRecord or annie.pcad.SlotRecord.

class annie.aca.StarDataRecord

Stores star data for a given slot.

calc_image_centroid(flight_plate_scale=True)

Computes first moment image centroid.

get_dr_dc()

Return the required shift in bgd_stack so that the img is fully contained.

update_bgd_stack(dyn_bgd_rows, dyn_bgd_cols)

Update bgd stack with bgd_stack_number using the edge pixels. Note that this is called after determining new row0, col0 and dragging the bgd_stack to the new location, but before shining a new image, so the location of the edge pixels is with respect to the last row0, col0.

acq_cycle_count = 0

How many times mag > maxmag for ACA autonomous RACQ->TRAK

bgd = None

8x8 img, custom bgd provided as input or derived bgd imgage

bgd_avg = None

Average (flight) bgd, scalar

bgd_col0 = -512
bgd_rms = None
bgd_row0 = -512
bgd_stack_number = 0
bgd_status = None
brightest = True
clock = None
property col0
fid = False
function = 'NONE'
halfwidth = 20
img_sum = 0.0
ir_flag = 'OK '
last_sdr = None
mag = 13.94
maxmag = 13.94
min_img_sum = 0.0

img_sum below which star is too faint and TRAK -> RACQ

rate_c = 0
rate_r = 0
repeat_count = 0

How many times data have appeared at frame starts

property row0
search_count = 0
size = 4
slot = None
sp_flag = 'OK '
threshold = 13.94
time = None
yag = -3276
yag_cat = -3276
zag = -3276
zag_cat = -3276
annie.aca.calc_flight_background(image)

Calculate average background of the input 8x8 image using the flight PEA background algorithm.

Parameters

image – 8x8 image (ndarray or ACAImage)

Returns

bgd_avg, bgd_rms, bgd_status

annie.aca.calc_img_sum(img, bgd=None)

Subtract background and for 6x6 and 8x8 returns the sum of the 6x6 mousebitten section. Otherwise returns sum of the whole background subtracted image.

Parameters
  • img – NxN ndarray

  • bgd – background to subtract, float of NXN ndarray

Returns

clipped img sum clip(1, None)

annie.aca.calc_median(val0, val1, val2, val3, val4)

Explicity find a median of 5 values. Requires 6 comparisons. Swap vals elements to remember their order.

Parameters

vals – five numbers for median computation

Returns

median

annie.aca.centroid_fm(img, bgd=None)

First moment centroid of img.

Return FM centroid in coords where lower left pixel of image has value (0.0, 0.0) at the center.

Parameters
  • img – NxN ndarray

  • bgd – background to subtract, float of NXN ndarray

Returns

row, col, norm float

annie.aca.get_bgd_subtracted_6x6_img(img, bgd=None)

Subtract background and in case of 8x8 image cut and return the 6x6 inner section.

Parameters
  • img – NxN ndarray

  • bgd – background to subtract, float of NXN ndarray

annie.aca.shift_bgd_stack(bgd_stack, dr, dc, bgd=None)

Shift bgd_stack in-place by dr rows and dc cols, filling in empty pixels with bgd.

PCAD subsystem

PCAD subsystem

class annie.pcad.AttitudeRecord
Stores information on attitude:
  • commanded, true and estimated attitudes,

  • yaw, pitch, and roll components of these attitudes,

  • yaw, pitch, and roll components of the dither pattern,

  • estimated and true yaw, pitch and roll rates,

  • yaw, pitch and roll attitude errors.

att_cmd = None
att_est = None
att_true = None
clock = None
last_att_record = None
pitch_cmd = None
pitch_dither = 0.0
pitch_dither_rate = 0.0
pitch_err = 0.0
pitch_est = 0.0
pitch_est_rate = 0.0
pitch_true = 0.0
pitch_true_rate = 0.0
roll_cmd = None
roll_dither = 0.0
roll_dither_rate = 0.0
roll_err = 0.0
roll_est = 0.0
roll_est_rate = 0.0
roll_true = 0.0
roll_true_rate = 0.0
time = None
yaw_cmd = None
yaw_dither = 0.0
yaw_dither_rate = 0.0
yaw_err = 0.0
yaw_est = 0.0
yaw_est_rate = 0.0
yaw_true = 0.0
yaw_true_rate = 0.0
class annie.pcad.PCAD(spacecraft)

PCAD subsystem

GS_identify(sdr)

For each slot, identify the images as ‘STAR’ if delta_y and delta_z are below the respective thresholds (GUIDE_DELTA_Y_THRESH, GUIDE_DELTA_Z_THRESH). Otherwise annie.pcad.slot_records[slot] == 'NULL_IMAGE' and a search command for this slot is added to ACA subsystem events queue.

Parameters

sdrannie.aca.StarDataRecord for a given slot

aca_processing()
ACA processing excecuted as part of annie.pcad.main_processing():
  • increment or zero annie.pcad.slot_records[slot].GS_loss_count counter depending on the status of the flags and ACA image function,

  • if GS_loss_count exceeds GS_LOSS_COUNT_THRESH (=100), zero the counter and add search command for this slot to ACA subsystem events queue,

  • perform guide star identification (STAR`|`NULL_IMAGE)

count_Kalman_stars()

Derive the number of good Kalman stars and store it in annie.pcad.n_Kalman_stars. Update annie.pcad.slot_records[slot].Kalman_ok for each slot.

find_delta_delta(sdr)

Find difference (in arcsec) between catalog y/z angles and y/z angles derived from stars taking into account dither and attitude errors.

Parameters

sdrannie.aca.StarDataRecord for a given slot

get_roll_pitch_yaw_from_stars()

Compute yaw, pitch, roll components corresponding to the attitude estimated from good Kalman star centroids.

initialize_rates()

Calculate true yaw, pitch, and roll rates based on the dither.

Set estimated rates to be the true rates. This is valid if there is no gyro bias error, in which case the gyros give an always-accurate measure of rate.

main_processing()

Main processing for PCAD subsystem which is scheduled each 1.025 sec. The processing consists of executing any pending commands and ACA processing.

set_att_cmd(att)

Set commanded attitude to att, and decompose into yaw, pitch, roll in degrees. (All three are zero in Kalman interval).

Parameters

att – attitude (any Quat-compatible value)

set_att_errors()

Set yaw, pitch attitude errors (in arcsec)

set_att_est(att)

Set estimate attitude to att. If att = None, set estimated attitude to true attitude.

Parameters

att – attitude, None or any Quat-compatible value

set_att_true(att=None)

Calculate the initial true attitude based on the commanded attitude and dither.

Parameters

att – attitude, None (default) or any Quat-compatible value

set_dither(dither=None)

Set yaw/pitch dither amplitude, period, and phase.

Parameters

ditherNone (default) or dict with keys ‘pitch_ampl’, ‘pitch_period’, ‘pitch_phase’, ‘yaw_ampl’, ‘yaw_period’, ‘yaw_phase’.

set_dither_yaw_pitch_roll()

Calculate commanded dither yaw and pitch at the current time. Set dither roll to zero.

set_star_catalog(starcat)

Set the star catalog for acquisition and guide tracking.

This catalog is used when the track_guide_stars() command is sent.

The starcat input should be an astropy Table with at least the following columns: slot (0-7), type (BOT`|`ACQ`|`GUI`|`MON`|`FID), sz (4, 6, 8), mag, maxmag, yang, zang, halfw.

Parameters

starcat – Table with star catalog entries

track_guide_stars()

Add search command to ACA commands queue. Once the search is executed and the guide stars are identified, they will start being tracked.

update_att()
Timing of PCAD’s processing():
  • put commands in pending_commands_list

  • execute regularly scheduled tasks

    • update_att()

    • main_processing()

      • excute_pending_commands()

      • aca_processing()

  • execute any events from the events list

As a result:
  • att_cmd/est/true are not set at the start of the 1st minor frame, when the update_att() method is called for the first time. Att errors cannot be derived at this time. True and estimated rates are set from dither (initialize_rates()).

Timing of update_att():
  • At the end of the 1st minor frame, att_cmd/est/true are available and recorded in attitude record

  • At the start of the 2nd minor frame: * if att_true is None, derive att_true from att_cmd and dither * if att_est is None, make it the same as att_true * derive attitude errors

  • Apply control low starting with 2nd (if att_true and att_est were commanded) or 3rd minor frame.

Update attitude according to the following procedure:
  • every minor frame derive att_true and att_est from rates,

  • every full frame with ccd.status == 'idle' (after new stars are read) derive att_est from stars.

Store all attributes related to attitude in pcad.att_record (annie.pcad.AttitudeRecord object). Telemetry stored in pcad.att_record is collected every minor frame (see Telemetry subsystem).

Kalman_not_ok_counter = 0

Number of frames with < 2 Kalman stars

Kalman_status = None

Kalman status list of T/F for each slot

att_data = None
att_record

Attitude record stores atts, rates, yaw, pitch, roll components, att errors and last_att_record. Telemetry stored in att_record is collected every minor frame with Telem subsystem regularly executed task annie.telem.Telem.attitude_processing().

att_source = 'simulation'

Source of attitudes followed during the simulation; one of (‘simulation’, ‘flight’, ‘ground’)

bright_threshold = 5.8

Bright star threshold, mag, TBD

cmd_star_catalog = None

Commanded (next-in-line) star catalog

dither_enabled = True

Dither enabled/disabled (boolean)

ir_flags_source

Source data of ionizing radiation flags

n_Kalman_stars = 0

Number of Kalman stars

n_full_racqs = 0

Number of full reacquisitions

pcad_att_control_loop = 'closed'

PCAD att control loop, apply att control law if ‘closed’

pitch_ampl = 8.0

Dither pitch amplitude in arcsec

pitch_period = 707.1

Dither pitch period in seconds

pitch_phase = 0

Dither pitch phase in radian

slot_records

Dictionary of annie.pcad.SlotRecord keyed by slot, but which iterates over values instead of key.

sp_flags_source

Source of saturated pixel flags

star_catalog = None

Current ACA subsystem star catalog

tasks = [('update_att', 'mnf', 0), ('main_processing', 'frame', 0)]

Regularly scheduled tasks

yaw_ampl = 8.0

Dither yaw amplitude in arcsec

yaw_period = 1000.0

Dither yaw period in seconds

yaw_phase = 0

Dither yaw phase in radian

class annie.pcad.SlotRecord
Stores information on stars tracked in a given slot:
  • slot number,

  • F_image (STAR`|`NULL_IMAGE),

  • GS_loss_count,

  • function (TRAK`|`RACQ`|`SRCH`|`NULL),

  • mag,

  • delta_y (arcsec),

  • delta_z (arcsec),

  • Kalman_ok (boolean, is the star OK for the Kalman filter?)

F_image = 'NULL_IMAGE'

Image function (STAR`|`NULL_IMAGE)

GS_loss_count = 0

Guide star loss counter (incremented if a flag is set or ACA function is ‘RACQ’

Kalman_ok = False

Kalman status for this slot

clock = None

Added in telemetry processing

delta_y = 0.0

y-angle residual

delta_z = 0.0

z-angle residual

function = None

ACA image function

mag = 13.94

Magnitude

slot = None

Slot number

time = None

Added in telemetry processing

annie.pcad.A2D = 0.0002777777777777778

Arcseconds to degrees

annie.pcad.D2A = 3600

Degrees to arcseconds

annie.pcad.GS_LOSS_COUNT_THRESH = 100

Guide star loss count threshold: how many RACQ frames or frames with a flag set before transition to SRCH?

annie.pcad.GUIDE_DELTA_Y_THRESH = 20

Threshold in arcsec to the y-angle deviation from the catalog value, if exceeded F_image is set to ‘NULL_IMAGE’

annie.pcad.GUIDE_DELTA_Z_THRESH = 20

Threshold in arcsec to the z-angle deviation from the catalog value, if exceeded F_image is set to ‘NULL_IMAGE’

annie.pcad.KALMAN_NOT_OK_THRESH = 30

Defines the number of frames with < 2 Kalman stars before restart

annie.pcad.KALMAN_THRESH = 5

Kalman star threshold in arcsec, if exceeded in y or z direction then the star is not considered to be a good Kalman star

annie.pcad.MAX_ATT_OFFSET = 25

Max allowed attitude offset (yaw or pitch) before simulation is terminated with a warning.

annie.pcad.MAX_RATE = 2.0

Attitude control law constant

annie.pcad.RATE_SCALE = 0.05

Attitude control law constant in 1/sec, 2 arcsec error gives 0.1 arcsec/sec adjustment to the rate

Telemetry subsystem

Telemetry collection subsystem

class annie.telem.Telem(spacecraft)

Methods related to collecting telemetry from various subsystems.

attitude_processing()

Collect attitude telemetry from annie.pcad.AttitudeRecord each minor frame.

clip(start=<Quantity 8.199 s>, stop=None)

Clip telemetry in place to within specified start and stop time range (inclusive).

Parameters
  • start – start time (None or float or time Quantity, default=8.199 sec)

  • stop – stop time (None or float or time Quantity, default=None)

main_processing()

Collect telemetry from subsystems each frame. Currently telemetry is collected from the ACA subsystem (annie.aca.StarDataRecord for each slot) and PCAD subsystem (annie.pcad.SlotRecord for each slot and Kalman status info).

Kalman_not_ok_counter

Counter for insufficient number of Kalman stars (see annie.pcad.PCAD.Kalman_not_ok_counter).

Kalman_status

Kalman status (see annie.pcad.PCAD.Kalman_status).

Kalman_times

Time stamps for Kalman records

property aca_slots
att_records

List containing attitude records (annie.pcad.AttitudeRecord).

n_Kalman_stars

Number of Kalman stars (see annie.pcad.PCAD.n_Kalman_stars).

n_full_racqs

Number of full reacquisitions

property pcad_att
property pcad_slots
slot_records

Dict keyed by slot number. The values are lists containing slot records (annie.pcad.SlotRecord).

star_data_records

Dict keyed by slot number. The values are lists containing star data records (annie.aca.StarDataRecord).

tasks = [('main_processing', 'frame', 0), ('attitude_processing', 'mnf', 0)]

Regularly scheduled tasks.

annie.telem.as_array(attr, objs)

Helper for Telem properties

Setting up and running a simulation

class annie.annie.Spacecraft(loglevel=50)

Create a new spacecraft which is the master controller for an annie simulation. Create all s/c subsystems from scratch. Creating the object registers the subsystem.

run()

Run annie simulation.

track_stars_setup(stop=<Quantity 20. s>, starcat=None, att_cmd=None, att_est=None, att_true=None, dither_enabled=True, dither=None, att_data=None, att_source='simulation', stars_source='agasc', stars_data=None, image_source='simulation', image_data='psf_library', ccd_bgd_source='dcc_date', ccd_bgd_data=None, bgd_algorithm='FlightBgd', t_ccd=None, t_ccd_ref=None, pcad_att_control_loop='closed', flight_plate_scale=True, ir_flags=None, sp_flags=None, enable_kalman_loss_racq=False, flicker=False, mouse_bit_dyn_bgd=False, dyn_bgd_stack_init=None, clear_bgd_stack_on_search=True)

Sets the simulation parameters.

See mica.starcheck for the convenience methods get_dither, get_starcat, and get_att. Example:

>>> from annie import Spacecraft
>>> from mica.starcheck import get_dither, get_starcat, get_att
>>> sc = Spacecraft()
>>> obsid = 20001
>>> sc.track_stars_setup(att_cmd=get_att(obsid),
                        dither=get_dither(obsid),
                        starcat=get_starcat(obsid))
Parameters
  • stop – stop time of the simulation (astropy Quantity or float seconds)

  • starcat – an astropy Table with at least the following columns: slot (0-7), type (‘BOT’|’ACQ’|’GUI’|’MON’|’FID’), sz (4, 6, 8), mag, maxmag, yang, zang, halfw.

  • att_cmd – commanded target attitude, [yaw, pitch, roll] (degrees) or any Quat-compatible value

  • att_est – estimated attitude (e.g. on-board solution) at the start of simulation, None (default) or [yaw, pitch, roll] (degrees)

  • att_true – true attitude (e.g. ground solution) at the start of simulation, None (default) or [yaw, pitch, roll] (degrees)

  • dither_enabled – True (default) or False

  • dither – definition of the yaw/pitch dither pattern for the simulation, None (which defaults to standard ACIS 8 arcsec dither) or dict with keys yaw_ampl, pitch_ampl (in arcsecs), yaw_period, pitch_period (in seconds), yaw_phase, pitch_phase (in radians)

  • att_source – source of the attitudes followed in the course of simulation. Implemented options include ‘simulation’ (default), ‘telemetry’ (e.g. a list of OBC quaternions), ‘ground’ (e.g. a list of ground quaternions)

  • att_data

    • None (default) if att_source='simulation'

    • list of quaternions if att_source=('telemetry'|'ground')

  • stars_source – source of the stars in the ACA field of view, ‘agasc’ (default) or ‘table’

  • stars_dataNone (default) if stars_source='agasc' or an astropy Table if stars_source='table' with at least the following columns: yag/zag OR yang/zang OR ra/dec, mag

  • image_source – source of the image for annie.CCD.shine. Implemented options include ‘simulation’ (default), or ‘telemetry’

  • image_data

    • psf_library (default) or gaussian if image_source='simulation',

    • dict keyed by slot with values being lists of telemetered ACAImages if image_source='telemetry'

  • ccd_bgd_source – source of the CCD background data for annie.CCD.shine. Implemented options include ‘constant’, ‘lists_8x8’, ‘custom_ACAImages’, ‘custom_1024x1024’, ‘dcc_date’ (default), None if image_source='telemetry'

  • ccd_bgd_data

    • constant if ccd_bgd_source='constant' (e-/sec),

    • dict keyed by slot with values being lists of custom 8x8 arrays if ccd_bgd_source='lists_8x8' (e-/sec),

    • dict keyed by slot with values being lists of custom ACA Images if ccd_bgd_source='custom_ACAImages' (e-/sec),

    • custom 1024x1024 array if ccd_bgd_source='custom_1024x1024' (e-/sec),

    • date if ccd_bgd_source='dcc_date' (default is the current date), ACA DCC map (e-/sec) nearest to this date will be fetched and scaled with temperature if t_ccd and t_ccd_ref are not None.

  • bgd_algorithm – ACA background subtraction algorithm. Implemented options include ‘FlightBgd’ (defualt), ‘FlightDynamicBgd’, ‘Constant’

  • t_ccd – temperature of the CCD, default is None

  • t_ccd_ref – reference temperature of the CCD, e.g. corresponding to a synthetic dark background when ccd_bgd_source='custom_1024x1024', default is None

  • pcad_att_control_loop – ‘closed’ (use the attitude control law) or ‘open’ (perfect dither) PCAD attitude control loop (default ‘closed’)

  • flight_plate_scale – use EEPROM flight cal instead of ground cal (default=True)

  • ir_flags|sp_flags – dict keyed by slot, values represent arrays/lists of flags for a given slot, default is None

  • enable_kalman_loss_racq – This flag should be set to True to correspond to the case where the OBC has been patched to implement this behavior. Note: circa 2019-May, this patch was being developed.

  • flicker

    enable flickering pixels (default=False). This can be either (True/False) or a dict with parameters (supplying a dict implies enabling flickering):

    • mean_time: mean time in secs between flickers (default=10000)

    • scale: scale factor for flicker amplitude (default=1.0)

    • update_time: min time in secs between running the flickering pixel update code (float seconds, default=20)

    • seed: random seed for flickering (default=’from_call_args’). This should be None (completely random), a 32-bit unsigned integer, or the special string value ‘from_call_args’. In the latter case the seed is uniquely derived from the input arguments so the simulation will be reproducible for the same call args but different otherwise.

    Flickering is only applied for ccd_bgd_source of ‘custom_1024x1024’ and ‘dcc_date’.

  • mouse_bit_dyn_bgd – include edge pixels plus 4 corner pixels of the 6x6 image in the dynamic background (default False).

  • dyn_bgd_stack_init – initialization value for pixels in dyn bgd stack. (default 10)

  • clear_bgd_stack_on_search – clear background stack following the search command, (default True).

aca

The aca subsystem.

ccd

The ccd subsystem.

clock

The clock subsystem.

logger

Set logger.

loglevel

Logging level (annie.annie.set_loglevel()).

pcad

The pcad subsystem.

sky

The sky subsystem.

telem

The telemetry subsystem.

annie.annie.run_from_starcheck(obs, verbose=False, **kwargs)

Run annie using the exact parameters from starcheck. This can be either the dict output from mica.starcheck.get_starcheck_catalog(), or a text string copied from the starcheck load review output, e.g.:

OBSID: 20742  PSR J1932+1916         ACIS-I SIM Z offset:-1163 (-2.92mm) Grating: NONE
RA, Dec, Roll (deg):   293.089417    19.271018    62.997577
Dither: ON  Y_amp= 8.0  Z_amp= 8.0  Y_period=1000.0  Z_period= 707.1
BACKSTOP GUIDE_SUMM OR MANVR DOT MAKE_STARS TLR

MP_TARGQUAT at 2018:057:10:59:49.314 (VCDU count = 9374359)
  Q1,Q2,Q3,Q4: 0.35108667  -0.40304355  -0.39046029  0.74955640
  MANVR: Angle= 104.31 deg  Duration= 2051 sec  Slew err= 71.1 arcsec  End= 2018:057:11:33:55

MP_STARCAT at 2018:057:10:59:50.957 (VCDU count = 9374366)
---------------------------------------------------------------------------------------------
 IDX SLOT        ID  TYPE   SZ   P_ACQ    MAG   MAXMAG   YANG   ZANG DIM RES HALFW PASS NOTES
---------------------------------------------------------------------------------------------
[ 1]  0           1   FID  8x8     ---   7.000   8.000    919   -904   1   1   25
[ 2]  1           4   FID  8x8     ---   7.000   8.000   2140    995   1   1   25
[ 3]  2           5   FID  8x8     ---   7.000   8.000  -1828    993   1   1   25
[ 4]  3   210372592   BOT  6x6   0.972   9.246  10.750  -2115   -355  28   1  160    a2
[ 5]  4   210376496   BOT  6x6   0.985   8.687  10.188  -1354  -1823  28   1  160    a2
[ 6]  5   210909704   BOT  6x6   0.985   8.320   9.828   1101  -1235  16   1  100
[ 7]  6   210910720   BOT  6x6   0.976   9.182  10.688   -669  -1224  28   1  160    a2
[ 8]  7   210380592   GUI  6x6     ---   9.011  10.516  -2348  -2242   1   1   25
[ 9]  7   210911344   ACQ  6x6   0.973   9.232  10.734   1254  -1919  28   1  160    a2
[10]  0   210910576   ACQ  6x6   0.819   9.395  10.906   1509  -2210  28   1  160    a2
[11]  1   210910976   ACQ  6x6   0.954   9.458  10.969   -762  -1835  28   1  160    a2
[12]  2   210910264   ACQ  6x6   0.938   9.576  11.078   -153  -1303  28   1  160    a2

>> WARNING: [10] Search spoiler.  210905424: Y,Z,Radial,Mag seps:  21 151 153 -0.7

Probability of acquiring 2,3, and 4 or fewer stars (10^x):-7.149-5.342-3.766
Acquisition Stars Expected  : 7.60
Predicted Max CCD temperature: -11.1 C  N100 Warm Pix Frac 0.254
Dynamic Mag Limits: Yellow 10.22  Red 10.51

If some parts of the text are not available (except for the star catalog itself), this routine will do its best to carry on. This parses:

  • Star catalog itself (required)

  • Dither (optional)

  • Observation date (approximate, from MP_STARCAT time; optional)

  • Attitude (from RA, Dec, Roll or Q1, Q2, Q3, Q4; optional)

  • CCD temperature (from Predicted Max CCD temperature)

Parameters
  • obs_text – text copied from starcheck output

  • verbose – display the parsed parameters that get sent to sc.track_stars_setup()

  • kwargs – other keyword args that get passed to track_stars_setup() and supplement or override those found in the catalog.

Returns sc

Spacecraft object for annie simulation