Skip to content

Commit 12c486e

Browse files
authored
Merge pull request #26 from oyve/copilot/document-cloudbase-height-return
Clarify cloudBaseHeight return value: AGL vs MSL
2 parents e3bb407 + be68856 commit 12c486e

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

src/phenomena/cloud.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,40 @@ import { liftingCondensationLevel } from '../formulas/humidity';
22
import { DRY_ADIABATIC_LAPSE_RATE } from '../constants';
33

44
/**
5-
* Estimate the altitude of the cloud base (in meters) from temperature and dew point.
6-
* This uses the lifting condensation level formula with the empirical approximation
7-
* from meteorological practice: approximately 124.7 meters for every degree (Celsius/Kelvin) of spread.
8-
* Formula: cloud_base_height = (T - Td) * 124.7 meters
5+
* Estimate the altitude of the cloud base from temperature and dew point.
6+
*
7+
* This function calculates the lifting condensation level (LCL), which is the height
8+
* above the surface where air reaches saturation and clouds begin to form. It uses the
9+
* empirical approximation from meteorological practice: approximately 124.7 meters for
10+
* every degree (Celsius/Kelvin) of temperature-dewpoint spread.
11+
*
12+
* **Important:** The return value depends on the altitude parameter:
13+
* - When altitude = 0 (default): Returns cloud base height above ground level (AGL)
14+
* - When altitude > 0: Returns cloud base height above mean sea level (MSL)
15+
*
16+
* Formula:
17+
* - Height above surface (AGL) = (T - Td) × 124.7 meters
18+
* - Height above MSL = altitude + (T - Td) × 124.7 meters
19+
*
920
* @param {number} temperature - Air temperature in Kelvin.
1021
* @param {number} dewPoint - Dew point temperature in Kelvin.
11-
* @param {number} altitude - Surface altitude in meters (default: 0).
12-
* @returns {number} Cloud base altitude in meters above mean sea level.
22+
* @param {number} altitude - Surface altitude in meters above mean sea level (default: 0).
23+
* @returns {number} Cloud base height in meters. When altitude is 0 or omitted, returns height
24+
* above ground level (AGL). When altitude is provided, returns height above
25+
* mean sea level (MSL).
1326
* @throws {Error} If dew point is greater than temperature (physically impossible).
27+
*
28+
* @example
29+
* // At sea level (altitude = 0): returns height above ground
30+
* const cloudHeightAGL = cloudBaseHeight(293.15, 283.15);
31+
* console.log(cloudHeightAGL); // 1247 meters above ground level
32+
*
33+
* @example
34+
* // At elevated location: returns height above mean sea level
35+
* const cloudHeightMSL = cloudBaseHeight(293.15, 283.15, 500);
36+
* console.log(cloudHeightMSL); // 1747 meters above mean sea level (500m surface + 1247m cloud base)
37+
*
38+
* @see https://en.wikipedia.org/wiki/Lifted_condensation_level
1439
*/
1540
export function cloudBaseHeight(
1641
temperature: number,

0 commit comments

Comments
 (0)