Advertisement
Guest User

LogLocator test

a guest
Sep 24th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # ATSC 5003 - Radiation HW 3
  5.  
  6. import numpy as np
  7. import matplotlib.pyplot as plt
  8. from matplotlib import ticker
  9.  
  10. plt.close('all')
  11. fig1 = plt.figure(figsize=(11, 8.5))
  12. ax1 = fig1.add_subplot(211)
  13.  
  14. # Approximate surface temperatures of bodies [K]
  15. temp_earth = 288
  16. temp_sun = 5800
  17.  
  18. # Define constants
  19. pi = np.pi
  20. c = 299792458.0     # speed of light [m/s]
  21. h = 6.62606896e-34  # Planck constant [J*s]
  22. k = 1.3806504e-23   # Boltzmann constant [J/K]
  23. eV = 1.602e-19      # 1 eV in [J]
  24. wavelength = np.linspace(7.4e-8, 1e-3, 40000)  # [m]
  25.  
  26. # Planck's function in wavelength domain (in spectral density form)
  27. def Plancks_wavelength(wavelength, temperature):
  28.     return (8 * pi * h * c) / (wavelength**5 * (np.exp((h * c)/ (k * temperature * wavelength))-1))
  29.  
  30. # Plotting as *irradiance* --hence the c/4 normalization, at the top of the atmosphere
  31. ax1.plot(wavelength*1e6, Plancks_wavelength(wavelength, temp_earth)*(6371e3/(6371e3+150e3))**2*c/4, 'k--', lw=2)
  32. ax1.plot(wavelength*1e6, Plancks_wavelength(wavelength, temp_sun)*(6.96e8/1.496e11)**2*c/4, 'k-.', lw=2)
  33. ax1.set_yscale('log')
  34. ax1.set_xscale('log')
  35. ax1.set_ylim(ymin=1e1, ymax=1e10)
  36. ax1.set_xlim(xmin=1e-7, xmax=1e10)
  37. xmin, xmax = ax1.xaxis.get_view_interval()
  38. #ax1.xaxis.set_ticks(10.**np.arange(np.log10(xmin),np.log10(xmax)+1,1))
  39. ax1.xaxis.set_minor_locator(ticker.LogLocator(subs=np.arange(2.0, 10.0)))
  40. ax1.yaxis.set_minor_locator(ticker.LogLocator(subs=np.arange(2.0, 10.0)))
  41. ax1.xaxis.set_label_text(u"Wavelength, μm", fontsize=16)
  42. ax1.yaxis.set_label_text(u"Irradiance, W / m²·m", fontsize=16)
  43.  
  44. plt.tight_layout()
  45. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement