/
residential_energy_consumption_survey_response.rb
142 lines (132 loc) · 8.03 KB
/
residential_energy_consumption_survey_response.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
require 'earth/model'
require 'earth/locality/census_division'
require 'earth/locality/census_region'
require 'earth/residence/air_conditioner_use'
require 'earth/residence/clothes_machine_use'
require 'earth/residence/dishwasher_use'
require 'earth/residence/residence_class'
require 'earth/residence/urbanity'
class ResidentialEnergyConsumptionSurveyResponse < ActiveRecord::Base
extend Earth::Model
TABLE_STRUCTURE = <<-EOS
CREATE TABLE recs_responses
(
id INTEGER NOT NULL PRIMARY KEY,
air_conditioner_use_id CHARACTER VARYING(255),
annual_energy_from_electricity_for_air_conditioners FLOAT,
annual_energy_from_electricity_for_air_conditioners_units CHARACTER VARYING( 255),
annual_energy_from_electricity_for_clothes_driers FLOAT,
annual_energy_from_electricity_for_clothes_driers_units CHARACTER VARYING(255),
annual_energy_from_electricity_for_dishwashers FLOAT,
annual_energy_from_electricity_for_dishwashers_units CHARACTER VARYING(255),
annual_energy_from_electricity_for_freezers FLOAT,
annual_energy_from_electricity_for_freezers_units CHARACTER VARYING(255),
annual_energy_from_electricity_for_heating_space FLOAT,
annual_energy_from_electricity_for_heating_space_units CHARACTER VARYING(255),
annual_energy_from_electricity_for_heating_water FLOAT,
annual_energy_from_electricity_for_heating_water_units CHARACTER VARYING(255),
annual_energy_from_electricity_for_other_appliances FLOAT,
annual_energy_from_electricity_for_other_appliances_units CHARACTER VARYING( 255),
annual_energy_from_electricity_for_refrigerators FLOAT,
annual_energy_from_electricity_for_refrigerators_units CHARACTER VARYING(255),
annual_energy_from_fuel_oil_for_appliances FLOAT,
annual_energy_from_fuel_oil_for_appliances_units CHARACTER VARYING(255),
annual_energy_from_fuel_oil_for_heating_space FLOAT,
annual_energy_from_fuel_oil_for_heating_space_units CHARACTER VARYING(255),
annual_energy_from_fuel_oil_for_heating_water FLOAT,
annual_energy_from_fuel_oil_for_heating_water_units CHARACTER VARYING(255),
annual_energy_from_kerosene FLOAT,
annual_energy_from_kerosene_units CHARACTER VARYING(255),
annual_energy_from_natural_gas_for_appliances FLOAT,
annual_energy_from_natural_gas_for_appliances_units CHARACTER VARYING(255),
annual_energy_from_natural_gas_for_heating_space FLOAT,
annual_energy_from_natural_gas_for_heating_space_units CHARACTER VARYING(255),
annual_energy_from_natural_gas_for_heating_water FLOAT,
annual_energy_from_natural_gas_for_heating_water_units CHARACTER VARYING(255),
annual_energy_from_propane_for_appliances FLOAT,
annual_energy_from_propane_for_appliances_units CHARACTER VARYING(255),
annual_energy_from_propane_for_heating_space FLOAT,
annual_energy_from_propane_for_heating_space_units CHARACTER VARYING(255),
annual_energy_from_propane_for_heating_water FLOAT,
annual_energy_from_propane_for_heating_water_units CHARACTER VARYING(255),
annual_energy_from_wood FLOAT,
annual_energy_from_wood_units CHARACTER VARYING(255),
attached_1car_garage INTEGER,
attached_2car_garage INTEGER,
attached_3car_garage INTEGER,
bathrooms FLOAT,
bedrooms INTEGER,
census_division_name CHARACTER VARYING(255),
census_division_number INTEGER,
census_region_name CHARACTER VARYING(255),
census_region_number INTEGER,
central_ac_use CHARACTER VARYING(255),
clothes_dryer_use CHARACTER VARYING(255),
clothes_machine_use_id CHARACTER VARYING(255),
clothes_washer_use CHARACTER VARYING(255),
construction_period CHARACTER VARYING(255),
construction_year DATE,
cooling_degree_days INTEGER,
cooling_degree_days_units CHARACTER VARYING(255),
detached_1car_garage INTEGER,
detached_2car_garage INTEGER,
detached_3car_garage INTEGER,
dishwasher_use_id CHARACTER VARYING(255),
efficient_lights_on_1_to_4_hours INTEGER,
efficient_lights_on_4_to_12_hours INTEGER,
efficient_lights_on_over_12_hours INTEGER,
floorspace FLOAT,
floorspace_units CHARACTER VARYING(255),
freezer_count INTEGER,
full_bathrooms INTEGER,
half_bathrooms INTEGER,
heated_garage INTEGER,
heating_degree_days INTEGER,
heating_degree_days_units CHARACTER VARYING(255),
lighting_efficiency FLOAT,
lighting_use FLOAT,
lighting_use_units CHARACTER VARYING(255),
lights_on_1_to_4_hours INTEGER,
lights_on_4_to_12_hours INTEGER,
lights_on_over_12_hours INTEGER,
outdoor_all_night_gas_lights INTEGER,
outdoor_all_night_lights INTEGER,
ownership BOOLEAN,
refrigerator_count INTEGER,
residence_class_id CHARACTER VARYING(255),
residents INTEGER,
rooms FLOAT,
thermostat_programmability BOOLEAN,
total_rooms INTEGER,
urbanity_id CHARACTER VARYING(255),
weighting FLOAT,
window_ac_use CHARACTER VARYING(255)
);
EOS
self.primary_key = "id"
self.table_name = :recs_responses
belongs_to :census_division, :foreign_key => 'census_division_number'
belongs_to :census_region, :foreign_key => 'census_region_number'
# what follows are entirely derived here
belongs_to :residence_class
belongs_to :urbanity
belongs_to :dishwasher_use
belongs_to :air_conditioner_use
belongs_to :clothes_machine_use
INPUT_CHARACTERISTICS = [
:ownership,
:construction_year,
:urbanity,
:residents,
:floorspace,
:bathrooms,
:bedrooms,
:rooms,
:residence_class,
:cooling_degree_days,
:heating_degree_days,
:census_region
]
# sabshere 9/20/10 sorted with sort -d -t "'" -k 2 ~/Desktop/parts.txt
warn_unless_size 4382
end