pittgoogle.utils

Functions to support working with alerts and related data.

class pittgoogle.utils.ProjectIds[source]

Registry of Google Cloud Project IDs.

pittgoogle: ClassVar[str] = 'ardent-cycling-243415'

Pitt-Google’s production project.

pittgoogle_dev: ClassVar[str] = 'avid-heading-329016'

Pitt-Google’s development project.

elasticc: ClassVar[str] = 'elasticc-challenge'

Project running a classifier for ELAsTiCC alerts and reporting to DESC.

class pittgoogle.utils.Cast[source]

Methods to convert data types.

static bytes_to_b64utf8(bytes_data)[source]

Convert bytes data to UTF-8.

Parameters

bytes_data (bytes) – Data to be converted to UTF-8.

Returns

databytes_data converted to a string in UTF-8 format

Return type

dict

static json_to_dict(bytes_data)[source]

Convert json serialized bytes data to a dict.

Parameters
  • bytes_data (bytes) – Data to be converted to a dictionary.

  • Returns

  • data (dict) – bytes_data unpacked into a dictionary.

static b64json_to_dict(bytes_data)[source]

Convert base64 encoded, json serialized bytes data to a dict.

Parameters
  • bytes_data (Base64) – Data to be converted to a dictionary.

  • Returns

  • data (dict) – bytes_data unpacked into a dictionary.

static avro_to_dict(bytes_data)[source]

Convert Avro serialized bytes data to a dict. The schema must be attached in the header.

Parameters

bytes_data (bytes) – Avro serialized bytes data to be converted to a dictionary

Returns

databytes_data unpacked into a dictionary.

Return type

dict

static b64avro_to_dict(bytes_data)[source]

Convert base64 encoded, Avro serialized bytes data to a dict.

Parameters

bytes_data (bytes:) – base64 encoded, Avro serialized bytes to be converted to a dictionary

Returns

databytes_data unpacked into a dictionary.

Return type

dict

static alert_dict_to_dataframe(alert_dict)[source]

Package a ZTF alert dictionary into a dataframe.

Adapted from: https://github.com/ZwickyTransientFacility/ztf-avro-alert/blob/master/notebooks/Filtering_alerts.ipynb

Return type

DataFrame

static alert_dict_to_table(alert_dict)[source]

Package a ZTF alert dictionary into an Astopy Table.

Return type

Table

static jd_to_readable_date(jd)[source]

Convert a Julian date to a human readable string.

Parameters

jd (float) – Datetime value in julian format

Returns

datejd in the format ‘day mon year hour:min’

Return type

str

pittgoogle.utils.ztf_fid_names()[source]

Return a dictionary mapping the ZTF fid (filter ID) to the common name.

Return type

dict