llama.files.gracedb module¶
FileHandlers for uploading and downloading files from GraceDB plus utilities for interacting with GraceDB.
-
class
llama.files.gracedb.
GraceDBPollingFileHandler
¶ Bases:
llama.filehandler.FileHandler
,llama.filehandler.mixins.OnlineVetoMixin
A data file that can be downloaded from GraceDB as soon as it is ready. SkymapInfo is necessarily a dependency for all subclasses (since we need to extract the GraceID from it). In most cases, this should be the only dependency.
-
DEPENDENCIES
= (<class 'llama.files.skymap_info.SkymapInfo'>,)¶
-
abstract property
remote_filename
¶ The name of the required data in a format recognizable by the remote resource’s API. This is quite possibly dynamically generated, and so it must be considered separate from the file handler’s name for this file.
-
-
class
llama.files.gracedb.
GraceDBReceipt
¶ Bases:
llama.com.utils.UploadReceipt
A log file created when a file is uploaded to GraceDB.
-
CLASSNAME_FMT
= 'RctGdb{}'¶
-
FILENAME_FMT
= 'rct_gdb_{}.log'¶
-
classmethod
decorator_dict
(upload, log_message='Upload from LLAMA pipeline.')¶ See
UploadReceipt.upload_this
andUploadReceipt.decorator_dict
.- Parameters
upload – The decorated
FileHandler
class that is being registered for upload.log_message (function or str, optional) – Either a string whose
format
function will be called with the newGraceDBReceipt
subclass as itsself
keyword argument or a function taking the newGraceDBReceipt
as its only argument (will become thelog_message
property for the newGraceDBReceipt
).
- Returns
newclassdict – A dictionary that can be passed to
type
to specify the attributes of a new class.- Return type
dict
- Raises
TypeError – If
log_message
is not a formattable string or callable object.
Specify tags (which affect display and access permissions) for the uploaded GraceDB file. Can be overridden for files that don’t fit the default topics:
[u’lvem’, u’em_follow’, u’sky_loc’]
-
abstract property
log_message
¶ A message to accompany this file on the GraceDB log entry for this event. The last line of this log file is a JSON object describing the result of the upload operation.
-
classmethod
set_class_attributes
(subclass)¶ See
UploadReceipt.set_class_attributes
; this method additionally addsSkymapInfo
to theDEPENDENCIES
list forsubclass
(if it is not implicitly there by virtue of being the uploaded file).
-
property
upload_dict
¶ When uploading to GraceDB via the REST API, the GraceDB client produces a dict with useful information about the uploaded file. This method returns that dict. An example instance of this dict:
- {u’N’: 46,
u’comment’: u’Testing json upload ONE MORE TIME!’, u’created’: u’2017-03-19T04:49:43.515566+00:00’, u’file’: (u’https://gracedb.ligo.org/api/events/M278200/’
u’files/icecube_neutrino_list.json,4’),
u’file_version’: 4, u’filename’: u’icecube_neutrino_list.json’, u’issuer’: {u’display_name’: u’Stefan Countryman’,
u’username’: u’stefan.countryman@LIGO.ORG’},
u’self’: u’https://gracedb.ligo.org/api/events/M278200/log/46’, u’tag_names’: [u’em_follow’], u’tags’: u’https://gracedb.ligo.org/api/events/M278200/log/46/tag/’}
If the log file doesn’t exist or the upload dict cannot be read, this function returns None.
-
-
class
llama.files.gracedb.
LVCGraceDbEventData
¶ Bases:
llama.filehandler.JSONFile
,llama.filehandler.mixins.OnlineVetoMixin
The event dictionary as returned by the GraceDb API. Includes richer information on the single-detector and multi-detector inspiral parameters than is provided in LVAlerts or GCN Notices. Convenience methods are provided for certain commonly-used reconstructed parameters, but full data can always be accessed by running
read_json
.-
DEPENDENCIES
= (<class 'llama.files.skymap_info.SkymapInfo'>,)¶
-
FILENAME
= 'lvc_gracedb_event_data.json'¶
-
GW_DETECTORS
= {'H1', 'L1', 'V1'}¶
-
MANIFEST_TYPES
= (<class 'llama.files.gracedb.LVCGraceDbEventData'>,)¶
-
UR_DEPENDENCIES
= (<class 'llama.files.skymap_info.SkymapInfo'>,)¶
-
UR_DEPENDENCY_TREE
= frozenset({<class 'llama.files.skymap_info.SkymapInfo'>})¶
-
property
chirp_mass
¶ The chirp mass. Raises a
KeyError
if it is not defined.
-
property
instruments
¶ A sorted list of the interferometers that participated in creating this trigger, e.g.
['H1', 'L1']
. Raises aValueError
if unexpected instruments are found. Raises aKeyError
if it is not defined.
-
property
offline
¶ Whether this trigger was generated offline.
-
property
snr
¶ The coincident signal-to-noise ratio (SNR). Raises a
KeyError
if it is not defined.
-
property
total_mass
¶ The total binary mass. Raises a
KeyError
if it is not defined.
-
-
class
llama.files.gracedb.
PAstro
¶ Bases:
llama.files.gracedb.GraceDBPollingFileHandler
,llama.filehandler.JSONFile
A classification of an event’s possible sources by probability.
-
FILENAME
= 'p_astro.json'¶
-
MANIFEST_TYPES
= (<class 'llama.files.gracedb.PAstro'>,)¶
-
UR_DEPENDENCIES
= (<class 'llama.files.skymap_info.SkymapInfo'>,)¶
-
UR_DEPENDENCY_TREE
= frozenset({<class 'llama.files.skymap_info.SkymapInfo'>})¶
-
property
most_likely_population
¶ Get the population that this event most likely belongs too by seeing whether it is more likely than not to contain NS matter. More precisely, compares
p_bbh
top_bns + p_nsbh + p_mass_gap
, returning'bbh'
if the former is larger and'bns'
if the latter is larger.p_terr
is ignored in this calculation.
-
property
p_bbh
¶ The probability that this was a BBH (binary black hole) merger.
-
property
p_bns
¶ The probability that this was a BNS (binary neutron star) merger.
-
property
p_mass_gap
¶ The probability that at least one of the compact objects in the merger was in the ambiguous mass gap between definite BH and definite NS.
-
property
p_nsbh
¶ The probability that this was a NSBH (neutron star/black hole) merger.
-
property
p_terr
¶ The probability that this event was terrestrial noise.
-
property
remote_filename
¶ The name of the required data in a format recognizable by the remote resource’s API. This is quite possibly dynamically generated, and so it must be considered separate from the file handler’s name for this file.
-
-
class
llama.files.gracedb.
RctSlkLmaLVCGraceDbEventData
¶ Bases:
llama.files.slack.SlackReceiptLlama
-
DEPENDENCIES
= (<class 'llama.files.gracedb.LVCGraceDbEventData'>, <class 'llama.files.skymap_info.SkymapInfo'>)¶
-
FILENAME
= 'rct_slk_lma_lvc_gracedb_event_data.json.json'¶
-
FILENAME_FMT
= 'rct_slk_lma_{}.json'¶
-
MANIFEST_TYPES
= (<class 'llama.files.gracedb.RctSlkLmaLVCGraceDbEventData'>,)¶
-
UPLOAD
¶ alias of
LVCGraceDbEventData
-
UR_DEPENDENCIES
= (<class 'llama.files.skymap_info.SkymapInfo'>, <class 'llama.files.gracedb.LVCGraceDbEventData'>)¶
-
UR_DEPENDENCY_TREE
= frozenset({<class 'llama.files.gracedb.LVCGraceDbEventData'>})¶
-
class_vetoes
= ()¶
-