contur.scan package

Submodules

contur.scan.grid_tools module

contur.scan.grid_tools.find_param_point(fileList, tag, paramList)[source]

Given a list of parameters and values, find the appropriate yoda file in a tree and return it. If no params given, just return the existing list

contur.scan.grid_tools.grid_loop(scan_path=None, patterns=None, extract=False, clean=True, unmerge=False, archive=False, check=False, check_all=False, resub=False, queue='')[source]

General purpose function for looking through all the files below scan_path and performing various operations. Unless told otherwise (by setting unmerge=True) it will always merge any unmerged yodas and zip the result.

Parameters
  • scan_path – the top directory to start from

  • patterns – if extract, then extract the analyses that match this pattern

  • extract – extract analyses matching pattern into new directory

  • clean – remove unnecessary files

  • unmerge – remove the merged yoda files and decompress the raw yoda files

  • archive – if true, remove unneccessary files and compress the rest

  • check – look for batch jobs that ran and failed

  • check_all – look for batch jobs that either ran and failed, or were never run

  • resub – resubmit any jobs identified by check ot check_all

  • queue – queue to resubmit them to

Returns

return a list of all the directories containing valid yoda files.

contur.scan.grid_tools.is_unmerged_yoda(filename)[source]

return true if the the file name is consistent with being a raw (ie unmerged) yoda file output from a job

contur.scan.grid_tools.is_unmerged_yoda_gz(filename)[source]

return true if the the file name is consistent with being a gzipped raw (ie unmerged) yoda file output from a job

contur.scan.grid_tools.merge_yodas(root, files)[source]

make a zipped, merged yoda file from any unmerged ones in the file list

Parameters
  • root – absolute path to the directory the files are in

  • files – list of filenames to check for merging.

contur.scan.merge_grids module

contur.scan.merge_grids.appears(s, terms=[])[source]
contur.scan.merge_grids.fileTypeInList(fileTypes, fileList, exclude=[], include=[])[source]
contur.scan.merge_grids.filesEqual(origFile, newFile)[source]
contur.scan.merge_grids.getEnergy(fileName)[source]
contur.scan.merge_grids.getEnergyPosition(energy)[source]
contur.scan.merge_grids.getSeed(fileName)[source]
contur.scan.merge_grids.merge_main(argv)[source]
contur.scan.merge_grids.removeBrokenYodas(logFile, yodaFiles)[source]
contur.scan.merge_grids.removeYoda(logFile, lineNumber, yodaFiles)[source]

contur.scan.os_functions module

Functions that operate directly on the operating/file system in a contur grid.

class contur.scan.os_functions.WorkingDirectory(temp_working_directory)[source]

Bases: object

Context manager to temporarily change working directory

contur.scan.os_functions.delete_files(root)[source]

delete all the superfluous files in root

the superfluous files are defined in contur.config.unneeded_files

contur.scan.os_functions.gen_format_dict(parameters, idx)[source]

Create dictionary to use in formatting template run card.

Parameters
  • parameters (dict) – (parameter, value) pairs

  • idx – numerical ID (nnnn) of the paramter point

contur.scan.os_functions.get_exclusions(filename='')[source]

Get points that we will exclude from param file

Parameters

filename – name of the parameter file to read. If empty, the value from contur.config is used.

contur.scan.os_functions.make_run_point_directory(run_point, output_dir)[source]

If run point directories don’t exist, make them and return path

contur.scan.os_functions.read_param_steering_file(filename='')[source]

Read in the parameter card and convert to a python dict

Parameters

filename – name of the steering file. If empty, the value from contur.config is used

contur.scan.os_functions.read_sampled_map(input_dir)[source]

read the sampled_points.dat file

Returns

sampled_points: the sampled points as a ConfigObj

contur.scan.os_functions.sanitise_inputs(section, key)[source]

Function specific to config obj to walk and convert key values.

contur.scan.os_functions.write_generator_files(templates, param_dict, run_point, run_point_path, pipe_hepmc, seed, num_events, beam)[source]

Write the generator steering files, based on templates, formatted with parameter values. Generator is determined by contur.config.mceg

Parameters
  • templates – list of template files

  • param_dict – dictionary of event generator parameters

  • run_point – the numeric id of the run point

  • run_point_path – the full path of the run point directory

  • pipe_hepmc (bool) – run the hepmc events from the generator through a unix pipe to rivet

  • seed – random number seed for the event generator

  • num_events – number of MC event generator events per parameter point

  • beam – collider beam being generated

contur.scan.os_functions.write_param_dat(param_dict, run_point_path, run_point)[source]

Write param file containing parameter values for given run point.

contur.scan.os_functions.write_sampled_map(output_dir, param_dict)[source]

write a config object of the sampled points to a text file (sampled_points.dat) in the output_dir containing parameters and values scanned in a grid beneath output_dir.

Parameters
  • output_dir – directory to write the file to

  • param_dict – dictionary of

contur.scan.scanning_functions module

contur.scan.scanning_functions.check_param_consistency(param_dict, template_path)[source]

Check that parameters in param file match those in templates.

contur.scan.scanning_functions.coords_from_axes(param_dict, param_names=None)[source]

Read the param_dict that has been dressed with axes values and build a grid to return

contur.scan.scanning_functions.create_axes(param_config_dict)[source]

this is a bit of hybrid mess, should just make the grid directly out of these axes and attach to object I think?….

contur.scan.scanning_functions.filter_param_dict_by_key(param_dict, expr)[source]

filter the parameter dictionary based on the key

Parameters
  • param_dict – dictionary containing the model parameters.

  • expr – expression which, if true, means the parameter passes

contur.scan.scanning_functions.generate_points(param_dict)[source]

Generate points to sample using given mode.

parameters:

param_dict: Dictionary with parameter names as keys each containing another dictionary with keys ‘range’ and ‘values’.

returns:
  • param_dict: Same param_dict as was passed in to the function but now filled with points.

  • num_points: The number of points generated.

contur.scan.scanning_functions.invalid_params(run_point, param_dict)[source]

return false is any of the params are invalid for this run_point

contur.scan.scanning_functions.load_df_points(param_dict)[source]

Loads the parameter points for DATAFRAME mode from the given Pickle file(s).

contur.scan.scanning_functions.read_old_points(map_file)[source]

Read coordinates of points sampled in .map file

contur.scan.scanning_functions.read_template_file(template_file_in)[source]

Read in template files and store contents in dictionary

contur.scan.scanning_functions.run_scan(param_dict, beams, num_points, template_file, out_dir, pipe_hepmc, seed, num_events, exclusions=[])[source]

Given points defined in param_dict, create run point directories and populate with MCEG template file and parameter file.

Parameters
  • param_dict – Dictionary with parameter names as keys each containing another dictionary with keys ‘range’ and ‘values’.

  • out_dir – top level output directory for the grid scan

  • pipe_hepmc – is True, running hepmc events to a pipe for rivet to read. otherwise using a native generator rivet interface.

  • seed – random number seed

  • num_events – number of events to generate

  • exclusions – list of run points to be excluded

Returns

None

contur.scan.scanning_functions.sample_fromvalues(param_dict, num_points)[source]

for read mode we return the grid by having already worked out each axis (allows us to mix LIN and LOG)

contur.scan.zoom_params module

contur.scan.zoom_params.generate_zoom_params(args)[source]

This function will investigate an n-dimensional .map file and rescale each parameter by checking for regions where there is little change. This function will investigate each point, and find the change is CLs values of all adjacent points. It will then find the average difference over all adjacent points. It will then consider a point inactive if the average CLs change is less than the threshold. For each parameter, this function will create a new range which excludes all inactive values at the maximum and minimum value for that parameter. If all points in the range of a parameter are considered inactive, it will return the original parameter range.

Parameters
  • replace – Boolean flag to replace new param file with old one

  • map_fname – Name/path of map file

  • param_old_fname – Name/path of original param file

  • param_new_fname – Name/path of new generated param file

  • thresh – Threshold to consider a point unchanging/unimportant

contur.scan.zoom_params.get_expanded_diffs(orig, mod_vals)[source]
contur.scan.zoom_params.is_important_val(point_val, important_vals)[source]

Module contents