def update_room_presets_and_units(preset, search, floor_area_text, ceiling_height_text, curr_floor_area, curr_ceiling_height): desc_file = ess.get_desc_file(ess.get_lang(search)) my_units = ess.get_units(search) curr_units = ess.did_switch_units(search, floor_area_text, ceiling_height_text) did_switch = False if curr_units != "": did_switch = True [floor_area, ceiling_height] = ess.convert_units(curr_units, my_units, curr_floor_area, curr_ceiling_height) if my_units == "british": text_output = [desc_file.floor_area_text, desc_file.ceiling_height_text] else: text_output = [desc_file.floor_area_text_metric, desc_file.ceiling_height_text_metric] # Update the room and behavior options based on the selected preset if preset == 'custom': if did_switch: return floor_area, ceiling_height, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, text_output[0], text_output[1] else: return dash.no_update, dash.no_update, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, text_output[0], text_output[1] else: curr_settings = ess.room_preset_settings[preset] if not did_switch: if my_units == "british": floor_area = curr_settings['floor-area'] ceiling_height = curr_settings['ceiling-height'] elif my_units == "metric": floor_area = round(curr_settings['floor-area-metric'], 2) ceiling_height = round(curr_settings['ceiling-height-metric'], 2) return floor_area, ceiling_height, curr_settings['ventilation'], \ curr_settings['recirc-rate'], curr_settings['filtration'], curr_settings['rh'], \ text_output[0], text_output[1]
def update_figure(floor_area, ceiling_height, air_exchange_rate, recirc_rate, merv, relative_humidity, breathing_flow_rate, infectiousness, mask_eff, mask_fit, risk_tolerance, def_aerosol_radius, max_viral_deact_rate, n_max_input, exp_time_input, search, floor_area_text, ceiling_height_text): language = ess.get_lang(search) error_msg = ess.get_err_msg(floor_area, ceiling_height, air_exchange_rate, merv, recirc_rate, def_aerosol_radius, max_viral_deact_rate, language, n_max_input, exp_time_input) if error_msg != "": return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, \ dash.no_update, dash.no_update, dash.no_update, dash.no_update, error_msg, True # Check our units! Did we switch? If so, convert values before calculating my_units = ess.get_units(search) curr_units = ess.did_switch_units(search, floor_area_text, ceiling_height_text) if curr_units != "": [floor_area, ceiling_height] = ess.convert_units(curr_units, my_units, floor_area, ceiling_height) # Check if we just moved to a preset; if not, change the preset dropdown to custom preset_dd_value = ess.get_room_preset_dd_value(floor_area, ceiling_height, air_exchange_rate, recirc_rate, merv, relative_humidity, my_units) # preset_dd_value = dash.no_update human_preset_dd_value = ess.get_human_preset_dd_value(breathing_flow_rate, infectiousness, mask_eff, mask_fit, my_units) # If metric, convert floor_area and ceiling_height to feet if my_units == "metric": floor_area = floor_area * 10.764 ceiling_height = ceiling_height * 3.281 # Update model with newly-selected parameters # Correct mask_passage_prob based on mask fit/compliance mask_real_eff = mask_eff * mask_fit mask_passage_prob = 1 - mask_real_eff # Calculate aerosol filtration efficiency aerosol_filtration_eff = Indoors.merv_to_eff(merv, def_aerosol_radius) # Convert recirc rate to outdoor air fraction outdoor_air_fraction = air_exchange_rate / (air_exchange_rate + recirc_rate) myInd.physical_params = [floor_area, ceiling_height, air_exchange_rate, outdoor_air_fraction, aerosol_filtration_eff, relative_humidity] myInd.physio_params = [breathing_flow_rate, def_aerosol_radius] myInd.disease_params = [infectiousness, max_viral_deact_rate] myInd.prec_params = [mask_passage_prob, risk_tolerance] myInd.calc_vars() # Get human behavior output text qb_text = ess.get_qb_text(myInd, my_units) cq_text = ess.get_cq_text(myInd, my_units) # Update the figure with a new model calculation new_fig = ess.get_model_figure(myInd, language) # Update the red text output with new model calculations model_output_text = ess.get_model_output_text(myInd, language) six_ft_text = ess.get_six_ft_text(myInd, language) six_ft_exp_time = ess.get_six_ft_exp_time(myInd, language) interest_output = ess.get_interest_output_text(myInd, my_units) exp_time_output = myInd.calc_max_time(n_max_input) exp_time_text = ess.time_to_text(exp_time_output, language) n_max_output = myInd.calc_n_max(exp_time_input) n_max_text = ess.get_n_max_text(n_max_output, myInd.get_n_max(), language) # Update all relevant display items (figure, red output text) return new_fig, model_output_text[0], model_output_text[1], model_output_text[2], model_output_text[3], \ model_output_text[4], model_output_text[5], model_output_text[6], model_output_text[7], \ six_ft_text, six_ft_exp_time, preset_dd_value, human_preset_dd_value, interest_output[0], \ interest_output[1], interest_output[2], \ interest_output[3], interest_output[4], interest_output[5], interest_output[6], interest_output[7], \ interest_output[8], interest_output[9], interest_output[10], interest_output[11], interest_output[12], \ interest_output[13], exp_time_text, n_max_text, qb_text, cq_text, error_msg, False
def update_lang(search, window_width): return ess.get_lang_text_adv(ess.get_lang(search), int(window_width))
def update_recirc_disp(recirc_rate, search): desc_file = ess.get_desc_file(ess.get_lang(search)) if hasattr(desc_file, 'recirc_type_output_units'): return [html.Span([desc_file.recirc_type_output_base.format(recirc_rate), desc_file.recirc_type_output_units])] else: return [desc_file.recirc_type_output_base.format(recirc_rate)]
def update_filt_disp(merv, search): desc_file = ess.get_desc_file(ess.get_lang(search)) return [desc_file.filt_type_output_base.format(merv)]
def update_vent_disp(air_exchange_rate, search): desc_file = ess.get_desc_file(ess.get_lang(search)) if hasattr(desc_file, 'vent_type_output_units'): return [html.Span([desc_file.vent_type_output_base.format(air_exchange_rate), desc_file.vent_type_output_units])] else: return [desc_file.vent_type_output_base.format(air_exchange_rate)]