Commit 7609140e authored by Marc R.'s avatar Marc R.

skew-T: entirely revised generation of diagram geometry to use the new...

skew-T: entirely revised generation of diagram geometry to use the new (T,p)->(x,y) mapping; simplified the code; NOTE: most other rendering parts are now broken!
parent e352085f
This diff is collapsed.
......@@ -163,7 +163,7 @@ private:
VertexRange isotherms;
VertexRange dryAdiabates;
VertexRange moistAdiabates;
VertexRange outline;
VertexRange frame;
VertexRange isobars;
};
......@@ -431,7 +431,7 @@ private:
GL::MVertexBuffer *vbDiagramVertices,
ModeSpecificDiagramConfiguration *config);
void generateDiagramVertices(GL::MVertexBuffer **vbDiagramVertices,
void generateDiagramGeometry(GL::MVertexBuffer **vbDiagramVertices,
ModeSpecificDiagramConfiguration *config);
void drawDiagram(MSceneViewGLWidget* sceneView,
......
......@@ -484,6 +484,18 @@ shader VS2D(in vec2 vertexCoord : 0, out vec2 worldPos)
}
shader VSDiagramXYtoFullscreen(in vec2 vertex : 0)
{
//TODO (mr, 10Jan2019) -- replace by matrix multiplication.
float hPad = 0.1;
float vPad = 0.1;
vec2 vertexClipSpace = vec2(vertex.x * (2.-2.*hPad) - 1.+hPad,
vertex.y * (2.-2.*vPad) - 1.+vPad);
gl_Position = vec4(vertexClipSpace.x, vertexClipSpace.y, layer, 1.);
}
shader VS2DVertexYInPressure(in vec2 vertexCoord : 0, out vec2 worldPos)
{
worldPos.x = vertexCoord.x;
......@@ -970,9 +982,11 @@ program DiagramVerticesVertOrHoriCheck
program DiagramVertices
{
vs(400)=VS2DVertexYInPressure();
gs(400)=GSVertices() : in(lines), out(line_strip, max_vertices = 2);
fs(400)=FSColourWithAreaTest();
// vs(400)=VS2DVertexYInPressure();
vs(400)=VSDiagramXYtoFullscreen();
// gs(400)=GSVertices() : in(lines), out(line_strip, max_vertices = 2);
fs(400)=FSColour();
// fs(400)=FSColourWithAreaTest();
};
program MeasurementPoint
......
......@@ -457,6 +457,14 @@ double potentialTemperature_K(double T_K, double p_Pa)
}
double ambientTemperatureOfPotentialTemperature_K(double theta_K, double p_Pa)
{
return theta_K / pow( 100000. / p_Pa,
MetConstants::GAS_CONSTANT_DRY_AIR /
MetConstants::SPECIFIC_HEAT_DRYAIR_CONST_PRESSURE );
}
double virtualTemperature_K(double T_K, double q_kgkg)
{
return T_K * (q_kgkg + 0.622*(1.-q_kgkg)) / 0.622;
......@@ -571,8 +579,8 @@ const double coefficients_ambientT_thetaRef_MoisseevaStull[21] = {
3.833143316160573733e+01
};
double temperatureAlongSaturatedAdiabat_K_MoisseevaStull(double p_Pa,
double thetaW_K)
double temperatureAlongSaturatedAdiabat_K_MoisseevaStull(double thetaW_K,
double p_Pa)
{
// This implementation directly follows Moisseeva and Stull (ACP, 2017),
// Section 4.1.
......@@ -653,7 +661,7 @@ const double coefficients_thetaW_TRef_MoisseevaStull[21] = {
double wetBulbPotentialTemperatureOfSaturatedAdiabat_K_MoisseevaStull(
double p_Pa, double T_K)
double T_K, double p_Pa)
{
// This implementation directly follows Moisseeva and Stull (ACP, 2017),
// Section 4.2.
......@@ -806,7 +814,7 @@ void test_temperatureAlongSaturatedAdiabat_K_MoisseevaStull()
double thetaW_K = values_p_thW_T[i][1] + 273.15;
double ambientT_K_target = values_p_thW_T[i][2] + 273.15;
double ambientT_K_computed =
temperatureAlongSaturatedAdiabat_K_MoisseevaStull(p_Pa, thetaW_K);
temperatureAlongSaturatedAdiabat_K_MoisseevaStull(thetaW_K, p_Pa);
QString s = QString("(%1) p_Pa = %2 thetaW_K = %3 target T_K = %4 computed T_K = %5")
.arg(i).arg(p_Pa).arg(thetaW_K).arg(ambientT_K_target).arg(ambientT_K_computed);
......@@ -847,7 +855,8 @@ void test_wetBulbPotentialTemperatureOfSaturatedAdiabat_K_MoisseevaStull()
double T_K = values_p_T_thW[i][1] + 273.15;
double thetaW_K_target = values_p_T_thW[i][2] + 273.15;
double thetaW_K_computed =
wetBulbPotentialTemperatureOfSaturatedAdiabat_K_MoisseevaStull(p_Pa, T_K);
wetBulbPotentialTemperatureOfSaturatedAdiabat_K_MoisseevaStull(
T_K, p_Pa);
QString s = QString("(%1) p_Pa = %2 T_K = %3 target thetaW_K = %4 computed thetaW_K = %5")
.arg(i).arg(p_Pa).arg(T_K).arg(thetaW_K_target).arg(thetaW_K_computed);
......@@ -865,6 +874,8 @@ void runMetRoutinesTests()
test_wetBulbPotentialTemperatureOfSaturatedAdiabat_K_MoisseevaStull();
}
} // namespace MetRoutinesTests
}
// namespace MetRoutinesTests
} // namespace Met3D
......@@ -288,6 +288,17 @@ double windSpeed3D_ms(double u_ms, double v_ms, double w_ms);
double potentialTemperature_K(double T_K, double p_Pa);
/**
Computes ambient temperature in [K] of a given potential temperature in [K]
at pressure @p p_Pa in [Pa].
Method:
T = theta / (p0/p)^(R/cp)
with p0 = 100000. Pa, R = 287.058 JK-1kg-1, cp = 1004 JK-1kg-1.
*/
double ambientTemperatureOfPotentialTemperature_K(double theta_K, double p_Pa);
/**
Computes the virtual temperature in [K] from temperature @p T_K in [K] and
specific humidity @p q_kgkg in [kg/kg].
......@@ -362,9 +373,14 @@ double equivalentPotentialTemperature_K_Bolton(double T_K, double p_Pa,
Stull (ACP, 2017), "Technical note: A noniterative approach to modelling
moist thermodynamics".
*/
double temperatureAlongSaturatedAdiabat_K_MoisseevaStull(double p_Pa,
double thetaW_K);
double temperatureAlongSaturatedAdiabat_K_MoisseevaStull(
double thetaW_K, double p_Pa);
/**
Inverse of @ref temperatureAlongSaturatedAdiabat_K_MoisseevaStull().
*/
double wetBulbPotentialTemperatureOfSaturatedAdiabat_K_MoisseevaStull(
double T_K, double p_Pa);
// Test functions for meteorological computations.
namespace MetRoutinesTests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment