function bbspec=bbspec(t,lambda);
%
% bbspec=bbspec(t,lambda);
%  Spectral Radiant Exitance in W/m^2/micron
%  of a black body at temp t, kelvin
%  at wavelength lambda, microns
%
% t or lambda can be an arbitrary in dimension and calculations are
% done point-by-point
%
% t and lambda can both be of some arbitrary dimension,
% provided that both have the same dimension.
% The calculations are done point-by-point
%
%  By Chuck DiMarzio
%  Northeastern University
%  2006
%
%   Rev 1.01 Feb 2007 to add comment
%
%   See also bbody
%
    if size(t)==size(lambda) | size(t)==1 | size(lambda)==1;
c=2.998E8;
h=6.626E-34;
k=1.381E-23;
lambdam=lambda/1e6; % convert to meters
bbspec=2*pi*h*c^2./lambdam.^5./(exp(h*c./(lambdam.*k.*t))-1);
bbspec=bbspec/1e6; % convert back to reciprocal microns wavelength only
else;
bbspec=-1;  % error flag if dimensions of t and lambda don't match.
end;

