Skip to content

Commit 9793c68

Browse files
committed
Added simplified temperature correction as a cross-check and unit tests
1 parent 0f09d9a commit 9793c68

5 files changed

Lines changed: 107 additions & 175 deletions

File tree

src/lib/calculations/temperature-correction/esdu-temperature-correction.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
}
5656
5757
console.debug("Resulting correction to be added to the elevation: hPAirplane %s", hPAirplane);
58-
5958
return add(aerodrome_elevation, hPAirplane);
6059
}
6160
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script context="module" lang="ts">
2+
import { add, parse, subtract, unit, type Unit } from "mathjs";
3+
4+
const isa_temperature_lapse_rate = unit("0.00198 K/ft");
5+
6+
const equation_t0 = parse("tAerodrome + L0 * HAerodrome");
7+
const equation_height_correction = parse("H * ((15K - t0)/(273K + t0 - 0.5 * L0 * (H + HSS)))");
8+
9+
export function simplifiedAltitudeCorrection (input_altitude: Unit, aerodrome_elevation: Unit, aerodrome_ground_temperature: Unit) {
10+
let input_height = subtract(input_altitude, aerodrome_elevation);
11+
12+
const calculation_parameters_t0 = {
13+
tAerodrome: aerodrome_ground_temperature,
14+
HAerodrome: aerodrome_elevation,
15+
L0: isa_temperature_lapse_rate
16+
};
17+
const t0 = equation_t0.evaluate(calculation_parameters_t0);
18+
19+
const calculation_parameters_height_correction = {
20+
H: input_height,
21+
t0: t0,
22+
L0: isa_temperature_lapse_rate,
23+
HSS: aerodrome_elevation,
24+
};
25+
26+
const height_correction = equation_height_correction.evaluate(calculation_parameters_height_correction);
27+
28+
return add(input_altitude, height_correction);
29+
}
30+
</script>

src/lib/components/AerodromeInput.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
if (calculatedIsaDeviation > 0) {
4545
inputErrors.push("Calculations are only possible for ISA deviations smaller than 0. So temperatures colder than the standard atmosphere.");
4646
}
47+
48+
// Normal errors, all will be shown at once
49+
if (calculatedIsaDeviation <- 80) {
50+
inputErrors.push("Calculations are only possible for ISA deviations down to -80 °C");
51+
}
4752
4853
if (aerodrome_elevation_ft > 36000) {
4954
inputErrors.push("The temperature correction calculation is only valid up to 36000 ft please enter a smaller input value!");

0 commit comments

Comments
 (0)