Core Modules

combiner.py

Function to combine data read by a LklCom reader class

likelihood_combiner.combiner.combiner(sigmav_range, LklCom_reader_class, output, sigmavULs=None, sigmavULs_Jnuisance=None, simulation_counter=None, total_number_of_simulation=None, simulations=[0])

Combine data read by one of the LklCom reader class for a given sigmav range.

Parameters
  • sigmav_range (numpy.ndarray of type numpy.float32) – sigmav range (ascending).

  • LklCom_reader_class (likelihood_combiner.reader.LklCom) – class of the lklcom to handle the reading of the likelihood or ts tables.

  • output (path) – path to the lklcom results directory or hdf5 file.

  • sigmavULs (multiprocessing.managers.DictProxy) – shared multiprocessing dict of the sigmav upper limits.

  • sigmavULs_Jnuisance (multiprocessing.managers.DictProxy) – shared multiprocessing dict of the sigmav upper limits including the J-Factors as a nuisance parameter.

  • simulation_counter (multiprocessing.Manager.Value) – current status of the simulation progress (needed for the progress bar with multiprocessing).

  • total_number_of_simulation (int) – total number of the simulation considered (needed for the progress bar with multiprocessing).

  • simulations (list of type int) – list of the numbers of the simulations.

class likelihood_combiner.reader.LklCom(LklCom_jfactor_class, channel=None, combination_data=None, simulations=None, sigmav_precision=3)

Abstract class for reading likelihood or ts tables.

class likelihood_combiner.reader.LklCom_hdf5(LklCom_jfactor_class, channel=None, combination_data=None, sigmav_precision=3)

Subclass to read likelihood or ts tables from the lklcom hdf5 file.

class likelihood_combiner.reader.LklCom_txtdir(LklCom_jfactor_class, channel=None, combination_data=None, sigmav_precision=3)

Subclass to read likelihood or ts tables from the gLike txt files.

class likelihood_combiner.reader.LklCom_custom(LklCom_jfactor_class, channel, combination_data, simulations, sigmav_precision=3)

Subclass to read likelihood or ts tables from the custom tstables dict. Only recommended to use for by passing lklcom or gLike data formats.

class likelihood_combiner.jfactor.JFactor(channel=None, sources=None, collaborations=None, resource=None, combination_data=None, precision=2, logJ=None, DlogJ=None, jnuisance=True)

Abstract class for handling the J-Factor.

class likelihood_combiner.jfactor.Bonnivard(channel, sources, collaborations, resource=None, combination_data=None, precision=2, jnuisance=True)

Jfactor class for handling the J-Factor set from Bonnivard et al. (https://arxiv.org/abs/1504.02048).

class likelihood_combiner.jfactor.GeringerSameth(channel, sources, collaborations, resource=None, combination_data=None, precision=2, jnuisance=True)

Jfactor class for handling the J-Factor set from Geringer-Sameth et al. (https://arxiv.org/abs/1408.0002).

class likelihood_combiner.jfactor.Custom(logJ, DlogJ, channel=None, jnuisance=True)

Custom class to hardcode the J-Factors and it’s uncertainties.

Modules

plotter.py

Functions to make DM plots

likelihood_combiner.plotter.plot_sigmav_CLbands_as_lines_from_hdf5(channel, file, key='sigmavULs_Jnuisance', ax=None, **kwargs)

Plot the sigmav confidence limit bands as lines from hdf5 file.

Parameters
  • channel (str) – name of the channel.

  • file (path) – path to a panda readable hdf5 file.

  • key (str) – name of the table of the hdf5 file.

  • ax (matplotlib.pyplot.axes) –

  • kwargs (kwargs for matplotlib.pyplot.plot) –

Returns

ax

Return type

matplotlib.pyplot.axes

likelihood_combiner.plotter.plot_sigmav_CLbands_as_lines_from_txt(file, ax=None, **kwargs)

Plot the sigmav confidence limit bands as lines from txt file (produced via gLike).

Parameters
  • file (path) – path to a txt file.

  • ax (matplotlib.pyplot.axes) –

  • kwargs (kwargs for matplotlib.pyplot.plot) –

Returns

ax

Return type

matplotlib.pyplot.axes

likelihood_combiner.plotter.plot_sigmav_CLbands_from_hdf5(channel, file, key='sigmavULs_Jnuisance', ax=None)

Plot the sigmav confidence limit bands from hdf5 file.

Parameters
  • channel (str) – name of the channel.

  • file (path) – path to a panda readable hdf5 file.

  • key (str) – name of the table of the hdf5 file.

  • ax (matplotlib.pyplot.axes) –

Returns

ax

Return type

matplotlib.pyplot.axes

likelihood_combiner.plotter.plot_sigmav_CLbands_from_txt(file, ax=None)

Plot the sigmav confidence limit bands from txt file (produced via gLike).

Parameters
  • file (path) – path to a txt file.

  • ax (matplotlib.pyplot.axes) –

  • kwargs (kwargs for matplotlib.pyplot.plot) –

Returns

ax

Return type

matplotlib.pyplot.axes

likelihood_combiner.plotter.plot_sigmav_ULs_from_hdf5(channel, file, key='sigmavULs_Jnuisance', ax=None, **kwargs)

Plot the sigmav upper limits from hdf5 file.

Parameters
  • channel (str) – name of the channel.

  • file (path) – path to a panda readable hdf5 file.

  • key (str) – name of the table of the hdf5 file.

  • ax (matplotlib.pyplot.axes) –

  • kwargs (kwargs for matplotlib.pyplot.plot) –

Returns

ax

Return type

matplotlib.pyplot.axes

likelihood_combiner.plotter.plot_sigmav_ULs_from_txt(file, ax=None, **kwargs)

Plot the sigmav upper limits from txt file (produced via gLike).

Parameters
  • file (path) – path to a txt file.

  • ax (matplotlib.pyplot.axes) –

  • kwargs (kwargs for matplotlib.pyplot.plot) –

Returns

ax

Return type

matplotlib.pyplot.axes

likelihood_combiner.plotter.plot_thermal_relic(ax=None, **kwargs)

Plot the thermal relic, which was taken from Steigman G., Dasgupta B, and Beacom J. F., Precise relic WIMP abundance and its impact onsearches for dark matter annihilation, Phys.Rev. D86(2012) 023506, [arXiv:1204.3622].

Parameters
  • ax (matplotlib.pyplot.axes) –

  • kwargs (kwargs for matplotlib.pyplot.plot) –

Returns

ax

Return type

matplotlib.pyplot.axes

io.py

Functions to translate between data formats

likelihood_combiner.io.gLikeLimits_to_lklcomLimits(input_dir, output_file)

Translate gLike limits in txt files into lklcom results hdf5 file.

Parameters
  • input_dir (path) – path to the input directory, which holds txt files of the results of gLike or any other framework.

  • output_file (path) – path to the lklcom results hdf5 file.

likelihood_combiner.io.gLike_to_lklcom(input_dir, output_file, mode='w')

Translate gLike txt files into lklcom hdf5 file.

Parameters
  • input_dir (path) – path to the input directory, which holds txt files in gLike format.

  • output_file (path) – path to the lklcom hdf5 file.

  • mode (str) – mode to open the lklcom hdf5 file.

likelihood_combiner.io.gloryduck_reducer(input_dir, reduce=True, shift=True)

Reduce and/or shift the GloryDuck txt files. Important note: The channel have to be in the filename!

Parameters
  • input_dir (path) – path to input directory.

  • reduce (bool) – flag, if the txt files should be reduced/compressed.

  • shift (bool) – flag, if the txt files should be shifted (TS values minimum to zero).

likelihood_combiner.io.lklcom_to_gLike(input_file, output_dir, reduce=True)

Translate the lklcom hdf5 file into gLike txt files.

Parameters
  • input_file (path) – path to the lklcom hdf5 input file.

  • output_dir (path) – path to the output directory.

  • reduce (bool) – flag, if the txt files should be reduced/compressed.

likelihood_combiner.io.merge_to_lklcom(input_dir, output_file)

Merge single lklcom hdf5 file produced by the cluster to the lklcom results hdf5 file.

Parameters
  • input_dir (path) – path to the input directory, which holds txt files of the results of gLike or any other framework.

  • output_file (path) – path to the lklcom results hdf5 file.

likelihood_combiner.io.write_to_lklcom(collaboration, source, channel, logJ, sigmav_range, lkl_dict, output_file, mode='a', simulation=- 1)

Write/append a given likelihood table into lklcom hdf5 file. lkl_dict is a dictionary with the DM mass as keys (str) and likelihood or ts values (ascending) as values (numpy.ndarray of type numpy.float32).

Parameters
  • collaboration (str) – name of the collaboration.

  • source (str) – name of the source.

  • channel (str) – name of the channel.

  • logJ (numpy.float32) – value of the log J-Factor.

  • sigmav_range (numpy.ndarray of type numpy.float32) – sigmav range (ascending).

  • lkl_dict (dict) – likelihood data as dictionary with the DM mass as keys (str) and likelihood or ts values (ascending) as values (numpy.ndarray of type numpy.float32).

  • output_file (path) – path to the lklcom hdf5 file.

  • mode (str) – mode to open the lklcom hdf5 file.

  • simulation (int) – number of the simulation.

sensitivity.py

Function to extract the upper limits and sensitivity.

likelihood_combiner.sensitivity.compute_sensitivity(sigmav_range, ts_dict, confidence_level=2.71)

Extract the upper limits and sensitivity.

Parameters
  • sigmav_range (numpy.ndarray of type numpy.float32) – sigmav range (ascending).

  • ts_dict (dict) – likelihood data as dictionary with the DM mass as keys (str) and likelihood or ts values (ascending) as values (numpy.ndarray of type numpy.float32).

  • confidence_level (float) – confidence level to extract the upper limit

Returns

  • limits (dict) – limits as dictionary with the DM mass as keys (str) and upper limit as values (numpy.float32).

  • sensitivities (dict) – sensitivities as dictionary with the DM mass as keys (str) and sensitivity as values (numpy.float32).

utils.py

Helper functions, which might be useful.

likelihood_combiner.utils.get_sigmav_range(sigmav_min=1e-28, sigmav_max=1e-18, sigmav_nPoints=1001, precision=3)

Retrieve the sigmav range in log-spacing.

Parameters
  • sigmav_min (float) – minimum value of the sigmav range.

  • sigmav_max (float) – maximum value of the sigmav range.

  • sigmav_nPoints (int) – number of points in the sigmav range.

  • precision (int) – precision of the returning sigmav range.

Returns

sigmav_range – sigmav range (ascending).

Return type

numpy.ndarray of type numpy.float32

likelihood_combiner.utils.progress_bar(current_value, total)

Print progress bar in parallel processing mode.

Parameters
  • current_value (int) – current status of the process.

  • total (int) – total number of simulation.

likelihood_combiner.utils.round_sigmav_range(sigmav_range, precision=3)

Round the sigmav range.

Parameters
  • sigmav_range (numpy.ndarray of type numpy.float32) – sigmav range (ascending).

  • precision (int) – precision of the returning sigmav range.

Returns

sigmav_range – rounded sigmav range (ascending).

Return type

numpy.ndarray of type numpy.float32

local.py

Function to automatically set up multiprocessing (only Linux supported)

likelihood_combiner.local.run_local(settings, input, output)

Run LklCom on a local linux machine. Support multiprocessing. This function only works for linux users, because MacOS or Windows don’t allow you to set up multiprocessing this way. See: https://www.pythonforthelab.com/blog/differences-between-multiprocessing-windows-and-linux/

Parameters
  • settings (dict) – settings of the combination, following the minimum skeleton (see example config file for more documentation): {‘Hardware’ : {‘cpu_counts’: int}, ‘Data’ : {‘buildin_j_factors’: string, ‘j_nuisance’: boolean, ‘simulations’: int}, ‘Configuration’ : {‘channels’: numpy.ndarray of type string, ‘sources’: numpy.ndarray of type string, ‘collaborations’: dictionary}}

  • input (str) – path to the input file or directory

  • output (str) – path to the output hdf5 file

cluster.py

Helper function to run LklCom on a cluster/coomputing farm

likelihood_combiner.cluster.run_cluster(settings, channel, input=None, output=None, simulation=0)

Run LklCom on a cluster/computing farm.

Parameters
  • settings (dict) – settings of the combination, following the minimum skeleton (see example config file for more documentation): {‘Data’ : {‘buildin_j_factors’: string, ‘j_nuisance’: boolean, ‘simulations’: int}, ‘Configuration’ : {‘channels’: numpy.ndarray of type string, ‘sources’: numpy.ndarray of type string, ‘collaborations’: dictionary}}

  • channel (string) – name of the channel.

  • input (string) – path to the input file or directory.

  • output (string) – path to the output directory.

  • simulation (int) – number of the simulation.