GWForge.utils

Attributes

Functions

remove_special_characters(input_string[, ...])

Remove specified special characters from a given input string.

hdf_append(f, key, value)

Append a value to an HDF5 dataset or create a new dataset if the key does not exist.

split_duration(duration[, size])

Split a duration into chunks of a specified size.

find_frame_files(directory[, filePattern, start_time, ...])

Get a list of frame files within a given directory optionally filtered by time range

source_type(name)

Canonical source-type token: bhns for a neutron-star--black-hole binary.

split_odd_even(items)

Split a list into its odd-indexed and even-indexed sublists.

generate_frame_file_sublists(frame_files[, window_size])

Generate sublists of frame files with a specified window size.

update_ET_channels(channel_dict)

save_frame_files(ifo, start_time, duration, ifo_directory)

Module Contents

GWForge.utils.remove_special_characters(input_string, characters_to_remove=['+', '-', '_', ' ', '#'])[source]

Remove specified special characters from a given input string.

Parameters:
  • input_string (str) – The input string from which to remove special characters.

  • characters_to_remove (list of str, optional) – A list of special characters to remove from the input string. Defaults to [“+”, “-”, “_”, “ “].

Returns:

The input string with specified special characters removed.

Return type:

str

GWForge.utils.hdf_append(f, key, value)[source]

Append a value to an HDF5 dataset or create a new dataset if the key does not exist.

Parameters:
  • f ((h5py.File)) – An HDF5 file object.

  • key (a new dataset is created with the specified) – The key to identify the dataset within the HDF5 file.

  • value ((float or numpy.ndarray)) – The value to be appended to the dataset.

  • exists (If the dataset with the specified key already)

  • dataset. (the function appends the given value to the existing)

  • exist (If the dataset does not)

  • key

  • stored. (and the value is)

  • Note (The function ensures that the stored value is a 1-dimensional array.)

GWForge.utils.GWLATEX_LABELS[source]
GWForge.utils.split_duration(duration, size=4096.0)[source]

Split a duration into chunks of a specified size.

Parameters:
  • duration (-) – The total duration to split

  • size (-) – The size of each chunk [Default:4096]

  • Returns

  • list (A list containing chunks of the specified size.)

GWForge.utils.find_frame_files(directory, filePattern='*gwf', start_time=None, end_time=None)[source]

Get a list of frame files within a given directory optionally filtered by time range :param directory: Path to frames directory :type directory: str :param filepattern: A Unix shell-style wildcard pattern to match files. [Default *gwf] :type filepattern: str :param start_time: GPS start time for time range filter :type start_time: float :param end_time: GPS end time for time range filter :type end_time: float

GWForge.utils.source_type(name)[source]

Canonical source-type token: bhns for a neutron-star–black-hole binary.

nsbh is accepted everywhere as an alias; everything else is lowercased.

GWForge.utils.split_odd_even(items)[source]

Split a list into its odd-indexed and even-indexed sublists.

Used by the workflow generator to schedule injection jobs for adjacent data segments in two non-overlapping passes: because neighbouring segments share frame files (window overlap), the even-indexed segments are made to depend on the odd-indexed ones so that no two adjacent segments are written concurrently.

Parameters:

items (list) – The list to split.

Returns:

tuple(list, list)

Return type:

(odd-indexed items, even-indexed items)

Example

>>> split_odd_even(['a', 'b', 'c', 'd', 'e'])
(['b', 'd'], ['a', 'c', 'e'])
GWForge.utils.generate_frame_file_sublists(frame_files, window_size=3)[source]

Generate sublists of frame files with a specified window size.

Parameters:
  • frame_files (list) – A list of file paths representing frame files.

  • window_size (int, optional) – The size of the sliding window to create sublists. [Defaults: 3]

Returns:

list

Return type:

A list of sublists containing frame file paths.

Example

>>> frame_files = ['file1.gwf', 'file2.gwf', 'file3.gwf', 'file4.gwf']
>>> generate_frame_file_sublists(frame_files, window_size=2)
[['file1.gwf', 'file2.gwf'], ['file2.gwf', 'file3.gwf'], ['file3.gwf', 'file4.gwf']]
GWForge.utils.update_ET_channels(channel_dict)[source]
GWForge.utils.save_frame_files(ifo, start_time, duration, ifo_directory)[source]
GWForge.utils.pycbc_labels[source]
GWForge.utils.reference_prior_dict[source]