gwcelery.tasks.external_skymaps module

Create and upload external sky maps.

gwcelery.tasks.external_skymaps.COMBINED_SKYMAP_FILENAME_MULTIORDER = 'combined-ext.multiorder.fits'

Filename of combined sky map in a multiordered format

gwcelery.tasks.external_skymaps.COMBINED_SKYMAP_FILENAME_PNG = 'combined-ext.png'

Filename of combined sky map plot

gwcelery.tasks.external_skymaps.FERMI_OFFICIAL_SKYMAP_FILENAME = 'glg_healpix_all_bn_v00'

Filename of sky map from official Fermi GBM analysis

(task)gwcelery.tasks.external_skymaps.create_combined_skymap(se_id, ext_id, preferred_event=None)[source]

Creates and uploads a combined LVK-external skymap, uploading to the external trigger GraceDB page. The filename used for the combined sky map will be ‘combined-ext.multiorder.fits’ if the external sky map is multi-ordered or ‘combined-ext.fits.gz’ if the external sky map is not. Will use the GW sky map in from the preferred event if given.

Parameters:
  • se_id (str) – Superevent GraceDB ID

  • ext_id (str) – External event GraceDB ID

  • preferred_event (str) – Preferred event GraceDB ID. If given, use sky map from preferred event

(task)gwcelery.tasks.external_skymaps.get_skymap_filename(graceid, is_gw)[source]

Get the skymap FITS filename.

If not available, will try again 10 seconds later, then 20, then 40, etc. up to a max 10 minutes retry delay.

Parameters:
  • graceid (str) – GraceDB ID

  • is_gw (bool) – If True, uses method for superevent or preferred event. Otherwise uses method for external event.

Returns:

filename – Filename of latest sky map

Return type:

str

(task)gwcelery.tasks.external_skymaps._download_skymaps(gw_filename, ext_filename, gw_id, ext_id)[source]

Download both superevent and external sky map to be combined.

Parameters:
  • gw_filename (str) – GW sky map filename

  • ext_filename (str) – External sky map filename

  • gw_id (str) – GraceDB ID of GW candidate, either superevent or preferred event

  • ext_id (str) – GraceDB ID of external candidate

Returns:

gw_skymap, ext_skymap – Tuple of gw_skymap and ext_skymap bytes

Return type:

tuple

gwcelery.tasks.external_skymaps.combine_skymaps_moc_moc(gw_sky, ext_sky)[source]

This function combines a multi-ordered (MOC) GW sky map with a MOC external skymap.

gwcelery.tasks.external_skymaps.combine_skymaps_moc_flat(gw_sky, ext_sky, ext_header)[source]

This function combines a multi-ordered (MOC) GW sky map with a flattened external one by re-weighting the MOC sky map using the values of the flattened one.

Header info is generally inherited from the GW sky map or recalculated using the combined sky map values.

Parameters:
  • gw_sky (Table) – GW sky map astropy Table

  • ext_sky (array) – External sky map array

  • ext_header (dict) – Header of external sky map

Returns:

comb_sky – Table of combined sky map

Return type:

Table

(task)gwcelery.tasks.external_skymaps.combine_skymaps(skymapsbytes, ext_moc=True)[source]

This task combines the two input sky maps, in this case the external trigger skymap and the LVK skymap and writes to a temporary output file. It then returns the contents of the file as a byte array.

There are separate methods in case the GW sky map is multiordered (we just reweight using the external sky map) or flattened (use standard ligo.skymap.combine method).

Parameters:
  • skymapbytes (tuple) – Tuple of gw_skymap and ext_skymap bytes

  • gw_moc (bool) – If True, assumes the GW sky map is a multi-ordered format

Returns:

combinedskymap – Bytes of combined sky map

Return type:

bytes

(task)gwcelery.tasks.external_skymaps.external_trigger_heasarc(external_id)[source]

Returns the HEASARC FITS file link.

Parameters:

external_id (str) – GraceDB ID of external event

Returns:

heasarc_link – Guessed HEASARC URL link

Return type:

str

(task)gwcelery.tasks.external_skymaps.get_external_skymap(link, search)[source]

Download the Fermi sky map FITS file and return the contents as a byte array. If GRB, will construct a HEASARC url, while if SubGRB, will use the link directly.

If not available, will try again 10 seconds later, then 20, then 40, etc. until up to 15 minutes after initial attempt.

Parameters:
  • link (str) – HEASARC URL link

  • search (str) – Search field of external event

Returns:

external_skymap – Bytes of external sky map

Return type:

bytes

(task)gwcelery.tasks.external_skymaps.read_upload_skymap_from_base64(event, skymap_str)[source]

Decode and upload 64base encoded sky maps from Kafka alerts.

Parameters:
  • event (dict) – External event dictionary

  • skymap_str (str) – Base 64 encoded sky map string

(task)gwcelery.tasks.external_skymaps.get_upload_external_skymap(event, skymap_link=None)[source]

If a Fermi sky map is not uploaded yet, tries to download one and upload to external event. If sky map is not available, passes so that this can be re-run the next time an update GCN notice is received. If GRB, will construct a HEASARC url, while if SubGRB, will use the link directly. If SubGRB or FromURL, downloads a skymap using the provided URL rather than construct one.

Parameters:
  • event (dict) – External event dictionary

  • skymap_link (str) – HEASARC URL link

gwcelery.tasks.external_skymaps.from_cone(pts, ra, dec, error)[source]

Based on the given RA, DEC, and error radius of the center points, it calculates the gaussian pdf.

gwcelery.tasks.external_skymaps.fermi_error_model(pts, ra, dec, error, core, tail, core_weight)[source]

Calculate the Fermi GBM error model from Connaughton et al. 2015 based on the given RA, Dec and error radius of the center point using the model parameters of core radii, tail radii, and core proportion (f in the paper).

gwcelery.tasks.external_skymaps.create_external_skymap(ra, dec, error, pipeline, notice_type=111)[source]

Create a sky map, either a gaussian or a single pixel sky map, given an RA, dec, and error radius.

If from Fermi, convolves the sky map with both a core and tail Gaussian and then sums these to account for systematic effects as measured in doi:10.1088/0067-0049/216/2/32

If from Swift, converts the error radius from that containing 90% of the credible region to ~68% (see description of Swift error here:https://gcn.gsfc.nasa.gov/swift.html#tc7)

Parameters:
  • ra (float) – Right ascension in deg

  • dec (float) – Declination in deg

  • error (float) – Error radius in deg

  • pipeline (str) – External trigger pipeline name

  • notice_type (int) – GCN notice type integer

Returns:

skymap – Sky map array

Return type:

array

gwcelery.tasks.external_skymaps.write_to_fits(skymap, event, notice_type, notice_date)[source]

Write external sky map FITS file, populating the header with relevant info.

Parameters:
  • skymap (array) – Sky map array

  • event (dict) – Dictionary of external event

  • notice_type (int) – GCN notice type integer

  • notice_date (str) – External event trigger time in ISO format

Returns:

skymap_fits – Bytes string of sky map

Return type:

str

(task)gwcelery.tasks.external_skymaps.create_upload_external_skymap(event, notice_type, notice_date)[source]

Create and upload external sky map using RA, dec, and error radius information.

Parameters:
  • event (dict) – Dictionary of external event

  • notice_type (int) – GCN notice type integer

  • notice_date (str) – External event trigger time in ISO format

(task)gwcelery.tasks.external_skymaps.plot_overlap_integral(coinc_far_dict, superevent, ext_event, var_label='\\mathcal{I}_{\\Omega}')[source]

Plot and upload visualization of the sky map overlap integral computed by ligo.search.overlap_integral.

Parameters:
  • coinc_far_dict (dict) – Dictionary containing coincidence false alarm rate results from RAVEN

  • superevent (dict) – Superevent dictionary

  • ext_event (dict) – External event dictionary

  • var_label (str) – The variable symbol used in plotting