Legacy DoL Functions

(gdt.missions.fermi.gbm.localization.dol.legacy_functions)

The methods provided in this module handle the basic functionality needed to operate the legacy DoL localization algorithm in a way that replicates the original Fortran code. These include legacy angular operations as well as coordinate conversions that would typically be handled by astropy in other parts of the GDT. A number of these methods are performed with 32-bit floating point accuracy to match the original Fortran code. A full list of available methods is shown in the Reference/API section at the bottom of this page.

Here we will focus on describing the core localization fit procedure find_best_location(). This method is a \(\chi^2\) minimization routine with \(\chi^2\) defined as

\[\chi^2 = \Sigma_i \frac{(M_i - E_i)^2}{E_i}\]

where \(M_i\) are the measured counts and \(E_i\) are the expected counts in detector \(i\). This assumes the measured counts follow a Gaussian distribution with symmetric variance \(E_i\), which is true for GBM given that typical backgrounds alone provide a few hundred measured counts across 50-300 keV in each detector during most GRB emission timescales.

The expected counts \(E_i\) are determined from the sum of the source \(S_i\) and background \(B_i\) expectations for each detector

\[E_i = S_i + B_i\]

\(B_i\) are typically determined from a polynomial fit to background periods (See Localization Example). \(S_i\) consists of the response of each detector \(R_i\) multiplied by the flux \(f\) of the source

\[S_i = f \times R_i\]

where the source flux \(f\) is found by solving for the value that minimizes \(\chi^2\). This is done by analytically setting the derivative of \(\chi^2\) equal to zero and solving for \(f\)

\[\frac{d}{df} \chi^{2} = 0\]

To make this process easier, the \(\chi^2\) is modified to exchange the model variance \(var(E_i) = E_i\) with the variance estimated from the measured counts \(var(M_i) = M_i\)

\[\chi^{2}_{\, var(M_i)} = \Sigma_i \frac{(M_i - E_i)^2}{M_i}\]

In this case, only the term \(E_i\) in the numerator depends on \(f\)

\[\frac{d}{df} \chi^{2}_{\, var(M_i)} = \frac{d}{df} \Sigma_i \frac{(M_i - E_i)^2}{M_i} = -2 \Sigma_i \frac{(M_i - E_i)}{M_i} \frac{d E_i}{df} = 0\]

Substituting \(E_i = f \times R_i + B_i\) then yields

\[\frac{d E_i}{df} = R_i\]
\[f = \frac{a}{b}, \quad a \equiv \Sigma_i \frac{(M_i - B_i)}{M_i} R_i, \quad b \equiv \Sigma_i \frac{R_i^2}{M_i}\]

Reference/API

gdt.missions.fermi.gbm.localization.dol.legacy_functions Module

Functions

add_scat(npoints, rgrid, ...)

Add scattering data for each spectrum

all_idx(idx[, axis])

Make a multidimensional index mask into another array

ang_to_cart_dec(ra, dec)

Convert right ascension and declination to Cartesian coordinates.

ang_to_cart_zen(az, zen)

Convert azimuth and zenith to Cartesian coordinates.

arctan2(x, y)

Compute arctan2.

choose_energy_data(ndet, nen, crange, ...)

Function to choose energy bins

compute_scat(npoints, rgrid, cenergies, ...)

Function to compute response of NaI detectors over a selected set of energy channels.

crossprod(x, y)

Cross product of two vectors

deadtime_correct(crange, mrates, brates, ...)

Compute deadtime corrected rates

dot(x, y)

Dot product of two vectors

eq2000_to_gal_r(ra2000, dec2000)

Function to convert from equatorial (ra, dec) coordinates in J2000 epoch to Galactic coordinates (lii, bii)

find_best_location(ndet, vpoints, udet, ...)

Calculate chi2 for each visible location and find minimum.

get_det_geometry(input_az, input_zen, ...)

Get detector geometry relative to source.

get_etog_matrix()

Function to calculate equatorial (ra, dec) to Galactic (lii, bii) coordinate rotation matrix.

get_geocenter(sc_quat, sc_pos[, verbose])

Get Earth center and spacecraft direction cosine matrix.

get_good_angle(input_xyz1, input_xyz2)

Given 2 Cartesian (unit or not) vectors, return angle between them.

get_occult(sc_pos, npoints, points_array)

Get list of points occulted by the Earth.

get_scattered_rates(rcart, gperp, gpmag, ...)

Calculate amount of scattering given geometry.

get_spec(spec, energies, mid_energies, erange)

Get spectral shape in each energy bin

initialize_det_geometry([verbose])

Contains geometry from rmk of 07/07 Given nai el & az, calculate unit vectors in SC frame of each NaI Tested 08/14/07 -- produces correct unit vector angles as per geometry from rmk of 07/07.

interpolatex(int_size, inter_array, ...)

Interpolate between 2 values by weighting by distance between 2 pts.

j2000_to_sc(scx, scy, scz, pos)

Convert from j2000 position to space craft azimuth and zenith.

read_earthpoints(geodir, nai_unit_vec, ...)

Read array of position vectors used to compute scattering of photons off Earth's atmosphere.

read_scatter_data([path])

Read atmospheric scattering matrix.

read_table(path, ndet, npoints)

Read database table with detector response for each point on the sky.

sc_to_j2000(scx, scy, scz, pos)

Convert Cartesian source position from space craft frame to right ascension and declination in Earth-centered frame.

sun_loc(sc_time_sec)

Compute the location of the sun in equatorial (ra, dec) coordinates

Classes

ETOG()

Definition of ETOG class which allows caching of ETOG value

Class Inheritance Diagram

Inheritance diagram of gdt.missions.fermi.gbm.localization.dol.legacy_functions.ETOG