0
# Physical Constants
1
2
MetPy provides a comprehensive library of over 60 physical constants essential for meteorological calculations. All constants include proper units through Pint integration, ensuring dimensional analysis and preventing unit errors in calculations.
3
4
## Capabilities
5
6
### Earth Constants
7
8
Fundamental properties of Earth used in atmospheric and geophysical calculations.
9
10
```python { .api }
11
# Earth geometric properties
12
earth_avg_radius = 6371008.7714 * units.m
13
earth_gravity = 9.80665 * units('m/s^2')
14
earth_avg_angular_vel = 7292115e-11 * units('rad/s')
15
16
# Earth orbital properties
17
earth_sfc_avg_dist_sun = 149597870700.0 * units.m
18
earth_ellipsoid_flattening = 1/298.257223563
19
earth_eccentricity = 0.081819221456
20
21
# Solar geometry
22
earth_max_declination_angle = 23.45 * units.degrees
23
```
24
25
### Atmospheric Constants
26
27
Properties of the atmosphere essential for meteorological calculations.
28
29
```python { .api }
30
# Dry air properties
31
dry_air_molecular_weight = 28.9647 * units('g/mol')
32
dry_air_gas_constant = 287.0 * units('J/(kg*K)')
33
dry_air_spec_heat_press = 1004.0 * units('J/(kg*K)') # Cp
34
dry_air_spec_heat_vol = 717.0 * units('J/(kg*K)') # Cv
35
dry_air_density_stp = 1.275 * units('kg/m^3')
36
37
# Atmospheric pressure
38
atmos_pressure_sea_level = 101325.0 * units.Pa
39
```
40
41
### Water and Moisture Constants
42
43
Water vapor and phase change properties for humidity and cloud physics calculations.
44
45
```python { .api }
46
# Water vapor properties
47
water_molecular_weight = 18.0153 * units('g/mol')
48
water_gas_constant = 461.5 * units('J/(kg*K)')
49
50
# Latent heats
51
water_heat_vaporization = 2.501e6 * units('J/kg')
52
water_heat_fusion = 3.337e5 * units('J/kg')
53
water_heat_sublimation = 2.834e6 * units('J/kg')
54
55
# Specific heats
56
water_specific_heat = 4186.0 * units('J/(kg*K)')
57
ice_specific_heat = 2106.0 * units('J/(kg*K)')
58
59
# Densities
60
density_water = 1000.0 * units('kg/m^3')
61
density_ice = 917.0 * units('kg/m^3')
62
63
# Triple point properties
64
water_triple_point_temperature = 273.16 * units.K
65
water_triple_point_pressure = 611.657 * units.Pa
66
```
67
68
### Universal Physical Constants
69
70
Fundamental constants from physics used in atmospheric radiation and thermodynamics.
71
72
```python { .api }
73
# Fundamental constants
74
boltzmann = 1.380649e-23 * units('J/K')
75
planck = 6.62607015e-34 * units('J*s')
76
avogadro = 6.02214076e23 * units('1/mol')
77
universal_gas_constant = 8.314462618 * units('J/(mol*K)')
78
79
# Electromagnetic constants
80
speed_of_light = 299792458.0 * units('m/s')
81
stefan_boltzmann = 5.670374419e-8 * units('W/(m^2*K^4)')
82
83
# Other constants
84
gravitational_constant = 6.67430e-11 * units('m^3/(kg*s^2)')
85
```
86
87
### Derived Constants
88
89
Commonly used ratios and derived quantities for atmospheric calculations.
90
91
```python { .api }
92
# Molecular weight ratios
93
epsilon = water_molecular_weight / dry_air_molecular_weight # ≈ 0.622
94
poisson_exponent = dry_air_gas_constant / dry_air_spec_heat_press # ≈ 0.286
95
96
# Heat capacity ratio
97
gamma = dry_air_spec_heat_press / dry_air_spec_heat_vol # ≈ 1.4
98
99
# Other derived quantities
100
dry_adiabatic_lapse_rate = earth_gravity / dry_air_spec_heat_press # ≈ 9.8 K/km
101
```
102
103
## Usage Examples
104
105
### Basic Constant Usage
106
107
```python
108
import metpy.constants as constants
109
from metpy.units import units
110
111
# Use constants in calculations
112
pressure = 1000 * units.hPa
113
temperature = 20 * units.celsius
114
115
# Calculate air density using ideal gas law
116
density = pressure / (constants.dry_air_gas_constant * temperature.to('kelvin'))
117
print(f"Air density: {density}")
118
119
# Calculate scale height
120
scale_height = (constants.dry_air_gas_constant * temperature.to('kelvin')) / constants.earth_gravity
121
print(f"Scale height: {scale_height}")
122
```
123
124
### Thermodynamic Calculations
125
126
```python
127
# Calculate potential temperature manually using constants
128
theta = temperature * (1000 * units.hPa / pressure) ** constants.poisson_exponent
129
print(f"Potential temperature: {theta}")
130
131
# Calculate saturation vapor pressure using Clausius-Clapeyron
132
e_sat = 611 * units.Pa * np.exp(
133
(constants.water_heat_vaporization * (temperature.to('kelvin') - 273.15 * units.K)) /
134
(constants.water_gas_constant * temperature.to('kelvin') * 273.15 * units.K)
135
)
136
print(f"Saturation vapor pressure: {e_sat}")
137
```
138
139
### Unit Conversions with Constants
140
141
```python
142
# Convert between different temperature scales
143
temp_celsius = 25 * units.celsius
144
temp_kelvin = temp_celsius.to('kelvin')
145
temp_fahrenheit = temp_celsius.to('fahrenheit')
146
147
# Energy conversions
148
kinetic_energy = 0.5 * 1000 * units.kg * (10 * units('m/s'))**2
149
kinetic_energy_cal = kinetic_energy.to('calorie')
150
151
# Pressure conversions using standard atmosphere
152
pressure_mb = 850 * units.mbar
153
pressure_pa = pressure_mb.to('pascal')
154
pressure_inhg = pressure_mb.to('inch_Hg')
155
```
156
157
## Constants Access Patterns
158
159
```python
160
# Import all constants
161
import metpy.constants as constants
162
163
# Access individual constants
164
g = constants.earth_gravity
165
R_d = constants.dry_air_gas_constant
166
L_v = constants.water_heat_vaporization
167
168
# Use in meteorological calculations
169
# Hydrostatic equation: dp/dz = -ρg
170
# Ideal gas law: p = ρRT
171
# Clausius-Clapeyron: de_s/dT = L_v*e_s/(R_v*T^2)
172
```
173
174
## Alternative Access Methods
175
176
```python
177
# Import specific constants directly
178
from metpy.constants import earth_gravity, dry_air_gas_constant
179
from metpy.constants import water_heat_vaporization as L_v
180
181
# Access through metpy.constants namespace
182
import metpy
183
g = metpy.constants.earth_gravity
184
```
185
186
## Types
187
188
```python { .api }
189
# All constants are Pint Quantity objects with appropriate units
190
from pint import Quantity
191
192
# Example constant types
193
earth_gravity: Quantity # Length/Time^2 units
194
dry_air_gas_constant: Quantity # Energy/(Mass*Temperature) units
195
water_heat_vaporization: Quantity # Energy/Mass units
196
atmos_pressure_sea_level: Quantity # Pressure units
197
```