mabuseif commited on
Commit
160dcb8
·
verified ·
1 Parent(s): ccc9fb2

Update data/climate_data.py

Browse files
Files changed (1) hide show
  1. data/climate_data.py +79 -16
data/climate_data.py CHANGED
@@ -129,22 +129,83 @@ class ClimateData:
129
  with st.form("manual_climate_form"):
130
  col1, col2 = st.columns(2)
131
  with col1:
132
- id_input = st.text_input("Location ID", value=f"{session_state.building_info['country'][:2].upper()}-{session_state.building_info['city'][:3].upper()}")
133
- state_province = st.text_input("State/Province", value="N/A")
134
- latitude = st.number_input("Latitude", min_value=-90.0, max_value=90.0, value=0.0, step=0.1)
135
- longitude = st.number_input("Longitude", min_value=-180.0, max_value=180.0, value=0.0, step=0.1)
136
- elevation = st.number_input("Elevation (m)", min_value=0.0, value=0.0, step=10.0)
137
- climate_zone = st.selectbox("Climate Zone", ["0A", "0B", "1A", "1B", "2A", "2B", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C", "6A", "6B", "7", "8"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  with col2:
140
- hdd = st.number_input("Heating Degree Days (base 18°C)", min_value=0.0, value=0.0, step=100.0)
141
- cdd = st.number_input("Cooling Degree Days (base 18°C)", min_value=0.0, value=0.0, step=100.0)
142
- winter_design_temp = st.number_input("Winter Design Temp (99.6%) (°C)", min_value=-50.0, max_value=20.0, value=0.0, step=0.5)
143
- summer_design_temp_db = st.number_input("Summer Design Temp DB (0.4%) (°C)", min_value=0.0, max_value=50.0, value=35.0, step=0.5)
144
- summer_design_temp_wb = st.number_input("Summer Design Temp WB (0.4%) (°C)", min_value=0.0, max_value=40.0, value=25.0, step=0.5)
145
- summer_daily_range = st.number_input("Summer Daily Range (°C)", min_value=0.0, value=5.0, step=0.5)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
- # Monthly Data with clear titles
148
  monthly_temps = {}
149
  monthly_humidity = {}
150
  month_names = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
@@ -168,10 +229,12 @@ class ClimateData:
168
  monthly_humidity[month] = st.number_input(f"{month} Humidity (%)", min_value=0.0, max_value=100.0, value=50.0, step=5.0, key=f"hum_{month}")
169
 
170
  if st.form_submit_button("Save Climate Data"):
 
 
171
  location = ClimateLocation(
172
- id=id_input,
173
  country=session_state.building_info["country"],
174
- state_province=state_province,
175
  city=session_state.building_info["city"],
176
  latitude=latitude,
177
  longitude=longitude,
@@ -191,7 +254,7 @@ class ClimateData:
191
  self.display_design_conditions(location)
192
  self.visualize_data(location, epw_data=None)
193
 
194
- # EPW Upload Tab
195
  with tab2:
196
  uploaded_file = st.file_uploader("Upload EPW File", type=["epw"])
197
  if uploaded_file:
 
129
  with st.form("manual_climate_form"):
130
  col1, col2 = st.columns(2)
131
  with col1:
132
+ latitude = st.number_input(
133
+ "Latitude",
134
+ min_value=-90.0,
135
+ max_value=90.0,
136
+ value=0.0,
137
+ step=0.1,
138
+ help="Enter the latitude of the location in degrees (e.g., 64.1 for Reykjavik)"
139
+ )
140
+ longitude = st.number_input(
141
+ "Longitude",
142
+ min_value=-180.0,
143
+ max_value=180.0,
144
+ value=0.0,
145
+ step=0.1,
146
+ help="Enter the longitude of the location in degrees (e.g., -21.9 for Reykjavik)"
147
+ )
148
+ elevation = st.number_input(
149
+ "Elevation (m)",
150
+ min_value=0.0,
151
+ value=0.0,
152
+ step=10.0,
153
+ help="Enter the elevation of the location above sea level in meters"
154
+ )
155
+ climate_zone = st.selectbox(
156
+ "Climate Zone",
157
+ ["0A", "0B", "1A", "1B", "2A", "2B", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C", "6A", "6B", "7", "8"],
158
+ help="Select the ASHRAE climate zone for the location (e.g., 6A for cold, humid climates)"
159
+ )
160
 
161
  with col2:
162
+ hdd = st.number_input(
163
+ "Heating Degree Days (base 18°C)",
164
+ min_value=0.0,
165
+ value=0.0,
166
+ step=100.0,
167
+ help="Enter the annual heating degree days using an 18°C base temperature"
168
+ )
169
+ cdd = st.number_input(
170
+ "Cooling Degree Days (base 18°C)",
171
+ min_value=0.0,
172
+ value=0.0,
173
+ step=100.0,
174
+ help="Enter the annual cooling degree days using an 18°C base temperature"
175
+ )
176
+ winter_design_temp = st.number_input(
177
+ "Winter Design Temp (99.6%) (°C)",
178
+ min_value=-50.0,
179
+ max_value=20.0,
180
+ value=0.0,
181
+ step=0.5,
182
+ help="Enter the 99.6% winter design temperature in °C (extreme cold condition)"
183
+ )
184
+ summer_design_temp_db = st.number_input(
185
+ "Summer Design Temp DB (0.4%) (°C)",
186
+ min_value=0.0,
187
+ max_value=50.0,
188
+ value=35.0,
189
+ step=0.5,
190
+ help="Enter the 0.4% summer design dry-bulb temperature in °C (extreme hot condition)"
191
+ )
192
+ summer_design_temp_wb = st.number_input(
193
+ "Summer Design Temp WB (0.4%) (°C)",
194
+ min_value=0.0,
195
+ max_value=40.0,
196
+ value=25.0,
197
+ step=0.5,
198
+ help="Enter the 0.4% summer design wet-bulb temperature in °C (for humidity consideration)"
199
+ )
200
+ summer_daily_range = st.number_input(
201
+ "Summer Daily Range (°C)",
202
+ min_value=0.0,
203
+ value=5.0,
204
+ step=0.5,
205
+ help="Enter the average daily temperature range in summer in °C"
206
+ )
207
 
208
+ # Monthly Data with clear titles (no help added here)
209
  monthly_temps = {}
210
  monthly_humidity = {}
211
  month_names = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
 
229
  monthly_humidity[month] = st.number_input(f"{month} Humidity (%)", min_value=0.0, max_value=100.0, value=50.0, step=5.0, key=f"hum_{month}")
230
 
231
  if st.form_submit_button("Save Climate Data"):
232
+ # Generate ID internally using country and city from session_state
233
+ generated_id = f"{session_state.building_info['country'][:2].upper()}-{session_state.building_info['city'][:3].upper()}"
234
  location = ClimateLocation(
235
+ id=generated_id,
236
  country=session_state.building_info["country"],
237
+ state_province="N/A", # Default since input removed
238
  city=session_state.building_info["city"],
239
  latitude=latitude,
240
  longitude=longitude,
 
254
  self.display_design_conditions(location)
255
  self.visualize_data(location, epw_data=None)
256
 
257
+ # EPW Upload Tab (unchanged)
258
  with tab2:
259
  uploaded_file = st.file_uploader("Upload EPW File", type=["epw"])
260
  if uploaded_file: