python_utils#

Back to API tree index

Purpose#

Numeric and Python utility helpers shared across modules.

Module summary#

No module-level description available.

Top-level functions#

Function

Summary

abbar

return c1 \* np.conjugate(c2) with numba vectorization

abs2

x.real^2 + x.imag^2

abs2sum

sum x.real^2 + x.imag^2 along last axis

archive_paths

No docstring summary available.

argmax_lastax

get axis=-1 (innermost \`column’) index of max in arr

argmaxnd

get unraveled (tuple) index of maximal element in arr

check_equal

recursive x == y that handles ragged mixed-type containers

flat_in_log

get n samples from log-uniform distribution between vmin and vmax

fmt

formatting number as string

import_matplotlib

Avoid annoying errors due to loading matplotlib on the server

invert_dict

return dictionary with inverted key-value pairs

is_numpy_float

check if type(x) is one of numpy’s float types

is_numpy_int

check if type(x) is one of numpy’s integer types

load_module

load python module by name (string)

load_symmetrix_matrix

load n x n symmetric matrix from 1d array formatted as in store_symmetric_matrix()

merge_dicts_safely

merge multiple dictionaries into one, accepting repeated keys if values are consistent, otherwise raise ValueError

next_power

get next power of 2 following n

nfft_of_rfft

ASSUMES nfft even <=> len(rfft_arr) odd

nfft_of_rfftlen

ASSUMES nfft even <=> rfftlen odd

npy_append_cols

append columns to array from .npy file at path infile if outfile_new given, write the result there; otherwise rewrite infile_npy with appended columns

npy_append_rows

append rows to array from .npy file at path infile if outfile_new given, write the result there; otherwise rewrite infile_npy with appended rows

printarr

wrapper for np.array2string printing

rand_azim

get nangles (int or tuple) samples ~ U(0, 2\*np.pi)

rand_cos

get nangles (int or tuple) samples ~ U(-1, 1)

rand_polar

get nangles (int or tuple) samples ~ np.arccos(U(-1, 1))

rfftlen_of_nfft

ASSUMES nfft even <=> len(rfft_arr) odd

store_symmetrix_matrix

store n x n symmetric matrix as 1d array of length n\*(n+1)/2

tukwin_back

back taper of tukey window (last half of hann)

tukwin_bandpass

taper_width is frequency interval length in Hz to be tapered at each end f_nyq & rfft_len are the nyquist frequency and length of the rfftfreq array

tukwin_front

front taper of tukey window (first half of hann)

tukwin_npts

get tukey window based on numbers of total and windowed points

zeropad_end

pad arr axis=-1 with zeros at (right/back) end to length pad_to_N if arr.shape[-1] < pad_to_N, raise ValueError

zip_to_array

O(10^3)x faster np.array([row for row in np.broadcast(\*args)]) usable when args are all at most 1d.

No public classes were found.