Exemplo n.º 1
0
def disturb(*args, glob_vars={}, printer=ConsolePrinter()):
    var = save_eval(*args, glob_vars=glob_vars, printer=printer)
    off = (random.random() - 0.5)*0.02
    res = []
    for val in var:
        res.append(val + (random.random()-0.5)*0.009 + off)

    return array(res)
Exemplo n.º 2
0
def convolute_with_psf(*args, glob_vars={}, printer=ConsolePrinter()):
    var = save_eval(*args, glob_vars=glob_vars, printer=printer)
    if "sigma" in glob_vars:
        printer.print("Variable sigma is defined. Taking it to scale point spread function...")
        sigma = glob_vars["sigma"]
    else:
        printer.print("Variable sigma is undefined. Taking 1...")
        sigma = 1

    if not isinstance(var, ndarray):
        printer.print("Convolution is only possible with matrices/vectors right now.", color="red")

    dim = len(var.shape)
    assert dim == 3

    result = zeros(var.shape)
Exemplo n.º 3
0
def convolute(*args, glob_vars={}, printer=ConsolePrinter()):
    var = save_eval(*args, glob_vars=glob_vars, printer=printer)
    if "sigma" in glob_vars:
        printer.print("Variable sigma is defined. Taking it to scale point spread function...")
        sigma = glob_vars["sigma"]
    else:
        printer.print("Variable sigma is undefined. Taking 1...")
        sigma = 1

    res = []
    for i in range(0, len(var)):
        this = 0
        for j in range(0, len(var)):
            this += point_spread_kernel(i, j, sigma, len(var)) * var[j]

        res.append(this)

    return array(res)
Exemplo n.º 4
0
def mmult(*args, glob_vars={}, printer=ConsolePrinter()):
    args = seperate_by_keywords(args, ["with"])
    first=save_eval(args[None], glob_vars=glob_vars, printer=printer)
    sec=save_eval(args["with"], glob_vars=glob_vars, printer=printer)
    return array(matrix(first)*matrix(sec))