Weather station lookup and passing to form working.
Need to tidy up and turn off debugging.
This commit is contained in:
parent
e5e5a42ae9
commit
3f238321fc
4 changed files with 59 additions and 8 deletions
|
|
@ -55,6 +55,8 @@ class FormData:
|
|||
infected_start: minutes_since_midnight
|
||||
location: str
|
||||
location_coordinates: str
|
||||
weather_station_location: str
|
||||
weather_station_ref: str
|
||||
mask_type: str
|
||||
mask_wearing_option: str
|
||||
mechanical_ventilation_type: str
|
||||
|
|
@ -105,8 +107,10 @@ class FormData:
|
|||
'infected_lunch_start': '12:30',
|
||||
'infected_people': _NO_DEFAULT,
|
||||
'infected_start': '08:30',
|
||||
'location': _NO_DEFAULT,
|
||||
'location': 'Geneva',
|
||||
'location_coordinates': '(46.2044, 6.1432)',
|
||||
'weather_station_location':'GENEVA COINTRIN',
|
||||
'weather_station_ref': '067000-99999',
|
||||
'mask_type': 'Type I',
|
||||
'mask_wearing_option': 'mask_off',
|
||||
'mechanical_ventilation_type': 'not-applicable',
|
||||
|
|
@ -264,9 +268,16 @@ class FormData:
|
|||
datetime_object = datetime.datetime.strptime(self.event_month[:3], "%b")
|
||||
month = datetime_object.month
|
||||
|
||||
#set location
|
||||
self.weather_station_location = data.location_to_weather_stn(self.location_coordinates)[1]
|
||||
print('wstn resolve location_', data.location_to_weather_stn(self.location_coordinates)[1])
|
||||
data.local_temperatures = data.location_celcius_per_hour(self.location_coordinates)
|
||||
print('inputcoords_', self.location_coordinates)
|
||||
inside_temp = models.PiecewiseConstant((0, 24), (293,))
|
||||
outside_temp = data.Temperatures[str(month)]
|
||||
|
||||
|
||||
|
||||
ventilation: models.Ventilation
|
||||
if self.window_type == 'window_sliding':
|
||||
ventilation = models.SlidingWindow(
|
||||
|
|
|
|||
|
|
@ -566,8 +566,8 @@ $(document).ready(function() {
|
|||
id: candidate.address,
|
||||
text: candidate.address,
|
||||
country: candidate.attributes.country,
|
||||
latitude: String(candidate.location.x),
|
||||
longitude: String(candidate.location.y),
|
||||
latitude: String(candidate.location.y),
|
||||
longitude: String(candidate.location.x),
|
||||
}
|
||||
}),
|
||||
pagination: {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@
|
|||
</p></li>
|
||||
<li><p class="data_text">Room Volume: {{ model.concentration_model.room.volume }} m³</p></li>
|
||||
<li><p class="data_text">Room Central Heating: {{ "On" if form.room_heating_option else "Off" }}</p></li>
|
||||
<li><p class="data_text">Room Location: {{ form.location }}</p></li>
|
||||
<li><p class="data_text">Geographic Location: {{ form.location }}</p></li>
|
||||
|
||||
<li><p class="data_text">Nearest weather station: {{ form.weather_station_location }}</p></li>
|
||||
</ul>
|
||||
|
||||
<p class="data_title">Ventilation data:</p>
|
||||
|
|
|
|||
46
cara/data.py
46
cara/data.py
|
|
@ -23,7 +23,11 @@ weather_debug = True
|
|||
def location_to_weather_stn(location_loc):
|
||||
#expects a tuple (lat, long)
|
||||
#returns: weather station ID, weather station name, weather station lat, long
|
||||
search_coords = [location_loc[0], location_loc[1]]
|
||||
print('location_loc,', location_loc)
|
||||
|
||||
search_coords = location_loc.split(',') #[location_loc[0], location_loc[1]]
|
||||
print('location_searchcoords,', search_coords)
|
||||
|
||||
lat=[]
|
||||
long=[]
|
||||
station_array=[]
|
||||
|
|
@ -63,22 +67,56 @@ def location_celcius_per_hour(location):
|
|||
weather_dict = json.load(json_file)
|
||||
Location_hourly_temperatures_celsius_per_hour = weather_dict[w_station[0]]
|
||||
if weather_debug:
|
||||
print(location)
|
||||
print("weather station name: ", w_station[1])
|
||||
weather_station_location = w_station[1]
|
||||
print("weather station ref: ", w_station[0])
|
||||
weather_station_ref = w_station[0]
|
||||
print("weather station location: ", w_station[2], " ", w_station[3])
|
||||
print(Location_hourly_temperatures_celsius_per_hour)
|
||||
return Location_hourly_temperatures_celsius_per_hour
|
||||
|
||||
#initialise with Geneva, change if location /=default.
|
||||
local_tempatures = {
|
||||
'1': [0.2, -0.3, -0.5, -0.9, -1.1, -1.4, -1.5, -1.5, -1.1, 0.1, 1.5,
|
||||
2.8, 3.8, 4.4, 4.5, 4.4, 4.4, 3.9, 3.1, 2.7, 2.2, 1.7, 1.5, 1.1],
|
||||
'2': [0.9, 0.3, 0.0, -0.5, -0.7, -1.1, -1.2, -1.1, -0.7, 0.8, 2.5,
|
||||
4.2, 5.4, 6.2, 6.3, 6.2, 6.1, 5.5, 4.5, 4.1, 3.5, 2.8, 2.5, 2.0],
|
||||
'3': [4.2, 3.5, 3.1, 2.5, 2.1, 1.6, 1.5, 1.6, 2.2, 4.0, 6.3, 8.4,
|
||||
10.0, 11.1, 11.2, 11.1, 11.0, 10.2, 8.9, 8.3, 7.5, 6.7, 6.3, 5.6],
|
||||
'4': [7.4, 6.7, 6.2, 5.5, 5.2, 4.7, 4.5, 4.6, 5.3, 7.2, 9.6, 11.9,
|
||||
13.7, 14.8, 14.9, 14.8, 14.7, 13.8, 12.4, 11.8, 10.9, 10.1, 9.6, 8.9],
|
||||
'5': [11.8, 11.1, 10.6, 9.9, 9.5, 8.9, 8.8, 8.9, 9.6, 11.6, 14.2, 16.6,
|
||||
18.4, 19.6, 19.7, 19.6, 19.4, 18.6, 17.1, 16.5, 15.6, 14.6, 14.2, 13.4],
|
||||
'6': [15.2, 14.4, 13.9, 13.2, 12.7, 12.2, 12.0, 12.1, 12.8, 15.0, 17.7,
|
||||
20.2, 22.1, 23.3, 23.5, 23.4, 23.2, 22.3, 20.8, 20.1, 19.1, 18.2, 17.7, 16.9],
|
||||
'7': [17.6, 16.7, 16.1, 15.3, 14.9, 14.3, 14.1, 14.2, 15.0, 17.3, 20.2,
|
||||
23.0, 25.0, 26.3, 26.5, 26.4, 26.2, 25.2, 23.6, 22.8, 21.8, 20.8, 20.2, 19.4],
|
||||
'8': [17.1, 16.2, 15.7, 14.9, 14.5, 13.9, 13.7, 13.8, 14.6, 16.9, 19.7,
|
||||
22.4, 24.4, 25.6, 25.8, 25.7, 25.5, 24.5, 22.9, 22.2, 21.2, 20.2, 19.7, 18.9],
|
||||
'9': [13.4, 12.7, 12.2, 11.5, 11.2, 10.7, 10.5, 10.6, 11.3, 13.2, 15.6,
|
||||
17.9, 19.6, 20.8, 20.9, 20.8, 20.7, 19.8, 18.4, 17.8, 16.9, 16.1, 15.6, 14.9],
|
||||
'10': [9.4, 8.8, 8.5, 7.9, 7.6, 7.2, 7.1, 7.2, 7.7, 9.3, 11.2, 13.0,
|
||||
14.4, 15.3, 15.4, 15.3, 15.2, 14.5, 13.4, 12.9, 12.2, 11.6, 11.2, 10.6],
|
||||
'11': [4.0, 3.6, 3.3, 2.9, 2.6, 2.3, 2.2, 2.2, 2.7, 3.9, 5.5, 6.9, 8.0,
|
||||
8.7, 8.8, 8.7, 8.7, 8.1, 7.2, 6.8, 6.3, 5.7, 5.5, 5.0],
|
||||
'12': [1.4, 1.0, 0.8, 0.4, 0.2, -0.0, -0.1, -0.1, 0.3, 1.3, 2.6, 3.8,
|
||||
4.7, 5.2, 5.3, 5.2, 5.2, 4.7, 4.0, 3.7, 3.2, 2.8, 2.6, 2.2]
|
||||
}
|
||||
|
||||
|
||||
# Geneva hourly temperatures as piecewise constant function (in Kelvin)
|
||||
Temperatures_hourly = {
|
||||
month: models.PiecewiseConstant(tuple(np.arange(25.)),
|
||||
tuple(273.15+np.array(temperatures)))
|
||||
for month,temperatures in location_celcius_per_hour(calc_location).items()
|
||||
for month,temperatures in local_tempatures.items()
|
||||
}
|
||||
# same temperatures on a finer temperature mesh
|
||||
Temperatures = {
|
||||
month: Temperatures_hourly[month].refine(refine_factor=4)
|
||||
for month,temperatures in location_celcius_per_hour(calc_location).items()
|
||||
month: Temperatures_hourly[month].refine(refine_factor=10)
|
||||
for month, temperatures in local_tempatures.items()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue