snews_cs.snews_coinc¶
Attributes¶
Classes¶
This class handles all the incoming data to the SNEWS CS Cache, |
|
Functions¶
|
Return the time difference between two numpy datetime64 objects in seconds |
Module Contents¶
- 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
- 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
- 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]¶
-
- clear_cache(is_test=False)[source]¶
When a reset cache is passed, recreate the CoincidenceDataHandler instance
- 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”,