In [0]:
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt

In [0]:
%matplotlib inline

In [0]:
c=2.99792458e+08  #m/s -- speed of light in vacumn
h=6.62606876e-34  #J s  -- Planck's constant
kb=1.3806503e-23  # J/K  -- Boltzman's constant

def planckwavelen(wavel,Temp):
    """input wavelength in microns and Temp in K, output
    bbr in W/m^2/micron
    """
    wavel=wavel*1.e-6  #convert to meters
    c1=2.*h*c**2.
    c2=h*c/kb
    Elambda=1.e-6*np.pi*c1/(wavel**5.*(np.exp(c2/(wavel*Temp)) -1))
    return Elambda

In [0]:
the_wavelengths=np.linspace(0.1,60,5000) #microns
the_temp=300. #K
flux=planckwavelen(the_wavelengths,the_temp)
fig1=plt.figure(1)
axis1=fig1.add_subplot(1,1,1)
axis1.plot(the_wavelengths,flux)

In [0]:
dlambda=np.diff(the_wavelengths)
dflux=np.diff(flux)
the_deriv=dflux/dlambda
fig2,axis2=plt.subplots(1,1)
axis2.plot(the_wavelengths[:-1],the_deriv,label="approx derivative")
wiens_law=2897/the_temp
axis2.plot(wiens_law,0,'k+',markersize=20,label="Wien's law")
axis2.legend()
axis2.set_title("Wien's law demonstration")
axis2.set_ylabel("$dE_lambda/dlambda\ (W/m^2/micron/micron)$")
axis2.set_xlabel('wavelength lambda (microns)')
#savefig('wien_answer.png')

Alternatively: find the zero crossing:

When I google "numpy find zero crossing" I get a hit on http://stackoverflow.com/questions/3843017/efficiently-detect-sign-changes-in-python" which gives me the recipe:

zero_crossings = numpy.where(numpy.diff(numpy.sign(a)))[0]

In [0]:
wavelengths=the_wavelengths[:-1]
zero_crossings=np.where(np.diff(np.sign(the_deriv)))
print(zero_crossings)
print(the_wavelengths[zero_crossings])
print(wiens_law)

In [0]: