snews_cs.snews_coinc

Attributes

log

Classes

CacheManager

This class handles all the incoming data to the SNEWS CS Cache,

CoincidenceDistributor

Functions

np_datetime_delta_sec(t_1, t_2)

Return the time difference between two numpy datetime64 objects in seconds

Module Contents

snews_cs.snews_coinc.log[source]
snews_cs.snews_coinc.np_datetime_delta_sec(t_1, t_2)[source]

Return the time difference between two numpy datetime64 objects in seconds Returns: float (seconds) .. rubric:: Notes

t_1 is expected to be the earlier time (no absolute value is taken)

class snews_cs.snews_coinc.CacheManager[source]

This class handles all the incoming data to the SNEWS CS Cache, adding messages, organizing sub-groups, retractions and updating cache entries

cache[source]
updated = [][source]
msg_state = None[source]
sub_group_state[source]
add_to_cache(message)[source]

Takes in SNEWS message and checks if it is a retraction, update or new addition to cache. This is the ‘core’ function of CoincidenceDataHandler :param message: SNEWS Message, must be PT valid :type message: dict

_manage_cache(message)[source]

This method will add a new message to cache, checks if:

A)It is an initial message (to the entire cache) or if it: B)Forms a new sub-group (sends message to _check_coinc_in_subgroups) C)Is confident to a sub-group (sends message to _check_coinc_in_subgroups)

Parameters:

message

_check_coinc_in_subgroups(message)[source]

This method either:

A)Adds Message to an existing sub-group, if coincident with the initial signal

B) If NOT coincident with any sub groups it creates two new sub groups, setting the message as their initial time. The new groups consist of coincident signals with earlier arrival time and later arrival times, respectively. Once created the new groups are checked to see if they are redundant, and if so then they are not added to the main cache.

Parameters:

message (dict) – SNEWS message

_check_for_redundancies(sub_cache)[source]

Checks if sub cache is redundant :param sub_cache: New sub group :type sub_cache: dataframe

Returns:

True if sub group is redundant False if sub cache is unique

Return type:

bool

_organize_cache(sub_cache)[source]

This method makes sure that the nu_delta_times are not negative, recalculates new deltas using the proper initial time

Parameters:

sub_cache (dataframe) – Sub group

_fix_deltas(sub_df)[source]

This method fixes the deltas of the sub group by resetting the initial nu time :param sub_df: Sub cache :type sub_df: Dataframe

Returns:

sub_df – Sub cache with fixed nu time deltas

Return type:

Dataframe

_update_message(message)[source]

If triggered this method updates the p_val and neutrino time of a detector in cache.

Parameters:

message (dict) – SNEWS message

cache_retraction(retraction_message)[source]

This method handles message retraction by parsing the cache and dumping any instance of the target detector

Parameters:

retraction_message (dict) – SNEWS retraction message

class snews_cs.snews_coinc.CoincidenceDistributor(env_path=None, drop_db=False, firedrill_mode=True, hb_path=None, server_tag=None, send_email=False, send_slack=True, show_table=False)[source]
show_table = False[source]
send_email = False[source]
send_slack = True[source]
hb_path = None[source]
server_tag = None[source]
storage[source]
topic_type = 'CoincidenceTier'[source]
coinc_threshold[source]
cache_expiration = 86400[source]
retriable_error_count = 0[source]
max_retriable_errors = 20[source]
exit_on_error = False[source]
initial_set = False[source]
alert[source]
test_alert[source]
test_topic[source]
alert_schema[source]
store_heartbeat[source]
heartbeat[source]
stash_time = 86400[source]
coinc_data[source]
test_coinc_data[source]
message_count[source]
test_message_count[source]
clear_cache(is_test=False)[source]

When a reset cache is passed, recreate the CoincidenceDataHandler instance

display_table(is_test=False)[source]

Display each sub list individually using a markdown table.

send_alert(sub_group_tag, alert_type, is_test=False)[source]
alert_decider(is_test=False)[source]

This method will publish an alert every time a new detector submits an observation message.

deal_with_the_cache(snews_message)[source]

Check if the message is a test or not, then add it to the cache and run the alert decider

Parameters:

snews_message (dict read from the Kafka stream.)

Return type:

adds messages to cache and runs the coincidence decider

run_coincidence()[source]

As the name states this method runs the coincidence system. Starts by subscribing to the hop observation_topic.

  • If a CoincidenceTier message is received then it is passed to _check_coincidence.

  • other commands include “test-connection”, “test-scenarios”,

    “hard-reset”, “Retraction”,