threeML.utils.data_builders package

Subpackages

Submodules

Module contents

class threeML.utils.data_builders.TimeSeriesBuilder(name: str, time_series: ~threeML.utils.time_series.time_series.TimeSeries, response=None, poly_order: int = -1, unbinned: bool = False, verbose: bool = True, restore_poly_fit=None, container_type=<class 'threeML.utils.spectrum.binned_spectrum.BinnedSpectrumWithDispersion'>, **kwargs)[source]

Bases: object

property background_counts_per_interval: ndarray
property background_poly_order

Get or set the background polynomial order

property bins
create_time_bins(start, stop, method='constant', **kwargs)[source]

Create time bins from start to stop with a given method (constant, siginificance, bayesblocks, custom). Each method has required keywords specified in the parameters. Once created, this can be used as a JointlikelihoodSet generator, or as input for viewing the light curve.

Parameters:
  • start – start of the bins or array of start times for custom mode

  • stop – stop of the bins or array of stop times for custom mode

  • method – constant, significance, bayesblocks, custom

  • dt – <constant method> delta time of the

  • sigma – <significance> sigma level of bins

  • min_counts – (optional) <significance> minimum number of counts per bin

  • p0 – <bayesblocks> the chance probability of having the correct bin configuration.

Returns:

fit_polynomial(**kwargs)[source]

Fit the polynominals to the selected time intervals. Must be called after set_background_interval. :param kwargs: :returns:

classmethod from_gbm_cspec_or_ctime(name, cspec_or_ctime_file, rsp_file, restore_background=None, trigger_time=None, poly_order=-1, verbose=True)[source]

A plugin to natively bin, view, and handle Fermi GBM TTE data. A TTE event file are required as well as the associated response

Background selections are specified as a comma separated string e.g. “-10-0,10-20”

Initial source selection is input as a string e.g. “0-5”

One can choose a background polynomial order by hand (up to 4th order) or leave it as the default polyorder=-1 to decide by LRT test

Parameters:
  • name – name for your choosing

  • tte_file – GBM tte event file

  • rsp_file – Associated TTE CSPEC response file

  • trigger_time – trigger time if needed

  • poly_order – 0-4 or -1 for auto

  • unbinned – unbinned likelihood fit (bool)

  • verbose – verbose (bool)

classmethod from_gbm_tte(name: str, tte_file: str, rsp_file=None, restore_background=None, trigger_time=None, poly_order: int = -1, unbinned: bool = True, verbose: bool = True, use_balrog: bool = False, trigdat_file=None, poshist_file=None, cspec_file=None)[source]

A plugin to natively bin, view, and handle Fermi GBM TTE data. A TTE event file are required as well as the associated response

Background selections are specified as a comma separated string e.g. “-10-0,10-20”

Initial source selection is input as a string e.g. “0-5”

One can choose a background polynomial order by hand (up to 4th order) or leave it as the default polyorder=-1 to decide by LRT test

Parameters:
  • name – name for your choosing

  • tte_file – GBM tte event file

  • rsp_file – Associated TTE CSPEC response file

  • trigger_time – trigger time if needed

  • poly_order – 0-4 or -1 for auto

  • unbinned – unbinned likelihood fit (bool)

  • verbose – verbose (bool)

  • use_balrog – (bool) if you have gbm_drm_gen installed, will build BALROGlike

  • trigdat_file – the trigdat file to use for location

  • poshist_file – the poshist file to use for location

  • cspec_file – the cspec file to use for location

classmethod from_konus_pha(name, pha_file, rsp_file, arf_file, restore_background=None, trigger_time=None, poly_order=-1, verbose=True)[source]

A plugin to natively bin, view, and handle Konus-Wind PHA data. One can choose a background polynomial order by hand (up to 4th order) or leave it as the default polyorder=-1 to decide by LRT test :param name: name for your choosing :param pha_file: Konus-Wind PHAII file :param rsp_file: Associated response file :param arf_file: Associated auxiliary response file :param trigger_time: trigger time if needed :param poly_order: 0-4 or -1 for auto :param verbose: verbose (bool)

classmethod from_lat_lle(name, lle_file, ft2_file, rsp_file, restore_background=None, trigger_time=None, poly_order=-1, unbinned=False, verbose=True)[source]

A plugin to natively bin, view, and handle Fermi LAT LLE data. An LLE event file and FT2 (1 sec) are required as well as the associated response

Background selections are specified as a comma separated string e.g. “-10-0,10-20”

Initial source selection is input as a string e.g. “0-5”

One can choose a background polynomial order by hand (up to 4th order) or leave it as the default polyorder=-1 to decide by LRT test

Parameters:
  • name – name of the plugin

  • lle_file – lle event file

  • ft2_file – fermi FT2 file

  • rsp_file – lle response file

  • trigger_time – trigger time if needed

  • poly_order – 0-4 or -1 for auto

  • unbinned – unbinned likelihood fit (bool)

  • verbose – verbose (bool)

classmethod from_phaII()[source]
classmethod from_polar_polarization(name, polar_hdf5_file, polar_hdf5_response, restore_background=None, trigger_time=0.0, poly_order=-1, unbinned=True, verbose=True)[source]
classmethod from_polar_spectrum(name, polar_hdf5_file, restore_background=None, trigger_time=0.0, poly_order=-1, unbinned=True, verbose=True)[source]
get_background_parameters()[source]

Returns a pandas DataFrame containing the background polynomial coefficients for each channel.

read_bins(time_series_builder) None[source]

Read the temporal bins from another binned TimeSeriesBuilder instance and apply those bins to this instance

Parameters:

time_series_builderbinned time series builder to copy

Returns:

save_background(file_name: str, overwrite=False) None[source]

save the background to and HDF5 file. The filename does not need an extension. The filename will be saved as <filename>_bkg.h5

Parameters:
  • file_name – name of file to save

  • overwrite – to overwrite or not

Returns:

set_active_time_interval(*intervals, **kwargs)[source]

Set the time interval to be used during the analysis. For now, only one interval can be selected. This may be updated in the future to allow for self consistent time resolved analysis. Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_active_time_interval(“0.0-10.0”)

which will set the energy range 0-10. seconds. :param options: :param intervals: :return:

set_background_interval(*intervals, **kwargs)[source]

Set the time interval to fit the background. Multiple intervals can be input as separate arguments Specified as ‘tmin-tmax’. Intervals are in seconds. Example:

set_background_interval(“-10.0-0.0”,”10.-15.”)

Parameters:
  • *intervals

  • **kwargs

Returns:

none

property significance_per_interval: ndarray
property time_series: TimeSeries
to_polarlike(from_bins=False, start=None, stop=None, interval_name='_interval', extract_measured_background=False)[source]
to_spectrumlike(from_bins: bool = False, start=None, stop=None, interval_name: str = '_interval', extract_measured_background: bool = False) list[source]

Create plugin(s) from either the current active selection or the time bins. If creating from an event list, the bins are from create_time_bins. If using a pre-time binned time series, the bins are those native to the data. Start and stop times can be used to control which bins are used.

Parameters:
  • from_bins – choose to create plugins from the time bins

  • start – optional start time of the bins

  • stop – optional stop time of the bins

  • extract_measured_background – Use the selected background rather than a polynomial fit to the background

  • interval_name – the name of the interval

Returns:

SpectrumLike plugin(s)

property total_counts_per_interval: ndarray
property tstart: float

start time of the active interval

Type:

return

property tstop: float

stop time of the active interval

Type:

return

view_lightcurve()[source]

view the binned light curve

Parameters:
  • start – start time of viewing

  • stop – stop time of viewing

  • dt – cadance of binning

  • use_binner – use the binning created by a binning method

write_pha_from_binner(file_name: str, start=None, stop=None, overwrite=False, force_rsp_write=False, extract_measured_background=False)[source]

Write PHA fits files from the selected bins. If writing from an event list, the bins are from create_time_bins. If using a pre-time binned time series, the bins are those native to the data. Start and stop times can be used to control which bins are written to files

Parameters:
  • file_name – the file name of the output files

  • start – optional start time of the bins

  • stop – optional stop time of the bins

  • overwrite – if the fits files should be overwritten

  • force_rsp_write – force the writing of RSPs

  • extract_measured_background – Use the selected background rather than a polynomial fit to the background

Returns:

None

class threeML.utils.data_builders.TransientLATDataBuilder(triggername, **init_values)[source]

Bases: object

display(get=False)[source]

Display the current set parameters

classmethod from_saved_configuration(triggername, config_file)[source]

Load a saved yaml configuration for the given trigger name

Parameters:
  • triggername – Trigger name of the source in YYMMDDXXX

  • config_file – the saved yaml configuration to use

Returns:

Return type:

run(include_previous_intervals=False, recompute_intervals=False)[source]

run GtBurst to produce the files needed for the FermiLATLike plugin

save_configuration(filename)[source]

Save the current configuration to a yaml file for use later. Suggested extension is .yml

Parameters:

filename – the yaml file name to save to

Returns:

Return type:

to_LATLike()[source]