gwnr.utils β€” general utilities

Cross-cutting helpers used throughout the package. Source: gwnr/utils/.

  1. Package-level
  2. support.py β€” general helpers
  3. types.py β€” LAL/PyCBC type conversions
  4. memory.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 separate multiprocessing.Process, raising if it exceeds timeout seconds (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/FrequencySeries with length made consistent with time_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 a FrequencySeries at a target delta_f, padding time series to avoid wraparound (unless delta_f forces 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.

Copyright © Prayush Kumar. Distributed under the GPL license.

This site uses Just the Docs, a documentation theme for Jekyll.