BatPartialCoding

class gdt.missions.swift.bat.detectors.BatPartialCoding(nside=128)[source]

Bases: HealPixPartialCoding

Represents the Swift BAT partial coding fraction in HEALPix.

Parameters:

nside (int, optional) – The NSIDE resolution at which to create the partial coding map. Default is 128.

Attributes Summary

npix

Number of pixels in the HEALPix map

nside

The HEALPix resolution

pcoding

The partial coding fraction HEALPix array

pixel_area

The area of each pixel in square degrees

trigtime

The reference time

Methods Summary

area(fraction)

Calculate the area, in square degrees, covered by a given partial coding fraction.

convolve(model, *args, **kwargs)

Convolve the map with a model kernel.

from_data(hpx_arr[, filename])

Create a HealPix object from healpix arrays

multiply(healpix1, healpix2[, primary, ...])

Multiply two HealPix maps and return a new HealPix object

partial_coding(phi, theta)

Calculate the partial coding fraction at the given coordinate.

partial_coding_path(fraction[, numpts_phi, ...])

Return the bounding path for a given partial coding fraction

plot_polygon(fraction, sky_plot[, color, alpha])

Plot the polygon defined by a partial coding fraction on the sky.

rotate(sc_frame)

Given a spacecraft frame, rotates the partial coding fraction map into the celestial frame.

Attributes Documentation

npix

Number of pixels in the HEALPix map

Type:

(int)

nside

The HEALPix resolution

Type:

(int)

pcoding

The partial coding fraction HEALPix array

Type:

(np.array)

pixel_area

The area of each pixel in square degrees

Type:

(float)

trigtime

The reference time

Type:

(float)

Methods Documentation

area(fraction)

Calculate the area, in square degrees, covered by a given partial coding fraction.

Parameters:

fraction (float) – The partial coding fraction (between 0 and 1).

Returns:

(float)

convolve(model, *args, **kwargs)

Convolve the map with a model kernel. The model can be a Gaussian kernel or any mixture of Gaussian kernels. Uses healpy.smoothing.

An example of a model kernel with a 50%/50% mixture of two Gaussians, one with a 1-deg width, and the other with a 3-deg width:

def gauss_mix_example():
    sigma1 = np.deg2rad(1.0)
    sigma2 = np.deg2rad(3.0)
    frac1 = 0.50
    return ([sigma1, sigma2], [frac1])
Parameters:
  • model (<function>) – The function representing the model kernel

  • *args – Arguments to be passed to the model kernel function

Returns:

(HealPix)

classmethod from_data(hpx_arr, filename=None, **kwargs)

Create a HealPix object from healpix arrays

Parameters:
  • hpx_arr (np.array) – The HEALPix array

  • trigtime (float, optional) – The reference time for the map

  • filename (str, optional) – The filename

Returns:

(HealPix)

classmethod multiply(healpix1, healpix2, primary=0, output_nside=128, **kwargs)

Multiply two HealPix maps and return a new HealPix object

Parameters:
  • healpix1 (HealPix) – One of the HEALPix maps to multiply

  • healpix2 (HealPix) – The other HEALPix map to multiply

  • primary (int, optional) – If 0, use the first map metadata, or if 1, use the second map metadata. Default is 0.

  • output_nside (int, optional) – The nside of the multiplied map. Default is 128.

Returns

(HealPix)

partial_coding(phi, theta)

Calculate the partial coding fraction at the given coordinate. If the partial coding has been rotated into the celestial frame then (phi, theta) corresponds to (ra, dec), otherwise it corresponds to (az, zen). This function interpolates the map at the requested point rather than providing the vale at the nearest pixel center.

Parameters:
  • phi (float) – The azimuthal value

  • theta (float) – The polar value

Returns:

(float)

partial_coding_path(fraction, numpts_phi=360, numpts_theta=180)

Return the bounding path for a given partial coding fraction

Parameters:
  • fraction (float) – The partial coding fraction (valid range 0-1)

  • numpts_phi (int, optional) – The number of grid points along the azimuthal axis. Default is 360.

  • numpts_theta (int, optional) – The number of grid points along the polar axis. Default is 180.

Returns:

[(np.array, np.array), …]

A list of phi, theta points, where each

item in the list is a continuous closed path.

plot_polygon(fraction, sky_plot, color='gray', alpha=0.3, **kwargs)

Plot the polygon defined by a partial coding fraction on the sky.

Parameters:
  • fraction (float) – The partial coding fraction

  • sky_plot (Skyplot) – The sky plot

  • color (str, optional) – The color of the polygon

  • alpha (float, optional) – The alpha opacity of the polygon

  • kwargs (optional) – Other options to pass to SkyPolygon

Returns:

(list of SkyPolygon)

rotate(sc_frame)

Given a spacecraft frame, rotates the partial coding fraction map into the celestial frame.

Parameters:

sc_frame (SpacecraftFrame) – The spacecraft frame

Returns:

(BatPartialCoding)