### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »

# toolbox - Toolbox of various functions and generic utilities

Toolbox of various functions and generic utilities.

Authors: Steve Morley, Jon Niehof, Brian Larsen, Josef Koller, Dan Welling Institution: Los Alamos National Laboratory Contact: smorley@lanl.gov, jniehof@lanl.gov, balarsen@lanl.gov, jkoller@lanl.gov, dwelling@lanl.gov Los Alamos National Laboratory

Copyright 2010 Los Alamos National Security, LLC.

- Array binning
- Array creation
- Array searching and masking
- Other functions
- Multithreading and multiprocessing
- System tools

## Array binning

`arraybin`(array, bins) | Split a sequence into subsequences based on value.
`bin_center_to_edges`(centers) | Convert a list of bin centers to their edges
`bin_edges_to_center`(edges) | Convert a list of bin edges to their centers
`binHisto`(data[, verbose]) | Calculates bin width and number of bins for histogram using Freedman-Diaconis rule, if rule fails, defaults to square-root method

## Array creation

`dist_to_list`(func, length[, min, max]) | Convert a probability distribution function to a list of values
`geomspace`(start[, ratio, stop, num]) | Returns geometrically spaced numbers.
`linspace`(min, max, num, **kwargs) | Returns linear-spaced bins.
`logspace`(min, max, num, **kwargs) | Returns log-spaced bins.

## Array searching and masking

`interweave`(a, b) | given two array-like variables interweave them together.
`isview`(array1[, array2]) | Returns if an object is a view of another object.
`tCommon`(ts1, ts2[, mask_only]) | Finds the elements in a list of datetime objects present in another
`tOverlap`(ts1, ts2, *args, **kwargs) | Finds the overlapping elements in two lists of datetime objects
`tOverlapHalf`(ts1, ts2[, presort]) | Find overlapping elements in two lists of datetime objects

## Other functions

`assemble`(fln_pattern, outfln[, sortkey, verbose]) | assembles all pickled files matching fln_pattern into single file and
`dictree`(in_dict[, verbose, spaces, levels, ...]) | pretty print a dictionary tree
`eventTimer`(Event, Time1) | Times an event then prints out the time and the name of the event,
`feq`(x, y[, precision]) | compare two floating point values if they are equal
`getNamedPath`(name) | Return the full path of a parent directory with name as the leaf
`human_sort`(l) | Sort the given list in the way that humans expect.
`hypot`(*args) | compute the N-dimensional hypot of an iterable or mnay arguments
`interpol`(newx, x, y[, wrap]) | 1-D linear interpolation with interpolation of hours/longitude
`intsolve`(func, value[, start, stop, maxit]) | Find the function input such that definite integral is desired value.
`medAbsDev`(series) | Calculate median absolute deviation of a given input series
`mlt2rad`(mlt[, midnight]) | Convert mlt values to radians for polar plotting
`normalize`(vec) | Given an input vector normalize the vector
`pmm`(a, *b) | print min and max of input arrays
`rad2mlt`(rad[, midnight]) | Convert radians values to mlt
`windowMean`(data[, time, winsize, overlap, ...]) | Windowing mean function, window overlap is user defined

## Multithreading and multiprocessing

`thread_job`(job_size, thread_count, target, ...) | Split a job into subjobs and run a thread for each
`thread_map`(target, iterable[, thread_count]) | Apply a function to every element of a list, in separate threads

## System tools

`do_with_timeout`(timeout, target, *args, **kwargs) | Execute a function (or method) with a timeout.
`loadpickle`(fln) | load a pickle and return content as dictionary
`progressbar`(count, blocksize, totalsize[, text]) | print a progress bar with urllib.urlretrieve reporthook functionality
`query_yes_no`(question[, default]) | Ask a yes/no question via raw_input() and return their answer.
`savepickle`(fln, dict[, compress]) | save dictionary variable dict to a pickle with filename fln
`timeout_check_call`(timeout, *args, **kwargs) | Call a subprocess with a timeout.
`TimeoutError` | Raised when a time-limited process times out
`update`([all, QDomni, omni, omni2, leapsecs, ...]) | Download and update local database for omni, leapsecs etc

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »