Convert between light exposure and intensity

import math,sys

def Exposure2Intensity(exposure): 
    exp = float(exposure)
    result = math.pow(2,exp)
    print(result)

Exposure2Intensity(0)

def Intensity2Exposure(intensity):
    inarg = float(intensity)
    
    if inarg == 0:
        print("Exposure of zero intensity is undefined.")
        return
    
    if inarg < 1e-323:
        inarg = max(inarg, 1e-323)
        print("Exposure of negative intensities is undefined. Clamping to a very small value instead (1e-323)")
    
    result = math.log(inarg, 2)
    print(result)

Intensity2Exposure(0.1)



Share: