Пример #1
0
def get_clusters(employment, **kwargs):
    '''
    Find the clusters for weekdays, saturday and sunday for a household member
    of the given eployment type based on the Crosstables given at
    # http://homepages.vub.ac.be/~daerts/Occupancy.html
    '''
    #first go the the correct location
    cdir = os.getcwd()
    PATH = '../Data/Aerts_Occupancy/Crosstables/'
    os.chdir(PATH)
    #create an empty dictionary
    keys = ['wkdy', 'sat', 'son']
    cluDict = dict()
    ##########################################################################
    # we find the cluster for each of the daytypes for the given employment
    # in 'Crosstable_employment.txt'
    for key in keys:
        order = ['U12', 'FTE', 'PTE', 'Unemployed', 'Retired', 'School']
        emp_i = order.index(employment)
        data = np.loadtxt('Crosstable_Employment_' + key + '.txt',
                          float).T[emp_i]
        rnd = np.random.random()
        cluster = stats.get_probability(rnd, data[1:], p_type='prob')
        cluDict.update({key: cluster})
    ##########################################################################
    # and return the final cluster id's
    os.chdir(cdir)
    return cluDict
Пример #2
0
def get_clusters(employment, **kwargs):
    '''
    Find the clusters for weekdays, saturday and sunday for a household member
    of the given eployment type based on the Crosstables given at
    # http://homepages.vub.ac.be/~daerts/Occupancy.html
    '''
    #first go the the correct location
    cdir = os.getcwd()
    PATH = '../Data/Aerts_Occupancy/Crosstables/'
    os.chdir(PATH)
    #create an empty dictionary
    keys = ['wkdy', 'sat', 'son']
    cluDict = dict()
    ##########################################################################
    # we find the cluster for each of the daytypes for the given employment
    # in 'Crosstable_employment.txt'
    for key in keys:
        order = ['U12','FTE','PTE','Unemployed','Retired','School']
        emp_i = order.index(employment)
        data = np.loadtxt('Crosstable_Employment_'+key+'.txt', float).T[emp_i]
        rnd = np.random.random()
        cluster = stats.get_probability(rnd, data[1:], p_type='prob')
        cluDict.update({key:cluster})
    ##########################################################################
    # and return the final cluster id's
    os.chdir(cdir)
    return cluDict
Пример #3
0
    def __shsetting__(self):
        '''
        Simulation of the space heating setting points.
        - Including weekend days,
        - starting from a regular monday at 4:00 AM.
        '''

        #######################################################################
        # we define setting types based on their setpoint temperatures when
        # when being active (1), sleeping (2) or absent (3).
        types = dict()
        types.update({'2' : {1:18.5, 2:15.0, 3:18.5}})
        types.update({'3' : {1:20.0, 2:15.0, 3:19.5}})
        types.update({'4' : {1:20.0, 2:11.0, 3:19.5}})
        types.update({'5' : {1:20.0, 2:14.5, 3:15.0}})
        types.update({'6' : {1:21.0, 2:20.5, 3:21.0}})
        types.update({'7' : {1:21.5, 2:15.5, 3:21.5}})
        # and the probabilities these types occur based on Duth research,
        # i.e. Leidelmeijer and van Grieken (2005).
        types.update({'prob' : [0.16, 0.35, 0.08, 0.11, 0.05, 0.20]})
        # and given a type, denote which rooms are heated
        given = dict()
        given.update({'2' : ['dayzone','bathroom']})
        given.update({'3' : [['dayzone'],['dayzone','bathroom'],['dayzone','nightzone']]})
        given.update({'4' : [['dayzone'],['dayzone','nightzone']]})
        given.update({'5' : ['dayzone']})
        given.update({'6' : ['dayzone','bathroom','nightzone']})
        given.update({'7' : ['dayzone','bathroom']})

        #######################################################################
        # select a type from the given tipes and probabilities
        rnd = np.random.random()
        shtype = str(1 + stats.get_probability(rnd, types['prob'], 'prob'))
        if len(np.shape(given[shtype])) != 1:
            nr = np.random.randint(np.shape(given[shtype])[0])
            shrooms = given[shtype][nr]
        else:
            shrooms = given[shtype]

        #######################################################################
        # create a profile for he heated rooms
        shnon = 12*np.ones(len(self.occ_m[0])+1)
        shset = np.hstack((self.occ_m[0],self.occ_m[0][-1]))
        for key in types[shtype].keys():
            for i in range(len(shset)):
                if int(shset[i]) == key:
                    shset[i] = types[shtype][key]

        #######################################################################
        # and couple to the heated rooms
        sh_settings = dict()
        for room in ['dayzone', 'nightzone', 'bathroom']:
            if room in shrooms:
                sh_settings.update({room:shset})
            else:
                sh_settings.update({room:shnon})
        # and store
        self.sh_settings = sh_settings
        print ' - Average comfort setting is %s Celsius' % str(round(np.average(sh_settings['dayzone']),2))
        return None
Пример #4
0
    def __shsetting__(self):
        '''
        Simulation of the space heating setting points.
        - Including weekend days,
        - starting from a regular monday at 4:00 AM.
        '''

        #######################################################################
        # we define setting types based on their setpoint temperatures
        # when being active (1), sleeping (2) or absent (3).
        types = dict()
        types.update({'2': {1: 18.5, 2: 15.0, 3: 18.5}})
        types.update({'3': {1: 20.0, 2: 15.0, 3: 19.5}})
        types.update({'4': {1: 20.0, 2: 11.0, 3: 19.5}})
        types.update({'5': {1: 20.0, 2: 14.5, 3: 15.0}})
        types.update({'6': {1: 21.0, 2: 20.5, 3: 21.0}})
        types.update({'7': {1: 21.5, 2: 15.5, 3: 21.5}})
        # and the probabilities these types occur based on Dutch research,
        # i.e. Leidelmeijer and van Grieken (2005).
        types.update({'prob': [0.16, 0.35, 0.08, 0.11, 0.05, 0.20]})
        # and given a type, denote which rooms are heated
        given = dict()
        given.update({'2': [['dayzone', 'bathroom']]})
        given.update({
            '3': [['dayzone'], ['dayzone', 'bathroom'],
                  ['dayzone', 'nightzone']]
        })
        given.update({'4': [['dayzone'], ['dayzone', 'nightzone']]})
        given.update({'5': [['dayzone']]})
        given.update({'6': [['dayzone', 'bathroom', 'nightzone']]})
        given.update({'7': [['dayzone', 'bathroom']]})

        #######################################################################
        # select a type from the given types and probabilities
        rnd = np.random.random()
        shtype = str(1 + stats.get_probability(rnd, types['prob'], 'prob'))
        if len(given[shtype]) != 1:
            nr = np.random.randint(np.shape(given[shtype])[0])
            shrooms = given[shtype][nr]
        else:
            shrooms = given[shtype][0]

        #######################################################################
        # create a profile for the heated rooms
        shnon = 12 * np.ones(len(self.occ_m[0]) + 1)
        shset = np.hstack((self.occ_m[0], self.occ_m[0][-1]))
        for key in types[shtype].keys():
            for i in range(len(shset)):
                if int(shset[i]) == key:
                    shset[i] = types[shtype][key]

        #######################################################################
        # and couple to the heated rooms
        sh_settings = dict()
        for room in ['dayzone', 'nightzone', 'bathroom']:
            if room in shrooms:
                sh_settings.update({room: shset})
            else:
                sh_settings.update({room: shnon})
        # and store
        self.sh_settings = sh_settings
        print(' - Average comfort setting is %s Celsius' %
              str(round(np.average(sh_settings['dayzone']), 2)))
        return None
Пример #5
0
    def __shsetting__(self):
        '''
        Simulation of the space heating setting points.
        '''

        #######################################################################
        # we define setting types based on their setpoint temperatures
        # when being active (1), sleeping (2) or absent (3).
        types = dict()
        types.update({'2': {1: 18.5, 2: 15.0, 3: 18.5}})
        types.update({'3': {1: 20.0, 2: 15.0, 3: 19.5}})
        types.update({'4': {1: 20.0, 2: 11.0, 3: 19.5}})
        types.update({'5': {1: 20.0, 2: 14.5, 3: 15.0}})
        types.update({'6': {1: 21.0, 2: 20.5, 3: 21.0}})
        types.update({'7': {1: 21.5, 2: 15.5, 3: 21.5}})
        # and the probabilities these types occur based on Dutch research,
        # i.e. Leidelmeijer and van Grieken (2005).
        types.update({'prob': [0.16, 0.35, 0.08, 0.11, 0.05, 0.20]})
        # and given the type, denote which rooms are heated (more than one possibility)
        shr = dict()
        shr.update({'2': [['dayzone', 'bathroom']]})
        shr.update({
            '3': [['dayzone'], ['dayzone', 'bathroom'],
                  ['dayzone', 'nightzone']]
        })
        shr.update({'4': [['dayzone'], ['dayzone', 'nightzone']]})
        shr.update({'5': [['dayzone']]})
        shr.update({'6': [['dayzone', 'bathroom', 'nightzone']]})
        shr.update({'7': [['dayzone', 'bathroom']]})

        #######################################################################
        # select a type based on random number and probabilities associated to types
        rnd = np.random.random()
        shtype = str(1 + stats.get_probability(rnd, types['prob'], 'prob'))
        #define which rooms will be heated
        if len(shr[shtype]
               ) != 1:  # if there are more possibilities, choose one randomly
            nr = np.random.randint(np.shape(shr[shtype])[0])
            shrooms = shr[shtype][nr]
        else:
            shrooms = shr[shtype][0]

        #######################################################################
        # create a profile for the heated rooms
        shnon = 12 * np.ones(len(self.occ_m[0]))  #non-heated rooms : 12 degC
        shset = 12 * np.ones(
            len(self.occ_m[0]
                ))  #initiate space heating settings also as non-heated
        occu = self.occ_m[0]  # get merged occupancy
        for key in types[shtype].keys():  # for each occupancy state
            shset[occu == key] = types[shtype][
                key]  # use appropriate temperature setting given in "types"

        #######################################################################
        # and couple to the heated rooms
        sh_settings = dict()
        for room in ['dayzone', 'nightzone', 'bathroom']:
            if room in shrooms:
                sh_settings.update({room: shset})
            else:
                sh_settings.update({room: shnon})
        # and store
        self.sh_settings = sh_settings
        print(' - Average comfort setting is %s Celsius' %
              str(round(np.average(sh_settings['dayzone']), 2)))

        self.variables.update({
            'sh_day':
            'Space heating set-point temperature for day-zone in degrees Celsius.',
            'sh_bath':
            'Space heating set-point temperature for bathroom in degrees Celsius.',
            'sh_night':
            'Space heating set-point temperature for night-zone in degrees Celsius.'
        })

        return None