forked from houjincheng1992/pre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
antproc.py
92 lines (83 loc) · 3.04 KB
/
antproc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import numpy as np
from numpy import pi
import pandas as pd
from pylab import *
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import os,sys
class filebox:
def __init__(self):
pass
def getfile(self):
path = os.path.abspath(os.path.join(os.path.pardir, 'param'))
ldir = os.listdir(path)
dirtemp = []
for k in ldir:
dirtemp.insert(-1, os.path.join(path, k))
#print dirtemp
return dirtemp
def getparam(self, dirlist):
param = {}
for filedir in dirlist:
print filedir
try:
data = pd.read_excel(filedir)
except:
data = pd.read_csv(filedir)
param.update({filedir: data})
return param
def procparam(self, param):
for k, v in param.items():
v = np.array(v)
row_l = v.shape[0]
col_l = v.shape[1]
#print v.shape
if row_l == 362:
v = v[1:, :]
elif row_l == 181:
arrtemp1 = v[3: 93, :]
arrtemp1 = arrtemp1[::-1]
arrtemp2 = v[91:, :]
arrtemp2 = arrtemp2[::-1]
temp = np.zeros((361, col_l))
temp[0: 90, :] = arrtemp1
temp[90: 271, :] = v
temp[271:, :] = arrtemp2
v = temp
if col_l == 37:
v = v[:, 1:]
elif col_l == 38:
v = v[:, 1: -1]
param[k] = v
#print v.shape
def mindata(self, param):
for k, v in param.items():
v = np.array(v)
v[np.where(v < -45)] = -45
v += 45
param[k] = v
def plotfigure(self, param):
for k, v in param.items():
#print k
theta = np.arange(-180., 181., 1) / 180 * pi
fine = np.arange(0., 180., 5) / 180 * pi
row_l = v.shape[0]
col_l = v.shape[1]
#print row_l, col_l
x = np.transpose(np.ones((col_l, 1)).dot(np.sin(theta).reshape(1, row_l))) * np.ones((row_l, 1)).dot(np.cos(fine).reshape(1, col_l)) * np.array(v)
y = np.transpose(np.ones((col_l, 1)).dot(np.sin(theta).reshape(1, row_l))) * np.ones((row_l, 1)).dot(np.sin(fine).reshape(1, col_l)) * np.array(v)
z = np.transpose(np.ones((col_l, 1)).dot(np.cos(theta).reshape(1, row_l))) * np.array(v)
fig = figure()
ax = Axes3D(fig)
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap = cm.jet, linewidth=0, antialiased=False)
ax.set_title(unicode(os.path.basename(k), "utf-8"))
ax.set_xlabel(unicode("satespeed", "utf-8"))
ax.set_ylabel(unicode("subspeed", "utf-8"))
ax.set_zlabel(unicode("earthtosate", "utf-8"))
show()
if __name__ == '__main__':
filelist = filebox().getfile()
param = filebox().getparam(filelist)
filebox().procparam(param)
filebox().mindata(param)
filebox().plotfigure(param)