gravelamps.core.file_handling

Gravelamps File Handling

Following are functions handling input and output files from the Gravelamps programs.

Written by Mick Wright 2022

Routines

create_bilby_pipe_config

Generate a bilby_pipe configuration dictionary

create_final_dag

Generate the overall gravelamps DAG

create_injection_file

Generate a bilby_pipe injection file

get_config

Retrieves user INI configuration from arguments

get_output_directories

Retrieves the output directories

retrieve_interpolator_files

Retrieves the files necessary for lens interpolator generation

grid_file_handler

Handles the interpolator grid file generation and locations

data_file_handler

Handles the interpolator data file generation and locations

read_event_file

Read in event information file

read_golum_reweighted_file

Read in GOLUM reweighted results and seperate out sample source parameter and lensing observable values

read golum_result_file

Read in GOLUM results file and seperate out sample source parameter and lensing observable values

Functions

create_bilby_pipe_config(config, args, ...)

Generates a bilby_pipe configuration dictionary

create_final_dag(config, output_directories)

Generate overall Gravelamps DAG.

create_injection_file(config)

Generate bilby_pipe injection file.

get_config(args)

Retrieves user INI configuration from arguments

get_output_directories(config[, from_config])

Retrieves the output directories.

retrieve_interpolator_files(config, args)

Retrieves files necessary for generation of the lens interpolator

grid_file_handler(config, args, data_subdirectory, ...)

Handles the interpolator grid file generation and locations

data_file_handler(args, data_subdirectory, file_dict)

Handles the interpolator data file generation and locations.

read_event_file(args)

Read in event information file

read_golum_reweighted_file(filepath)

Read in GOLUM reweighted results and seperate out sample source parameter and lensing observable

read_golum_result_file(filepath, ...)

Read in GOLUM result file and seperate out sample source parameter and lensing observable

Module Contents

gravelamps.core.file_handling.create_bilby_pipe_config(config, args, output_directories, **kwargs)

Generates a bilby_pipe configuration dictionary

Parameters:
configconfigparser.ConfigParser

Object containing settings from INI file

argsargparse.Namespace

Object containing commandline arguments to the program

output_directoriesdict

Contains the output directories for the run

injection_filestr, optional

Path of file containing injection data

analysis_waveform_argumentsdict, optional

Arguments dictionary to the analysis waveform generator

injection_waveform_argumentsdict, optional

Arguments dictionary for the injection waveform generator

Returns:
bilby_pipe_configdict

Contains the configuration settings for a bilby_pipe run

gravelamps.core.file_handling.create_final_dag(config, output_directories)

Generate overall Gravelamps DAG.

This DAG will contain the jobs to be submitted to the HTCondor scheduler with correct parent child linking. Lens generation jobs will be run first and may run with no linking to each other. These jobs form the parents of the bilby_pipe inference runs using the lensed waveforms.

Parameters:
configconfigparser.ConfigParser

Object containing settings from INI file

output_directoriesdict

Contains the output directories for the run

Returns:
final_dagstr

Path to the gravelamps DAG file

gravelamps.core.file_handling.create_injection_file(config)

Generate bilby_pipe injection file.

Parameters:
configconfigparser.ConfigParser

Object containing settings from INI file

Returns:
injection_filestr

Path to the created bilby_pipe injection file

gravelamps.core.file_handling.get_config(args)

Retrieves user INI configuration from arguments

Parameters:
argsargparse.Namespace

Object containing commandline arguments to program

Returns:
configconfigparser.ConfigParser

Object containing settings from INI file

Raises:
IOError

Where the INI file is not specified within the arguments or cannot be read

gravelamps.core.file_handling.get_output_directories(config, from_config=True)

Retrieves the output directories.

The output directories specified are the top level output directory, followed by data and submit subdirectories with the specified names, ‘data’, and ‘submit’.

The top level directory is typically specified within the user specified INI file. This will fallback to the current working directory, or can be specified to directly run presuming such. These folders will be created if they are not already extant.

Parameters:
configconfigparser.ConfigParser

Object containing settings from INI file

from_configbool, optional

Flag to ignore the INI and set the top level directory to the current directory

Returns:
output_dir_dictdict

Contains the output top level directory and submit and data subdirectories in the specified keys.

gravelamps.core.file_handling.retrieve_interpolator_files(config, args)

Retrieves files necessary for generation of the lens interpolator

Will proceed if the file does not exist—specifying that it needs to be created. Will throw exception if a file that does not exist is specified to exist.

Parameters:
configconfigparser.ConfigParser

Object containing settings from INI file

argsargparse.Namespace

Object containing commandline arguments to program

Returns:
file_dictdict

Contains dimnesionless_frequency, source_position, amplification_factor_real, amplification_factor_imag keys. Each of these is a string path to file containing the specified data for the lens interpolator generation.

Raises:
IOError

In case where a file is specified in the INI that does not exist

gravelamps.core.file_handling.grid_file_handler(config, args, data_subdirectory, file_dict)

Handles the interpolator grid file generation and locations

These files specify the dimensionless frequency and source position grid structure that is interpolated over for the amplification factor data. These files may be directly specified in the INI, or may be constructed if not. User will be warned if the amplification factor files are defined without also defining the grid files, since the grid may not be accurate if generated for pre-existing data.

Parameters:
configconfigparser.ConfigParser

Object containing settings from INI file

argsargparse.Namesapce

Object containing commandline arguments to program

data_subdirectorystr

Path to the subdirectory containing data files

file_dictdict

Contains either location of grid files, or None indicating these files require generation

Returns:
lens_file_dictdict

Contains locations of completed grid files. Equivalent to file_dict if these are specified in the data_subdirectory.

gravelamps.core.file_handling.data_file_handler(args, data_subdirectory, file_dict)

Handles the interpolator data file generation and locations.

These files specify the real and imaginary components of the amplification factor data that forms the base of the interpolator objects. These files may be directly specified in the INI or may not be, specifying that they need generation. This handler does not run the generation itself due to the computational complexity, instead it specifies the number of files that are complete.

Parameters:
argsargparse.Namespace

Object containing commandline arguments to program

data_subdirectorystr

Path to the subdirectory containing the data files

file_dictdict

Contains either the path to the files, or None to indicate they require generation

Returns:
lens_file_dictdict

Contains the path to the files for construction of lens interpolator. Equivalent to file_dict if these files are specified in data_subdirectory

complete_filesint

Number of data files that are complete

gravelamps.core.file_handling.read_event_file(args)

Read in event information file

Parameters:
argsargparse.Namespace

Object containing commandline arguments to the program

Returns:
event_datadict

Information about the event

gravelamps.core.file_handling.read_golum_reweighted_file(filepath)

Read in GOLUM reweighted results and seperate out sample source parameter and lensing observable values

Parameters:
filepathstr

Path to the GOLUM reweighted result file

Returns:
source_parametersdict

Sample source parameter values

lens_observablesdict

Sample lensing observable values

gravelamps.core.file_handling.read_golum_result_file(filepath, source_parameter_list, lens_observable_list)

Read in GOLUM result file and seperate out sample source parameter and lensing observable values

Parameters:
filepathstr

Path to the GOLUM result file

source_parameter_listList[str]

Names of source parameters

lens_observable_listList[str]

Names of lens observables

Returns:
source_parametersdict

Sample source parameter values

lens_observablesdict

Sample lensing observable values