Atmo
Atmo
¶
Atmo(
altitude: Optional[Union[float, Distance]] = None,
pressure: Optional[Union[float, Pressure]] = None,
temperature: Optional[Union[float, Temperature]] = None,
humidity: float = 0.0,
powder_t: Optional[Union[float, Temperature]] = None,
)
Atmospheric conditions and density calculations.
This class encapsulates atmospheric conditions (altitude, pressure, temperature, relative humidity)
and provides helpers to derive air density ratio, actual densities, and local speed of sound (Mach 1).
The instance stores an internal "base" altitude/pressure/temperature snapshot (_a0, _p0, _t0)
used to interpolate conditions at other altitudes using lapse-rate models.
Attributes:
| Name | Type | Description |
|---|---|---|
altitude |
Distance
|
Altitude relative to sea level. |
pressure |
Pressure
|
Unadjusted barometric (station) pressure. |
temperature |
Temperature
|
Ambient air temperature. |
humidity |
float
|
Relative humidity expressed either as fraction [0..1] or percent [0..100]. |
powder_temp |
Temperature
|
Powder temperature (may differ from ambient when powder sensitivity enabled). |
density_ratio |
float
|
Ratio of local air density to standard density. |
mach |
Velocity
|
Local speed of sound (Mach 1). |
density_metric |
float
|
Air density in kg/m^3. |
density_imperial |
float
|
Air density in lb/ft^3. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
Optional[Union[float, Distance]]
|
Altitude relative to sea level. Defaults to 0. |
None
|
pressure
|
Optional[Union[float, Pressure]]
|
Station pressure (unadjusted). Defaults to standard pressure for altitude. |
None
|
temperature
|
Optional[Union[float, Temperature]]
|
Ambient temperature. Defaults to standard temperature for altitude. |
None
|
humidity
|
float
|
Relative humidity (fraction or percent). Defaults to 0. |
0.0
|
powder_t
|
Optional[Union[float, Temperature]]
|
Powder (propellant) temperature. Defaults to ambient temperature. |
None
|
Example
from pyballistic import Atmo, Unit
atmo = Atmo(
altitude=Unit.Meter(100),
pressure=Unit.hPa(1000),
temperature=Unit.Celsius(20),
humidity=50,
powder_t=Unit.Celsius(15)
)
Notes
The constructor caches base conditions (_t0 in °C, _p0 in hPa, _a0 in feet) and computes associated
_mach and _density_ratio. Subsequent changes to humidity trigger an automatic density recomputation.
Methods:
| Name | Description |
|---|---|
update_density_ratio |
Recompute density ratio for changed humidity. |
temperature_at_altitude |
Interpolate temperature (°C) at altitude using lapse rate. |
pressure_at_altitude |
Interpolate pressure (hPa) at altitude using barometric formula. |
get_density_and_mach_for_altitude |
Compute density ratio and Mach (fps) for the specified altitude. |
standard_temperature |
ICAO standard temperature for altitude (valid to ~36,000 ft). |
standard_pressure |
ICAO standard pressure for altitude (valid to ~36,000 ft). |
icao |
Create a standard ICAO atmosphere at altitude. |
machF |
Mach 1 (fps) for given Fahrenheit temperature. |
machC |
Mach 1 (m/s) for given Celsius temperature. |
machK |
Mach 1 (m/s) for given Kelvin temperature. |
calculate_air_density |
Air density from temperature (°C), pressure (hPa), and humidity. |
Source code in pyballistic/conditions.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
Attributes¶
powder_temp
property
¶
powder_temp: Temperature
Powder temperature (falls back to ambient when unspecified).
density_ratio
property
¶
density_ratio: float
Ratio of local density to standard density (dimensionless).
Functions¶
update_density_ratio
¶
update_density_ratio() -> None
Recompute density ratio for changed humidity.
Source code in pyballistic/conditions.py
203 204 205 | |
temperature_at_altitude
¶
Interpolate temperature (°C) at altitude using lapse rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Altitude above mean sea level (ft). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Temperature in degrees Celsius (bounded by model lower limit). |
Source code in pyballistic/conditions.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
pressure_at_altitude
¶
Interpolate pressure (hPa) at altitude using barometric formula.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Altitude above mean sea level (ft). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Pressure in hPa. |
Source code in pyballistic/conditions.py
226 227 228 229 230 231 232 233 234 235 236 237 | |
get_density_and_mach_for_altitude
¶
Compute density ratio and Mach (fps) for the specified altitude.
Uses lapse-rate interpolation unless altitude is within 30 ft of the base altitude, in which case the initial cached values are used for performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
float
|
Altitude above mean sea level (ft). |
required |
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
Tuple (density_ratio, mach_fps). |
Source code in pyballistic/conditions.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
standard_temperature
staticmethod
¶
standard_temperature(altitude: Distance) -> Temperature
ICAO standard temperature for altitude (valid to ~36,000 ft).
Source code in pyballistic/conditions.py
272 273 274 275 | |
standard_pressure
staticmethod
¶
ICAO standard pressure for altitude (valid to ~36,000 ft).
Source code in pyballistic/conditions.py
277 278 279 280 281 282 283 284 285 286 | |
icao
staticmethod
¶
icao(
altitude: Union[float, Distance] = 0,
temperature: Optional[Temperature] = None,
humidity: float = cStandardHumidity,
) -> Atmo
Create a standard ICAO atmosphere at altitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
altitude
|
Union[float, Distance]
|
Altitude (defaults to sea level). |
0
|
temperature
|
Optional[Temperature]
|
Optional override temperature (defaults to standard at altitude). |
None
|
humidity
|
float
|
Relative humidity (fraction or percent). Defaults to standard humidity. |
cStandardHumidity
|
Returns:
| Type | Description |
|---|---|
Atmo
|
Atmo instance representing standard atmosphere at altitude. |
Source code in pyballistic/conditions.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
machF
staticmethod
¶
Mach 1 (fps) for given Fahrenheit temperature.
Source code in pyballistic/conditions.py
312 313 314 315 316 317 318 319 | |
machC
staticmethod
¶
Mach 1 (m/s) for given Celsius temperature.
Source code in pyballistic/conditions.py
321 322 323 324 325 326 327 328 | |
machK
staticmethod
¶
Mach 1 (m/s) for given Kelvin temperature.
Source code in pyballistic/conditions.py
330 331 332 333 334 335 336 337 | |
calculate_air_density
staticmethod
¶
Air density from temperature (°C), pressure (hPa), and humidity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Temperature in degrees Celsius. |
required |
p_hpa
|
float
|
Pressure in hPa (hectopascals). Internally converted to Pa. |
required |
humidity
|
float
|
Relative humidity (fraction or percent). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Air density in kg/m³. |
Notes
- Divide result by
cDensityImperialToMetricto get density in lb/ft³. - Source: CIPM-2007 (https://www.nist.gov/system/files/documents/calibrations/CIPM-2007.pdf)
Source code in pyballistic/conditions.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
Vacuum
¶
Vacuum(
altitude: Optional[Union[float, Distance]] = None,
temperature: Optional[Union[float, Temperature]] = None,
)
Bases: Atmo
Vacuum atmosphere (zero density => zero drag).
Source code in pyballistic/conditions.py
410 411 412 413 414 415 | |