Implement all required conversion functions
This commit is contained in:
@@ -1,43 +1,56 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
// https://bmcnoldy.earth.miami.edu/Humidity.html
|
// https://bmcnoldy.earth.miami.edu/Humidity.html
|
||||||
// https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.18280890511
|
// https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.18280890511
|
||||||
// https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.18441370202
|
// https://onlinelibrary.wiley.com/doi/abs/10.1002/andp.18441370202
|
||||||
|
|
||||||
// NOTE: EXP and LN are exponential and natural logarithm functions
|
// TODO: Make sure all results for conversion functions are correct.
|
||||||
|
|
||||||
|
// Conversion constants
|
||||||
|
static const float C1 = 100.0f;
|
||||||
|
static const float C2 = 243.04f;
|
||||||
|
static const float C3 = 17.625f;
|
||||||
|
|
||||||
// Dewpoint TD
|
// Dewpoint TD
|
||||||
// 243.04*(LN(RH/100)+((17.625*T)/(243.04+T)))/
|
|
||||||
// (17.625-LN(RH/100)-((17.625*T)/(243.04+T)))
|
|
||||||
float Dewp(float t, float rh)
|
float Dewp(float t, float rh)
|
||||||
{
|
{
|
||||||
// TODO
|
float a, b;
|
||||||
UNUSED(tc);
|
|
||||||
UNUSED(rh);
|
|
||||||
|
|
||||||
return 0.0f;
|
a = log(rh / C1);
|
||||||
|
b = C3 * t / (C2 + t);
|
||||||
|
|
||||||
|
// 243.04*(LN(RH/100)+((17.625*T)/(243.04+T)))/
|
||||||
|
// (17.625-LN(RH/100)-((17.625*T)/(243.04+T)))
|
||||||
|
|
||||||
|
return C2 * (a + b) / (C3 - a - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temperature T
|
// Temperature T
|
||||||
// 243.04*(((17.625*TD)/(243.04+TD))-LN(RH/100))/
|
|
||||||
// (17.625+LN(RH/100)-((17.625*TD)/(243.04+TD)))
|
|
||||||
float Temp(float td, float rh)
|
float Temp(float td, float rh)
|
||||||
{
|
{
|
||||||
// TODO
|
float a, b;
|
||||||
UNUSED(dc);
|
|
||||||
UNUSED(rh);
|
|
||||||
|
|
||||||
return 0.0f;
|
a = log(rh / C1);
|
||||||
|
b = C3 * td / (C2 + td);
|
||||||
|
|
||||||
|
// 243.04*(((17.625*TD)/(243.04+TD))-LN(RH/100))/
|
||||||
|
// (17.625+LN(RH/100)-((17.625*TD)/(243.04+TD)))
|
||||||
|
|
||||||
|
return C2 * (b - a) / (C3 + a - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relative Humidity RH
|
// Relative Humidity RH
|
||||||
// 100*(EXP((17.625*TD)/(243.04+TD))/
|
|
||||||
// EXP((17.625*T)/(243.04+T)))
|
|
||||||
float Rhum(float t, float td)
|
float Rhum(float t, float td)
|
||||||
{
|
{
|
||||||
// TODO
|
float a, b;
|
||||||
UNUSED(tc);
|
|
||||||
UNUSED(dc);
|
|
||||||
|
|
||||||
return 0.0f;
|
a = C3 * td / (C2 + td);
|
||||||
|
b = C3 * t / (C2 + t);
|
||||||
|
|
||||||
|
// 100*(EXP((17.625*TD)/(243.04+TD))/
|
||||||
|
// EXP((17.625*T)/(243.04+T)))
|
||||||
|
|
||||||
|
return C1 * (exp(a) / exp(b));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user