0001 %GENERATE_WBB_SPECTRUM - Generates a mathematical approximation of the spectrum 0002 % produced by a tungsten filament incandescent light 0003 % bulb. 0004 % 0005 % The filament's temperature can be plugged into Planck's law and corrected for 0006 % tungsten's emissivity to get a mathematical approximation of the light bulb's 0007 % spectrum. Wbb stands for tungsten black body. 0008 % 0009 % The output is spectral photon radiance because a CCD measures intensity by 0010 % counting photons. 0011 % 0012 % Emissivity data is available for temperatures 1600 to 2800 K and wavelengths 0013 % 250 to 3500 nm. Emissivity outside of temperature range is extrapolated, 0014 % which may result in error. If lambda is outside of the wavelength range an 0015 % error is returned. 0016 % 0017 % Even when two bulbs appear identical the emissivity of their filaments 0018 % can differ significantly, so don't rely on this function to return 0019 % an entirely accurate model of your light bulb's spectrum. 0020 % 0021 % Syntax: [N, lambda] = generate_Wbb_spectrum(lambda, Tf, dist_type) 0022 % 0023 % Inputs: 0024 % lambda - wavelength scale in nanometers [nm], set lambda = [] if you want 0025 % to use the default lambda. 0026 % Tf - the temperature of the filament in Kelvin [K]. 0027 % dist_type - the type of spectrum to return. 'power' is [W/(sr*m^2)/nm], 0028 % 'quantal' is [photons/(s*sr*m^2)/nm] 0029 % 0030 % Outputs: 0031 % N - the tungsten filament's emissivity corrected black body spectrum. 0032 % lambda - the default lambda if the input argument lambda is empty. 0033 % 0034 % Example: 0035 % % Tf = 2786.8 K is the result of averaging several sources stating the 0036 % % filament temperature of a 100 W, 120 V incandescent lamp. 0037 % N = generate_Wbb_spectrum(lambda, 2786.8, 'power'); 0038 % 0039 % % If you'd like to use the full range of wavelengths covered by the 0040 % % spectral emissivity data, set lambda to empty. 0041 % [N, lambda] = generate_Wbb_spectrum([], 2786.8, 'quantal'); 0042 % 0043 % 0044 % Other m-files required: none 0045 % Subfunctions: none 0046 % MAT-files required: none 0047 % 0048 % See also: WAVELENGTH_CALIBRATE 0049 % 0050 % Author: Jonathan Thomson 0051 % Work: 0052 % email: 0053 % Website: http://jethomson.wordpress.com 0054 % 0055 0056 function [N, lambda] = generate_Wbb_spectrum(lambda, Tf, dist_type) 0057 0058 if (nargin ~= 3) 0059 usage('generate_Wbb_spectrum(lambda, Tf, dist_type)'); 0060 end 0061 0062 if (isempty(Tf) || isempty(dist_type)) 0063 error(['generate_Wbb_spectrum: empty value for argument ' ... 0064 'dist_type not allowed.']); 0065 end 0066 0067 s = filesep; 0068 0069 % load lambda_ems [nm], T [K], and spectral_emissivity. 0070 % the spectral emissivity of tungsten is temperature and wavelength 0071 % dependent. 0072 load(['data' s 'essential_data_sets' s 'spectral_emissivity.mat']); 0073 spectral_emissivity_Tf = interp1(T, spectral_emissivity, Tf, ... 0074 'spline', 'extrap'); 0075 0076 M = blackbody_spectrum(lambda_ems, Tf, dist_type); 0077 0078 % tungsten is not a perfect black-body radiator so M must be corrected 0079 % with tungsten's spectral emissivity at temperature Tf. 0080 Me = spectral_emissivity_Tf.*M; 0081 0082 if ~isempty(lambda) 0083 if (lambda(1) < lambda_ems(1) || lambda(end) > lambda_ems(end)) 0084 warning('generate_Wbb_spectrum: lambda is out of range.'); 0085 end 0086 % interpolate so we can use lambda [nm] instead of lambda_ems 0087 N = interp1(lambda_ems, Me, lambda, 'spline', 0); 0088 else 0089 lambda = lambda_ems.'; 0090 N = Me.'; 0091 end 0092 end