viperleed.calc.lib.base

Contains generic functions used in the TensErLEED scripts.

Functions

addUnequalPoints(l1, l2, eps[, uniqueLists])

Adds all points from l1 to l2, if they are not already in l2 (+- epsilon).

add_edges_and_corners(cartesian, fractional, ...)

Add atoms at edges and corners to the Cartesian coordinates given.

angle(v1, v2)

Returns the angle between two 2D vectors

available_cpu_count()

Number of available virtual or physical CPUs on this system, i.e. user/real as output by time(1) when called with an optimally scaling userspace-only program.

collapse(cartesians, ucell[, ucell_inv, method])

Collapse Cartesian coordinates to the base cell.

collapse_fractional(coordinates[, method, ...])

Collapse fractional coordinates to the base cell.

copytree_exists_ok(source, destination)

Copy the whole tree at the source directory to destination.

cosvec(x, y)

Returns the cosine of the angle between two vectors

dict_equal(d1, d2)

Checks whether two dictionaries are equal, i.e. contain the same set of keys with the same values.

dist_from_line(p1, p2, r)

Calculates the distance of a point from a line, with the line defined by two other points.

ensure_integer_matrix(matrix[, eps])

Return a rounded version of matrix.

fortranContLine(s)

Takes a sting that might be too long to fit on a single line of fortran code and splits it into continuation lines as necessary.

get_elapsed_time_str(t)

Takes float time in seconds, returns a formatted string giving the elapsed times in minutes, hours or seconds, as appropriate.

lcm(a, b)

Calculate the lowest common multiple of two integers a and b

make_unique_list(w_duplicates)

Helper function to remove duplicates from list.

max_diff(list_)

Find the index in a list such that list[i] - list[i-1] is the largest value difference in the list (after sorting).

pairwise(iterable)

Return a generator of pairs of subsequent elements.

parent_name(dotted_name[, remove])

Return a version of dotted_name with the last attribute removed.

parseMathSqrt(s)

range_to_str(il)

Takes a list of integers, sorts them and returns a string short form.

readIntLine(line[, width])

Reads an (arbitrary length) line of integers with fixed width.

readIntRange(s)

Takes a string, returns a list of integers.

readToExc(llist)

For reading PARAMETERS files; takes a list, returns elements until the first one that starts with an exclamation mark.

readVector(s[, ucell, defRelaltive])

Takes a string 'xyz[f1 f2 f3]', 'abc[f1 f2 f3]' or just '[f1 f2 f3]' and returns the corresponding vector in cartesian coordinates, or None if the string cannot be parsed.

recombineListElements(llist, com)

Takes a list, checks in each element whether the first/last characters are the given combination character, and if so, combines list elements with the list element before/after.

rotation_matrix(angle[, dim])

Returns a (2x2) matrix for in-plane rotation of the given rotation angle.

rotation_matrix_order(order[, dim])

Returns a (2x2) matrix for in-plane rotation of the given rotation order.

splitMaxRight(s, sep)

Same as s.split(sep, maxsplit=1), but splitting at the first instance from the right.

splitSublists(llist, sep)

Takes a list and a separator, splits strings in the list by the separator, returns results as list of lists

split_string_range(range_string)

Return start and stop as strings from "start:stop" or "start-stop".

strip_comments(line)

Return the part of line to the left of comments.

Classes

BackwardsReader(file[, blksize, encoding])

Simple class for reading a large file in reverse without having to read the entire file to memory.

CustomLogFormatter([fmt, datefmt, style, ...])

Logging Formatter for level-dependent message formatting

Exceptions

NonIntegerMatrixError

A matrix that should have integer values does not.

SingularMatrixError

A matrix that needs inversion is singular.