我正在使用一个脚本,该脚本通过经度和纬度来计算相对于地球上特定点的天体位置。但是,当我将90°用作经度时,我注意到结果是相同的。
相对于以下位置的相对位置:经度70°,纬度-50和50
date sun(ra) sun(ra)
10/11/18 1:00 3.425910744 3.425889278
10/11/18 1:00 3.425916336 3.425894886
相对于:90°经度,-50和50纬度的基本位置
date sun(ra) sun(ra)
10/11/18 1:00 3.425897035 3.425897035
10/11/18 1:00 3.425902615 3.425902615
10/11/18 1:01 3.425908196 3.425908196
这似乎发生在所有经度为90度的纬度上。
以下代码:
import numpy as np
import scipy as sp
import ephem
import scipy.constants
import datetime
celestial_masses = {
'sun': 1.989e30,
'mercury': 0.330e24,
'venus': 4.870e24,
'earth': 5.970e24,
'moon': 0.073e24,
'mars': 0.642e24,
'jupiter': 1898e24,
'saturn': 568e24,
'uranus': 86.8e24,
'neptune': 102e24,
'pluto': 0.0146e24, }
celestials = {
name: (eval('ephem.{}()'.format(name.title())), mass)
for name, mass in celestial_masses.items() if name != 'earth'}
gg = sp.constants.gravitational_constant
observer = ephem.Observer()
# Revere, Massachusetts, USA
observer.lon = '-50'
observer.lat = '70'
start_datetime = datetime.datetime(2018, 10, 1, 1, 0, 0)
end_datetime = datetime.datetime(2018, 10, 30, 23, 0, 0)
values = 'ra', 'dec'
labels = ('date',) + tuple(
'{}({})'.format(name, value)
for name in celestials.keys()
for value in values)
data = []
observer.date = start_datetime
delta_datetime = datetime.timedelta(minutes=5)
while (observer.date.datetime() < end_datetime):
row = [observer.date]
for name, (body, mass) in celestials.items():
body.compute(observer)
row.extend([
body.ra, body.dec])
data.append(row)
observer.date = observer.date.datetime() + delta_datetime
import csv
filepath = 'celestial_bodies.csv'
with open(filepath, 'w') as file_obj:
csv_obj = csv.writer(file_obj)
csv_obj.writerow(labels)
for row in data:
# : use default string conversion
# csv_obj.writerow(row)
# : a possible conversion to float for all but the `date`
csv_obj.writerow([
float(x) if i != labels.index('date') else x
for i, x in enumerate(row)])