bilby_pipe.utils
A set of generic utilities used in bilby_pipe
Attributes
Exceptions
Common base class for all non-exit exceptions. |
|
Common base class for all non-exit exceptions. |
Classes
A convenience object to aid in the creation of argument strings |
|
Wrapper around other types so that "None" always evaluates to None. |
|
An dictionary with immutable key-value pairs |
Functions
|
|
Helper function to return the list of command line arguments |
|
|
|
|
Parse an argument list using parser generated by create_parser() |
|
Checks if the given directory exists and creates it if it does not exist |
|
Setup logging output: call at the start of the script to use |
|
|
|
Convert a string to a tuple |
|
Convert a string repr of a string to a python dictionary |
|
Converts a string to a list, e.g. the mode_array waveform argument |
|
|
|
Writes ini file |
A generic test to see if the network is reachable |
|
|
|
|
|
|
Function to determine memory required at the data generation step |
|
Generate a time prior given some uncertainty. |
|
Get a new geocent time within some uncertainty from the original geocent time. |
|
Convert string inputs into a standard form for the detectors |
|
|
Partitions s at top-level commas |
|
Yields partitioning slices, skipping each index of ixs |
|
|
Takes a string in 'K=V' format and returns dictionary. |
Checks if the string/bytes-like object/number s represents an int |
|
|
Convert an input dictionary to a pretty-printed string |
|
|
|
|
|
Check if the psd_file can be found in the bilby built-in directory |
Module Contents
- exception bilby_pipe.utils.BilbyPipeError(message)[source]
Bases:
Exception
Common base class for all non-exit exceptions.
- exception bilby_pipe.utils.BilbyPipeInternalError(message)[source]
Bases:
Exception
Common base class for all non-exit exceptions.
- class bilby_pipe.utils.ArgumentsString[source]
Bases:
object
A convenience object to aid in the creation of argument strings
- class bilby_pipe.utils.DataDump(label, outdir, trigger_time, likelihood_lookup_table, likelihood_roq_weights, likelihood_roq_params, likelihood_multiband_weights, priors_dict, priors_class, interferometers, meta_data, idx)[source]
Bases:
object
- class bilby_pipe.utils.NoneWrapper(type)[source]
Bases:
object
Wrapper around other types so that “None” always evaluates to None.
This is needed to properly read None from ini files.
- bilby_pipe.utils.get_command_line_arguments()[source]
Helper function to return the list of command line arguments
- bilby_pipe.utils.parse_args(input_args, parser, allow_unknown=True)[source]
Parse an argument list using parser generated by create_parser()
- Parameters:
- input_args: list
A list of arguments
- Returns:
- args: argparse.Namespace
A simple object storing the input arguments
- unknown_args: list
A list of any arguments in input_args unknown by the parser
- bilby_pipe.utils.check_directory_exists_and_if_not_mkdir(directory)[source]
Checks if the given directory exists and creates it if it does not exist
- Parameters:
- directory: str
Name of the directory
- bilby_pipe.utils.setup_logger(outdir=None, label=None, log_level='INFO')[source]
Setup logging output: call at the start of the script to use
- Parameters:
- outdir, label: str
If supplied, write the logging output to outdir/label.log
- log_level: str, optional
[‘debug’, ‘info’, ‘warning’] Either a string from the list above, or an integer as specified in https://docs.python.org/2/library/logging.html#logging-levels
- bilby_pipe.utils.convert_string_to_tuple(string, key=None, n=None)[source]
Convert a string to a tuple
- Parameters:
- string: str
The string to convert
- key: str
Name used for printing useful debug messages
- n: int
The length of the string to check against, if None no check performed.
- Returns:
- tup: tuple
A tuple
- bilby_pipe.utils.convert_string_to_dict(string, key=None)[source]
Convert a string repr of a string to a python dictionary
- Parameters:
- string: str
The string to convert
- key: str (None)
A key, used for debugging
- bilby_pipe.utils.convert_string_to_list(string)[source]
Converts a string to a list, e.g. the mode_array waveform argument
See tests/utils_test for tested behaviour.
- Returns:
- new_list: list
A list (or lists)
- bilby_pipe.utils.write_config_file(config_dict, filename, comment=None, remove_none=False)[source]
Writes ini file
- Parameters:
- config_dict: dict
Dictionary of parameters for ini file
- filename: str
Filename to write the config file to
- comment: str
Additional information on ini file generation
- remove_none: bool
If true, remove None’s from the config_dict before writing otherwise a ValueError is raised
- bilby_pipe.utils.request_memory_generation_lookup(duration, roq=False)[source]
Function to determine memory required at the data generation step
- bilby_pipe.utils.get_time_prior(time, uncertainty, name='geocent_time', latex_label='$t_c$')[source]
Generate a time prior given some uncertainty.
- Parameters:
- time: float
The GPS geocent_time (time of coalescence at the center of the Earth)
- uncertainty: float
The +/- uncertainty based around the geocenter time.
- name: str
The name of the time parameter
- latex_label: str
The latex label for the time parameter
- Returns:
- A bilby.core.prior.Uniform for the time parameter.
- bilby_pipe.utils.get_geocent_time_with_uncertainty(geocent_time, uncertainty)[source]
Get a new geocent time within some uncertainty from the original geocent time.
- Parameters:
- geocent_time: float
The GPS geocent_time (time of coalescence at the center of the Earth)
- uncertainty: float
The +/- uncertainty based around the geocenter time.
- Returns:
- A geocent GPS time (float) inside the range of geocent time - uncertainty and
- geocent time + uncertainty.
- bilby_pipe.utils.convert_detectors_input(string)[source]
Convert string inputs into a standard form for the detectors
- Parameters:
- string: str
A string representation to be converted
- Returns:
- detectors: list
A sorted list of detectors
- bilby_pipe.utils.make_partition_slices(ixs)[source]
Yields partitioning slices, skipping each index of ixs
- bilby_pipe.utils.kv_parser(kv_str, remove_leading_namespace=False)[source]
Takes a string in ‘K=V’ format and returns dictionary.
- bilby_pipe.utils.check_if_represents_int(s)[source]
Checks if the string/bytes-like object/number s represents an int
- bilby_pipe.utils.pretty_print_dictionary(dictionary)[source]
Convert an input dictionary to a pretty-printed string
- Parameters:
- dictionary: dict
Input dictionary
- Returns:
- pp: str
The dictionary pretty-printed as a string
- class bilby_pipe.utils.DuplicateErrorDict(color=True, *args)[source]
Bases:
dict
An dictionary with immutable key-value pairs
Once a key-value pair is initialized, any attempt to update the value for an existing key will raise a BilbyPipeError.
- Raises:
- BilbyPipeError:
When a user attempts to update an existing key.