ism3d.utils.utils

General-purpose utility Functions used by other modules

Functions

backup

backup file / dirwectiory to be overwrite

chi2red_to_lognsigma

gal_flat

translated from IDL/gal_flat.pro im in (nz,ny,nx) cen is (xc,yc)

get_autocoor_time

get_dirsize

get the size of a file or directory

gmake_listpars

print out the parameter dict

gmake_pformat

fill.

h5ls

h5ls_print

imcontsub

linechan / contchan: tuple with [fmin,fmax] in each element

inp_validate

validate the input parameters, will do the follows step by step

make_slice

parsing the slicing syntax in STRING

moments

obj_defunit

convert quatity to values in default internal units

one_beam

paste_array

past a small array into a larger array with shifting works for high dimension or off-edge cases wall/block requires in the same dimension number loc: the index of left-bottom pixel of block in wall.

paste_slice

make slice for the overlapping region

pprint

A modified pprint.pprint without sorting dictionary keys

read_par

read parameter quantity / values (in default units) from a parameter dictionary this function can handle literal slicing and attribute syntax e.g.: par_str[ind_str]@section_name par_str.attrubute@section_name

read_range

modifiy the parameter exploring bounrdary according to the info from opt section a: absolute

repr_parameter

Similiar to the built-in repr(), but can handle Quantity / SkyCoord used for writing input files

rotate_xy

rotate points in a 2D coordinate system angle: rotate points by angle in CCW ref: rotate_xy.pro rot_3d.pro performance consideration: https://gist.github.com/LyleScott/e36e08bfb23b1f87af68c9051f985302 https://stackoverflow.com/questions/33004551/why-is-b-numpy-dota-x-so-much-slower-looping-through-doing-bi-numpy https://en.wikipedia.org/wiki/Rotation_matrix

sample_grid

this is loosely based on my sample_grid.pro in IDL with improvement on defining x-/y-range angle in rad ratio=major/minor

set_threads

some underline alrgoithm library can use OMP turn on OMP is beneficial for iteration optimizwer but not for parallele optimizer this function can turn on / turn off OMP in modelling alrothjm

sort_on_runtime

write_par

write parameter values