Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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]
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo n.º 5
0
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'
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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