コード例 #1
0
    def TDSECalculator(self, eplusOutputTables, PATH_TO_ESO):
        # Getting Tables That We Need From HTML or HTM
        for eplusOutputTable in eplusOutputTables:
            if 'Zone Sensible Cooling' in str(eplusOutputTable[0]):
                zoneSensibleCoolingTable = eplusOutputTable[1]

        self.calculatedDesignLoad = 0
        for num in range(1, len(zoneSensibleCoolingTable)):
            self.calculatedDesignLoad = self.calculatedDesignLoad + zoneSensibleCoolingTable[
                num][1]

        eso = esoreader.read_from_path(PATH_TO_ESO)

        CoolingTower = eso.dd.find_variable('Tower')

        if CoolingTower == []:
            self.airCooledChilledWaterSystem(eso)
            self.System = 'Air Cooled Chilled Water System'
            self.judgeAirTDSE(self.calculatedDesignLoad,
                              self.airCooledChillerPlantEfficiency,
                              self.airDistributionEfficiency)
        else:
            self.waterCooledChilledWaterSystem(eso)
            self.System = 'Water Cooled Chilled Water System'
            self.judgeWaterTDSE(self.calculatedDesignLoad,
                                self.waterCooledChillerPlantEfficiency,
                                self.airDistributionEfficiency)
コード例 #2
0
def _cesar_summary_one_bldg_annual(
        single_result_folder: str, res_param_keys,
        ureg: pint.UnitRegistry) -> Dict[str, pint.Quantity]:
    """
    Quite tailered function to assemble yearly results for one building. It should replicate the result summary excel file known from the cesar Matlab version.
    All energies (Unit J) are reported by square meter, which is done by dividing the per building demand by the total floor area.
    Includes the total floor area of the building, which is retrieved from the eio eplus results file.

    :param single_result_folder: folder with energy plus result files for one building (expected files: eplusout.eso and eplusout.eio)
    :param res_param_keys: name of result parameters to collect
    :param ureg: reference to unit registry object
    :param do_report_agg_val: names of result parameters to add as per building values
    :return: pandas.DataFrame with one row, columns with a multiindex of parameter name and unit
    """
    eso = esoreader.read_from_path(single_result_folder / Path(_ESO_FILE_NAME))

    res = dict()
    # res = pd.DataFrame(columns=pd.MultiIndex(levels=[[], []], codes=[[], []], names=[PD_FRAME_IDX_VAR_NAME, PD_FRAME_IDX_UNIT_NAME]))
    for res_param in res_param_keys:
        variables = eso.find_variable(res_param,
                                      key=None,
                                      frequency=ResultsFrequency.ANNUAL.value)
        for var in variables:
            (data, unit_str) = __get_data_series_with_unit(eso, var)
            data_w_unit = data[0] * ureg(unit_str) / ureg.year
            try:
                data_w_unit = data_w_unit.to(ureg.kWh / ureg.year)
            except pint.errors.DimensionalityError:
                pass
            res[var[2]] = data_w_unit
    return res
コード例 #3
0
def results():
    setup_name = request.args.get('name')
    setup_path = BASE_PATH / setup_name

    variables = request.args.getlist('variables')  # list
    simulation_id = request.args.get('id')
    typ = request.args.get('type')
    period = request.args.get('period')

    debug_message = 'Reading results for {n} with id: {id}'.format(
        n=setup_name, id=simulation_id)
    debug_message += '; type: {t}; period: {p}, variables: {v}'.format(
        t=typ, p=period, v=variables)
    app.logger.debug(debug_message)

    simulation_address = setup_path / "run" / simulation_id
    if not simulation_address.exists():
        message = 'No result directory for id: {i}'.format(i=simulation_id)
        app.logger.debug(message)
        return message

    end_path = simulation_address / 'eplusout.end'
    with end_path.open('r') as end_file:
        end_success = end_file.readline()
        app.logger.debug(end_success)
    if 'EnergyPlus Completed Successfully' not in end_success:
        message = 'Simulation failed for id: {i}'.format(i=simulation_id)
        app.logger.info(message)
        return message

    eso_path = simulation_address / 'eplusout.eso'
    if not eso_path.exists():
        message = 'No result for id: {i}'.format(i=simulation_id)
        app.logger.debug(message)
        return message

    eso = esoreader.read_from_path(str(eso_path))

    with VARS_ADDRESS.open('r') as var_data:
        var_info = json.load(var_data)
        var_dict = var_info['var_dict']
        units = var_info['units']

    res_dfs = []
    # app.logger.debug(variables)
    for var in variables:
        var_name = var_dict[typ][var]
        df = eso.to_frame(var_name, frequency=period)
        df = df.sum(axis='columns')
        df.name = var
        if units[var] == 'J':  # Convert to kWh
            df /= (3.6 * 1e6)
        elif units[var] == '-J':
            df /= -(3.6 * 1e6)
        res_dfs.append(df)

    result = pd.concat(res_dfs, axis='columns')

    return jsonify(result.to_json(orient='split'))
コード例 #4
0
    def __init__(self):
        path = os.path.abspath('.')
        sys.path.append(path)
        PATH_TO_ESO = "5ZoneAirCooled.eso"
        eso = esoreader.read_from_path(PATH_TO_ESO)

        CoolingTower = eso.dd.find_variable('Tower')

        if CoolingTower == []:
            self.airCooledChilledWaterSystem(eso)
        else:
            self.waterCooledChilledWaterSystem(eso)
コード例 #5
0
    def results_detailed_local(self, variable: str, name: str, sim_id: str, typ: str, period: str):

        simulation_address = Path(f'{self.output_directory}_{name}') / sim_id
        eso_path = simulation_address / 'eplusout.eso'
        eso = esoreader.read_from_path(str(eso_path))

        var_name = EnergyPlusSimulation.var_dict[typ][variable]
        df = eso.to_frame(var_name, frequency=period)
        if EnergyPlusSimulation.units[variable] == 'J':  # Convert to kWh
            df /= (3.6 * 1e6)
        elif EnergyPlusSimulation.units[variable] == '-J':
            df /= -(3.6 * 1e6)

        return df
コード例 #6
0
def collect_multi_entry_annual_result(single_result_folder: str,
                                      var_name: str):

    eso = esoreader.read_from_path(single_result_folder / Path(_ESO_FILE_NAME))

    variable_instances = eso.dd.find_variable(var_name)

    results_dict = {}

    for var_def in variable_instances:
        # index pos 1 = entry name e.g. surface name
        (data, unit) = __get_data_series_with_unit(eso, var_def)
        assert len(
            data
        ) == 1, f"data (f{var_def}) is not a single value, it has more than one value!"
        results_dict[var_def[1]] = data[0]

    return results_dict
コード例 #7
0
    def results_local(self, variables: Union[str, List[str]], name: str,  sim_id: str,
                      typ: str = 'zone', period: str = 'monthly'):
        if variables == 'all':
            variables = EnergyPlusSimulation.var_dict[typ.lower()].keys()

        elif isinstance(variables, str):
            variables = [variables]

        simulation_address = Path(f'{self.output_directory}_{name}') / sim_id

        if not simulation_address.exists():
            message = 'No result directory for id: {i}'.format(i=sim_id)
            logger.debug(message)
            return message

        end_path = simulation_address / 'eplusout.end'
        with end_path.open('r') as end_file:
            end_success = end_file.readline()
            logger.debug(end_success)
        if 'EnergyPlus Completed Successfully' not in end_success:
            message = 'Simulation failed for id: {i}'.format(i=sim_id)
            logger.info(message)
            return message

        eso_path = simulation_address / 'eplusout.eso'
        if not eso_path.exists():
            message = 'No result for id: {i}'.format(i=sim_id)
            logger.debug(message)
            return message

        eso = esoreader.read_from_path(str(eso_path))
        res_dfs = []
        for var in variables:
            var_name = EnergyPlusSimulation.var_dict[typ][var]
            df = eso.to_frame(var_name, frequency=period)
            df = df.sum(axis='columns')
            df.name = var
            if EnergyPlusSimulation.units[var] == 'J':  # Convert to kWh
                df /= (3.6*1e6)
            elif EnergyPlusSimulation.units[var] == '-J':
                df /= -(3.6 * 1e6)
            res_dfs.append(df)

        return pd.concat(res_dfs, axis='columns')
コード例 #8
0
def results_detailed():
    setup_name = request.args.get('name')
    setup_path = BASE_PATH / setup_name

    variable = request.args.get('variable')
    simulation_id = request.args.get('id')
    typ = request.args.get('type')
    period = request.args.get('period')

    simulation_address = setup_path / "run" / simulation_id
    end_path = simulation_address / 'eplusout.end'
    with end_path.open('r') as end_file:
        end_success = end_file.readline()
    if 'EnergyPlus Completed Successfully' not in end_success:
        message = 'Simulation failed for id: {i}'.format(i=simulation_id)
        app.logger.debug(message)
        return message
    eso_path = simulation_address / 'eplusout.eso'
    if not eso_path.exists():
        message = 'No result for id: {i}'.format(i=simulation_id)
        app.logger.debug(message)
        return message

    eso = esoreader.read_from_path(str(eso_path))

    with VARS_ADDRESS.open('r') as var_data:
        var_info = json.load(var_data)
        var_dict = var_info['var_dict']
        units = var_info['units']

    var_name = var_dict[typ][variable]
    df = eso.to_frame(var_name, frequency=period)
    if units[variable] == 'J':  # Convert to kWh
        df /= (3.6 * 1e6)
    elif units[variable] == '-J':
        df /= -(3.6 * 1e6)

    return jsonify(df.to_json(orient='split'))
コード例 #9
0
ファイル: timeseries.py プロジェクト: katsuya0719/EPengine
 def read(self, path):
     eso = esoreader.read_from_path(path)
     self.eso = eso
     self.getKeyword()
コード例 #10
0
def collect_multi_params_for_site(
        result_folders: Mapping[int, str], result_keys: Sequence,
        results_frequency: ResultsFrequency) -> pd.DataFrame:
    """
    Returns data in a flat pandas DataFrame. Index is sequence from 0..n, columns are timing, fid, var (variable name), value, unit.
    You can import this data series e.g. into Excel and create a pivot table to analyze the data.

    To convert the result to a mutli-indexed DataFrame, do:
        `res_mi = res_df.set_index(["fid", "var", "unit"], append=True)`
    if you further want to convert the row-multiindex to column-multiindex, do:
        `res_tbl = res_mi.unstack(["fid", "var", "unit"])`
    To select data from the res_tbl with columns mutli-index, do:
        Select all results for certain fid:
            `fid_res = res_tbl.xs(1, level="fid", axis=1)`
        To remove the unit header do:
            `fid_res.columns = fid_res.columns.droplevel("unit")`
        Select all results for timestep 3 (if hourly that would be hour 4) - result is a series
        `res_tbl.loc[3]`

    :param result_folders: folders containing result files, one eso file named eplusout.eso is expected per folder
    :param result_keys: List of names of the result parameters to get. Parameter name has to point to unique result, e.g. DistrictHeating:HVAC (not only DistrictHeating).
    :param results_frequency: Time steps of results, e.g. RunPeriod, Hourly
    :return: pandas.DataFrame with MulitIndex, Level 0 fid, Level 1 result key
    """

    aggregated_res = pd.DataFrame(columns=["fid", "var", "value", "unit"])
    for fid, single_result_folder in result_folders.items():
        try:
            eso_path = single_result_folder / Path(_ESO_FILE_NAME)
            logging.getLogger(__name__).debug(f"Open {eso_path}")
            eso = esoreader.read_from_path(eso_path)
        except FileNotFoundError:
            logging.getLogger(__name__).warning(
                f"No {eso_path} not found. Skipping.")
            continue
        except Exception as msg:
            logging.getLogger(__name__).warning(
                f"Malformed eso {eso_path}. Skipping. Caused by: {msg}")
            continue
        for result_key in result_keys:
            try:
                vars_matching = eso.find_variable(
                    result_key, frequency=results_frequency.value)
                if not vars_matching:
                    logging.getLogger(__name__).warning(
                        f"{result_key} not found in {eso_path}. Skipping.")
                    continue
                (data,
                 unit) = __get_data_series_with_unit(eso, vars_matching[0])
                res = pd.DataFrame(data, columns=["value"])
                res["fid"] = fid
                res["unit"] = unit
                res["var"] = result_key
                aggregated_res = pd.concat([aggregated_res, res], sort=False)
                aggregated_res.index.name = "timing"
            except Exception as msg:
                logging.getLogger(__name__).warning(
                    f"Variable {result_key} could not be extracted from {eso_path}. Skipping this variable. Caused by: {msg}"
                )
                continue
    return aggregated_res