Converting Between λ and ν

For non-spectral quantities, such as absorbance (dI/I), converting datasets is as simple as inverting the x-values. For spectral quantities, such as irradiance, conservation of energy must be taken into account:

\[f(\lambda)d\lambda = f(\nu)(-d\nu)\]

where f is any radiometric function, e.g. spectral radiance. The sign difference is due to the direction of increasing wavelength being opposite to the direction of increasing wavenumber. By differentiation,

\[f(\lambda) = f(\nu)\frac{-d\nu}{d\lambda} = f(\nu)\frac{d}{d\lambda}\left(\frac{-1}{\lambda}\right) = \frac{f(\nu)}{\lambda^2} = f(\nu)\nu^2\]

Similarly,

\[f(\nu) = f(\lambda)\frac{d\lambda}{-d\nu} = f(\lambda)\frac{d}{d\nu}\left(\frac{-1}{\nu}\right) = \frac{f(\lambda)}{\nu^2} = f(\lambda)\lambda^2\]

In the code, below, solar irradiance is calculated separately using the wavenumber blackbody function and wavelength blackbody function. Each result is converted.

_images/solar_irradiance.png
 1'''
 2Python 3.x
 3'''
 4
 5import numpy as np
 6import matplotlib.pyplot as plt
 7
 8c = 2.998e8 # speed of light, m/s       
 9h = 6.626e-34 # Planck constant, J*s
10kB = 1.381e-23 # Boltzmann constant, J/K
11
12def wn2wl(x, y0, spectral=True):
13    y = y0*x**2 if spectral else y0
14    return 1/x, y
15
16def wl2wn(x, y0, spectral=True):
17    return wn2wl(x, y0, spectral)
18
19def blackbody_wl(wl, T):
20    return 2*h*c**2/wl**5/(np.exp(h*c/wl/kB/T)-1) # W/sr/m^2/m
21
22def blackbody_wn(wn, T):
23    return 2*h*c**2*wn**3/(np.exp(h*c*wn/kB/T)-1) # W/sr/m^2/m^-1
24
25T = 5778 # blackbody temperature of the Sun, Kelvin
26sun_distance = 92.935e6 # mi
27sun_diameter = 865370 # mi
28theta = np.arctan(sun_diameter/2/sun_distance) # Sun half-angle
29Omega = np.pi*np.sin(theta)**2 # projected solid angle
30
31wl_bb = np.linspace(200e-9, 2500e-9, 50) # wavelengths, m
32wn_bb = 1/wl_bb # wavenumbers, m^-1
33E_wl_bb = Omega*blackbody_wl(wl_bb, T) # solar irradiance, W/m^2/m
34E_wn_bb = Omega*blackbody_wn(wn_bb, T) # W/m^2/m^-1
35wn_converted, E_wn_converted = wl2wn(wl_bb, E_wl_bb, spectral=True)
36wl_converted, E_wl_converted = wn2wl(wn_bb, E_wn_bb, spectral=True)
37
38plt.figure(num='Conversions'); plt.clf()
39plt.subplot(211)
40plt.plot(wl_bb*1e9, E_wl_bb*1e6*1e-4*1e-9, label='Ω*BB(λ)')
41plt.plot(wl_converted*1e9, E_wl_converted*1e6*1e-4*1e-9, 
42         'x', label='Ω*BB(ν), Converted')
43plt.xlabel('nm'); 
44plt.ylabel('μW/cm$^2$/nm'); 
45plt.grid(); plt.legend()
46plt.title('Solar Irradiance at Top of Atmosphere')
47
48plt.subplot(212)
49plt.plot(wn_bb*1e-2, E_wn_bb*1e6*1e-4*1e2, label='Ω*BB(ν)')
50plt.plot(wn_converted*1e-2, E_wn_converted*1e6*1e-4*1e2, 
51         'x', label='Ω*BB(λ), Converted')
52plt.xlabel('ν, cm$^{-1}$'); 
53plt.ylabel('μW/cm$^2$/cm$^{-1}$'); 
54plt.grid(); plt.legend()
55plt.title('Solar Irradiance at Top of Atmosphere')
56plt.tight_layout()