SHARE
TWEET

Untitled

a guest Apr 20th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. fname = 'Three Solar Spectra.txt'
  5. with open (fname, 'r') as infile:
  6.     lines = infile.readlines()[0].splitlines()
  7. print len(lines)
  8. data = zip(*[[float(x) for x in line.split()] for line in lines[1:]])
  9. data = np.array(data)
  10. lam, a, b, c = data
  11. dlam = lam[1:] - lam[:-1]
  12.  
  13. vis = (lam >= 400) * (lam <= 700)
  14.  
  15. Atot, Btot, Ctot = [(thing[:-1] * dlam).sum() for thing in (a, b, c)]
  16. Avis, Bvis, Cvis = [(thing[:-1] * dlam * vis[:-1]).sum() for thing in (a, b, c)]
  17. Arat, Brat, Crat = Avis/Atot, Bvis/Btot, Cvis/Ctot
  18.  
  19. print data.shape, data.dtype
  20. print lines[0]
  21.  
  22. print Atot, Btot, Ctot
  23. print Avis, Bvis, Cvis
  24. print Arat, Brat, Crat
  25.  
  26. if True:
  27.     plt.figure()   # vis 39.4%  vis43.1%  vis 41.7%
  28.     labels = ('Extraterrestrial, vis 39.4%', 'Global tilt, vis43.1%', 'Direct+circumsolar, vis 41.7%')
  29.     if False:
  30.         plt.text
  31.     for thing, label in zip((a, b, c), labels):
  32.         plt.plot(lam, thing, label=label)
  33.     ymin, ymax = plt.ylim(0, 2.5)
  34.     plt.plot([400, 400], [ymin, ymax], '-k')
  35.     plt.plot([700, 700], [ymin, ymax], '-k')
  36.     plt.xlabel('wavelength (nm)')
  37.     plt.ylabel('W*m-2*nm-1')
  38.     plt.legend()
  39.     plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top