示例#1
0
文件: ddy_test.py 项目: zha/ladybug
def test_ddy_from_design_day():
    """Test ddy from design day method."""
    relative_path = './tests/fixtures/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]
示例#2
0
文件: ddy_test.py 项目: zha/ladybug
def test_dict_methods():
    """Test dict methods for the DDY object."""
    relative_path = './tests/fixtures/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()
    for dday1, dday2 in zip(ddy.design_days, reconstructed_ddy.design_days):
        assert dday1 == dday2
示例#3
0
文件: ddy_test.py 项目: zha/ladybug
def test_import_ddy():
    """Test import standard ddy."""
    relative_path = './tests/fixtures/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)
示例#4
0
def test_monthly_cooling_design_days():
    """Test the monthly cooling design days within the stat object."""
    relative_path = './tests/fixtures/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/fixtures/ddy/chicago_monthly.ddy'
    monthly_ddy = DDY(stat.location, m_ddy_050)
    monthly_ddy.save(ddy_path)
    def to_ddy(self):
        """Get this SizingParameter as a Ladybug DDY object.

        This can be written to a .ddy file if so desired.
        """
        assert len(self._design_days) != 0, \
            'There must be at least one design_day to use SizingParameter.to_ddy.'
        return DDY(self._design_days[0].location, self._design_days)
示例#6
0
def test_sizing_parameter_to_ddy():
    """Test the setting of properties of SizingParameter."""
    sizing = SizingParameter()
    relative_path = './tests/ddy/chicago_monthly.ddy'
    sizing.add_from_ddy(relative_path)
    ddy_obj = DDY.from_ddy_file(relative_path)

    assert sizing.to_ddy() == ddy_obj
    def add_from_ddy(self, ddy_file):
        """Add all design days within a .ddy file to this object.

        Args:
            ddy_file: The full path to a .ddy file on this machine.
        """
        ddy_obj = DDY.from_ddy_file(ddy_file)
        for dday in ddy_obj:
            self._design_days.append(dday)
示例#8
0
文件: ddy_test.py 项目: zha/ladybug
def test_duplicate():
    """Test duplicate method for the DDY object."""
    relative_path = './tests/fixtures/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    ddy_dup = ddy.duplicate()

    assert ddy is ddy
    assert ddy is not ddy_dup
    assert ddy == ddy_dup
    ddy_dup[0].dry_bulb_condition.dry_bulb_max = 40
    assert ddy != ddy_dup
    def add_from_ddy_keyword(self, ddy_file, keyword):
        """Add DesignDays from a .ddy file using a keyword in the DesignDay name.

        Args:
            ddy_file: The full path to a .ddy file on this machine.
            keyword: String for a keyword, which will be used to select DesignDays
                from the .ddy file to add to this object.
        """
        ddy_obj = DDY.from_ddy_file(ddy_file)
        for dday in ddy_obj:
            if keyword in dday.name:
                self._design_days.append(dday)
示例#10
0
def epw_to_ddy(epw_file, percentile, output_file):
    """Get a DDY file with a heating + cooling design day from this EPW.

    This method will first check if there is a heating or cooling design day
    that meets the input percentile within the EPW itself. If None is
    found, the heating and cooling design days will be derived from analysis
    of the annual data within the EPW, which is usually less accurate.

    \b
    Args:
        epw_file: Path to an .epw file.
    """
    try:
        epw_obj = EPW(epw_file)
        ddy_obj = DDY(epw_obj.location, epw_obj.best_available_design_days(percentile))
        output_file.write(ddy_obj.to_file_string())
    except Exception as e:
        _logger.exception('DDY translation failed.\n{}'.format(e))
        sys.exit(1)
    else:
        sys.exit(0)
示例#11
0
文件: ddy_test.py 项目: zha/ladybug
def test_duplicate_design_day():
    """Test duplicate method for the DesignDay object."""
    relative_path = './tests/fixtures/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)

    des_day = ddy[0]
    des_day_dup = des_day.duplicate()

    assert des_day is des_day
    assert des_day is not des_day_dup
    assert des_day == des_day_dup
    des_day_dup.dry_bulb_condition.dry_bulb_max = 40
    assert des_day != des_day_dup
示例#12
0
    def add_from_ddy_990_010(self, ddy_file):
        """Add the 99.0% and 1.0% design days within a .ddy file to this object.

        99.0% means that this percent of the hours of the year have outside heating
        conditions warmer than this design day. 1.0% means that this percent of the
        hours of the year have outside cooling conditions cooler than this design day.

        Args:
            ddy_file: The full path to a .ddy file on this machine.
        """
        ddy_obj = DDY.from_ddy_file(ddy_file)
        for dday in ddy_obj:
            if '99%' in dday.name or '1%' in dday.name:
                self._design_days.append(dday)
示例#13
0
文件: ddy_test.py 项目: zha/ladybug
def test_monthly_ddy_properties():
    """Test properties of a monthly ddy."""
    relative_path = './tests/fixtures/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 isinstance(des_day, DesignDay)
        assert des_day.day_type == 'SummerDesignDay'
示例#14
0
文件: ddy_test.py 项目: zha/ladybug
def test_standard_ddy_properties():
    """Test properties of a standard ddy."""
    relative_path = './tests/fixtures/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 isinstance(des_day, DesignDay)
    assert len(ddy.filter_by_keyword('.4%')) == 4
    assert len(ddy.filter_by_keyword('99.6%')) == 3
    _sim_par_.output.reporting_frequency = 'Timestep'
    _sim_par_.simulation_control.run_for_sizing_periods = True
    _sim_par_.simulation_control.run_for_run_periods = False
    if run_bal_:
        _sim_par_.output.add_zone_energy_use('Sensible')
        _sim_par_.output.add_gains_and_losses('Sensible')
        _sim_par_.output.add_surface_energy_flow()

    # load design days to the simulation parameters
    if _ddy_file.lower().endswith('.epw'):  # load design days from EPW
        epw_obj = EPW(_ddy_file)
        des_days = epw_obj.best_available_design_days()
        _sim_par_.sizing_parameter.design_days = des_days
        location = epw_obj.location
    else:  # load design days from DDY
        ddy_obj = DDY.from_ddy_file(_ddy_file)
        w_days = [
            day for day in ddy_obj.design_days
            if day.day_type == 'WinterDesignDay'
        ]
        s_days = [
            day for day in ddy_obj.design_days
            if day.day_type == 'SummerDesignDay'
        ]
        check_and_filter_des_days(_sim_par_, w_days, 'WinterDesignDay')
        check_and_filter_des_days(_sim_par_, s_days, 'SummerDesignDay')
        location = ddy_obj.location

    # get the dates of the heating and cooling design days
    h_dt = _sim_par_.sizing_parameter.design_days[0].sky_condition.date
    c_dt = _sim_par_.sizing_parameter.design_days[1].sky_condition.date
示例#16
0
文件: ddy_test.py 项目: zha/ladybug
def test_write_ddy():
    """Test write ddy."""
    relative_path = './tests/fixtures/ddy/chicago.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    new_file_path = './tests/fixtures/ddy/chicago_edited.ddy'
    ddy.save(new_file_path)