Last active
March 18, 2016 14:43
-
-
Save HotelCalifornia/3b224891ff45156de494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.special import lpmv as p | |
from numpy.core.umath import sin, cos | |
import csv | |
import urllib2 | |
url = 'https://drive.google.com/open?id=0B6ZzcxI-pS7DWC1NaGo0YU5yMGc' | |
resp = urllib2.urlopen(url) | |
data = csv.reader(resp) | |
ggm02c = [] | |
data_dict = {} | |
i = 0 | |
curr_epoch = '' | |
t_data = [] | |
for row in data: | |
if 'GGM02C' in row: | |
ggm02c.append(row) | |
if 'EPOCH' in row: | |
data_dict[curr_epoch] = t_data | |
t_data = [] | |
curr_epoch = row | |
i = 0 | |
if i != 0: | |
t_data.append(row) | |
i += 1 | |
# data_dict = { 'epoch':['geoest, n, m, c, s, cs, ss, epoch', ...], ...} | |
for k, v in data_dict: | |
for row in v: | |
s = '' | |
t = row.split(',') | |
for p in t: | |
if p != 'GEOEST' and p != t[-1]: | |
s += str(p) + ',' | |
row = s | |
# data_dict = { 'epoch':['n, m, c, s, cs, ss', ...], ... } | |
ttt = [] | |
# noinspection PyRedeclaration | |
for k, v in data_dict: | |
for row in v: | |
t = row.split(',') | |
tt = [] | |
tt[0] = int(t[0]) | |
tt[1] = int(t[1]) | |
tt[2] = int(t[2]) + int(t[4]) | |
tt[3] = int(t[3]) + int(t[5]) | |
ttt.append(tt) | |
v = ttt | |
# data_dict = { 'epoch':[[int(n), int(m), int(c + cs), int(s + ss)], ...], ... } | |
# [1, 0, (c + cs)_10, (s + ss)_10] | |
# [2, 0, (c + cs)_20, (s + ss)_20] | |
# [3, 0, ...] | |
# [4, 0, ...] | |
# [5, 0, ...] | |
# [1, 1, ...] | |
# [1, 2, ...] | |
# [1, 3, ...] | |
# [1, 4, ...] | |
# [1, 5, ...] | |
# . | |
# . | |
# . | |
# [5, 5, (c + cs)_55, (s + ss)_55] | |
G = 6.67e-11 | |
M = 5.972e24 | |
R = 6.371e6 | |
r = R + 500000 | |
# using current EPOCH... | |
def c(n, m): | |
# parse data to find C coefficient of order n and degree m | |
pass | |
def s(n, m): | |
# parse data to find S coefficient of order n and degree m | |
pass | |
# noinspection PyShadowingNames | |
def coeff(n, m, longi): | |
return c(n, m) * cos(m * longi) + s(n, m) * sin(m * longi) | |
data_pro = [] | |
for longi in xrange(-180, 180): | |
for lati in xrange(-90, 90+1): | |
summ = [[ | |
((R / r) ** n) * (coeff(n, m, long)) * p(n, m, sin(lati)) | |
for m in xrange(0, n + 1)] | |
for n in xrange(2, 5 + 1) | |
] | |
data_pro.append(summ) | |
# U = (G * M / r) * (1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on how your data looks now the brute force would just be
Given how your data is structured now you can do the following
(from SO)