redback.get_data.swift.SwiftDataGetter

class redback.get_data.swift.SwiftDataGetter(grb: str, transient_type: str, data_mode: str, instrument: str = 'BAT+XRT', bin_size: str = None, snr: int | str = 4, force_download: bool = False)[source]

Bases: GRBDataGetter

__init__(grb: str, transient_type: str, data_mode: str, instrument: str = 'BAT+XRT', bin_size: str = None, snr: int | str = 4, force_download: bool = False) None[source]

Constructor class for a data getter. The instance will be able to download the specified Swift data.

Parameters:
  • grb (str) – Telephone number of GRB, e.g., ‘GRB140903A’ or ‘140903A’ are valid inputs.

  • transient_type (str) – Type of the transient. Should be ‘prompt’ or ‘afterglow’.

  • data_mode (str) – Data mode must be from redback.get_data.swift.SwiftDataGetter.VALID_DATA_MODES.

  • instrument (str) – Instrument(s) to use. Must be from redback.get_data.swift.SwiftDataGetter.VALID_INSTRUMENTS.

  • bin_size (str) – Bin size. Must be from redback.get_data.swift.SwiftDataGetter.SWIFT_PROMPT_BIN_SIZES.

  • snr (int or str) – BAT Burst Analyser SNR choice (e.g., 4, 5, 6, 7).

  • force_download (bool) – If True, re-download data from API even if cached files exist.

__call__(**kwargs)

Call self as a function.

Methods

__init__(grb, transient_type, data_mode[, ...])

Constructor class for a data getter.

collect_data()

Downloads the data from the Swift website and saves it into the raw file path.

convert_burst_analyser_api_data_to_csv()

Converts Burst Analyser data from the swifttools API into the expected CSV format.

convert_combined_api_data_to_csv()

Converts combined XRT (from getLightCurves) and BAT (from getBurstAnalyser) data to CSV.

convert_flux_density_data_to_csv()

Converts the flux data into processed data and saves it into the processed file path.

convert_integrated_flux_data_to_csv()

Converts the flux data into processed data and saves it into the processed file path.

convert_raw_afterglow_data_to_csv()

Converts the raw afterglow data into processed data and saves it into the processed file path.

convert_raw_data_to_csv()

Converts the raw data into processed data and saves it into the processed file path.

convert_raw_prompt_data_to_csv()

Converts the raw prompt data into processed data and saves it into the processed file path.

convert_xrt_api_data_to_csv()

Converts XRT data from the swifttools API into the expected CSV format.

convert_xrt_data_to_csv()

Converts the raw XRT data into processed data and saves it into the processed file path.

create_directory_structure()

download_burst_analyser_data_via_api()

Downloads BAT+XRT Burst Analyser data using the swifttools API.

download_directly()

Downloads prompt or XRT data directly without using PhantomJS if possible.

download_xrt_data_via_api()

Downloads XRT data using the swifttools API.

get_data()

Downloads the raw data and produces a processed .csv file.

get_swift_id_from_grb()

Gets the Swift ID from the GRB number.

load_raw_api_data()

Loads previously saved raw API data from the raw file path.

save_raw_api_data()

Saves the raw API data to the raw file path for debugging and reprocessing.

Attributes

FLUX_DENSITY_KEYS

INTEGRATED_FLUX_KEYS

PROMPT_DATA_KEYS

SWIFT_PROMPT_BIN_SIZES

VALID_BAT_SNR

VALID_DATA_MODES

VALID_INSTRUMENTS

VALID_TRANSIENT_TYPES

XRT_DATA_KEYS

data_mode

Ensures the data mode to be from SwiftDataGetter.VALID_DATA_MODES.

grb

The GRB number with prepended 'GRB'.

grb_website

The GRB website depending on the data mode and instrument.

instrument

Ensures the data mode to be from SwiftDataGetter.VALID_INSTRUMENTS.

snr

Returns BAT Burst Analyser SNR selection.

stripped_grb

The GRB number without prepended 'GRB'.

swifttools_grb_name

Formats the GRB name for swifttools (expects 'GRB 060729' style).

transient_type

Checks if the transient type is valid when setting.

trigger

Gets the trigger number based on the GRB name.

collect_data() None[source]

Downloads the data from the Swift website and saves it into the raw file path.

convert_burst_analyser_api_data_to_csv() DataFrame[source]

Converts Burst Analyser data from the swifttools API into the expected CSV format.

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_combined_api_data_to_csv() DataFrame[source]

Converts combined XRT (from getLightCurves) and BAT (from getBurstAnalyser) data to CSV.

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_flux_density_data_to_csv() DataFrame[source]

Converts the flux data into processed data and saves it into the processed file path. The column names are in SwiftDataGetter.FLUX_DENSITY_KEYS

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_integrated_flux_data_to_csv() DataFrame[source]

Converts the flux data into processed data and saves it into the processed file path. The column names are in SwiftDataGetter.INTEGRATED_FLUX_KEYS

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_raw_afterglow_data_to_csv() DataFrame[source]

Converts the raw afterglow data into processed data and saves it into the processed file path.

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_raw_data_to_csv() DataFrame | None[source]

Converts the raw data into processed data and saves it into the processed file path.

Returns:

The processed data

Return type:

pandas.DataFrame

convert_raw_prompt_data_to_csv() DataFrame[source]

Converts the raw prompt data into processed data and saves it into the processed file path. The column names are in SwiftDataGetter.PROMPT_DATA_KEYS

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_xrt_api_data_to_csv() DataFrame[source]

Converts XRT data from the swifttools API into the expected CSV format.

Returns:

The processed data.

Return type:

pandas.DataFrame

convert_xrt_data_to_csv() DataFrame[source]

Converts the raw XRT data into processed data and saves it into the processed file path. The column names are in SwiftDataGetter.XRT_DATA_KEYS

Returns:

The processed data.

Return type:

pandas.DataFrame

create_directory_structure() DirectoryStructure[source]
Returns:

A namedtuple with the directory path, raw file path, and processed file path.

Return type:

redback.get_data.directory.DirectoyStructure

property data_mode: str

Ensures the data mode to be from SwiftDataGetter.VALID_DATA_MODES.

Returns:

The data mode

Return type:

str

download_burst_analyser_data_via_api() dict[source]

Downloads BAT+XRT Burst Analyser data using the swifttools API.

Returns:

The Burst Analyser data dictionary

Return type:

dict

download_directly() None[source]

Downloads prompt or XRT data directly without using PhantomJS if possible.

download_xrt_data_via_api() DataFrame[source]

Downloads XRT data using the swifttools API.

Returns:

The XRT lightcurve data

Return type:

pandas.DataFrame

get_data() DataFrame[source]

Downloads the raw data and produces a processed .csv file.

Returns:

The processed data

Return type:

pandas.DataFrame

get_swift_id_from_grb() str[source]

Gets the Swift ID from the GRB number.

Returns:

The Swift ID

Return type:

str

property grb: str

The GRB number with prepended ‘GRB’. :rtype: str

Type:

return

property grb_website: str

The GRB website depending on the data mode and instrument. :rtype: str

Type:

return

property instrument: str

Ensures the data mode to be from SwiftDataGetter.VALID_INSTRUMENTS.

Returns:

The instrument

Return type:

str

load_raw_api_data() None[source]

Loads previously saved raw API data from the raw file path.

save_raw_api_data() None[source]

Saves the raw API data to the raw file path for debugging and reprocessing.

property snr: str

Returns BAT Burst Analyser SNR selection.

property stripped_grb: str

The GRB number without prepended ‘GRB’. :rtype: str

Type:

return

property swifttools_grb_name: str

Formats the GRB name for swifttools (expects ‘GRB 060729’ style).

property transient_type: str

Checks if the transient type is valid when setting.

Returns:

The transient type.

Return type:

str

property trigger: str

Gets the trigger number based on the GRB name.

Returns:

The trigger number.

Return type:

str