Exemplo n.º 1
0
def base_idf():
    iddsnippet = iddcurrent.iddtxt
    iddfhandle = StringIO(iddsnippet)
    if IDF.getiddname() == None:
        IDF.setiddname(iddfhandle)
    idftxt = ""
    idfhandle = StringIO(idftxt)
    idf = IDF(idfhandle)
    return idf
Exemplo n.º 2
0
def view_idf(fname=None, idf_txt=None, test=False):
    # type: (Optional[str], Optional[str], Optional[bool]) -> None
    """Display an IDF for inspection.

    :param fname: Path to the IDF.
    :param idf_txt: The string representation of an IDF.
    """
    try:
        plt.figure()
    except TclError:
        # this is as expected on the test server
        return
    if fname and idf_txt:
        raise ValueError('Pass either fname or idf_txt, not both.')
    # set the IDD for the version of EnergyPlus
    iddfhandle = StringIO(iddcurrent.iddtxt)
    if IDF.getiddname() is None:
        IDF.setiddname(iddfhandle)

    if fname:
        # import the IDF
        idf = IDF(fname)
    elif idf_txt:
        idf = IDF()
        idf.initreadtxt(idf_txt)
    # create the figure and add the surfaces
    ax = plt.axes(projection='3d')
    collections = _get_collections(idf, opacity=0.5)
    for c in collections:
        ax.add_collection3d(c)

    # calculate and set the axis limits
    limits = _get_limits(idf=idf)
    ax.set_xlim(limits['x'])
    ax.set_ylim(limits['y'])
    ax.set_zlim(limits['z'])

    if not test:
        plt.show()
Exemplo n.º 3
0
def view_idf(fname=None, idf_txt=None):
    """Display an IDF for inspection.
    
    Parameters
    ----------
    fname : str
        Path to the IDF.
    idf_txt : str
        The string representation of an IDF.

    """
    # set the IDD for the version of EnergyPlus
    iddfhandle = StringIO(iddcurrent.iddtxt)
    if IDF.getiddname() == None:
        IDF.setiddname(iddfhandle)

    if fname:
        # import the IDF
        idf = IDF(fname)
    elif idf_txt:
        idf = IDF()
        idf.initreadtxt(idf_txt)
    # create the figure and add the surfaces
    fig = plt.figure()
    ax = plt.axes(projection='3d')
    collections = _get_collections(idf, opacity=0.5)
    for c in collections:
        ax.add_collection3d(c)

    # calculate and set the axis limits
    limits = _get_limits(idf=idf)
    ax.set_xlim(limits['x'])
    ax.set_ylim(limits['y'])
    ax.set_zlim(limits['z'])

    plt.show()
Exemplo n.º 4
0
# =======================================================================
"""py.test for hvacbuilder"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import eppy.hvacbuilder as hvacbuilder
from eppy.modeleditor import IDF
from six import StringIO

# idd is read only once in this test
# if it has already been read from some other test, it will continue with the old reading
from eppy.iddcurrent import iddcurrent
iddfhandle = StringIO(iddcurrent.iddtxt)
if IDF.getiddname() == None:
    IDF.setiddname(iddfhandle)


def test_flattencopy():
    """py.test for flattencopy"""
    tdata = (
        ([1, 2], [1, 2]),  #lst , nlst
        ([1, 2, [3, 4]], [1, 2, 3, 4]),  #lst , nlst
        ([1, 2, [3, [4, 5, 6], 7, 8]], [1, 2, 3, 4, 5, 6, 7, 8]),  #lst , nlst
        ([1, 2, [3, [4, 5, [6, 7], 8], 9]], [1, 2, 3, 4, 5, 6, 7, 8, 9]),
        #lst , nlst
    )
    for lst, nlst in tdata:
        result = hvacbuilder.flattencopy(lst)
        assert result == nlst
Exemplo n.º 5
0
from eppy.pytest_helpers import almostequal
import eppy.snippet as snippet


iddsnippet = iddcurrent.iddtxt
idfsnippet = snippet.idfsnippet

# idffhandle = StringIO(idfsnippet)
# iddfhandle = StringIO(iddsnippet)
# bunchdt, data, commdct, gdict = idfreader.idfreader(idffhandle, iddfhandle, None)

# idd is read only once in this test
# if it has already been read from some other test, it will continue with
# the old reading
iddfhandle = StringIO(iddcurrent.iddtxt)
if IDF.getiddname() == None:
    IDF.setiddname(iddfhandle)


def test_poptrailing():
    """py.test for poptrailing"""
    tdata = (
        (
            [1, 2, 3, '', 56, '', '', '', ''],
            [1, 2, 3, '', 56]
        ),  # lst, popped
        (
            [1, 2, 3, '', 56],
            [1, 2, 3, '', 56]
        ),  # lst, popped
        (
Exemplo n.º 6
0
WindExposed,             !- Wind Exposure
0.50000,                 !- View Factor to Ground
4,                       !- Number of Vertices
0.0,0.0,3.0,  !- X,Y,Z ==> Vertex 1 {m}
0.0,0.0,2.4,  !- X,Y,Z ==> Vertex 2 {m}
30.5,0.0,2.4,  !- X,Y,Z ==> Vertex 3 {m}
30.5,0.0,3.0;  !- X,Y,Z ==> Vertex 4 {m}
BranchList,
Heating Supply Side Branches,  !- Name
Heating Supply Inlet Branch,  !- Branch 1 Name
Central Boiler Branch,   !- Branch 2 Name
Heating Supply Bypass Branch,  !- Branch 3 Name
Heating Supply Outlet Branch;  !- Branch 4 Name
"""

if IDF.getiddname() is None:
    IDF.setiddname(StringIO(iddtxt))


def test_extensiblefields2list():
    """py.test for extensiblefields2list"""
    tdata = (
        ("branchlist", False, [
            "Heating Supply Inlet Branch", "Central Boiler Branch",
            "Heating Supply Bypass Branch", "Heating Supply Outlet Branch"
        ]),  # idfkey, nested, expected
        ("BuildingSurface:Detailed", False,
         [0.0, 0.0, 3.0, 0.0, 0.0, 2.4, 30.5, 0.0, 2.4, 30.5, 0.0,
          3.0]),  # idfkey, nested, expected
        ("BuildingSurface:Detailed", True, [(0.0, 0.0, 3.0), (0.0, 0.0, 2.4),
                                            (30.5, 0.0, 2.4), (30.5, 0.0, 3.0)