#Computes the flux of photons at wavelengths #shorter than a given value stated in nanometers import math from ClimateUtilities import * import planets,phys #Some useful conversion factors evJoules = 1.60218e-19 #1 electron volt in Joules evAttoJoules = .160218 #1 electron volt in attojoules #Orbit and stellar data TSun = 5780. rSun = 6.955e8 #Move these to planets module Afact = (rSun/planets.Earth.rsm)**2 #Work in units of 1/nm instead of frequency, so #the romberg integrator doesn't get confused by #big or small numbers when applying convergence criterion. #For same reason, leave out division by h until later. def fPhotons(waveNum,T): nu = phys.c*waveNum*1.e9 #The following is OK becaue dnu/nu = dWaveNum/WaveNum #It is correct also to put the factor of pi here, since #we compute the flux at Earth's radius by finding the total #power output of the Sun and dividing by the area of the sphere #with radius equal to the Earth's orbit return math.pi*phys.B(nu,T)/waveNum m = romberg(fPhotons,100) #Use more starting divisions to resolve tail def photons(WaveLen): return Afact*m([1./WaveLen,1./10.],TSun)/phys.h