Beispiel #1
0
def fmt_mdif_block(dims, db):
    dimnames = [x.name for x in dims]
    fmts = [x.outputformat for x in dims]
    for coord in itertools.product(*[x.data for x in dims[1:]]):
        for iname, fmt, value in zip(dimnames[1:], fmts[1:], coord):
            #            import pdb;pdb.set_trace()
            yield [("VAR SWEEP.%s(real) = " + fmt) % (iname, value)]
        blockname = db.blockname
        if blockname is None:
            blockname = "DATABLOCK"
        yield ["BEGIN %s" % blockname]

        attribnames, attribdata = zip(*[(k, v) for (k, v) in db.vardata.items() if v.dims == dims[1:]])
        attribheader = format_complex_header(attribnames, attribdata, "%s(real)", "%s(complex)", None, unit_fmt=False)
        for name, data in zip(attribheader, attribdata):
            yield [("# %s = %s" % (name, data.outputformat)) % data[coord]]

        header, columns = zip(*[(k, v) for (k, v) in db.vardata.items() if v.dims == dims])
        header = (dims[0].name,) + header

        idx = (Ellipsis,) + coord
        columns = [col[idx] for col in columns]
        columns = [hfarray(dims[0])] + columns
        outheader = format_complex_header(header, columns, "%s(real)", "%s(complex)", None, unit_fmt=False)

        yield ["% " + " ".join(outheader)]
        fmts = [x.outputformat for x in columns]
        #        import pdb;pdb.set_trace()
        for row in zip(*columns):
            out = []
            for elem, fmt in zip(row, fmts):
                out.extend(format_elem(fmt, elem))
            yield out
        yield ["END"]
Beispiel #2
0
def format_sp_block(sweepvars, header, fmts, columns, blockname, comments):
    for comment in comments.fullcomments:
        yield ["!" + comment.lstrip("!")]
    for iname, fmt, value in sweepvars:
        yield [("!@%s=" + fmt) % (iname, value)]
    header, columns = make_col_from_matrix(header, columns, "%s%s%s")
    outheader = format_complex_header(header, columns, "%s", "Re(%s)", "Im(%s)", padheader=True)

    yield outheader
    fmts = [x.outputformat for x in columns]
    for row in zip(*columns):
        out = []
        for elem, fmt in zip(row, fmts):
            out.extend(format_elem(fmt, elem))
        yield out
Beispiel #3
0
def format_sp_block(sweepvars, header, fmts, columns, blockname, comments):
    for comment in comments.fullcomments:
        yield ["!" + comment.lstrip("!")]
    for iname, fmt, value in sweepvars:
        yield [("!@%s=" + fmt) % (iname, value)]
    header, columns = make_col_from_matrix(header, columns, "%s%s%s")
    outheader = format_complex_header(header, columns, "%s", "Re(%s)",
                                      "Im(%s)")

    yield outheader
    fmts = [x.outputformat for x in columns]
    for row in zip(*columns):
        out = []
        for elem, fmt in zip(row, fmts):
            out.extend(format_elem(fmt, elem))
        yield out
Beispiel #4
0
def fmt_mdif_block(dims, db):
    dimnames = [x.name for x in dims]
    fmts = [x.outputformat for x in dims]
    for coord in itertools.product(*[x.data for x in dims[1:]]):
        for iname, fmt, value in zip(dimnames[1:], fmts[1:], coord):
            #            import pdb;pdb.set_trace()
            yield [("VAR SWEEP.%s(real) = " + fmt) % (iname, value)]
        blockname = db.blockname
        if blockname is None:
            blockname = "DATABLOCK"
        yield ["BEGIN %s" % blockname]

        attribnames, attribdata = zip(*[(k, v)
                                        for (k, v) in db.vardata.items()
                                        if v.dims == dims[1:]])
        attribheader = format_complex_header(attribnames,
                                             attribdata,
                                             "%s(real)",
                                             "%s(complex)",
                                             None,
                                             unit_fmt=False)
        for name, data in zip(attribheader, attribdata):
            yield [("# %s = %s" % (name, data.outputformat)) % data[coord]]

        header, columns = zip(*[(k, v) for (k, v) in db.vardata.items()
                                if v.dims == dims])
        header = (dims[0].name, ) + header

        idx = (Ellipsis, ) + coord
        columns = [col[idx] for col in columns]
        columns = [hfarray(dims[0])] + columns
        outheader = format_complex_header(header,
                                          columns,
                                          "%s(real)",
                                          "%s(complex)",
                                          None,
                                          unit_fmt=False)

        yield ["% " + " ".join(outheader)]
        fmts = [x.outputformat for x in columns]
        #        import pdb;pdb.set_trace()
        for row in zip(*columns):
            out = []
            for elem, fmt in zip(row, fmts):
                out.extend(format_elem(fmt, elem))
            yield out
        yield ["END"]