legacy_DoL¶
- class gdt.missions.fermi.gbm.localization.dol.legacy_dol.legacy_DoL(spec=None, locrates=None, usedet=None, nen=8, ndet=14, ldet=12, verbose=False)[source]¶
Bases:
objectThe legacy DoL localization code for Fermi GBM with float32 support
- Parameters:
spec (list) –
List of spectrum definitions given as (name, spectrum). Example:
spec = [("Hard", "comp,index=-0.25,epeak=1000.,amp=10.0"), ("Normal", "comp,index=-1.15,epeak=350.0,amp=10.0"), ("Soft", "comp,index=-1.95,epeak=50.0,amp=10.0")]
locrates (list) –
List of paths to locrates file for each entry in
spec. Example:locrates = ["locrates_1deg_50_300_hard_n.npy", "locrates_1deg_50_300_normal_n.npy", "locrates_1deg_50_300_soft_n.npy"]
usedet (np.array, optional) – A boolean array containing True (1) if the detector is to be included or False (0) if a detector is not to be included. If not set, then all detectors (including BGOs) are used
nen (int, optional) – Number of energy bins. Default is 8.
ndet (int, optional) – Total number of detectors. Default is 14.
ldet (int, optional) – Max number of detectors for use in localization. Default is 12.
Attributes Summary
Default number of detectors for localization
Default total number of detectors
Default number of energy bins for localization
List of locrates tables for each spectrum
Version number of the routine
Methods Summary
display_nai_angles(ang)Function to show angles of NaI detectors relative to location.
eval(crange, mrates, brates, sduration, ...)Evaluate DoL localization and write results to files.
initialize_sky_grid(loctable)Build grid of sky positions using grid_res resolution.
join_float(val[, unit])Helper function to join float values into space separated str.
localize(crange, mrates, brates, sduration, ...)Perform the localization routine over all spectra.
stdout(loc)Routine to print standard output from DoL.
to_GbmHealPix(loc, frame[, grid_nearest])Converts a DoL localization dictionary to a
GbmHealPixprobability mapwrite_chi2grid(path, scx, scy, scz, sc_pos, chi2)Write grid of chi2 values on the sky to a text file.
write_summary(path, loc)Write summary text file with important info.
Attributes Documentation
- default_ldet = 12¶
Default number of detectors for localization
- Type:
(int)
- default_ndet = 14¶
Default total number of detectors
- Type:
(int)
- default_nen = 8¶
Default number of energy bins for localization
- Type:
(int)
- locrates¶
List of locrates tables for each spectrum
- Type:
(list)
- ver_no = '4.15a'¶
Version number of the routine
- Type:
(str)
Methods Documentation
- display_nai_angles(ang)[source]¶
Function to show angles of NaI detectors relative to location.
- Parameters:
ang (np.ndarray) – Array with detector angles
- eval(crange, mrates, brates, sduration, bgduration, sc_pos, sc_quat, energies, fra, fdec, sc_time, scat_opt, fname='', odir='')[source]¶
Evaluate DoL localization and write results to files.
- Parameters:
crange (np.ndarray(2, int32)) – Array of energy channel IDs chosen for localization
mrates (np.ndarry(
ndet*nen, int32)) – Array of measured detector counts in each energy channelbrates (np.ndarry(
ndet*nen, int32)) – Array of estimated background counts in each energy channelsduration (float32) – Timescale of measured detector counts
bgduration (float32) – Timescale of estimated background counts
sc_pos (np.ndarray(3, float32)) – Spacecraft position x, y, z coordinates
sc_quat (np.ndarray(4, float64)) – Quaternion of the space craft. Last element is the scalar field.
energies (np.ndarray(
nen+ 1, float32)) – Array with end points of energy channel binsfra (float32) – Initial right ascension value for localization in degrees
fdec (float32) – Initial declination value for localization in degrees
sc_time (int64) – Spacecraft time in MET seconds
scat_opt (int32) – Scattering option. 1 means include scattering when computing the expected detector counts for a given spectrum. 0 means do not include scattering when computing expected detector counts.
fname (str) – Output file name string
odir (str) – Directory path to output file
- Returns:
(dict) – Dictionary object with information about the best localization
- initialize_sky_grid(loctable)[source]¶
Build grid of sky positions using grid_res resolution. First find out how many points will fill grid = npoints.
- Parameters:
loctable (np.ndarray) – Table from locrates file
- join_float(val, unit=None)[source]¶
Helper function to join float values into space separated str.
- Parameters:
val (np.ndarray) – Array of floating point values
unit (float32/64) – Unit used for display string
- Returns:
(str) – String of values separated by spaces
- localize(crange, mrates, brates, sduration, bgduration, sc_pos, sc_quat, energies, sc_time, scat_opt)[source]¶
Perform the localization routine over all spectra.
- Parameters:
crange (np.ndarray(2, int32) – Array of energy channel IDs chosen for localization
mrates (np.ndarry(
ndet*nen, int32)) – Array of measured detector counts in each energy channelbrates (np.ndarry(
ndet*nen, int32)) – Array of estimated background counts in each energy channelsduration (float32) – Timescale of measured detector counts
bgduration (float32) – Timescale of estimated background counts
sc_pos (np.ndarray(float32)) – Spacecraft position x, y, z coordinates
sc_quat (np.ndarray(4, float64)) – Quaternion of the spacecraft. Last element is the scalar field.
energies (np.ndarray(
nen+ 1, float32)) – Array with end points of energy channel binssc_time (int64) – Spacecraft time in MET seconds
scat_opt (int32) – Scattering option. 1 means include scattering when computing the expected detector counts for a given spectrum. 0 means do not include scattering when computing expected detector counts.
- Returns:
(dict) – Dictionary object with information about best localization
- stdout(loc)[source]¶
Routine to print standard output from DoL.
- Parameters:
loc (dict) – Dictionary object from eval() with localization info
- to_GbmHealPix(loc, frame, grid_nearest=True, **kwargs)[source]¶
Converts a DoL localization dictionary to a
GbmHealPixprobability map- Parameters:
loc (dict) – Dictionary containing a chi2 array returned by the
eval()methodframe (
FermiFrame) – Frame object with spacecraft position and rotationgrid_nearest (bool) – Perform approximate nearest pixel interpolation between chi2 grid and GbmHealPix map when True.
- Returns:
(
GbmHealPix) – GbmHealPix probability map describing the localization
- write_chi2grid(path, scx, scy, scz, sc_pos, chi2)[source]¶
Write grid of chi2 values on the sky to a text file.
- Parameters:
path (str) – Path to output file
scx (np.ndarray(3, float64)) – Vector along +x axis of spacecraft
scy (np.ndarray(3, float64)) – Vector along +y axis of spacecraft
scz (np.ndarray(3, float64)) – Vector along +z axis of spacecraft
sc_pos (np.ndarray(3, float64)) – Spacecraft position
chi2 (np.ndarray(
npoints, float32)) – Grid of chi2 values on the sky