<commit_before># -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import division

"""
Classes of building properties
"""

from __future__ import division

import numpy as np
import pandas as pd
from geopandas import GeoDataFrame as Gdf

from cea.demand import constants
from cea.utilities.dbf import dbf_to_dataframe
from cea.datamanagement.data_helper import get_list_of_uses_in_case_study, calc_mainuse

# import constants
H_F = constants.H_F
RSE = constants.RSE
H_MS = constants.H_MS
H_IS = constants.H_IS
B_F = constants.B_F
LAMBDA_AT = constants.LAMBDA_AT


class BuildingProperties(object):
    """
    Groups building properties used for the calc-thermal-loads functions. Stores the full DataFrame for each of the
    building properties and provides methods for indexing them by name.

    <NAME>   BuildingPropsThermalLoads   27.05.2016
    """

    def __init__(self, locator, override_variables=False):
        """
        Read building properties from input shape files and construct a new BuildingProperties object.

        :param locator: an InputLocator for locating the input files
        :type locator: cea.inputlocator.InputLocator

        :param override_variables: override_variables from config
        :type override_variables: bool

        :returns: BuildingProperties
        :rtype: BuildingProperties
        """

        print("read input files")
        prop_geometry = Gdf.from_file(locator.get_zone_geometry())
        prop_geometry['footprint'] = prop_geometry.area
        prop_geometry['perimeter'] = prop_geometry.length
        prop_geometry['Blength'], prop_geometry['Bwidth'] = self.calc_bounding_box_geom(locator.get_zone_geometry())
        prop_geometry = prop_geometry.drop('geometry', axis=1).set_index('Name')
        prop_hvac = dbf_to_dataframe(locator.get_building_hvac())
        prop_occupancy_df = dbf_to_dataframe(locator.get_building_occupancy()).set_index('Name')
        # Drop 'REFERENCE' column if it exists
        if 'REFERENCE' in prop_occupancy_df:
            prop_occupancy_df.drop('REFERENCE', 1, inplace=True)
        prop_occupancy_df.fillna(value=0.0, inplace=True)  # fix badly formatted occupancy file...
        prop_occupancy = prop_occupancy_df.loc[:, (prop_occupancy_df != 0).any(axis=0)]
        prop_architectures = dbf_to_dataframe(locator.get_building_architecture())
        prop_age = dbf_to_dataframe(locator.get_building_age()).set_index('Name')
        # Drop 'REFERENCE' column if it exists
        if 'REFERENCE' in prop_age:
            prop_age.drop('REFERENCE', 1, inplace=True)
        prop_comfort = dbf_to_dataframe(locator.get_building_comfort()).set_index('Name')
        prop_internal_loads = dbf_to_dataframe(locator.get_building_internal()).set_index('Name')
        prop_supply_systems_building = dbf_to_dataframe(locator.get_building_supply())

        # GET SYSTEMS EFFICIENCIES
        prop_supply_systems = get_properties_supply_sytems(locator, prop_supply_systems_building).set_index(
            'Name')

        # get temperatures of operation
        prop_HVAC_result = get_properties_technical_systems(locator, prop_hvac).set_index('Name')

        # get envelope properties
        prop_envelope = get_envelope_properties(locator, prop_architectures).set_index('Name')

        # apply overrides
        if override_variables:
            self._overrides = pd.read_csv(locator.get_building_overrides()).set_index('Name')
            prop_envelope = self.apply_overrides(prop_envelope)
            prop_internal_loads = self.apply_overrides(prop_internal_loads)
            prop_comfort = self.apply_overrides(prop_comfort)
            prop_HVAC_result = self.apply_overrides(prop_HVAC_result)

        # get properties of rc demand model
        prop_rc_model = self.calc_prop_rc_model(locator, prop_occupancy, prop_envelope,
                                                prop_geometry, prop_HVAC_result)

        # get solar properties
        solar = get_prop_solar(locator, prop_rc_model, prop_envelope).set_index('Name')

        # calculate mainuse of buildings -> used in occupancy model to look up temperature set-point schedules
        list_uses = get_list_of_uses_in_case_study(prop_occupancy_df)
        mainuse = calc_mainuse(prop_occupancy_df, list_uses)
        prop_comfort['mainuse'] = mainuse


        # df_windows = geometry_reader.create_windows(surface_properties, prop_envelope)<commit_msg>remove mainuse calculation from building properties<commit_after># -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import division

"""
Classes of building properties
"""

from __future__ import division

import numpy as np
import pandas as pd
from geopandas import GeoDataFrame as Gdf

from cea.demand import constants
from cea.utilities.dbf import dbf_to_dataframe

# import constants
H_F = constants.H_F
RSE = constants.RSE
H_MS = constants.H_MS
H_IS = constants.H_IS
B_F = constants.B_F
LAMBDA_AT = constants.LAMBDA_AT


class BuildingProperties(object):
    """
    Groups building properties used for the calc-thermal-loads functions. Stores the full DataFrame for each of the
    building properties and provides methods for indexing them by name.

    <NAME>   BuildingPropsThermalLoads   27.05.2016
    """

    def __init__(self, locator, override_variables=False):
        """
        Read building properties from input shape files and construct a new BuildingProperties object.

        :param locator: an InputLocator for locating the input files
        :type locator: cea.inputlocator.InputLocator

        :param override_variables: override_variables from config
        :type override_variables: bool

        :returns: BuildingProperties
        :rtype: BuildingProperties
        """

        print("read input files")
        prop_geometry = Gdf.from_file(locator.get_zone_geometry())
        prop_geometry['footprint'] = prop_geometry.area
        prop_geometry['perimeter'] = prop_geometry.length
        prop_geometry['Blength'], prop_geometry['Bwidth'] = self.calc_bounding_box_geom(locator.get_zone_geometry())
        prop_geometry = prop_geometry.drop('geometry', axis=1).set_index('Name')
        prop_hvac = dbf_to_dataframe(locator.get_building_hvac())
        prop_occupancy_df = dbf_to_dataframe(locator.get_building_occupancy()).set_index('Name')
        # Drop 'REFERENCE' column if it exists
        if 'REFERENCE' in prop_occupancy_df:
            prop_occupancy_df.drop('REFERENCE', 1, inplace=True)
        prop_occupancy_df.fillna(value=0.0, inplace=True)  # fix badly formatted occupancy file...
        prop_occupancy = prop_occupancy_df.loc[:, (prop_occupancy_df != 0).any(axis=0)]
        prop_architectures = dbf_to_dataframe(locator.get_building_architecture())
        prop_age = dbf_to_dataframe(locator.get_building_age()).set_index('Name')
        # Drop 'REFERENCE' column if it exists
        if 'REFERENCE' in prop_age:
            prop_age.drop('REFERENCE', 1, inplace=True)
        prop_comfort = dbf_to_dataframe(locator.get_building_comfort()).set_index('Name')
        prop_internal_loads = dbf_to_dataframe(locator.get_building_internal()).set_index('Name')
        prop_supply_systems_building = dbf_to_dataframe(locator.get_building_supply())

        # GET SYSTEMS EFFICIENCIES
        prop_supply_systems = get_properties_supply_sytems(locator, prop_supply_systems_building).set_index(
            'Name')

        # get temperatures of operation
        prop_HVAC_result = get_properties_technical_systems(locator, prop_hvac).set_index('Name')

        # get envelope properties
        prop_envelope = get_envelope_properties(locator, prop_architectures).set_index('Name')

        # apply overrides
        if override_variables:
            self._overrides = pd.read_csv(locator.get_building_overrides()).set_index('Name')
            prop_envelope = self.apply_overrides(prop_envelope)
            prop_internal_loads = self.apply_overrides(prop_internal_loads)
            prop_comfort = self.apply_overrides(prop_comfort)
            prop_HVAC_result = self.apply_overrides(prop_HVAC_result)

        # get properties of rc demand model
        prop_rc_model = self.calc_prop_rc_model(locator, prop_occupancy, prop_envelope,
                                                prop_geometry, prop_HVAC_result)

        # get solar properties
        solar = get_prop_solar(locator, prop_rc_model, prop_envelope).set_index('Name')

        # df_windows = geometry_reader.create_windows(surface_properties, prop_envelope)
{'fraction_non_alphanumeric': 0.07975245212517515, 'fraction_numerical': 0.0037365716954694066, 'mean_word_length': 3.647314161692892, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3082836', 'n_tokens_mistral': 2609, 'n_tokens_neox': 2529, 'n_words': 528}