contur.util package

Submodules

contur.util.file_readers module

contur.util.file_readers.get_generator_values(root, files, matrix_elements, particles)[source]

read and parse the generator log files to get subprocess cross sections and/or particle properties.

contur.util.file_readers.get_histos(filename)[source]

Get signal histograms from a generated YODA file. Loops over all yoda objects in the input file looking for valid signal histograms.

Ignores REF and THY (which are read elsewhere) and RAW histograms.

Param filename:

(`string`) name of yoda input file.

Returns:

  • mchistos = dictionary containing {path, ao} pairs for candidate signal histograms.

  • xsec = yoda analysis object containing the generated xsec and its uncertainty

  • Nev = yoda analysis object containing sum of weights, sum of squared weight, number of events

contur.util.file_readers.read_param_point(file_path)[source]

Read a parameter file and return dictionary of (strings of) contents

Parameters:

file_path (string) – full path the the parameter file

Returns:

dictionary of parameter (parameter_name, value) pairs

contur.util.file_readers.read_slha_file(root, slha_file, block_list)[source]

read requested blocks from an SLHA1 file (if found)

returns a dictionary blocks_dict{ block: {name: value} } for each block in block_list.

the name of the block is prepended to each parameter, for disambiguation when written to the map file.

for the MASS block the binwidth and binoffset will be applied, if provided. @TODO that would be better handled at the visualisation/plotting step?

Parameters:
  • root – path to SLHA file

  • slha_file – name of SLHA file

  • block_list – list of SLHA blocks to read

Returns:

dictionary (blockname, (name, value))

contur.util.utils module

Miscellaneous helper functions that may be used by more than one contur submodule

class contur.util.utils.Plot[source]

Bases: dict

A tiny Plot object to help writing out the head in the .dat file

contur.util.utils.analysis_select(name, veto_only=False)[source]

return true if the analysis passes the select/veto conditions, false otherwise

contur.util.utils.cleanupCommas(text)[source]

Replace commas and multiple spaces in text by single spaces

contur.util.utils.compress_particle_info(name, info)[source]

Turns a dictionary of properties of the particle <name> into simple string-formatted dictionary suitable for storing as parameters: (removes commas, backslashes and spaces and puts <particlename>_<property>)

contur.util.utils.compress_xsec_info(info, matrix_elements)[source]

compresses a dict of subprocess cross sections into a format they can be stored as AUX params (removes commas, backslashes and spaces and puts AUX:<name>_<property>) Also, if matrix_elements is not None, then remove any which are not in it.

contur.util.utils.executeScript(script, plot_dir='', multiprocess=False, shared_modules_list=[], print_script=True)[source]

execute a single Python script, with argument string arg

contur.util.utils.find_ref_file(analysis)[source]

return the REF data file name and path for analysis with name a_name if not found, return an empty string.

contur.util.utils.find_thy_predictions(analysis, prediction_id=None)[source]

return the THY data file name and path for analysis with name a_name and chosen ID. if not found, return an empty string.

contur.util.utils.get_beam_dirs(beams)[source]

return a dict of the paths (under cfg.grid) containing the name of each beam, keyed on beam beams = a list of beams to look for.

contur.util.utils.get_inspire(inspire_id)[source]

Function to query InspireHEP database and return a dictionary containing the metadata

extracted/adapted from rivet-findid

if contur.config.config.offline is True, no web query is made and returned variables are set to “Offline” if contur.config.config.offline is False, but web query fails, returned variables are set to “Failed”

Parameters:

inspire_id (string) – the ID of the publication on Inspire

Returns:

pub_data dictionary – selected metadata as a dictionary of strings

contur.util.utils.get_numcores(nreq)[source]
contur.util.utils.hack_journal(bibtex)[source]

Add a dummy journal field if absent, to stop sphinx barfing.

contur.util.utils.insert_line_break(string, length=25)[source]

insert a LaTeX

ewline after <length> characters,

so that labels stay on the plot canvas

contur.util.utils.make_mpl_plots(pyScripts, numcores=1)[source]
contur.util.utils.mkoutdir(outdir)[source]

Function to make an output directory if it does not already exist. Also tests if an existing directory is write-accessible.

contur.util.utils.newlogspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None)[source]

Numpy logspace returns base^start to base^stop, we modify this here so it returns logspaced between start and stop

contur.util.utils.pairwise(iterable)[source]

Iterates pairwise over a list. Example: s -> (s0, s1), (s2, s3), (s4, s5), ..

contur.util.utils.permission_to_continue(message)[source]

Get permission to continue program

contur.util.utils.progress_bar(iterable, **kwargs)[source]
contur.util.utils.remove_brackets(text)[source]

remove any brackets from text, and try to turn it into a float. return None if not possible.

contur.util.utils.splitPath(path)[source]

Take a yoda histogram path and return the analysis name and the histogram name :arg path: the full path of a yoda analysis object :type: String

contur.util.utils.walklevel(some_dir, level=1)[source]

Like os.walk but can specify a level to walk to useful for managing directories a bit better

https://stackoverflow.com/questions/229186/os-walk-without-digging-into-directories-below

contur.util.utils.write_banner()[source]

Write a text banner giving the version and pointing to the documentation

Module contents