照度转换器
在勒克斯、英尺烛光、照度等单位之间转换。
常见问题
代码实现
# Illuminance unit conversion in Python
# Conversion factors relative to lux (lx)
ILLUM_TO_LUX = {
"lux": 1.0,
"foot_candle": 10.7639, # 1 fc = 10.7639 lux
"phot": 10000.0, # CGS unit: 1 ph = 10000 lux
"nox": 0.001, # 1 nox = 0.001 lux
}
def convert_illuminance(value: float, from_unit: str, to_unit: str) -> float:
lux = value * ILLUM_TO_LUX[from_unit]
return lux / ILLUM_TO_LUX[to_unit]
# Core formula: fc ↔ lux
def lux_to_fc(lux: float) -> float:
return lux / 10.7639
def fc_to_lux(fc: float) -> float:
return fc * 10.7639
# Examples
print(lux_to_fc(500)) # 46.45 (office 500 lux → fc)
print(fc_to_lux(50)) # 538.2 (stage lighting)
print(convert_illuminance(1000, "lux", "foot_candle")) # 92.9
print(convert_illuminance(100, "foot_candle", "lux")) # 1076.39Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.