From 66fde1008f717e9672d2fcec853d5de9bb4ed379 Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Sun, 16 Oct 2022 15:46:26 -0700 Subject: [PATCH] fix pyrometry equation and more --- examples/formula_testing.py | 48 +++++++++++++++++++++---------------- ratio_pyrometry.py | 16 +++++++------ templates/results.jinja2 | 2 +- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/examples/formula_testing.py b/examples/formula_testing.py index d02f5a2..d6e49d7 100644 --- a/examples/formula_testing.py +++ b/examples/formula_testing.py @@ -1,13 +1,18 @@ -# R & G values taken from images import math +# R & G values taken from images +# white_hot = (255, 255) +# hi = (168, 55) +# med = (146, 26) +# low = (25, 4) +# custom = (156, 20) -# Values -white_hot = (255, 255) -hi = (168, 55) -med = (146, 26) -low = (25, 4) - +# firebrand_test +rg_values = [ + (219, 7), + (227, 14), + (166, 14), +] # Settings I_Darkcurrent = 7.7 @@ -21,13 +26,12 @@ def pyrometry_calibration_formula(i_ng, i_nr): in Celsius. """ try: - return 362.73 * math.log10( - (i_ng/i_nr) ** 3 - ) + 2186.7 * math.log10( - (i_ng/i_nr) ** 2 - ) + 4466.5 * math.log10( - (i_ng / i_nr) - ) + 3753.5 + return ( + 362.73 * math.log10(i_ng/i_nr) ** 3 + + 2186.7 * math.log10(i_ng/i_nr) ** 2 + + 4466.5 * math.log10(i_ng / i_nr) + + 3753.5 + ) # return 362.73 * math.log10( # (i_ng/i_nr) ** 3 # ) + 2186.7 * math.log10( @@ -55,13 +59,17 @@ def grtemp(px): round(px[0] / px[1], 2), round(r_norm, 2), round(g_norm, 2), - round(r_norm / g_norm), + round(g_norm / r_norm, 4), res, ) - tprint('RED', 'GREEN', 'RATIO', 'RNORM', 'GNORM', 'NRATIO', 'RES TEMP') -grtemp(white_hot) -grtemp(hi) -grtemp(med) -grtemp(low) + +for val in rg_values: + grtemp(val) + +# grtemp(white_hot) +# grtemp(hi) +# grtemp(med) +# grtemp(low) +# grtemp(custom) diff --git a/ratio_pyrometry.py b/ratio_pyrometry.py index 3de7b40..34672a1 100644 --- a/ratio_pyrometry.py +++ b/ratio_pyrometry.py @@ -45,6 +45,9 @@ def rg_ratio_normalize( # min intensity = 0 pix_i = temp_C - MIN_TEMP + # temp_new = temp_C - MIN_TEMP + # pix_i = temp_new / MAX_TEMP * 255 + imgnew[i][j] = [pix_i, pix_i, pix_i] # imgnew[i][j] = [0, g_norm, r_norm] @@ -60,13 +63,12 @@ def pyrometry_calibration_formula(i_ng, i_nr, default=24.0): in Celsius. Defaults to room temperature if there's an error. """ try: - return 362.73 * math.log10( - (i_ng/i_nr) ** 3 - ) + 2186.7 * math.log10( - (i_ng/i_nr) ** 2 - ) + 4466.5 * math.log10( - (i_ng / i_nr) - ) + 3753.5 + return ( + 362.73 * math.log10(i_ng/i_nr) ** 3 + + 2186.7 * math.log10(i_ng/i_nr) ** 2 + + 4466.5 * math.log10(i_ng / i_nr) + + 3753.5 + ) except: return default diff --git a/templates/results.jinja2 b/templates/results.jinja2 index f44e35a..512d396 100644 --- a/templates/results.jinja2 +++ b/templates/results.jinja2 @@ -4,7 +4,7 @@ - + {# Original image #}
Input ImageResultant HeatmapOutput Heatmap