{"record":{"id":"de6e4e944babd681","repo":"TheAlgorithms/Python","slug":"value-higher-than-pressure-at-sea-level","errorCode":null,"errorMessage":"Value Higher than Pressure at Sea Level !","messagePattern":"Value Higher than Pressure at Sea Level !","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"physics/altitude_pressure.py","lineNumber":43,"sourceCode":"    Examples:\n    >>> get_altitude_at_pressure(pressure=100_000)\n    105.47836610778828\n    >>> get_altitude_at_pressure(pressure=101_325)\n    0.0\n    >>> get_altitude_at_pressure(pressure=80_000)\n    1855.873388064995\n    >>> get_altitude_at_pressure(pressure=201_325)\n    Traceback (most recent call last):\n      ...\n    ValueError: Value Higher than Pressure at Sea Level !\n    >>> get_altitude_at_pressure(pressure=-80_000)\n    Traceback (most recent call last):\n      ...\n    ValueError: Atmospheric Pressure can not be negative !\n    \"\"\"\n\n    if pressure > 101325:\n        raise ValueError(\"Value Higher than Pressure at Sea Level !\")\n    if pressure < 0:\n        raise ValueError(\"Atmospheric Pressure can not be negative !\")\n    return 44_330 * (1 - (pressure / 101_325) ** (1 / 5.5255))\n\n\nif __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n","sourceCodeStart":25,"sourceCodeEnd":53,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/physics/altitude_pressure.py#L25-L53","documentation":"Raised by get_altitude_at_pressure when the supplied pressure exceeds 101325 Pa, the standard sea-level pressure. The barometric formula used (44330 * (1 - (p/101325)^(1/5.5255))) is only defined for pressures at or below sea level; higher pressures would correspond to negative altitudes outside the model.","triggerScenarios":"Calling get_altitude_at_pressure(pressure=201_325), or any pressure > 101325 such as values in different units (e.g. hPa like 1013 hPa passed as 101300... actually 1013 hPa = 101300 Pa is fine; passing 150000 does raise).","commonSituations":"Unit confusion — passing pressure in hPa where Pa is expected (e.g. 1013 instead of 101300 does not raise but yields wrong results), or using pressures from below-sea-level sites / pressurized enclosures that exceed one atmosphere.","solutions":["Ensure the pressure is in pascals and at most 101325 (standard sea level)","Convert units first if your data is in hPa or atm: hPa * 100, atm * 101325","If pressures above one atmosphere are legitimate for your use case, this model is not applicable"],"exampleFix":"# before\nget_altitude_at_pressure(pressure=201_325)  # ValueError\n\n# after\nget_altitude_at_pressure(pressure=min(pressure_pa, 101_325))  # or fix the source data","handlingStrategy":"validation","validationCode":"SEA_LEVEL_PA = 101_325\n\ndef plausible_pressure(pressure_pa) -> bool:\n    return 0 <= pressure_pa <= SEA_LEVEL_PA","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on pascals across the pipeline and convert hPa/atm at the boundary","Clamp or reject readings above one atmosphere before calling the altitude model"],"tags":["physics","pressure","unit-conversion","range-check"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}