gwnr.utils β general utilities
Cross-cutting helpers used throughout the package. Source:
gwnr/utils/.
- Package-level
support.pyβ general helperstypes.pyβ LAL/PyCBC type conversionsmemory.pyβ memory profiling
Package-level
get_unique_hex_tag(N=1, num_digits=10)/get_sim_hash(...)β unique hex identifiers for runs/simulations.
support.py β general helpers
- Strings/formatting:
add_strings,join_list_of_strings,format_string(template filling),get_sec/get_time(time parsing) - Arrays:
find_nearest(a, a0),approx_equal(A, B, eps=1e-4),nextpow2(n),nCr(n, r),insert_min_max_into_array(arr, low, high),trim_leading_zeros/trim_trailing_zeros,zero_pad_beginning(h, steps=1) - Geometry:
area_inside_contour(vs)β enclosed area via Greenβs theorem - Filesystem:
mkdir,rmdir - Progress/robustness:
update_progress(progress)β simple progress bar;call_with_timeout(myfunc, args, kwargs, timeout=5)β run a function in a separatemultiprocessing.Process, raising if it exceedstimeoutseconds (used to guard against hanging waveform generators) get_uniform_mass_range(m_lower, m_upper, m_sep)
types.py β LAL/PyCBC type conversions
convert_TimeSeries_to_lalREAL8TimeSeries(h, name=None)/convert_lalREAL8TimeSeries_to_TimeSeries(h)β round-trip between PyCBC and LAL time-series types.convert_numpy_to_pycbc_type(arr, out_type, sample_rate, time_length)β numpy βTimeSeries/FrequencySerieswith length made consistent withtime_length.extend_waveform_TimeSeries(wav, filter_N)/extend_waveform_FrequencySeries(wav, filter_n, force_fit=False)β zero-extend series to a target filter length.make_padded_frequency_series(vec, filter_N=None, delta_f=None)β convert a time- or frequency-series to aFrequencySeriesat a targetdelta_f, padding time series to avoid wraparound (unlessdelta_fforces a shorter duration).write_series(series, filename)β write a series to disk.
memory.py β memory profiling
MemoryUsage(o)β recursive memory footprint of a Python object graph (nested dicts, lists, tuples, sets).ShowMemoryUsage(objs=[], prefac=1e-6, prefac_name='Mb')β print total sizes for a list of objects.