Esempio n. 1
0
    def test_short_cycling_expect_success(self):
        """Test: Compressor is switched on/off (HVACstat = 2) every 10 mins."""
        a = dt.datetime(2014, 1, 1, 0, 0, 0, 0)
        b = dt.datetime(2014, 1, 1, 1, 0, 0, 0)
        HVACstat = set_up_datetimes(a, b, 360)
        HVAC_data = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]
        append_data_to_datetime(HVACstat, HVAC_data)

        result = short_cycling(HVACstat, 100, 100)
    def test_short_cycling_expect_success(self):
        """Test: Compressor is switched on/off (HVACstat = 2) every 10 mins."""
        a = dt.datetime(2014, 1, 1, 0, 0, 0, 0)
        b = dt.datetime(2014, 1, 1, 1, 0, 0, 0)
        HVACstat = set_up_datetimes(a, b, 360)
        HVAC_data = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]
        append_data_to_datetime(HVACstat, HVAC_data)

        result = short_cycling(HVACstat, 100, 100)
    def test_short_cycling_basic(self):
        """Test: Compressor is switched on/off (HVACstat = 2) every minute."""
        a = dt.datetime(2014, 1, 1, 0, 0, 0, 0)
        b = dt.datetime(2014, 1, 1, 0, 29, 0, 0)
        HVACstat = set_up_datetimes(a, b, 60)
        HVAC_data = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2,
                0, 2, 0, 2, 0, 2, 0, 2, 0, 2]
        append_data_to_datetime(HVACstat, HVAC_data)

        result = short_cycling(HVACstat, 100, 100)
        self.assertTrue('Problem' in result.keys())
 def test_short_cycling_mixed_status(self):
     """Test: Compressor is switched on/off (HVACstat = 2) mixed in different statuses."""
     a = dt.datetime(2014, 1, 1, 0, 0, 0, 0)
     b = dt.datetime(2014, 1, 1, 0, 29, 0, 0)
     HVAC_data = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 2,
             0, 2, 0, 2, 0, 2, 0, 2, 0, 2]
     HVACstat = set_up_datetimes(a, b, 60)
     append_data_to_datetime(HVACstat, HVAC_data)
     
     result = short_cycling(HVACstat, 100, 100)
     self.assertTrue('Problem' in result.keys())
Esempio n. 5
0
    def test_short_cycling_basic(self):
        """Test: Compressor is switched on/off (HVACstat = 2) every minute."""
        a = dt.datetime(2014, 1, 1, 0, 0, 0, 0)
        b = dt.datetime(2014, 1, 1, 0, 29, 0, 0)
        HVACstat = set_up_datetimes(a, b, 60)
        HVAC_data = [
            0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2,
            0, 2, 0, 2, 0, 2, 0, 2
        ]
        append_data_to_datetime(HVACstat, HVAC_data)

        result = short_cycling(HVACstat, 100, 100)
        self.assertTrue('Problem' in result.keys())
Esempio n. 6
0
    def test_short_cycling_mixed_status(self):
        """Test: Compressor is switched on/off (HVACstat = 2) mixed in different statuses."""
        a = dt.datetime(2014, 1, 1, 0, 0, 0, 0)
        b = dt.datetime(2014, 1, 1, 0, 29, 0, 0)
        HVAC_data = [
            0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 2, 0, 2,
            0, 2, 0, 2, 0, 2, 0, 2
        ]
        HVACstat = set_up_datetimes(a, b, 60)
        append_data_to_datetime(HVACstat, HVAC_data)

        result = short_cycling(HVACstat, 100, 100)
        self.assertTrue('Problem' in result.keys())
Esempio n. 7
0
    def execute(self):
        # Called after User hits GO
        """
        Calculates weather sensitivity using Spearman rank.
        Also, outputs data points for energy signature scatter plot.
        """
        self.out.log("Starting Day Time Temperature Analysis", logging.INFO)

        self.out.log('@operating_sched'+str(self.operating_sched), logging.INFO)
        self.out.log('@building_area'+str(self.building_area), logging.INFO)
        self.out.log('@electricity_cost'+str(self.electricity_cost), logging.INFO)
        
        # Query the database
        zat_query = self.inp.get_query_sets('zat', exclude={'value':None},
                                                   wrap_for_merge=True,
                                                   group_by='minute')
                                                   
        dat_query = self.inp.get_query_sets('dat', exclude={'value':None},
                                                   wrap_for_merge=True,
                                                   group_by='minute')
                                                   
        oat_query = self.inp.get_query_sets('oat', exclude={'value':None},
                                                   wrap_for_merge=True,
                                                   group_by='minute')
                                                   
        status_query = self.inp.get_query_sets('hvacstatus', exclude={'value':None},
                                                   wrap_for_merge=True,
                                                   group_by='minute')
        # Merge temperatures and the HVACStatus
        merged_temperatures_status = self.inp.merge(zat_query, oat_query, dat_query,status_query)
        
        # Get conversion factor
        base_topic = self.inp.get_topics()
        meta_topics = self.inp.get_topics_meta()
        zat_unit = meta_topics['zat'][base_topic['zat'][0]]['unit']
        dat_unit = meta_topics['dat'][base_topic['dat'][0]]['unit']
        oat_unit = meta_topics['oat'][base_topic['oat'][0]]['unit']
        
        #From the merged values make the arrays for the models
        datetime_ZAT = []
        datetime_DAT = []
        datetime_OAT = []
        datetime_HVACStatus = []
        for line in merged_temperatures_status:
            # Convert datetime str to datetime obj
            datetimeObj = dt.datetime.strptime(line['time'],'%Y-%m-%d %H:%M')
            
            # Convert ZAT
            if zat_unit == 'celcius':
                convertedZAT = cu.convertCelciusToFahrenheit(line['zat'][0])
            elif zat_unit == 'kelvin':
                convertedZAT = cu.convertKelvinToCelcius(
                                cu.convertCelciusToFahrenheit(line['zat'][0]))
            else: 
                convertedZAT = line['zat'][0]
            #    
            datetime_ZAT.append((datetimeObj, convertedZAT)) 
        
            # Convert DAT
            if dat_unit == 'celcius':
                convertedDAT = cu.convertCelciusToFahrenheit(line['dat'][0])
            elif dat_unit == 'kelvin':
                convertedDAT = cu.convertKelvinToCelcius(
                                cu.convertCelciusToFahrenheit(line['dat'][0]))
            else: 
                convertedDAT = line['dat'][0]        
            #
            datetime_DAT.append((datetimeObj, convertedDAT)) 
                
            # Convert OAT
            if oat_unit == 'celcius':
                convertedOAT = cu.convertCelciusToFahrenheit(line['oat'][0])
            elif oat_unit == 'kelvin':
                convertedOAT = cu.convertKelvinToCelcius(
                                cu.convertCelciusToFahrenheit(line['oat'][0]))
            else: 
                convertedOAT = line['oat'][0]
            #
            datetime_OAT.append((datetimeObj, convertedOAT)) 
            #
            datetime_HVACStatus.append((datetimeObj, line['hvacstatus'][0])) 
        # Apply the comfort_and_setpoint model.
        comfort_flag, setback_flag = cs.comfort_and_setpoint(datetime_ZAT, 
                                                   datetime_DAT, 
                                                   self.operating_sched, 
                                                   self.building_area, 
                                                   self.electricity_cost, 
                                                   datetime_HVACStatus)
        if comfort_flag != {}:
            self.out.insert_row('SensorSuitcaseHVAC', { 
                                'analysis': 'Comfort Optimization',
                                'problem': comfort_flag['Problem'],
                                'diagnostic': comfort_flag['Diagnostic'],
                                'recommendation': comfort_flag['Recommendation'],
                                'savings': '${:.2f}'.format(comfort_flag['Savings'])
                                })
                                
        if setback_flag != {}:
            self.out.insert_row('SensorSuitcaseHVAC', { 
                                'analysis': 'Comfort Optimization',
                                'problem': setback_flag['Problem'],
                                'diagnostic': setback_flag['Diagnostic'],
                                'recommendation': setback_flag['Recommendation'],
                                'savings': '${:.2f}'.format(setback_flag['Savings'])
                                })
                                
        # Apply the economizer model.
        economizer_flag = ecn.economizer(datetime_DAT, 
                                         datetime_OAT, 
                                         datetime_HVACStatus, 
                                         self.electricity_cost, 
                                         self.building_area)    
        if economizer_flag != {}:
            self.out.insert_row('SensorSuitcaseHVAC', { 
                                'analysis': 'Economizer Diagnostics',
                                'problem': economizer_flag['Problem'],
                                'diagnostic': economizer_flag['Diagnostic'],
                                'recommendation': economizer_flag['Recommendation'],
                                'savings': '${:.2f}'.format(economizer_flag['Savings'])
                                })
        
        # Apply the setback_non_op model.
        setback_nonop_flag = sb.setback_non_op(datetime_ZAT, 
                                         datetime_DAT, 
                                         self.operating_sched, 
                                         self.electricity_cost, 
                                         self.building_area, 
                                         datetime_HVACStatus)
        if setback_nonop_flag != {}:
            self.out.insert_row('SensorSuitcaseHVAC', { 
                                'analysis': 'Setback During Unoccupied Hours',
                                'problem': setback_nonop_flag['Problem'],
                                'diagnostic': setback_nonop_flag['Diagnostic'],
                                'recommendation': setback_nonop_flag['Recommendation'],
                                'savings': '${:.2f}'.format(setback_nonop_flag['Savings'])
                                })
        
        # Apply the short_cycling model.
        shortcycling_flag = shc.short_cycling(datetime_HVACStatus, 
                                              self.electricity_cost)
        if shortcycling_flag != {}:
            self.out.insert_row('SensorSuitcaseHVAC', { 
                                'analysis': 'Shortcycling',
                                'problem': shortcycling_flag['Problem'],
                                'diagnostic': shortcycling_flag['Diagnostic'],
                                'recommendation': shortcycling_flag['Recommendation'],
                                'savings': '${:.2f}'.format(shortcycling_flag['Savings'])
                                })
Esempio n. 8
0
    def execute(self):
        # Called after User hits GO
        """
        Calculates weather sensitivity using Spearman rank.
        Also, outputs data points for energy signature scatter plot.
        """
        self.out.log("Starting application: Sensor Suitcase HVAC.",
                     logging.INFO)

        self.out.log('@operating_sched' + str(self.operating_sched),
                     logging.INFO)
        self.out.log('@building_area' + str(self.building_area), logging.INFO)
        self.out.log('@electricity_cost' + str(self.electricity_cost),
                     logging.INFO)

        # Query the database
        zat_query = self.inp.get_query_sets('zat',
                                            exclude={'value': None},
                                            wrap_for_merge=True,
                                            group_by='minute')

        dat_query = self.inp.get_query_sets('dat',
                                            exclude={'value': None},
                                            wrap_for_merge=True,
                                            group_by='minute')

        oat_query = self.inp.get_query_sets('oat',
                                            exclude={'value': None},
                                            wrap_for_merge=True,
                                            group_by='minute')

        status_query = self.inp.get_query_sets('hvacstatus',
                                               exclude={'value': None},
                                               wrap_for_merge=True,
                                               group_by='minute')
        # Merge temperatures and the HVACStatus
        merged_temperatures_status = self.inp.merge(zat_query, oat_query,
                                                    dat_query, status_query)

        self.out.log("Getting unit conversions.", logging.INFO)
        base_topic = self.inp.get_topics()
        meta_topics = self.inp.get_topics_meta()

        zat_unit = meta_topics['zat'][base_topic['zat'][0]]['unit']
        self.out.log(
            "Convert zone air temperatures from [{}] to [F].".format(zat_unit),
            logging.INFO)

        dat_unit = meta_topics['dat'][base_topic['dat'][0]]['unit']
        self.out.log(
            "Convert discharge air temperatures from [{}] to [F].".format(
                dat_unit), logging.INFO)

        oat_unit = meta_topics['oat'][base_topic['oat'][0]]['unit']
        self.out.log(
            "Convert outside air temperatures from [{}] to [F].".format(
                oat_unit), logging.INFO)

        #From the merged values make the arrays for the models
        datetime_ZAT = []
        datetime_DAT = []
        datetime_OAT = []
        datetime_HVACStatus = []
        for line in merged_temperatures_status:
            # Convert datetime str to datetime obj
            #             datetimeObj = dt.datetime.strptime(line['time'],'%Y-%m-%d %H:%M')
            datetimeObj = line['time']

            # Convert ZAT
            if zat_unit == 'celcius':
                convertedZAT = cu.convertCelciusToFahrenheit(line['zat'][0])
            elif zat_unit == 'kelvin':
                convertedZAT = cu.convertKelvinToCelcius(
                    cu.convertCelciusToFahrenheit(line['zat'][0]))
            else:
                convertedZAT = line['zat'][0]
            #
            datetime_ZAT.append((datetimeObj, convertedZAT))

            # Convert DAT
            if dat_unit == 'celcius':
                convertedDAT = cu.convertCelciusToFahrenheit(line['dat'][0])
            elif dat_unit == 'kelvin':
                convertedDAT = cu.convertKelvinToCelcius(
                    cu.convertCelciusToFahrenheit(line['dat'][0]))
            else:
                convertedDAT = line['dat'][0]
            #
            datetime_DAT.append((datetimeObj, convertedDAT))

            # Convert OAT
            if oat_unit == 'celcius':
                convertedOAT = cu.convertCelciusToFahrenheit(line['oat'][0])
            elif oat_unit == 'kelvin':
                convertedOAT = cu.convertKelvinToCelcius(
                    cu.convertCelciusToFahrenheit(line['oat'][0]))
            else:
                convertedOAT = line['oat'][0]
            #
            datetime_OAT.append((datetimeObj, convertedOAT))
            #
            datetime_HVACStatus.append((datetimeObj, line['hvacstatus'][0]))
        # Apply the comfort_and_setpoint model.
        comfort_flag, setback_flag = cs.comfort_and_setpoint(
            datetime_ZAT, datetime_DAT, self.operating_sched,
            self.building_area, self.electricity_cost, datetime_HVACStatus)
        if comfort_flag != {}:
            self.out.insert_row(
                'SensorSuitcaseHVAC', {
                    'analysis': 'Comfort Optimization',
                    'problem': comfort_flag['Problem'],
                    'diagnostic': comfort_flag['Diagnostic'],
                    'recommendation': comfort_flag['Recommendation'],
                    'savings': '${:.2f}'.format(comfort_flag['Savings'])
                })

        if setback_flag != {}:
            self.out.insert_row(
                'SensorSuitcaseHVAC', {
                    'analysis': 'Comfort Optimization',
                    'problem': setback_flag['Problem'],
                    'diagnostic': setback_flag['Diagnostic'],
                    'recommendation': setback_flag['Recommendation'],
                    'savings': '${:.2f}'.format(setback_flag['Savings'])
                })

        # Apply the economizer model.
        economizer_flag = ecn.economizer(datetime_DAT, datetime_OAT,
                                         datetime_HVACStatus,
                                         self.electricity_cost,
                                         self.building_area)
        if economizer_flag != {}:
            self.out.insert_row(
                'SensorSuitcaseHVAC', {
                    'analysis': 'Economizer Diagnostics',
                    'problem': economizer_flag['Problem'],
                    'diagnostic': economizer_flag['Diagnostic'],
                    'recommendation': economizer_flag['Recommendation'],
                    'savings': '${:.2f}'.format(economizer_flag['Savings'])
                })

        # Apply the setback_non_op model.
        setback_nonop_flag = sb.setback_non_op(datetime_ZAT, datetime_DAT,
                                               self.operating_sched,
                                               self.electricity_cost,
                                               self.building_area,
                                               datetime_HVACStatus)
        if setback_nonop_flag != {}:
            self.out.insert_row(
                'SensorSuitcaseHVAC', {
                    'analysis': 'Setback During Unoccupied Hours',
                    'problem': setback_nonop_flag['Problem'],
                    'diagnostic': setback_nonop_flag['Diagnostic'],
                    'recommendation': setback_nonop_flag['Recommendation'],
                    'savings': '${:.2f}'.format(setback_nonop_flag['Savings'])
                })

        # Apply the short_cycling model.
        shortcycling_flag = shc.short_cycling(datetime_HVACStatus,
                                              self.electricity_cost,
                                              self.building_area)
        if shortcycling_flag != {}:
            self.out.insert_row(
                'SensorSuitcaseHVAC', {
                    'analysis': 'Shortcycling',
                    'problem': shortcycling_flag['Problem'],
                    'diagnostic': shortcycling_flag['Diagnostic'],
                    'recommendation': shortcycling_flag['Recommendation'],
                    'savings': '${:.2f}'.format(shortcycling_flag['Savings'])
                })