broker_utils.data_utils¶
The data_utils
module contains common functions used to manipulate
survey and broker data.
- broker.broker_utils.broker_utils.data_utils.alert_avro_to_dict(alert_avro)[source]¶
Load an alert Avro to a dictionary.
- Parameters
alert_avro (
Union
[str
,bytes
]) – Either the path of Avro file to load, or the bytes encoding the Avro-formated alert.- Return type
dict
- Returns
alert as a dict
- broker.broker_utils.broker_utils.data_utils.alert_dict_to_dataframe(alert_dict, schema_map)[source]¶
Packages an alert into a dataframe. Adapted from: https://github.com/ZwickyTransientFacility/ztf-avro-alert/blob/master/notebooks/Filtering_alerts.ipynb
- Return type
DataFrame
- broker.broker_utils.broker_utils.data_utils.decode_alert(alert_avro, return_as='dict', schema_map=None, drop_cutouts=False)[source]¶
Load an alert Avro and return in requested format.
Wraps alert_avro_to_dict() and alert_dict_to_dataframe().
- Parameters
alert_avro (
Union
[str
,bytes
]) – Either the path of Avro file to load, or the bytes encoding the Avro-formated alert.return_as (
str
) – Format the alert will be returned in.schema_map (
Optional
[dict
]) – Mapping between survey schema and broker’s generic schema. Required if return_as=’df’ or drop_cutouts=True.drop_cutouts (
bool
) – Whether to drop or return the cutouts (stamps). If return_as=’df’ the cutouts are always dropped.
- Return type
Union
[dict
,DataFrame
]- Returns
alert packet in requested format