utils#

Back to API tree index

Purpose#

Cross-cutting utility functions and run/path helpers.

Module summary#

No module-level description available.

Top-level functions#

Function

Summary

A_lm_halfinclin

No docstring summary available.

A_lm_inclin

No docstring summary available.

amend_indices

Joins blocks together if they are separated by less than n_tol

asdf_fromfile

band_filter

Creates desired filter, and computes its impulse response length

before_write_save_old

No docstring summary available.

bincent

No docstring summary available.

bool2int

No docstring summary available.

change_filter_times_fd

Converts a conditioned filter to a different time array by zero-padding in time-domain

change_filter_times_td

Converts a conditioned filter to a different time array by zero-padding in time-domain

change_wf_fd_grid

checkempty

No docstring summary available.

close_hdf5

coherent_score

Combine H1 terms from scores_vetoed_max, returns scalar for single element

colorbar

No docstring summary available.

condition_filter

Compute support, weight, and truncate input frequency domain filter

condition_filter_td

Compute support, weight, and truncate input time domain filter

create_chirp_mass_directory_dict

Reads the names of all subdirectories, and creates a dictionary of dictionaries, with the outer dictionary having chirp mass ids as keys and the inner dictionary having subbank ids as keys and subdirectory names as values

define_coarser_mask

delete_hdf5_datasets

Convenience function to prune some leaves from a hdf5 file

env_init_lines

Creates text snippet to be added before submitting jobs to clusters

extract_filename

Extracts the filename from a string representation of a buffer object

extract_parts

Extracts the parts of the directory name based on the prefix and suffix

find_closest_coarse_calphas

Finds the closest associated coarse calphas to given fine calphas

gen_step_fd

No docstring summary available.

get_coincident_json_filelist

Assumes that the file names go like “Det-Detn-….” where Detn is the key

get_detector_fnames

get_dirs

Gives a list of length n_runs with each entry being a dictionary of dictionaries with the outer dictionary having chirp mass ids as keys and the inner dictionary having subbank ids as keys and subdirectory names as values. Figures out the number of subbanks and chirp mass ids by itself

get_dtype

No docstring summary available.

get_evname_from_tgps

No docstring summary available.

get_gwf_channel_names

No docstring summary available.

get_hdf5_file

Returns a hdf5 file object with the given mode, given a source. Warning, if the file is already open in read-only mode, we can’t return a writeable version.

get_HL_filenames

No docstring summary available.

get_injection_details

No docstring summary available.

get_json_fname

TODO: What if we choose a different fmax? Assumes that the file names go like “Det-Detn-….” where Detn is the detector key

get_left_right_fnames

No docstring summary available.

get_lsc_event_times

No docstring summary available.

get_O3_lsc_pe_samples

Returns a PESummary object to interact with the LSC PE samples

get_root_dirs

Gets root directories by run, used since O3a is on scratch

get_run

Returns the run name for a given GPS time

get_spectrum

Function used to dechirp Gets a trigger in the format of trigger, bank_id

get_strain_fnames

Returns the strain file names given a time

get_tgps_from_evname

No docstring summary available.

handle_missing_run

No docstring summary available.

hilbert_transform

No docstring summary available.

hole_edges

No docstring summary available.

hole_edges_to_mask

No docstring summary available.

incoherent_score

index_after_removal

No docstring summary available.

index_limits

Function that decides which indices to include in the average such that we always average window_size indices to avoid \`regression-to-mean’ artifacts due to fewer samples near holes

interpolate_asd

get log-log interpolant of ASD with old_f[0] >= 0,

interpolate_wf_fd

get log-log interpolant of amp & lin of phase with old_f[0] >= 0,

is_close_to

is_in_run

Check if a GPS time is in a given run, works with HM/non-standard runs

is_LIGO_valid

No docstring summary available.

is_LIGO_valid_between

Take two gps times t1 and t2 and return: 0 if the hole chunk from t1 to t2 is invalid 1 if it is partially valid 2 if it is fully valid where valid means that both H and L have all the [‘DATA’, ‘CBC_CAT1’, ‘CBC_CAT2’, ‘CBC_CAT3’] flags True. (e.g. for assessing whether a waveform between t1 and t2 had the right to be found or not)

is_within

No docstring summary available.

load_dict_from_hdf5_attrs

Loads a dictionary from the attributes of a hdf5 file

load_pesummary_io

I need to do some monkey patching to make it work on my machine

m1_m2_mt

complete m1, m2, mt or check consistency if all given –> return m1, m2, mt

m1_m2_s1_s2_to_chieff_chia

No docstring summary available.

make_LIGO_mask

Run this only once to make the file /data/bzackay/GW/LIGO_holes.npy

make_template_ids

No docstring summary available.

make_trigger_ids

No docstring summary available.

mass_conversion

Computes all conversions given a subset of parameters describing the masses

match

Computes match, or cosine, between waveforms

mmap_h5

Memory mapping is much faster for single row access than non-chunked hdf5, as long as we have a 64 bit architecture It is slower for random access, as the kernel version on the IAS systems is older and doesn’t activate the madvise system call WARNING: If the hdf5 file is already open (e.g., in a writeable manner), the values in the mmap object might not be updated until the changes to the hdf5 file are flushed (despite the description of the dedault UNIX driver, it has a small buffer, set by rdcc_nbytes)!

multiprocessing

A shorthand function to apply multiprocessing in a one liner

notch_filter

Creates notch filter

notch_filter_sos

Defines set of sos filters to apply to notch out lines

offset_background

Finds the amount to shift the detectors’ data streams by. It returns an integer multiple of dt_shift

orthogonalize_split

Function to compute orthogonalized scores to those in the L subset

pars_from_pars

WARNING: this sees keys ‘chi1’ and ‘chi2’ as being the vector spins [sjx, sjy, sjz] \*UNLIKE\* in other places where chij = sqrt(sjx^2 + sjy^2 + sjz^2) complete intrinsic parameter dictionary from sufficient parts

plot_veto_details

Make four-panel diagnostic plot for vetoes

populate_magic_methods

Decorator to populate magic methods for HDF5DatasetSubset, they enable us to interact with it like it’s a numpy array when needed

preprocess_wildcards

No docstring summary available.

q_and_eta

No docstring summary available.

read_hdf5_node

Convenience function to read/create a group from a hdf5 file

remove_bad_times

Removes elements of dat that are in the same bucket as in bad_time_list

remove_old_versions

No docstring summary available.

rm_suffix

Utility to change the extension of a path

s1z_s2z_chieff_chia_from_pars

\*NOTE\* this uses chia = (m1\*s1z - m2\*s2z) / (m1 + m2)

safe_concatenate

No docstring summary available.

safelen

No docstring summary available.

save_dict_to_hdf5_attrs

Saves a dictionary to the attributes of a hdf5 file

scalar

No docstring summary available.

sigma_from_median

Computes sigma from median for an array with Gaussian samps + outliers Silently returns 1 if we passed in an empty array

sinc_interp_by_factor_of_2

sinc_interp_x2D

exact same as sinc_interp_by_factor_of_2() except along last axis of two dimensional array x2D

sine_gaussian

Function to return time-domain sine-gaussian pulses (ready for FFT)

splitarray

Splits a single or multi-dimensional array into sub-arrays based on a coordinate

standardize_run_name

Maintain consistency in run names, mainly used to confirm with the GWOSC naming conventions

submask

threshold_rv

track_job

Track a multiprocessing job that was submitted in chunks

unbias_split

Function to compute split scores - expectations from total score

write_hdf5_node

Convenience function to create/overwrite a leaf in a hdf5 file

Y_lm

NOTE: azim = pi/2 - vphi

Y_lm_halfinclin

NOTE: azim = pi/2 - vphi

Classes#

Class

Summary

CustomDefaultdict

No class docstring summary available.

CustomHDF5File

Custom h5py file object that wraps datasets with EditableHDF5Dataset on access

CustomHDF5Group

Custom h5py group object that wraps datasets with EditableHDF5Dataset on access

EditableHDF5Dataset

Wrapper of hdf5 dataset that returns references instead of copies when indexed if it is multidimensional or variable-length

HDF5DatasetSubset

Simulates a copy-on-write reference to a subset of a multidimensional or variable-length HDF5 dataset. This is needed because by default, edits to a HDF5 dataset’s elements don’t propagate back to the underlying dataset

NumpyEncoder

No class docstring summary available.

TupleEncoder

No class docstring summary available.