Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import re
- halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
- degs, rads = 180/pi, pi/180.
- fnames = ('horizons_results Sun from Apollo 14.txt',
- 'horizons_results Earth from Apollo 14.txt',
- 'horizons_results Sun from Apollo 12.txt',
- 'horizons_results Earth from Apollo 12.txt')
- linez = []
- for fname in fnames:
- with open(fname, 'r') as infile:
- lines = infile.read().splitlines()
- linez.append(lines)
- data = []
- sun_angles = []
- for lines in linez:
- iSOE = [i for i, line in enumerate(lines) if "$$SOE" in line][0]
- iEOE = [i for i, line in enumerate(lines) if "$$EOE" in line][0]
- hours, azimuths, elevations = [], [], []
- SOTs, STOs = [], []
- first_day = None
- d_day = 0
- for line in lines[iSOE+1:iEOE]:
- line = list(filter(None, re.split("[, ]+", line)))
- day = float(line[0].split('-')[2])
- if first_day is None:
- first_day = day
- hour, minute = [float(x) for x in line[1].split(':')]
- hours.append(float(hour) + float(minute)/60. + 24.*(day-first_day))
- RA, Dec, Az, El = [float(x) for x in line[4:8]]
- SOT, STO = [float(line[i]) for i in (12, 14)]
- azimuths.append(Az)
- elevations.append(El)
- SOTs.append(SOT)
- STOs.append(STO)
- data.append((hours, azimuths, elevations))
- sun_angles.append((hours, SOTs, STOs))
- print ('hours min, max: ', min(hours), max(hours))
- fnames = ('horizons_results Sun from Apollo 14.txt',
- 'horizons_results Earth from Apollo 14.txt',
- 'horizons_results Sun from Apollo 12.txt',
- 'horizons_results Earth from Apollo 12.txt')
- Apollo_14_Sun, Apollo_14_Earth, Apollo_12_Sun, Apollo_12_Earth = data
- Apollo_14_SOT_STO, Apollo_12_SOT_STO = sun_angles[1::2]
- if True:
- plt.figure()
- plt.subplot(2, 1, 1)
- plt.title('Apollo 12 Sun Earth angle', fontsize=16)
- hours, SOT, STO = Apollo_12_SOT_STO
- plt.plot(hours, SOT, linewidth=2)
- plt.ylim(0, 180)
- plt.subplot(2, 1, 2)
- plt.title('Apollo 14 Sun Earth angle', fontsize=16)
- hours, SOT, STO = Apollo_12_SOT_STO
- plt.plot(hours, SOT, linewidth=2)
- plt.ylim(0, 180)
- plt.show()
- if True:
- plt.figure()
- plt.subplot(4, 1, 1)
- plt.title('Apollo 12 Azimuth', fontsize=16)
- hours, Az, El = Apollo_12_Sun
- plt.plot(hours, Az, '-r', linewidth=2)
- hours, Az, El = Apollo_12_Earth
- plt.plot(hours, Az, '--b', linewidth=2)
- plt.ylim(45, 135)
- plt.subplot(4, 1, 2)
- plt.title('Apollo 12 Elevation', fontsize=16)
- hours, Az, El = Apollo_12_Sun
- plt.plot(hours, El, '-r', linewidth=2)
- hours, Az, El = Apollo_12_Earth
- plt.plot(hours, El, '--b', linewidth=2)
- plt.ylim(0, 90)
- plt.subplot(4, 1, 3)
- plt.title('Apollo 14 Azimuth', fontsize=16)
- hours, Az, El = Apollo_14_Sun
- plt.plot(hours, Az, '-r', linewidth=2)
- hours, Az, El = Apollo_14_Earth
- plt.plot(hours, Az, '--b', linewidth=2)
- plt.ylim(45, 135)
- plt.subplot(4, 1, 4)
- plt.title('Apollo 14 Elevation', fontsize=16)
- hours, Az, El = Apollo_14_Sun
- plt.plot(hours, El, '-r', linewidth=2)
- hours, Az, El = Apollo_14_Earth
- plt.plot(hours, El, '--b', linewidth=2)
- plt.ylim(0, 90)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement