| |
- awrite(data, outFile=None, format='%g ', comments=None, append=False, commentChar='#')
- Write (a) numeric array(s) to file (or fileObject, or stdout if unspecified).
data: a numpy array or a list/tuple of numpy arrays (with consistent number of rows, i.e., identical first shape)
outFile: filename or file object
if unspecified: write to stdout
if an already opened file object, awrite does not close the file after writing
format: must have one, two, or data.shape[1] specifiers (line feed is appended if necessary)
comments: a (list of) string(s) to be written as a file header in front of the data
append: flag
commentChar: default #
[awrite is similar to numpy.savetxt, but smarter, more flexible, ....
Note that the output file (object) is optional here, hence the second argument!]
- commonExtension(files)
- Return the common extension of all files, if identical; otherwise return None.
- countUniqueNames(listOfNames)
- Given a list of strings, return the number of unique strings (i.e. without duplicates).
- cstack(*arrays)
- Shorthand robust version of numpy.column_stack: 'paste' arrays side-by-side.
See also the numpy builtin c_
- getCommentLines(inFile, commentChar='#')
- Read a tabular (xy) formatted ascii file and return list of ALL comments (without commentChar) found in file.
- get_command(maxArgs=13)
- Return a string with the command line used (optionally truncated).
- grep_array_from_header(inFile, keyword, keyValSep=':', commentChar='#', intType=0)
- Scan thru list of records (typically read as file header), search for ONE keyword, and return data as numpy array.
- grep_from_header(inFile, keyword, sep=':', commentChar='#')
- Scan thru list of records (typically read as file header), search for ONE keyword, and return its 'value'.
(Equivalent to parse_comments (readFileHeader(file),keyword)[keyword], but returns only the entry).
- grep_word(inFile, firstWord, commentChar='#')
- Scan thru header section of file and search for a comment line starting with <firstWord>;
Return list of words.
- join_words(wordList, sep=' ')
- Join / concatenate list or tuple of 'words' (not in a strict grammar sense) and return a single string.
(This function should work similar to the string.join function of Python 2)
- loadxy(xyFile, usecols=(0, 1), xLimits=None, verbose=False, commentChar='#')
- Read a tabular two-column ascii file with loadtxt and separately return the xGrid and the yValues arrays.
- loadxyy(xyyFile, verbose=False, commentChar='#')
- Read a tabular ascii file with loadtxt and separately return the xGrid array and the y data 'matrix'.
- minmaxmean(xy, name='xy')
- Print some 'statistics' of a numpy array.
- open_outFile(outFile, commentChar='#')
- Open output file and write job specification (command line).
- parse_comments(commentLines, keywords, sep=':', commentChar='#')
- Scan thru list of records (typically read as file header) and search for certain keys;
returns a dictionary with (ideally) len(keywords) key,value(s) pairs
If units are specified in the key (like "name [unit]: value(s)),
the value(s) are converted to the standard cgs unit (e.g. mb -> g/cm/s**2).
- readDataAndComments(inFile, commentChar='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False)
- Read tabular (xy) formatted ascii file, return data as numpy array and list of comments in file header.
(Most options are simply passed thru to numpy.loadtxt)
- readFileHeader(inFile, commentChar='#')
- Read a tabular (xy) formatted ascii file and return list of comments (without commentChar) found in header.
Stops reading when the first non-comment line is found.
- read_first_line(sFile, verbose=0)
- Try to determine filetype (pickle or ascii or ...) automatically from first nonblank character in file.
- read_xyz_file(xyzFile, yInfo=-1, verbose=False, commentChar='#')
- Read a xGrid, yGrid and a zzz "matrix" from a tabular ascii file.
Return first column as xGrid, yGrid given in header or as function argument, further columns as zzz matrix.
ARGUMENTS:
----------
xyzFile: the data file to read (using numpy.loadtxt)
yInfo: * an integer indicating the line number in the file header where to read the y grid.
default -1: read the last header line
* a numpy array (or list of floats) with length equal to zzz.shape[1]
verbose: flag
commentChar: default '#'
- uniqueNames(listOfNames)
- Given a list of strings, return the list of unique strings (i.e. a list without duplicates).
|