contur.scan package

Submodules

contur.scan.grid_tools module

contur.scan.grid_tools.find_param_point(grid_name, tag, paramList, verbose=False)[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(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.

the top directory to start from is taken from config.grid

Parameters:
  • extract – extract analyses with names in the strong config.onlyAnalyses into new directory

  • clean – remove unnecessary files

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

  • archive – if true, remove unnecessary files (unless told not to) 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.hide_directory(dirname)[source]

return true or false depending on if the input directory name is in the list of directories that should be hidden/ignored when looking for 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.is_valid_yoda_filename(filename)[source]

return true if the the file name is consistent with being a merged yoda file

contur.scan.grid_tools.merge_yodas(root, files, has_subdir)[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.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 cfg.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 cfg 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 cfg 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 cfg.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, single, 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)

Module contents