コード例 #1
0
ファイル: loopdiagram1.py プロジェクト: Nobatek/eppy
def main():
    from argparse import RawTextHelpFormatter
    parser = argparse.ArgumentParser(usage=None, 
                description=__doc__, 
                formatter_class=RawTextHelpFormatter)
                # need the formatter to print newline from __doc__
    parser.add_argument('idd', action='store', 
        help='location of idd file = ./somewhere/eplusv8-0-1.idd')
    parser.add_argument('file', action='store', 
        help='location of idf file = ./somewhere/f1.idf') 
    nspace = parser.parse_args()
    fname = nspace.file
    iddfile = nspace.idd
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)
    print("constructing the loops")
    edges = makeairplantloop(data, commdct)
    print("cleaning edges")
    edges = clean_edges(edges)
    print("making the diagram")
    g = makediagram(edges)
    dotname = '%s_branch.dot' % (os.path.splitext(fname)[0])
    pngname = '%s_branch.png' % (os.path.splitext(fname)[0])
    g.write(dotname)
    print("saved file: %s" % (dotname, ))
    g.write_png(pngname)
    print("saved file: %s" % (pngname, ))
コード例 #2
0
def main(argv=None):
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="])
        except getopt.error as msg:
            raise Usage(msg)

        # option processing
        for option, value in opts:
            if option == "-v":
                verbose = True
            if option in ("-h", "--help"):
                raise Usage(help_message)
            if option in ("-o", "--output"):
                output = value

        iddfile = "./resources/iddfiles/Energy+V6_0.idd"
        fname = args[0]
        print("readingfile")
        data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)
        print("constructing the loops")
        edges = makeairplantloop(data, commdct)
        print(edges)
        print("making the diagram")
        g = makediagram(edges)
        dotname = '%s.dot' % (os.path.splitext(fname)[0])
        pngname = '%s.png' % (os.path.splitext(fname)[0])
        g.write(dotname)
        g.write_png(pngname)
    except Usage as err:
        sys.stderr.write()(sys.argv[0].split("/")[-1] + ": " + str(err.msg))
        sys.stderr.write()("\t for help use --help")
        return 2
コード例 #3
0
ファイル: loopdiagram.py プロジェクト: Nobatek/eppy
def main(argv=None):
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="])
        except getopt.error as msg:
            raise Usage(msg)

        # option processing
        for option, value in opts:
            if option == "-v":
                verbose = True
            if option in ("-h", "--help"):
                raise Usage(help_message)
            if option in ("-o", "--output"):
                output = value

        iddfile = "./resources/iddfiles/Energy+V6_0.idd"
        fname = args[0]
        print("readingfile")
        data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)
        print("constructing the loops")
        edges = makeairplantloop(data, commdct)
        print(edges)
        print("making the diagram")
        g = makediagram(edges)
        dotname = '%s.dot' % (os.path.splitext(fname)[0])
        pngname = '%s.png' % (os.path.splitext(fname)[0])
        g.write(dotname)
        g.write_png(pngname)
    except Usage as err:
        sys.stderr.write()(sys.argv[0].split("/")[-1] + ": " + str(err.msg))
        sys.stderr.write()("\t for help use --help")
        return 2
コード例 #4
0
ファイル: loopdiagram.py プロジェクト: secondmover/eppy
def main():
    from argparse import RawTextHelpFormatter
    parser = argparse.ArgumentParser(usage=None,
                                     description=__doc__,
                                     formatter_class=RawTextHelpFormatter)
    # need the formatter to print newline from __doc__
    parser.add_argument(
        'idd',
        action='store',
        help='location of idd file = ./somewhere/eplusv8-0-1.idd')
    parser.add_argument('file',
                        action='store',
                        help='location of idf file = ./somewhere/f1.idf')
    nspace = parser.parse_args()
    fname = nspace.file
    iddfile = nspace.idd
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)
    print "constructing the loops"
    edges = makeairplantloop(data, commdct)
    print "cleaning edges"
    edges = clean_edges(edges)
    print "making the diagram"
    g = makediagram(edges)
    dotname = '%s.dot' % (os.path.splitext(fname)[0])
    pngname = '%s.png' % (os.path.splitext(fname)[0])
    g.write(dotname)
    print "saved file: %s" % (dotname, )
    g.write_png(pngname)
    print "saved file: %s" % (pngname, )
コード例 #5
0
def process_idf(fname, iddfile):
    data, commdct, _iddindex = readidf.readdatacommdct(fname, iddfile=iddfile)
    print("constructing the loops")
    edges = makeairplantloop(data, commdct)
    print("cleaning edges")
    edges = clean_edges(edges)
    print("making the diagram")

    return makediagram(edges)
コード例 #6
0
ファイル: loopdiagram.py プロジェクト: jamiebull1/eppy
def process_idf(fname, iddfile):
    data, commdct, _iddindex = readidf.readdatacommdct(fname, iddfile=iddfile)
    print("constructing the loops")
    edges = makeairplantloop(data, commdct)
    print("cleaning edges")
    edges = clean_edges(edges)
    print("making the diagram")

    return makediagram(edges)
コード例 #7
0
ファイル: idfreader.py プロジェクト: santoshphilip/eppy
def idfreader(fname, iddfile, conv=True):
    """read idf file and return bunches"""
    data, commdct, idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
    if conv:
        convertallfields(data, commdct)
    # fill gaps in idd
    ddtt, dtls = data.dt, data.dtls
    # skiplist = ["TABLE:MULTIVARIABLELOOKUP"]
    nofirstfields = iddgaps.missingkeys_standard(
        commdct, dtls, skiplist=["TABLE:MULTIVARIABLELOOKUP"])
    iddgaps.missingkeys_nonstandard(None, commdct, dtls, nofirstfields)
    bunchdt = makebunches(data, commdct)
    return bunchdt, data, commdct, idd_index
コード例 #8
0
ファイル: idfreader.py プロジェクト: santoshphilip/eppy
def idfreader(fname, iddfile, conv=True):
    """read idf file and return bunches"""
    data, commdct, idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
    if conv:
        convertallfields(data, commdct)
    # fill gaps in idd
    ddtt, dtls = data.dt, data.dtls
    # skiplist = ["TABLE:MULTIVARIABLELOOKUP"]
    nofirstfields = iddgaps.missingkeys_standard(
        commdct, dtls,
        skiplist=["TABLE:MULTIVARIABLELOOKUP"])
    iddgaps.missingkeys_nonstandard(None, commdct, dtls, nofirstfields)
    bunchdt = makebunches(data, commdct)
    return bunchdt, data, commdct, idd_index
コード例 #9
0
ファイル: bunch_subclass.py プロジェクト: Nobatek/eppy
def main():
    """main function"""
    # read code
    # iddfile = "../iddfiles/Energy+V6_0.idd"
    iddfile = "./walls.idd"
    fname = "./walls.idf" # small file with only surfaces
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)

    # setup code walls - can be generic for any object
    ddtt = data.dt
    dtls = data.dtls
    wall_i = dtls.index('BuildingSurface:Detailed'.upper())
    wallkey = 'BuildingSurface:Detailed'.upper()

    dwalls = ddtt[wallkey]
    dwall = dwalls[0]

    wallfields = [comm.get('field') for comm in commdct[wall_i]]
    wallfields[0] = ['key']
    wallfields = [field[0] for field in wallfields]
    wall_fields = [bunchhelpers.makefieldname(field) for field in wallfields]
    print(wall_fields[:20])

    bwall = EpBunch(dwall, wall_fields)

    print(bwall.Name)
    print(data.dt[wallkey][0][1])
    bwall.Name = 'Gumby'
    print(bwall.Name)
    print(data.dt[wallkey][0][1])
    print()

    # set aliases
    bwall.__aliases = {'Constr':'Construction_Name'}

    print("wall.Construction_Name = %s" % (bwall.Construction_Name, ))
    print("wall.Constr = %s" % (bwall.Constr, ))
    print()
    print ("change wall.Constr")
    bwall.Constr = 'AnewConstr'
    print("wall.Constr = %s" % (bwall.Constr, ))
    print("wall.Constr = %s" % (data.dt[wallkey][0][3], ))
    print()

    # add functions
    bwall.__functions = {'svalues':somevalues}

    print(bwall.svalues)
    print(bwall.__functions)
コード例 #10
0
ファイル: bunch_subclass.py プロジェクト: secondmover/eppy
def main():
    """main function"""
    # read code
    # iddfile = "../iddfiles/Energy+V6_0.idd"
    iddfile = "./walls.idd"
    fname = "./walls.idf"  # small file with only surfaces
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)

    # setup code walls - can be generic for any object
    ddtt = data.dt
    dtls = data.dtls
    wall_i = dtls.index('BuildingSurface:Detailed'.upper())
    wallkey = 'BuildingSurface:Detailed'.upper()

    dwalls = ddtt[wallkey]
    dwall = dwalls[0]

    wallfields = [comm.get('field') for comm in commdct[wall_i]]
    wallfields[0] = ['key']
    wallfields = [field[0] for field in wallfields]
    wall_fields = [bunchhelpers.makefieldname(field) for field in wallfields]
    print(wall_fields[:20])

    bwall = EpBunch(dwall, wall_fields)

    print(bwall.Name)
    print(data.dt[wallkey][0][1])
    bwall.Name = 'Gumby'
    print(bwall.Name)
    print(data.dt[wallkey][0][1])
    print()

    # set aliases
    bwall.__aliases = {'Constr': 'Construction_Name'}

    print("wall.Construction_Name = %s" % (bwall.Construction_Name, ))
    print("wall.Constr = %s" % (bwall.Constr, ))
    print()
    print("change wall.Constr")
    bwall.Constr = 'AnewConstr'
    print("wall.Constr = %s" % (bwall.Constr, ))
    print("wall.Constr = %s" % (data.dt[wallkey][0][3], ))
    print()

    # add functions
    bwall.__functions = {'svalues': somevalues}

    print(bwall.svalues)
    print(bwall.__functions)
コード例 #11
0
ファイル: loopdiagram1.py プロジェクト: Nobatek/eppy
def getedges(fname, iddfile):
    """return the edges of the idf file fname"""
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)
    edges = makeairplantloop(data, commdct)
    return edges
コード例 #12
0
def test_EpBunch():
    """py.test for EpBunch"""
    iddfile = "./walls%s.idd" % (random.randint(11111, 99999))
    fname = "./walls%s.idf" % (random.randint(11111, 99999))
    open(iddfile, 'wb').write(iddtxt)
    open(fname, 'wb').write(idftxt)
    # iddfile = "./walls.idd"
    # iddfile = "../iddfiles/Energy+V6_0.idd"
    # fname = "./walls.idf" # small file with only surfaces
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)

    # setup code walls - can be generic for any object
    dt = data.dt
    dtls = data.dtls
    wall_i = dtls.index('BuildingSurface:Detailed'.upper())
    wallkey = 'BuildingSurface:Detailed'.upper()
    wallidd = commdct[wall_i]

    dwalls = dt[wallkey]
    dwall = dwalls[0]


    wallfields = [comm.get('field') for comm in commdct[wall_i]]
    wallfields[0] = ['key']
    wallfields = [field[0] for field in wallfields]
    wall_fields = [bunchhelpers.makefieldname(field) for field in wallfields]
    assert wall_fields[:20] == ['key', 'Name', 'Surface_Type', 'Construction_Name', 'Zone_Name', 'Outside_Boundary_Condition', 'Outside_Boundary_Condition_Object', 'Sun_Exposure', 'Wind_Exposure', 'View_Factor_to_Ground', 'Number_of_Vertices', 'Vertex_1_Xcoordinate', 'Vertex_1_Ycoordinate', 'Vertex_1_Zcoordinate', 'Vertex_2_Xcoordinate', 'Vertex_2_Ycoordinate', 'Vertex_2_Zcoordinate', 'Vertex_3_Xcoordinate', 'Vertex_3_Ycoordinate', 'Vertex_3_Zcoordinate']
    

    bwall = EpBunch(dwall, wall_fields, wallidd)

    # print bwall.Name
    # print data.dt[wallkey][0][1]
    assert bwall.Name == data.dt[wallkey][0][1]
    bwall.Name = 'Gumby'
    # print bwall.Name
    # print data.dt[wallkey][0][1]
    # print
    assert bwall.Name == data.dt[wallkey][0][1]

    # set aliases
    bwall.__aliases = {'Constr':'Construction_Name'} 

    # print "wall.Construction_Name = %s" % (bwall.Construction_Name, )
    # print "wall.Constr = %s" % (bwall.Constr, )
    # print
    assert bwall.Construction_Name == bwall.Constr
    # print "change wall.Constr"
    bwall.Constr = 'AnewConstr'
    # print "wall.Constr = %s" % (bwall.Constr, )
    # print "wall.Constr = %s" % (data.dt[wallkey][0][3], )
    # print
    assert bwall.Constr == data.dt[wallkey][0][3]

    # add functions
    bwall.__functions = {'svalues':bunch_subclass.somevalues} 

    # print bwall.svalues
    assert bwall.svalues == ('Gumby', 'AnewConstr', ['BuildingSurface:Detailed', 'Gumby', 'Wall', 'AnewConstr', 'West Zone', 'Outdoors', '', 'SunExposed', 'WindExposed', '0.5000000', '4', '0', '0', '3.048000', '0', '0', '0', '6.096000', '0', '0', '6.096000', '0', '3.048000'])
    
    # print bwall.__functions
    
    # test __getitem__
    assert bwall["Name"] == data.dt[wallkey][0][1]
    # test __setitem__
    newname = "loofah"
    bwall["Name"] = newname
    assert bwall.Name == newname
    assert bwall["Name"] == newname
    assert data.dt[wallkey][0][1] == newname
    # test functions and alias again
    assert bwall.Constr == data.dt[wallkey][0][3]
    assert bwall.svalues == (newname, 'AnewConstr', ['BuildingSurface:Detailed', newname, 'Wall', 'AnewConstr', 'West Zone', 'Outdoors', '', 'SunExposed', 'WindExposed', '0.5000000', '4', '0', '0', '3.048000', '0', '0', '0', '6.096000', '0', '0', '6.096000', '0', '3.048000'])
    # test bunch_subclass.BadEPFieldError
    with pytest.raises(bunch_subclass.BadEPFieldError):
        bwall.Name_atypo = "newname"
    with pytest.raises(bunch_subclass.BadEPFieldError):
        thename = bwall.Name_atypo
    with pytest.raises(bunch_subclass.BadEPFieldError):
        bwall["Name_atypo"] = "newname"
    with pytest.raises(bunch_subclass.BadEPFieldError):
        thename = bwall["Name_atypo"]

    # test where constr["obj"] has to be extended
    # more items are added to an extendible field
    constr_i = dtls.index('Construction'.upper())
    constrkey = 'Construction'.upper()
    constridd = commdct[constr_i]
    dconstrs = dt[constrkey]
    dconstr = dconstrs[0]
    constrfields = [comm.get('field') for comm in commdct[constr_i]]
    constrfields[0] = ['key']
    constrfields = [field[0] for field in constrfields]
    constr_fields = [bunchhelpers.makefieldname(field) for field in constrfields]
    bconstr = EpBunch(dconstr, constr_fields, constridd)
    assert bconstr.Name == "Dbl Clr 3mm/13mm Air"
    bconstr.Layer_4 = "butter"
    assert bconstr.obj == ['Construction', 'Dbl Clr 3mm/13mm Air', 'CLEAR 3MM', 'AIR 13MM', 'CLEAR 3MM', 'butter']
    bconstr.Layer_7 = "cheese"
    assert bconstr.obj == ['Construction', 'Dbl Clr 3mm/13mm Air', 'CLEAR 3MM', 'AIR 13MM', 'CLEAR 3MM', 'butter', '', '', 'cheese']
    bconstr["Layer_8"] = "jam"
    assert bconstr.obj == ['Construction', 'Dbl Clr 3mm/13mm Air', 'CLEAR 3MM', 'AIR 13MM', 'CLEAR 3MM', 'butter', '', '', 'cheese', 'jam']
    
    # retrieve a valid field that has no value
    assert bconstr.Layer_10 == ''
    assert bconstr["Layer_10"] == ''
    os.remove(iddfile)
    os.remove(fname)
コード例 #13
0
def getedges(fname, iddfile):
    """return the edges of the idf file fname"""
    data, commdct, _idd_index = readidf.readdatacommdct(fname, iddfile=iddfile)
    edges = makeairplantloop(data, commdct)
    return edges
コード例 #14
0
ファイル: loopdiagram.py プロジェクト: jmarrec/eppy
def getedges(fname, iddfile, do_plant_loops=True, do_air_loops=True):
    """return the edges of the idf file fname"""
    data, commdct, _iddindex = readidf.readdatacommdct(fname, iddfile=iddfile)
    edges = makeairplantloop(data, commdct, do_plant_loops, do_air_loops)
    return edges