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: Optional[str] = None)[source]

Bases: GRBDataGetter

__init__(grb: str, transient_type: str, data_mode: str, instrument: str = 'BAT+XRT', bin_size: Optional[str] = None) 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.

__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_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_data_to_csv()

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

create_directory_structure()

return:

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

download_directly()

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

download_flux_density_data()

Downloads flux density data from the Swift website.

download_integrated_flux_data()

Downloads integrated flux density data from the Swift website.

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.

Attributes

FLUX_DENSITY_KEYS

INTEGRATED_FLUX_KEYS

PROMPT_DATA_KEYS

SWIFT_PROMPT_BIN_SIZES

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.

stripped_grb

The GRB number without prepended 'GRB'.

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_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() Optional[DataFrame][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_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_directly() None[source]

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

download_flux_density_data() None[source]

Downloads flux density data from the Swift website. Uses the PhantomJS headless browser to click through the website. Properly quits the driver.

download_integrated_flux_data() None[source]

Downloads integrated flux density data from the Swift website. Uses the PhantomJS headless browser to click through the website. Properly quits the driver.

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

property stripped_grb: str

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

Type:

return

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