Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 3.0.0 instead.
Reason given by maintainers: This version is no longer compatible with snews-cs deployed infrastructure

SNEWS Publishing Tool

Documentation Status testing
See the docs at

Docs: https://snews-publishing-tools.readthedocs.io/en/latest/

This packages provides users with a Python API and CLI to publish observation messages to SNEWS

How to Install

Note: Make sure your hop credentials are set up !!
Follow the instructions here if needed

First you need to clone this repo. In your terminal run the following:

git clone https://github.com/SNEWS2/SNEWS_Publishing_Tools.git

Once cloned, install the package using pip (make sure you're in the cloned dir)

pip install .

Message Schemas

Note: Not the final schemas !!

Coincidence Tier

_id                 
detector_name     (user input)    
sent_time           
machine_time      (user input)    
neutrino_time     (user input)     
p_val             (user input)    

Significance Tier

_id                 
detector_name    (user input)      
sent_time           
machine_time     (user input)        
neutrino_time    (user input)       
p_value(s)       (user input)    

Time Series Tier

_id                
detector_name   (user input)      
sent_time           
machine_time    (user input)      
neutrino_time   (user input)     
timing_series   (user input)

False Obs

_id
detector_name           (user input)          
false_id                (user input, optional)    
which_tier              (user input)    
N_retract_latest        (user input)    
retraction_reason       (user input, optional)  
sent_time           

How to Publish

Before we get started, right now the publishing method will send your message to the test kafka server.

First you need to import your Publisher:

# Import the constructor for SNEWS Tiers and Publisher class
from SNEWS_PT.snews_pub import SNEWSTiersPublisher

Passing Message Parameters as Arguments.

To send a message you need initialize the Publisher, construct your message by initializing SNEWSTiers and passing your parameters of choice. The backend will parse your arguments, check their data types and determine which tiers you can send a message to (see Publishing Protocols). If you pass multiple parameters (see code bellow) the sender will send a message all the appropriate tiers.

SNEWSTiersPublisher(detector_name='KamLAND', neutrino_time='22/02/28 4:31:08:565',
                    timing_series=['22/02/28 4:31:08:565', '22/02/28 4:31:08:765', '22/02/28 4:31:09:001'],
                    p_val=0.000007, machine_time='22/02/28 4:31:08:565', 
                    ).send_to_snews()

This instance has parameters for CoincidenceTier and TimingTier, thus it will send a message to both. The output should look like this: img.png!

Passing Message Parameters from JSON File.

You can also pass your input from a json file, and make modifications on the spot. Let's first create an observation object this time before sending it to snews;

observation = SNEWSTiersPublisher.from_json('my_input_asjson.json', 
                                            detector_name='XENONnT', 
                                            comment="This is submitted from a json file")

Here, we read the content from the 'my_input_asjson.json' file, and overwrite detector_name and also add a comment field (which will be accepted as a meta data). Notice we still haven't sent it to snews yet. You can display, and modify the parsed messages after you create the object instance. Depending on the fields you provided SNEWSTierPublisher will decide where to submit your data (see above). You can see these tier(s) and the individual message contents. See, observation.tiernames to get names of the tiers that your input message belongs, and observation.messages to display their content, and modify if desired.

Once you are done, you can just send that observation object to snews.

observation.send_to_snews()

See this examples notebook for more tutorial scripts

Publishing Protocols

Coincidence Tier

  • p_value and neutrino_time need to be passed.
    • p_val must be a float.
    • neutrino_time must be a string, format: '%y/%m/%d %H:%M:%S'

Significance Tier

  • p_values needs to be passed.
    • p_values must be a list (float).

Timing Tier

  • p_value and timing_series need to be passed.
    • p_val must be a float.
    • timing_series must be a list (string), format: '%y/%m/%d %H:%M:%S'

Retraction

  • n_retract_latest and which need to be passed.
    • n_retract_latest must be a int (and >0 ). You can also pass it as a 'ALL'.
    • which_tier must be a which_tier, format: '%y/%m/%d %H:%M:%S'

Pre-SN Timing Tier

  • is_pre_sn and timing_series need to be passed.
    • is_pre_sn must be a bool.
    • timing_series must be a list (string), format: '%y/%m/%d %H:%M:%S'

Notice that your message can contain fields that corresponds to several tiers e.g. if you have p_value, neutrino_time, and p_values we submit two separate messages to Coincidence and Significance tiers by selecting the relevant fields from your input.

How to Subscribe

In two lines, one can subscribe to the alert topic specified in the default configuration.
This starts a stream, and waits for alert messages to be received.

from SNEWS_PT.snews_sub import Subscriber

Subscriber().subscribe()

Should there be an alert message, this will be both displayed on the screen and saved into your local machine as SNEWS_MSGs/<today fmt="%y_%m_%d">/subscribed_messages.json and if there are multiple messages in the same day e.g. hype-mode is on and for the same supernova you kept receiving alerts with every coincidence message, these will be appended in this file with the sent time as the first key. An example (partly missing) can be found here


Command Line Interface (CLI)

There also exists tools for command line interactions. These are explained in detail here

Metadata

Release files for snews-pt 0.0.1.dev360

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snews-pt 0.0.1.dev360
File Size Uploaded Provenance Actions
SNEWS_PT-0.0.1.dev360.tar.gz 160.7 kB Without provenance Details for SNEWS_PT-0.0.1.dev360.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for snews-pt 0.0.1.dev360
File Interpreter ABI Platform Actions
SNEWS_PT-0.0.1.dev360-py3-none-any.whl Python 3 none any Details for SNEWS_PT-0.0.1.dev360-py3-none-any.whl

Total release size: 187.3 kB

Release files / SNEWS_PT-0.0.1.dev360.tar.gz

Download URL SNEWS_PT-0.0.1.dev360.tar.gz
Size 160.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2deac00be811238a19e16db97d294fe740632d1d19b194e4f00de66467ff8c5d
BLAKE2b-256 checksum
How to use checksums
d28c6e96db9af3848bde8c2f8971ef42af18999a214c48c56023eb96e9098918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.60.0 importlib-metadata/4.11.2 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.5

Release files / SNEWS_PT-0.0.1.dev360-py3-none-any.whl

Download URL SNEWS_PT-0.0.1.dev360-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a0e824a97ed189939698096a41ca6f46e200431c4801782846749081bff6b2e
BLAKE2b-256 checksum
How to use checksums
8a83c5a4a4e4acb5a36be548aeae87a439a3e0108a38ead52ceb4dd09d97ff37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.60.0 importlib-metadata/4.11.2 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.5

Security for snews-pt 0.0.1.dev360

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page