def test_ddy_from_design_day():
    """Test ddy from design day method."""
    relative_path = './tests/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    new_ddy = DDY.from_design_day(ddy.design_days[0])
    assert ddy.location == new_ddy.location
    assert ddy.design_days[0] == new_ddy.design_days[0]
def test_dict_methods():
    """Test dict methods for the DDY object."""
    relative_path = './tests/ddy/chicago.ddy'
    ddy = DDY.from_ddy_file(relative_path)

    ddy_dict = ddy.to_dict()
    reconstructed_ddy = DDY.from_dict(ddy_dict)
    assert ddy_dict == reconstructed_ddy.to_dict()
Beispiel #3
0
    def test_json_methods(self):
        """Test json methods for the DDY object."""
        relative_path = './tests/ddy/chicago.ddy'
        ddy = DDY.from_ddy_file(relative_path)

        ddy_json = ddy.to_json()
        reconstructed_ddy = DDY.from_json(ddy_json)
        assert ddy_json == reconstructed_ddy.to_json()
def test_import_ddy():
    """Test import standard ddy."""
    relative_path = './tests/ddy/chicago.ddy'
    abs_path = os.path.abspath(relative_path)

    ddy_rel = DDY.from_ddy_file(relative_path)
    ddy = DDY.from_ddy_file(abs_path)

    # Test imports don't break
    assert ddy.file_path == abs_path
    assert ddy_rel.file_path == os.path.normpath(relative_path)
Beispiel #5
0
    def test_monthly_cooling_design_days(self):
        relative_path = './tests/stat/chicago.stat'
        stat = STAT(relative_path)

        m_ddy_050 = stat.monthly_cooling_design_days_050
        m_ddy_100 = stat.monthly_cooling_design_days_100
        m_ddy_020 = stat.monthly_cooling_design_days_020
        m_ddy_004 = stat.monthly_cooling_design_days_004

        assert len(m_ddy_050) == len(m_ddy_100) == len(m_ddy_020) == \
            len(m_ddy_004) == 12

        ddy_path = './tests/ddy/chicago_monthly.ddy'
        monthly_ddy = DDY(stat.location, m_ddy_050)
        monthly_ddy.save(ddy_path)
Beispiel #6
0
def test_monthly_cooling_design_days():
    """Test the monthly cooling design days within the stat object."""
    relative_path = './tests/stat/chicago.stat'
    stat = STAT(relative_path)

    m_ddy_050 = stat.monthly_cooling_design_days_050
    m_ddy_100 = stat.monthly_cooling_design_days_100
    m_ddy_020 = stat.monthly_cooling_design_days_020
    m_ddy_004 = stat.monthly_cooling_design_days_004

    assert len(m_ddy_050) == len(m_ddy_100) == len(m_ddy_020) == \
        len(m_ddy_004) == 12

    ddy_path = './tests/ddy/chicago_monthly.ddy'
    monthly_ddy = DDY(stat.location, m_ddy_050)
    monthly_ddy.save(ddy_path)
def test_monthly_ddy_properties():
    """Test properties of a monthly ddy."""
    relative_path = './tests/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)

    # Test accuracy of import
    assert ddy.location.city == 'Chicago Ohare Intl Ap'
    assert ddy.location.latitude == approx(41.96, rel=1e-1)
    assert ddy.location.longitude == approx(-87.92, rel=1e-1)
    assert ddy.location.time_zone == -6
    assert ddy.location.elevation == 201

    assert len(ddy.design_days) == 12
    for des_day in ddy.design_days:
        assert hasattr(des_day, 'isDesignDay')
        assert des_day.day_type == 'SummerDesignDay'
def test_standard_ddy_properties():
    """Test properties of a standard ddy."""
    relative_path = './tests/ddy/tokyo.ddy'

    ddy = DDY.from_ddy_file(relative_path)

    # Test accuracy of import
    assert ddy.location.city == 'TOKYO HYAKURI_JPN Design_Conditions'
    assert ddy.location.latitude == approx(36.18, rel=1e-1)
    assert ddy.location.longitude == approx(140.42, rel=1e-1)
    assert ddy.location.time_zone == 9
    assert ddy.location.elevation == 35

    assert len(ddy.design_days) == 18
    for des_day in ddy.design_days:
        assert hasattr(des_day, 'isDesignDay')
    assert len(ddy.filter_by_keyword('.4%')) == 4
    assert len(ddy.filter_by_keyword('99.6%')) == 3
def test_write_ddy():
    """Test write ddy."""
    relative_path = './tests/ddy/chicago.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    new_file_path = './tests/ddy/chicago_edited.ddy'
    ddy.save(new_file_path)
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
"""
Import data from a standard .ddy file.

-

    Args:
        _ddy_file: A .ddy file path on your system as a string.
        
    Returns:
        location: A Ladybug Location object describing the location data in the DDY file.
        design_days: A list of DesignDay objects representing the design days
            contained within the ddy file.
"""

ghenv.Component.Name = "LadybugPlus_Import DDY"
ghenv.Component.NickName = 'importDDY'
ghenv.Component.Message = 'VER 0.0.04\nOCT_14_2018'
ghenv.Component.Category = "LadybugPlus"
ghenv.Component.SubCategory = '00 :: Ladybug'
ghenv.Component.AdditionalHelpFromDocStrings = "4"

try:
    from ladybug.designday import DDY
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

if _ddy_file:
    ddy_obj = DDY.from_ddy_file(_ddy_file)
    location = ddy_obj.location
    design_days = ddy_obj.design_days
Beispiel #11
0
        
    Returns:
        ddy_file: A .ddy file path that has been written to your system.
"""

ghenv.Component.Name = "LadybugPlus_Write DDY"
ghenv.Component.NickName = 'writeDDY'
ghenv.Component.Message = 'VER 0.0.04\nOCT_14_2018'
ghenv.Component.Category = "LadybugPlus"
ghenv.Component.SubCategory = '00 :: Ladybug'
ghenv.Component.AdditionalHelpFromDocStrings = "5"

import os
try:
    from ladybug.designday import DDY
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

if _location and _design_days != [] and _run == True:
    # default folder and file name
    if _folder_ is None:
        _folder_ = os.path.join(os.environ['USERPROFILE'], 'ladybug')
    if _name_ is None:
        _name_ = 'unnamed.ddy'
    if not _name_.lower().endswith('.ddy'):
        _name_ = _name_ + '.ddy'
    ddy_file = os.path.join(_folder_, _name_)

    # write the DDY file
    ddy_obj = DDY(_location, _design_days)
    ddy_obj.save(ddy_file)