added visualisation for ach table in form and report
This commit is contained in:
parent
780467c195
commit
a80c804832
4 changed files with 23 additions and 8 deletions
|
|
@ -319,6 +319,12 @@ def readable_minutes(minutes: int) -> str:
|
|||
return time_str + unit
|
||||
|
||||
|
||||
def hour_format(hour: float) -> str:
|
||||
hours = int(hour)
|
||||
minutes = int(hour % 1 * 60)
|
||||
|
||||
return f"{hours}:{minutes}"
|
||||
|
||||
def percentage(absolute: float) -> float:
|
||||
return absolute * 100
|
||||
|
||||
|
|
@ -514,6 +520,7 @@ class ReportGenerator:
|
|||
env.filters['non_zero_percentage'] = non_zero_percentage
|
||||
env.filters['readable_minutes'] = readable_minutes
|
||||
env.filters['minutes_to_time'] = minutes_to_time
|
||||
env.filters['hour_format'] = hour_format
|
||||
env.filters['float_format'] = "{0:.2f}".format
|
||||
env.filters['int_format'] = "{:0.0f}".format
|
||||
env.filters['percentage'] = percentage
|
||||
|
|
|
|||
|
|
@ -125,6 +125,12 @@ function validate() {
|
|||
return submit;
|
||||
}
|
||||
|
||||
function display_transition_times_hour_format(start, stop) {
|
||||
var minutes_start = start % 1 * 60;
|
||||
var minutes_stop = stop % 1 * 60;
|
||||
return Math.floor(start) + ':' + minutes_start.toPrecision(2) + ' - ' + Math.floor(stop) + ':' + minutes_stop.toPrecision(2);
|
||||
}
|
||||
|
||||
function display_fitting_data(json_response) {
|
||||
$("#DIV_CO2_fitting_result").show();
|
||||
$("#CO2_data_plot").attr("src", json_response['CO2_plot']);
|
||||
|
|
@ -132,11 +138,10 @@ function display_fitting_data(json_response) {
|
|||
delete json_response['CO2_plot'];
|
||||
$("#CO2_fitting_result").val(JSON.stringify(json_response));
|
||||
$("#exhalation_rate_fit").html('Exhalation rate: ' + String(json_response['exhalation_rate'].toFixed(2)) + ' m³/h');
|
||||
let ventilation_table = "<tr><th>Time</th><th>Ventilation value (ACH)</th></tr>";
|
||||
let ventilation_table = "<tr><th>Time (HH:MM)</th><th>ACH value (h⁻¹)</th></tr>";
|
||||
json_response['ventilation_values'].map((val, index) => {
|
||||
console.log(json_response['transition_times'])
|
||||
let transition_times = `${(json_response['transition_times'][index]).toFixed(2)} - ${(json_response['transition_times'][index + 1]).toFixed(2)}`
|
||||
ventilation_table += `<tr><td>${transition_times}</td><td>${val}</td></tr>`;
|
||||
let transition_times = display_transition_times_hour_format(json_response['transition_times'][index], json_response['transition_times'][index + 1]);
|
||||
ventilation_table += `<tr><td>${transition_times}</td><td>${val.toPrecision(2)}</td></tr>`;
|
||||
});
|
||||
$("#ventilation_rate_fit").html(ventilation_table);
|
||||
$("#generate_fitting_data").html('Fit data');
|
||||
|
|
|
|||
|
|
@ -500,7 +500,6 @@ function ventilation_from_fitting(condition_from_fitting) {
|
|||
$('input[type=radio][id=mechanical_ventilation]').prop("disabled", condition_from_fitting);
|
||||
$('input[type=radio][id=natural_ventilation]').prop("disabled", condition_from_fitting);
|
||||
$('input[type=radio][id=from_fitting]').prop("disabled", !condition_from_fitting);
|
||||
|
||||
if (condition_from_fitting) {
|
||||
$('input[type=radio][id=from_fitting]').prop('checked',true);
|
||||
$('#DIVfrom_fitting').after($('#window_opening_regime'));
|
||||
|
|
|
|||
|
|
@ -530,11 +530,15 @@
|
|||
{% endif %}
|
||||
<li><p class="data_text">From Fitting:
|
||||
{% if form.ventilation_type == "from_fitting" %}
|
||||
Yes
|
||||
Yes
|
||||
<table border="1" style="width: 20%; margin-left: 30px; margin-top: 20px">
|
||||
<tr><th>Ventilation value (ACH)</th></tr>
|
||||
<tr><th> Time (HH:MM)</th><th>ACH value (h⁻¹)</th></tr>
|
||||
{% for ventilation in form.CO2_fitting_result['ventilation_values'] %}
|
||||
<tr><th>{{ventilation}}</th></tr>
|
||||
{% set transition_time = form.CO2_fitting_result['transition_times'] %}
|
||||
<tr>
|
||||
<td>{{ transition_time[loop.index - 1] | hour_format }} - {{ transition_time[loop.index] | hour_format }}</td>
|
||||
<td>{{ ventilation | float_format }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue