コード例 #1
0
ファイル: LoadCustomer.py プロジェクト: jdovi/buildingspeak
    def handle(self, *args, **options):

    ###---Users
        try:
            userJD = User.objects.get(username = '******')       #loaded to add to all new accounts
            userDA = User.objects.get(username = '******')     #loaded to add to all new accounts
            
            user1 = User(
                username = '******',
                password = '******',
                first_name = 'Jesse',
                last_name = 'Dovi',
                email = '*****@*****.**',
                is_active = True,
                is_staff = False,
                is_superuser = False,
                )
            user1.save()
        except:
            print 'Failed to create new Users.'
        else:
            print 'Created new Users.'
            
    ###---UserProfiles
        try:
            userprofile1 = UserProfile(
                user = user1,
                organization = 'Dovi Motors Inc. - COR'
                )
            userprofile1.save()
            #post-creation actions
            #--load image file
            set_file_field(userprofile1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/default.jpg')
        except:
            print 'Failed to create new UserProfiles.'
        else:
            print 'Created new UserProfiles.'
            
    ###---Account
        try:
            acct1 = Account(
                name = 'Dovi Motors Inc. - COR',
                account_type = 'Commercial',
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                launch_date = timezone.now(),
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                status = 'Active',
                monthly_payment = Decimal(0.0),
                )
            acct1.save()
            
            #post-creation actions
            #--attach users
            acct1.users.add(user1)
            acct1.users.add(userJD)
            acct1.users.add(userDA)
            
            #--load image file
            set_file_field(acct1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/default.jpg')
        except:
            print 'Failed to create new Accounts.'
        else:
            print 'Created new Accounts.'
        
    ###---Buildings
        try:
            ws = WeatherStation.objects.get(name = 'Cortland, NY')
            
            bldg1 = Building(
                name = 'Main Building',
                building_type = 'Automotive Facility',
                EIA_type = 'Mercantile - Retail (Other Than Mall)',
                ESPM_type = 'Retail Store',
                account = acct1,
                weather_station = ws,
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                age = 1950,
                square_footage = Decimal(8401),
                stories = 1,
                max_occupancy = None,
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                )
            bldg1.save()
    
            #post-creation actions
            #--load image file
            set_file_field(bldg1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/BuildingImages/main.JPG')
            
            bldg2 = Building(
                name = 'Body Shop',
                building_type = 'Automotive Facility',
                EIA_type = 'Warehouse and Storage',
                ESPM_type = 'Warehouse (Refrigerated or Unrefrigerated)',
                account = acct1,
                weather_station = ws,
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                age = 1975,
                square_footage = Decimal(2800),
                stories = 1,
                max_occupancy = None,
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                )
            bldg2.save()
            
            #post-creation actions:
            #--load image file
            set_file_field(bldg2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/BuildingImages/body.JPG')
        except:
            print 'Failed to create new Buildings.'
        else:
            print 'Created new Buildings.'
        
    ###---Spaces
        try:
            space1 = Space(
                name = 'Showroom',
                building = bldg1,
                square_footage = Decimal(4000),
                max_occupancy = None,
                space_type = 'Automotive Facility',
                EIA_type = 'Mercantile - Retail (Other Than Mall)',
                ESPM_type = 'Retail Store',
                )
            space1.save()
            #post-creation actions:
            #--load image file
            set_file_field(space1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/SpaceImages/default_space_image.png')
            
            space2 = Space(
                name = 'Repair Shop',
                building = bldg2,
                square_footage = Decimal(4401),
                max_occupancy = None,
                space_type = 'Automotive Facility',
                EIA_type = 'Warehouse and Storage',
                ESPM_type = 'Warehouse (Refrigerated or Unrefrigerated)',
                )
            space2.save()
            #post-creation actions:
            #--load image file
            set_file_field(space2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/SpaceImages/default_space_image.png')
            
        except:
            print 'Failed to create new Spaces.'
        else:
            print 'Created new Spaces.'
            
    ###---Meters
        try:
            #pdb.set_trace()
            u1 = Utility.objects.get(name = 'National Grid')
            u2 = Utility.objects.get(name = 'Hess Energy Marketing')
            u3 = Utility.objects.get(name = 'NYSEG')
            u4 = Utility.objects.get(name = 'NY Water')
            
            r1 = GeneralConsumption(name = 'National Grid - Dovi Motors',
                                    utility = u1,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r1.save()
            r2 = GeneralConsumption(name = 'Hess Energy Marketing - Dovi Motors',
                                    utility = u2,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r2.save()
            r3 = GeneralConsumption(name = 'NYSEG - Dovi Motors',
                                    utility = u3,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r3.save()
            r4 = GeneralConsumption(name = 'NY Water - Dovi Motors',
                                    utility = u4,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r4.save()
            
            meter1 = Meter(
                name = 'Main Building (electric)',
                utility_type = 'electricity',
                location = 'Side of bldg inside parts cage',
                serves = 'all of main building',
                units = 'kW,kWh',
                weather_station = ws,
                utility = u2,
                rate_schedule = r2,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '05036-74100',
                utility_meter_number = '05542682',
                )
            meter1.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Main_Meter.JPG')
            set_file_field(meter1,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Main_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter1,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/main-electric.csv')
            try:
                meter1.upload_bill_data(create_models_if_nonexistent=True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter1.id)
            meter1.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter1,
                                              building = bldg1,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            #--connect to spaces
            sma1 = SpaceMeterApportionment(meter = meter1,
                                           space = space2,
                                           assigned_fraction = Decimal(0.4))
            sma1.save()
            sma2 = SpaceMeterApportionment(meter = meter1,
                                           space = space1,
                                           assigned_fraction = Decimal(0.6))
            sma2.save()
            
            meter2 = Meter(
                name = 'Body Shop (electric)',
                utility_type = 'electricity',
                location = 'East side of the body shop',
                serves = 'Body Shop',
                units = 'kW,kWh',
                weather_station = ws,
                utility = u2,
                rate_schedule = r2,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '05036-74100',
                utility_meter_number = '34264564',
                )
            meter2.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Body_Meter.JPG')
            set_file_field(meter2,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Body_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter2,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/body-electric.csv')
            try:
                meter2.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter2.id)
            meter2.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter2,
                                              building = bldg2,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            
            
            
            meter3 = Meter(
                name = 'Main Building (natural gas)',
                utility_type = 'natural gas',
                location = 'unknown',
                serves = 'Main bldg heating and domestic hot water',
                units = 'ccf/h,ccf',
                weather_station = ws,
                utility = u3,
                rate_schedule = r3,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '1001-0074-630',
                utility_meter_number = '06079962',
                )
            meter3.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter3,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            set_file_field(meter3,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            #--load bill data file, possibly create meter models
            set_file_field(meter3,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/main-gas.csv')
            try:
                meter3.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter3.id)
            meter3.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter3,
                                              building = bldg1,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            #--connect to spaces
            sma1 = SpaceMeterApportionment(meter = meter3,
                                           space = space2,
                                           assigned_fraction = Decimal(0.6))
            sma1.save()
            sma1 = SpaceMeterApportionment(meter = meter3,
                                           space = space1,
                                           assigned_fraction = Decimal(0.4))
            sma1.save()
            
            meter4 = Meter(
                name = 'Body Shop (natural gas)',
                utility_type = 'natural gas',
                location = 'unknown',
                serves = 'Body Shop heating and domestic hot water',
                units = 'ccf/h,ccf',
                weather_station = ws,
                utility = u3,
                rate_schedule = r3,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '1001-0631-181',
                utility_meter_number = '0C263464',
                )
            meter4.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter4,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            set_file_field(meter4,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            #--load bill data file, possibly create meter models
            set_file_field(meter4,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/body-gas.csv')
            try:
                meter4.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter4.id)
            meter4.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter4,
                                              building = bldg2,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            
            
            meter5 = Meter(
                name = 'Main Building (water)',
                utility_type = 'domestic water',
                location = 'unknown',
                serves = 'unknown',
                units = 'gpm,gal',
                weather_station = ws,
                utility = u4,
                rate_schedule = r4,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '316',
                utility_meter_number = 'unknown',
                )
            meter5.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter5,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/MainWater_Meter.JPG')
            set_file_field(meter5,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/MainWater_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter5,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/main-water.csv')
            try:
                meter5.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter5.id)
            meter5.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter5,
                                              building = bldg1,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            #--connect to spaces
            sma1 = SpaceMeterApportionment(meter = meter5,
                                           space = space1,
                                           assigned_fraction = Decimal(.5))
            sma1.save()
            sma2 = SpaceMeterApportionment(meter = meter5,
                                           space = space2,
                                           assigned_fraction = Decimal(.5))
            sma2.save()
            
            meter6 = Meter(
                name = 'Body Shop (water)',
                utility_type = 'domestic water',
                location = 'unknown',
                serves = 'unknown',
                units = 'gpm,gal',
                weather_station = ws,
                utility = u4,
                rate_schedule = r4,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '315',
                utility_meter_number = 'unknown',
                )
            meter6.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter6,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/BodyWater_Meter.JPG')
            set_file_field(meter6,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/BodyWater_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter6,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/body-water.csv')
            try:
                meter6.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter6.id)
            meter6.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter6,
                                              building = bldg2,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()            


        except:
            print 'Failed to create new Meters.'
        else:
            print 'Created new Meters.'
    def handle(self, *args, **options):

    ###---Users
        try:
            userJD = User.objects.get(username = '******')       #loaded to add to all new accounts
            userDA = User.objects.get(username = '******')     #loaded to add to all new accounts
            
#            user1 = User(
#                username = '******',
#                password = '******',
#                first_name = 'Jesse',
#                last_name = 'Dovi',
#                email = '*****@*****.**',
#                is_active = True,
#                is_staff = False,
#                is_superuser = False,
#                )
#            user1.save()
        except:
            print 'Failed to create new Users.'
        else:
            print 'Created new Users.'
            
    ###---UserProfiles
#        try:
#            userprofile1 = UserProfile(
#                user = user1,
#                organization = 'Dovi Motors Inc. - COR'
#                )
#            userprofile1.save()
#            #post-creation actions
#            #--load image file
#            set_file_field(userprofile1,
#                            'image_file',
#                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/default.jpg')
#        except:
#            print 'Failed to create new UserProfiles.'
#        else:
#            print 'Created new UserProfiles.'
            
    ###---Account
        try:
            acct1 = Account(
                name = 'Dryden Automotive, Inc.',
                account_type = 'Commercial',
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                launch_date = timezone.now(),
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                status = 'Active',
                monthly_payment = Decimal(0.0),
                )
            acct1.save()
            
            #post-creation actions
            #--attach users
#            acct1.users.add(user1)
            acct1.users.add(userJD)
            acct1.users.add(userDA)
            
            #--load image file
            set_file_field(acct1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/DrydenAutomotiveAccountLogo.png')
        except:
            print 'Failed to create new Accounts.'
        else:
            print 'Created new Accounts.'
        
    ###---Buildings
        try:
            ws = WeatherStation.objects.get(name = 'Cortland, NY')
            
            bldg1 = Building(
                name = 'Main Building',
                building_type = 'Automotive Facility',
                EIA_type = 'Mercantile - Retail (Other Than Mall)',
                ESPM_primary_function = 'Retail Store',
                account = acct1,
                weather_station = ws,
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                vintage = 1950,
                square_footage = Decimal(8400),
                stories = 1,
                max_occupancy = None,
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                )
            bldg1.save()
    
            #post-creation actions
            #--load image file
            set_file_field(bldg1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/BuildingImages/main.JPG')
            
            bldg2 = Building(
                name = 'Body Shop',
                building_type = 'Automotive Facility',
                EIA_type = 'Warehouse and Storage',
                ESPM_primary_function = 'Non-Refrigerated Warehouse',
                account = acct1,
                weather_station = ws,
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                vintage = 1975,
                square_footage = Decimal(2622),
                stories = 1,
                max_occupancy = None,
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                )
            bldg2.save()
            
            #post-creation actions:
            #--load image file
            set_file_field(bldg2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/BuildingImages/body.JPG')
        except:
            print 'Failed to create new Buildings.'
        else:
            print 'Created new Buildings.'
        
    ###---Spaces
        try:
            space1 = Space(
                name = 'Showroom',
                building = bldg1,
                square_footage = Decimal(3155),
                totalGrossFloorArea = Decimal(3155),
                max_occupancy = None,
                space_type = 'Automotive Facility',
                EIA_type = 'Mercantile - Retail (Other Than Mall)',
                ESPM_type = 'retail',
                )
            space1.save()
            #post-creation actions:
            #--load image file
            set_file_field(space1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/SpaceImages/default_space_image.png')
            
            space2 = Space(
                name = 'Repair Shop',
                building = bldg1,
                square_footage = Decimal(5245),
                totalGrossFloorArea = Decimal(5245),
                max_occupancy = None,
                space_type = 'Automotive Facility',
                EIA_type = 'Warehouse and Storage',
                ESPM_type = 'nonRefrigeratedWarehouse',
                )
            space2.save()
            #post-creation actions:
            #--load image file
            set_file_field(space2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/SpaceImages/default_space_image.png')
            
            space3 = Space(
                name = 'Body Shop',
                building = bldg2,
                square_footage = Decimal(2622),
                totalGrossFloorArea = Decimal(2622),
                max_occupancy = None,
                space_type = 'Automotive Facility',
                EIA_type = 'Warehouse and Storage',
                ESPM_type = 'nonRefrigeratedWarehouse',
                )
            space3.save()
            #post-creation actions:
            #--load image file
            set_file_field(space3,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/SpaceImages/default_space_image.png')
            
        except:
            print 'Failed to create new Spaces.'
        else:
            print 'Created new Spaces.'
            
    ###---Meters
        try:
            u1 = Utility.objects.get(name = 'National Grid')
            u2 = Utility.objects.get(name = 'Hess Energy Marketing')
            u3 = Utility.objects.get(name = 'NYSEG')
            u4 = Utility.objects.get(name = 'NY Water')
            
            r1 = GeneralConsumption(name = 'National Grid - Dovi Motors, Inc.',
                                    utility = u1,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r1.save()
            r2 = GeneralConsumption(name = 'Hess Energy Marketing - Dovi Motors, Inc.',
                                    utility = u2,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r2.save()
            r3 = GeneralConsumption(name = 'NYSEG - Dovi Motors, Inc.',
                                    utility = u3,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r3.save()
            r4 = GeneralConsumption(name = 'NY Water - Dovi Motors, Inc.',
                                    utility = u4,
                                    rate_type = 'moving average',
                                    moving_average_window_length = 6)
            r4.save()
            
            try:
                meter1 = Meter(
                    name = 'Main Building (electric)',
                    utility_type = 'electricity',
                    location = 'Side of bldg inside parts cage',
                    serves = 'all of main building',
                    units = 'kW,kWh',
                    weather_station = ws,
                    utility = u2,
                    rate_schedule = r2,
                    account = acct1,
                    make = 'unknown',
                    model = 'unknown',
                    serial_number = 'unknown',
                    utility_account_number = '05036-74100',
                    utility_meter_number = '05542682',
                    )
                meter1.save()
                #post-creation actions:
                #--load image files
                set_file_field(meter1,
                                'image_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/Main_Meter.JPG')
                set_file_field(meter1,
                                'nameplate_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/Main_Meter.JPG')
                #--load bill data file, possibly create meter models
                set_file_field(meter1,
                                'bill_data_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/ME_baseline.csv')
                try:
                    meter1.upload_bill_data(create_models_if_nonexistent=True)
                except:
                    print 'Failed to upload data for Meter %s.' % str(meter1.id)
                meter1.save()
                #--connect to buildings
                bma1 = BuildingMeterApportionment(meter = meter1,
                                                  building = bldg1,
                                                  assigned_fraction = Decimal(1.0))
                bma1.save()
                #--connect to spaces
                sma1 = SpaceMeterApportionment(meter = meter1,
                                               space = space2,
                                               assigned_fraction = Decimal(0.4))
                sma1.save()
                sma2 = SpaceMeterApportionment(meter = meter1,
                                               space = space1,
                                               assigned_fraction = Decimal(0.6))
                sma2.save()
            except:
                logging.exception('Failed to complete Meter 1.')
                
            try:
                meter2 = Meter(
                    name = 'Body Shop (electric)',
                    utility_type = 'electricity',
                    location = 'East side of the body shop',
                    serves = 'Body Shop',
                    units = 'kW,kWh',
                    weather_station = ws,
                    utility = u2,
                    rate_schedule = r2,
                    account = acct1,
                    make = 'unknown',
                    model = 'unknown',
                    serial_number = 'unknown',
                    utility_account_number = '05036-74100',
                    utility_meter_number = '34264564',
                    )
                meter2.save()
                #post-creation actions:
                #--load image files
                set_file_field(meter2,
                                'image_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/Body_Meter.JPG')
                set_file_field(meter2,
                                'nameplate_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/Body_Meter.JPG')
                #--load bill data file, possibly create meter models
                set_file_field(meter2,
                                'bill_data_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/BE_baseline.csv')
                try:
                    meter2.upload_bill_data(create_models_if_nonexistent = True)
                except:
                    print 'Failed to upload data for Meter %s.' % str(meter2.id)
                meter2.save()
                #--connect to buildings
                bma1 = BuildingMeterApportionment(meter = meter2,
                                                  building = bldg2,
                                                  assigned_fraction = Decimal(1.0))
                bma1.save()
                #--connect to spaces
                sma1 = SpaceMeterApportionment(meter = meter2,
                                               space = space3,
                                               assigned_fraction = Decimal(1.0))
                sma1.save()
            except:
                logging.exception('Failed to complete Meter 2.')
                
                
                
            try:
                meter3 = Meter(
                    name = 'Main Building (natural gas)',
                    utility_type = 'natural gas',
                    location = 'unknown',
                    serves = 'Main bldg heating and domestic hot water',
                    units = 'ccf/h,ccf',
                    weather_station = ws,
                    utility = u3,
                    rate_schedule = r3,
                    account = acct1,
                    make = 'unknown',
                    model = 'unknown',
                    serial_number = 'unknown',
                    utility_account_number = '1001-0074-630',
                    utility_meter_number = '06079962',
                    )
                meter3.save()
                #post-creation actions:
                #--load image files
                set_file_field(meter3,
                                'image_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/default_meter_location_image.png')
                set_file_field(meter3,
                                'nameplate_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/default_meter_nameplate_image.png')
                #--load bill data file, possibly create meter models
                set_file_field(meter3,
                                'bill_data_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/MN_baseline.csv')
                try:
                    meter3.upload_bill_data(create_models_if_nonexistent = True)
                except:
                    print 'Failed to upload data for Meter %s.' % str(meter3.id)
                meter3.save()
                #--connect to buildings
                bma1 = BuildingMeterApportionment(meter = meter3,
                                                  building = bldg1,
                                                  assigned_fraction = Decimal(1.0))
                bma1.save()
                #--connect to spaces
                sma1 = SpaceMeterApportionment(meter = meter3,
                                               space = space2,
                                               assigned_fraction = Decimal(0.6))
                sma1.save()
                sma1 = SpaceMeterApportionment(meter = meter3,
                                               space = space1,
                                               assigned_fraction = Decimal(0.4))
                sma1.save()
            except:
                logging.exception('Failed to complete Meter 3.')
                
            try:
                meter4 = Meter(
                    name = 'Body Shop (natural gas)',
                    utility_type = 'natural gas',
                    location = 'unknown',
                    serves = 'Body Shop heating and domestic hot water',
                    units = 'ccf/h,ccf',
                    weather_station = ws,
                    utility = u3,
                    rate_schedule = r3,
                    account = acct1,
                    make = 'unknown',
                    model = 'unknown',
                    serial_number = 'unknown',
                    utility_account_number = '1001-0631-181',
                    utility_meter_number = '0C263464',
                    )
                meter4.save()
                #post-creation actions:
                #--load image files
                set_file_field(meter4,
                                'image_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/default_meter_location_image.png')
                set_file_field(meter4,
                                'nameplate_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/default_meter_nameplate_image.png')
                #--load bill data file, possibly create meter models
                set_file_field(meter4,
                                'bill_data_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/BN_baseline.csv')
                try:
                    meter4.upload_bill_data(create_models_if_nonexistent = True)
                except:
                    print 'Failed to upload data for Meter %s.' % str(meter4.id)
                meter4.save()
                #--connect to buildings
                bma1 = BuildingMeterApportionment(meter = meter4,
                                                  building = bldg2,
                                                  assigned_fraction = Decimal(1.0))
                bma1.save()
                #--connect to spaces
                sma1 = SpaceMeterApportionment(meter = meter4,
                                               space = space3,
                                               assigned_fraction = Decimal(1.0))
                sma1.save()
            except:
                logging.exception('Failed to complete Meter 4.')
                
                
            try:
                meter5 = Meter(
                    name = 'Main Building (water)',
                    utility_type = 'domestic water',
                    location = 'unknown',
                    serves = 'unknown',
                    units = 'gpm,gal',
                    weather_station = ws,
                    utility = u4,
                    rate_schedule = r4,
                    account = acct1,
                    make = 'unknown',
                    model = 'unknown',
                    serial_number = 'unknown',
                    utility_account_number = '316',
                    utility_meter_number = 'unknown',
                    )
                meter5.save()
                #post-creation actions:
                #--load image files
                set_file_field(meter5,
                                'image_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/MainWater_Meter.JPG')
                set_file_field(meter5,
                                'nameplate_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/MainWater_Meter.JPG')
                #--load bill data file, possibly create meter models
                set_file_field(meter5,
                                'bill_data_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/MW_baseline.csv')
                try:
                    meter5.upload_bill_data(create_models_if_nonexistent = True)
                except:
                    print 'Failed to upload data for Meter %s.' % str(meter5.id)
                meter5.save()
                #--connect to buildings
                bma1 = BuildingMeterApportionment(meter = meter5,
                                                  building = bldg1,
                                                  assigned_fraction = Decimal(1.0))
                bma1.save()
                #--connect to spaces
                sma1 = SpaceMeterApportionment(meter = meter5,
                                               space = space1,
                                               assigned_fraction = Decimal(0.5))
                sma1.save()
                sma2 = SpaceMeterApportionment(meter = meter5,
                                               space = space2,
                                               assigned_fraction = Decimal(0.5))
                sma2.save()
            except:
                logging.exception('Failed to complete Meter 5.')
                
            try:
                meter6 = Meter(
                    name = 'Body Shop (water)',
                    utility_type = 'domestic water',
                    location = 'unknown',
                    serves = 'unknown',
                    units = 'gpm,gal',
                    weather_station = ws,
                    utility = u4,
                    rate_schedule = r4,
                    account = acct1,
                    make = 'unknown',
                    model = 'unknown',
                    serial_number = 'unknown',
                    utility_account_number = '315',
                    utility_meter_number = 'unknown',
                    )
                meter6.save()
                #post-creation actions:
                #--load image files
                set_file_field(meter6,
                                'image_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/BodyWater_Meter.JPG')
                set_file_field(meter6,
                                'nameplate_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterImages/BodyWater_Meter.JPG')
                #--load bill data file, possibly create meter models
                set_file_field(meter6,
                                'bill_data_file',
                                STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/BW_baseline.csv')
                try:
                    meter6.upload_bill_data(create_models_if_nonexistent = True)
                except:
                    print 'Failed to upload data for Meter %s.' % str(meter6.id)
                meter6.save()
                #--connect to buildings
                bma1 = BuildingMeterApportionment(meter = meter6,
                                                  building = bldg2,
                                                  assigned_fraction = Decimal(1.0))
                bma1.save()            
                sma1 = SpaceMeterApportionment(meter = meter6,
                                               space = space3,
                                               assigned_fraction = Decimal(1.0))
                sma1.save()
            except:
                logging.exception('Failed to complete Meter 6.')

        except:
            print 'Failed to create new Meters.'
        else:
            print 'Created new Meters.'


    ###---Equipment
        try:
            off01 = PackageUnit(name = 'RTU-01',
                                equipment_type = 'Package Unit',
                                location = 'Main Building rooftop',
                                description = '',
                                serves = 'main building',
                                vintage = None,
                                make = 'Trane',
                                model = 'YCD048C3L0BA',
                                serial_number = 'J161427170',
                                nameplate_tons = Decimal(4.0),
                                nameplate_EER = None,
                                nameplate_MBH_in = Decimal(90.0),
                                nameplate_MBH_out = Decimal(72.9),
                                nameplate_ng_eta = Decimal(0.81),
                                nameplate_V = Decimal(230.0),
                                nameplate_phase = Decimal(3),
                                nameplate_pf = None,
                                nameplate_RFC = None,
                                nameplate_c1_QTY = Decimal(1),
                                nameplate_c1_RLA = Decimal(14.8),
                                nameplate_c1_PH = None,
                                nameplate_c2_QTY = None,
                                nameplate_c2_RLA = None,
                                nameplate_c2_PH = None,
                                nameplate_c3_QTY = None,
                                nameplate_c3_RLA = None,
                                nameplate_c3_PH = None,
                                nameplate_e1_QTY = Decimal(1),
                                nameplate_e1_PH = Decimal(1),
                                nameplate_e1_FLA = Decimal(4.2),
                                nameplate_e2_QTY = None,
                                nameplate_e2_PH = None,
                                nameplate_e2_FLA = None,
                                nameplate_f1_QTY = Decimal(1),
                                nameplate_f1_PH = Decimal(1),
                                nameplate_f1_FLA = Decimal(2.1),
                                nameplate_f2_QTY = None,
                                nameplate_f2_PH = None,
                                nameplate_f2_FLA = None,
                                dP_fan_max = None,
                                dP_fan_min = None,
                                SAF_max = None,
                                SAF_min = None,
                                speed_min = None,
                                T_max = None,
                                T_min = None,
                                d0 = None,
                                d1 = None,
                                d2 = None,
                                m0 = None,
                                m1 = None,
                                m2 = None,
                                m3 = None,
                                f0 = None,
                                f1 = None,
                                f2 = None,
                                e0 = None,
                                e1 = None,
                                e2 = None,
                                SCOC = None,
                                SCUN = None,
                                SHOC = None,
                                SHUN = None,
                                SRFC = None,
                                )
            off01.save()
            #post-creation actions:
            #--connect to buildings
            off01.buildings.add(bldg1)
            #--connect to spaces
            off01.spaces.add(space1)
            #--connect to meters
            off01.meters.add(meter1)        #electric
            off01.meters.add(meter3)   #gas
            #--load image files
            set_file_field(off01,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/EquipmentImages/OFF-01-photo.JPG')
            set_file_field(off01,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/EquipmentImages/OFF-01-nameplate.JPG')

            off02 = PackageUnit(name = 'RTU-02',
                                equipment_type = 'Package Unit',
                                location = 'Main Building rooftop',
                                description = '',
                                serves = 'main building',
                                vintage = None,
                                make = 'Lennox',
                                model = 'GCS16-1353-270-7Y',
                                serial_number = '5692C00479',
                                nameplate_tons = Decimal(10.0),
                                nameplate_EER = None,
                                nameplate_MBH_in = Decimal(270.0),
                                nameplate_MBH_out = Decimal(216.0),
                                nameplate_ng_eta = Decimal(0.80),
                                nameplate_V = Decimal(230.0),
                                nameplate_phase = Decimal(3),
                                nameplate_pf = None,
                                nameplate_RFC = None,
                                nameplate_c1_QTY = Decimal(2),
                                nameplate_c1_RLA = Decimal(17.3),
                                nameplate_c1_PH = None,
                                nameplate_c2_QTY = None,
                                nameplate_c2_RLA = None,
                                nameplate_c2_PH = None,
                                nameplate_c3_QTY = None,
                                nameplate_c3_RLA = None,
                                nameplate_c3_PH = None,
                                nameplate_e1_QTY = Decimal(1),
                                nameplate_e1_PH = Decimal(3),
                                nameplate_e1_FLA = Decimal(10.6),
                                nameplate_e2_QTY = None,
                                nameplate_e2_PH = None,
                                nameplate_e2_FLA = None,
                                nameplate_f1_QTY = Decimal(2),
                                nameplate_f1_PH = Decimal(1),
                                nameplate_f1_FLA = Decimal(2.1),
                                nameplate_f2_QTY = None,
                                nameplate_f2_PH = None,
                                nameplate_f2_FLA = None,
                                dP_fan_max = None,
                                dP_fan_min = None,
                                SAF_max = None,
                                SAF_min = None,
                                speed_min = None,
                                T_max = None,
                                T_min = None,
                                d0 = None,
                                d1 = None,
                                d2 = None,
                                m0 = None,
                                m1 = None,
                                m2 = None,
                                m3 = None,
                                f0 = None,
                                f1 = None,
                                f2 = None,
                                e0 = None,
                                e1 = None,
                                e2 = None,
                                SCOC = None,
                                SCUN = None,
                                SHOC = None,
                                SHUN = None,
                                SRFC = None,
                                )
            off02.save()
            #post-creation actions:
            #--connect to buildings
            off02.buildings.add(bldg1)
            #--connect to spaces
            off02.spaces.add(space2)
            #--connect to meters
            off02.meters.add(meter1)        #electric
            off02.meters.add(meter3)   #gas
            #--load image files
            set_file_field(off02,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/EquipmentImages/OFF-02-photo.JPG')
            set_file_field(off02,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/EquipmentImages/OFF-02-nameplate.JPG')

            off03 = PackageUnit(name = 'RTU-03',
                                equipment_type = 'Package Unit',
                                location = 'Body Shop rooftop',
                                description = '',
                                serves = 'body shop',
                                vintage = None,
                                make = 'Payne',
                                model = '588ANW030080ACAD',
                                serial_number = '2196G10899',
                                nameplate_tons = Decimal(2.5),
                                nameplate_EER = None,
                                nameplate_MBH_in = Decimal(80.0),
                                nameplate_MBH_out = Decimal(64.8),
                                nameplate_ng_eta = Decimal(0.81),
                                nameplate_V = Decimal(230.0),
                                nameplate_phase = Decimal(1),
                                nameplate_pf = None,
                                nameplate_RFC = None,
                                nameplate_c1_QTY = Decimal(1),
                                nameplate_c1_RLA = Decimal(14.4),
                                nameplate_c1_PH = None,
                                nameplate_c2_QTY = None,
                                nameplate_c2_RLA = None,
                                nameplate_c2_PH = None,
                                nameplate_c3_QTY = None,
                                nameplate_c3_RLA = None,
                                nameplate_c3_PH = None,
                                nameplate_e1_QTY = Decimal(1),
                                nameplate_e1_PH = Decimal(1),
                                nameplate_e1_FLA = Decimal(2.0),
                                nameplate_e2_QTY = None,
                                nameplate_e2_PH = None,
                                nameplate_e2_FLA = None,
                                nameplate_f1_QTY = Decimal(1),
                                nameplate_f1_PH = Decimal(1),
                                nameplate_f1_FLA = Decimal(1.4),
                                nameplate_f2_QTY = None,
                                nameplate_f2_PH = None,
                                nameplate_f2_FLA = None,
                                dP_fan_max = None,
                                dP_fan_min = None,
                                SAF_max = None,
                                SAF_min = None,
                                speed_min = None,
                                T_max = None,
                                T_min = None,
                                d0 = None,
                                d1 = None,
                                d2 = None,
                                m0 = None,
                                m1 = None,
                                m2 = None,
                                m3 = None,
                                f0 = None,
                                f1 = None,
                                f2 = None,
                                e0 = None,
                                e1 = None,
                                e2 = None,
                                SCOC = None,
                                SCUN = None,
                                SHOC = None,
                                SHUN = None,
                                SRFC = None,
                                )
            off03.save()
            #post-creation actions:
            #--connect to buildings
            off03.buildings.add(bldg2)
            #--connect to spaces
            off03.spaces.add(space3)
            #--connect to meters
            off03.meters.add(meter2)        #electric
            off03.meters.add(meter4)   #gas
            #--load image files
            set_file_field(off03,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/EquipmentImages/OFF-03-photo.JPG')
            set_file_field(off03,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/EquipmentImages/OFF-03-nameplate.JPG')

        except:
            print 'Failed to create new Equipment.'
        else:
            print 'Created new Equipment.'

    ###---Measures
        try:
            em1_elec = EfficiencyMeasure(name = 'Controls on RTUs (electric)',
                                            when = datetime(2013,7,1,tzinfo=UTC),
                                            utility_type = 'electricity',
                                            units = 'kW,kWh',
                                            annual_consumption_savings = Decimal(5000.0),
                                            peak_demand_savings = Decimal(0.0),
                                            annual_cost_savings = Decimal(500.0),
                                            percent_uncertainty = Decimal(0.05),
                                            percent_cool = Decimal(1.0),
                                            percent_heat = Decimal(0.0),
                                            percent_flat = Decimal(0.0),
                                            percent_fixed = Decimal(0.0),
                                            
                                            weather_station = ws,
                                            )
            em1_elec.save()
            #post-creation actions:
            #--apportion annual savings numbers to individual months
            em1_elec.apportion_savings()
            #--create intermediate models to assign to Meters
            emma1 = EMMeterApportionment(efficiency_measure = em1_elec,
                                         meter = meter1,
                                         assigned_fraction = Decimal(0.75))
            emma1.save()
            emma2 = EMMeterApportionment(efficiency_measure = em1_elec,
                                         meter = meter2,
                                         assigned_fraction = Decimal(0.25))
            emma2.save()
            #--create intermediate models to assign to Equipment
            for equip in [off01, off02, off03]:
                emeaX = EMEquipmentApportionment(efficiency_measure = em1_elec,
                                                 equipment = equip,
                                                 assigned_fraction = Decimal(0.333))
                emeaX.save()
                
            em1_gas = EfficiencyMeasure(name = 'Controls on RTUs (natural gas)',
                                        when = datetime(2013,7,1,tzinfo=UTC),
                                        utility_type = 'natural gas',
                                        units = 'therms/h,therms',
                                        annual_consumption_savings = Decimal(300.0),
                                        peak_demand_savings = Decimal(0.0),
                                        annual_cost_savings = Decimal(400.0),
                                        percent_uncertainty = Decimal(0.05),
                                        percent_cool = Decimal(0.0),
                                        percent_heat = Decimal(1.0),
                                        percent_flat = Decimal(0.0),
                                        percent_fixed = Decimal(0.0),
                                        
                                        weather_station = ws,
                                        )
            em1_gas.save()
            #post-creation actions:
            #--apportion annual savings numbers to individual months
            em1_gas.apportion_savings()
            #--create intermediate models to assign to Meters
            emma1 = EMMeterApportionment(efficiency_measure = em1_gas,
                                         meter = meter3,
                                         assigned_fraction = Decimal(0.5))
            emma1.save()
            emma2 = EMMeterApportionment(efficiency_measure = em1_gas,
                                         meter = meter4,
                                         assigned_fraction = Decimal(0.5))
            emma2.save()
            #--create intermediate models to assign to Equipment
            for equip in [off01, off02, off03]:
                emeaX = EMEquipmentApportionment(efficiency_measure = em1_gas,
                                             equipment = equip,
                                             assigned_fraction = Decimal(0.333))
                emeaX.save()
            
        except:
            print 'Failed to create new Measures.'
        else:
            print 'Created new Measures.'


    ###---loading post-retrofit, non-baseline meter data
        try:
            set_file_field(meter1,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/ME_post_retrofit.csv')
            meter1.upload_bill_data()
            meter1.save()
        except:
            print 'Failed to load post-retrofit, non-baseline meter data for Meter %s.' % str(meter1.id)
        else:
            print 'Loaded post-retrofit, non-baseline meter data for Meter %s.' % str(meter1.id)

        try:
            set_file_field(meter2,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/BE_post_retrofit.csv')
            meter2.upload_bill_data()
            meter2.save()
        except:
            print 'Failed to load post-retrofit, non-baseline meter data for Meter %s.' % str(meter2.id)
        else:
            print 'Loaded post-retrofit, non-baseline meter data for Meter %s.' % str(meter2.id)

        try:
            set_file_field(meter3,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/MN_post_retrofit.csv')
            meter3.upload_bill_data()
            meter3.save()
        except:
            print 'Failed to load post-retrofit, non-baseline meter data for Meter %s.' % str(meter3.id)
        else:
            print 'Loaded post-retrofit, non-baseline meter data for Meter %s.' % str(meter3.id)

        try:
            set_file_field(meter4,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount_DrydenAutomotiveInc/MeterBillData/BN_post_retrofit.csv')
            meter4.upload_bill_data()
            meter4.save()
        except:
            print 'Failed to load post-retrofit, non-baseline meter data for Meter %s.' % str(meter4.id)
        else:
            print 'Loaded post-retrofit, non-baseline meter data for Meter %s.' % str(meter4.id)
コード例 #3
0
ファイル: LoadCustomer.py プロジェクト: jdovi/buildingspeak
    def handle(self, *args, **options):

    ###---Users
        try:
            userJD = User.objects.get(username = '******')       #loaded to add to all new accounts
            userDA = User.objects.get(username = '******')     #loaded to add to all new accounts
            
            user1 = User(
                username = '******',
                password = '******',
                first_name = 'Jesse',
                last_name = 'Dovi',
                email = '*****@*****.**',
                is_active = True,
                is_staff = False,
                is_superuser = False,
                )
            user1.save()
        except:
            print 'Failed to create new Users.'
        else:
            print 'Created new Users.'
            
    ###---UserProfiles
        try:
            userprofile1 = UserProfile(
                user = user1,
                organization = 'Dovi Motors Inc. - COR'
                )
            userprofile1.save()
            #post-creation actions
            #--load image file
            set_file_field(userprofile1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/default.jpg')
        except:
            print 'Failed to create new UserProfiles.'
        else:
            print 'Created new UserProfiles.'
            
    ###---Account
        try:
            acct1 = Account(
                name = 'Dovi Motors Inc. - COR',
                account_type = 'Commercial',
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                launch_date = timezone.now(),
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                status = 'Active',
                monthly_payment = Decimal(0.0),
                )
            acct1.save()
            
            #post-creation actions
            #--attach users
            acct1.users.add(user1)
            acct1.users.add(userJD)
            acct1.users.add(userDA)
            
            #--load image file
            set_file_field(acct1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/default.jpg')
        except:
            print 'Failed to create new Accounts.'
        else:
            print 'Created new Accounts.'
        
    ###---Buildings
        try:
            ws = WeatherStation.objects.get(name = 'ATL - downtown west')
            
            bldg1 = Building(
                name = 'Main Building',
                building_type = 'Multi-Purpose',
                EIA_type = 'Other',
                ESPM_type = 'Other',
                account = acct1,
                weather_station = ws,
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                age = 1950,
                square_footage = Decimal(8401),
                stories = 1,
                max_occupancy = None,
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                )
            bldg1.save()
    
            #post-creation actions
            #--load image file
            set_file_field(bldg1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/BuildingImages/main.JPG')
            
            bldg2 = Building(
                name = 'Body Shop',
                building_type = 'Multi-Purpose',
                EIA_type = 'Other',
                ESPM_type = 'Other',
                account = acct1,
                weather_station = ws,
                street_address = '263 Tompkins St',
                city = 'Cortland',
                state = 'NY',
                zip_code = '13045',
                age = 1975,
                square_footage = Decimal(2800),
                stories = 1,
                max_occupancy = None,
                first_name = 'Jesse',
                last_name = 'Dovi',
                title = 'Owner',
                email = '*****@*****.**',
                phone = '607-756-2801',
                )
            bldg2.save()
            
            #post-creation actions:
            #--load image file
            set_file_field(bldg2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/BuildingImages/body.JPG')
        except:
            print 'Failed to create new Buildings.'
        else:
            print 'Created new Buildings.'
        
    ###---Spaces
        try:
            space1 = Space(
                name = 'Showroon',
                building = bldg1,
                square_footage = Decimal(4000),
                max_occupancy = None,
                space_type = 'Dormitory',
                EIA_type = 'Lodging',
                ESPM_type = 'Dormitory / Residence Hall',
                )
            space1.save()
            #post-creation actions:
            #--load image file
            set_file_field(space1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/SpaceImages/default_space_image.png')
            
            space2 = Space(
                name = 'Repair Shop',
                building = bldg1,
                square_footage = Decimal(4401),
                max_occupancy = None,
                space_type = 'Dining: Family',
                EIA_type = 'Food Service',
                ESPM_type = 'Other',
                )
            space2.save()
            #post-creation actions:
            #--load image file
            set_file_field(space2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/SpaceImages/default_space_image.png')
            
        except:
            print 'Failed to create new Spaces.'
        else:
            print 'Created new Spaces.'
            
    ###---Meters
        try:
            gpc = Utility.objects.get(name = 'Georgia Power Company')
            infe = Utility.objects.get(name = 'Infinite Energy')
            atlw = Utility.objects.get(name = 'City of Atlanta, Dept. of Watershed Mgmt.')
            
            atlwww = CityOfATLWWW.objects.get(name = 'Water and Wastewater 2012')
            infebizgas = InfiniteEnergyGAGas.objects.get(name = 'Fixed Business Rate')
            gpc_plm8_sec_in = GAPowerPandL.objects.get(name = 'GPC-PLM-8-secondary-inside')
            
            meter1 = Meter(
                name = 'Main Building (electric)',
                utility_type = 'electricity',
                location = 'Side of bldg inside parts cage',
                serves = 'all of main building',
                units = 'kW,kWh',
                weather_station = ws,
                utility = gpc,
                rate_schedule = gpc_plm8_sec_in,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '05036-74100',
                utility_meter_number = '05542682',
                )
            meter1.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter1,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Main_Meter.JPG')
            set_file_field(meter1,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Main_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter1,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/main-electric.csv')
            try:
                meter1.upload_bill_data(create_models_if_nonexistent=True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter1.id)
            meter1.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter1,
                                              building = bldg1,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            #--connect to spaces
            sma1 = SpaceMeterApportionment(meter = meter1,
                                           space = space2,
                                           assigned_fraction = Decimal(0.4))
            sma1.save()
            sma2 = SpaceMeterApportionment(meter = meter1,
                                           space = space1,
                                           assigned_fraction = Decimal(0.6))
            sma2.save()
            
            meter2 = Meter(
                name = 'Body Shop (electric)',
                utility_type = 'electricity',
                location = 'East side of the body shop',
                serves = 'Body Shop',
                units = 'kW,kWh',
                weather_station = ws,
                utility = gpc,
                rate_schedule = gpc_plm8_sec_in,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '05036-74100',
                utility_meter_number = '34264564',
                )
            meter2.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter2,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Body_Meter.JPG')
            set_file_field(meter2,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/Body_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter2,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/body-electric.csv')
            try:
                meter2.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter2.id)
            meter2.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter2,
                                              building = bldg2,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            
            
            
            meter3 = Meter(
                name = 'Main Bilding (natural gas)',
                utility_type = 'natural gas',
                location = 'unknown',
                serves = 'Main bldg heating and domestic hot water',
                units = 'ccf/h,ccf',
                weather_station = ws,
                utility = infe,
                rate_schedule = infebizgas,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '1001-0074-630',
                utility_meter_number = '06079962',
                )
            meter3.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter3,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            set_file_field(meter3,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            #--load bill data file, possibly create meter models
            set_file_field(meter3,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/main-gas.csv')
            try:
                meter3.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter3.id)
            meter3.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter3,
                                              building = bldg1,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            #--connect to spaces
            sma1 = SpaceMeterApportionment(meter = meter3,
                                           space = space2,
                                           assigned_fraction = Decimal(0.6))
            sma1.save()
            sma1 = SpaceMeterApportionment(meter = meter3,
                                           space = space1,
                                           assigned_fraction = Decimal(0.4))
            sma1.save()
            
            meter4 = Meter(
                name = 'Body Shop (natural gas)',
                utility_type = 'natural gas',
                location = 'unknown',
                serves = 'Body Shop heating and domestic hot water',
                units = 'ccf/h,ccf',
                weather_station = ws,
                utility = infe,
                rate_schedule = infebizgas,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '1001-0631-181',
                utility_meter_number = '0C263464',
                )
            meter4.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter4,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            set_file_field(meter4,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/default_meter_image.png')
            #--load bill data file, possibly create meter models
            set_file_field(meter4,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/body-gas.csv')
            try:
                meter4.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter4.id)
            meter4.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter4,
                                              building = bldg2,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            
            
            meter5 = Meter(
                name = 'Main Building (water)',
                utility_type = 'domestic water',
                location = 'unknown',
                serves = 'unknown',
                units = 'gpm,gal',
                weather_station = ws,
                utility = atlw,
                rate_schedule = atlwww,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '316',
                utility_meter_number = 'unknown',
                )
            meter5.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter5,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/MainWater_Meter.JPG')
            set_file_field(meter5,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/MainWater_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter5,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/main-water.csv')
            try:
                meter5.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter5.id)
            meter5.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter5,
                                              building = bldg1,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()
            #--connect to spaces
            sma1 = SpaceMeterApportionment(meter = meter5,
                                           space = space1,
                                           assigned_fraction = Decimal(.5))
            sma1.save()
            sma2 = SpaceMeterApportionment(meter = meter5,
                                           space = space2,
                                           assigned_fraction = Decimal(.5))
            sma2.save()
            
            meter6 = Meter(
                name = 'Body Shop (water)',
                utility_type = 'domestic water',
                location = 'unknown',
                serves = 'unknown',
                units = 'gpm,gal',
                weather_station = ws,
                utility = atlw,
                rate_schedule = atlwww,
                account = acct1,
                make = 'unknown',
                model = 'unknown',
                serial_number = 'unknown',
                utility_account_number = '315',
                utility_meter_number = 'unknown',
                )
            meter6.save()
            #post-creation actions:
            #--load image files
            set_file_field(meter6,
                            'image_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/BodyWater_Meter.JPG')
            set_file_field(meter6,
                            'nameplate_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterImages/BodyWater_Meter.JPG')
            #--load bill data file, possibly create meter models
            set_file_field(meter6,
                            'bill_data_file',
                            STATIC_URL + 'upload_files/NewAccount/MeterBillData/body-water.csv')
            try:
                meter6.upload_bill_data(create_models_if_nonexistent = True)
            except:
                print 'Failed to upload data for Meter %s.' % str(meter6.id)
            meter6.save()
            #--connect to buildings
            bma1 = BuildingMeterApportionment(meter = meter6,
                                              building = bldg2,
                                              assigned_fraction = Decimal(1.0))
            bma1.save()            


        except:
            print 'Failed to create new Meters.'
        else:
            print 'Created new Meters.'