Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- fname = 'Three Solar Spectra.txt'
- with open (fname, 'r') as infile:
- lines = infile.readlines()[0].splitlines()
- print len(lines)
- data = zip(*[[float(x) for x in line.split()] for line in lines[1:]])
- data = np.array(data)
- lam, a, b, c = data
- dlam = lam[1:] - lam[:-1]
- vis = (lam >= 400) * (lam <= 700)
- Atot, Btot, Ctot = [(thing[:-1] * dlam).sum() for thing in (a, b, c)]
- Avis, Bvis, Cvis = [(thing[:-1] * dlam * vis[:-1]).sum() for thing in (a, b, c)]
- Arat, Brat, Crat = Avis/Atot, Bvis/Btot, Cvis/Ctot
- print data.shape, data.dtype
- print lines[0]
- print Atot, Btot, Ctot
- print Avis, Bvis, Cvis
- print Arat, Brat, Crat
- if True:
- plt.figure() # vis 39.4% vis43.1% vis 41.7%
- labels = ('Extraterrestrial, vis 39.4%', 'Global tilt, vis43.1%', 'Direct+circumsolar, vis 41.7%')
- if False:
- plt.text
- for thing, label in zip((a, b, c), labels):
- plt.plot(lam, thing, label=label)
- ymin, ymax = plt.ylim(0, 2.5)
- plt.plot([400, 400], [ymin, ymax], '-k')
- plt.plot([700, 700], [ymin, ymax], '-k')
- plt.xlabel('wavelength (nm)')
- plt.ylabel('W*m-2*nm-1')
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement