9
9
from matplotlib .ticker import EngFormatter
10
10
import numpy as np
11
11
12
+
12
13
class DatcomPlotter (object ):
13
14
14
15
def __init__ (self , parser_dict ):
15
16
self .d = parser_dict
16
17
if not os .path .isdir ('fig' ):
17
18
os .mkdir ('fig' )
18
- self .figpath = os .path .abspath ('fig' )
19
+ self .figpath = os .path .abspath ('fig' )
19
20
20
21
def common_plots (self ):
21
22
## lift plots
@@ -87,7 +88,7 @@ def common_plots(self):
87
88
title = '{name}: YawRate effect on Roll Moment Coefficient' ,
88
89
x_name = 'alpha' , x_label = 'Alpha, deg' ,
89
90
y_name = 'dCl_YawRate' , y_label = 'dCl' )
90
-
91
+
91
92
## pitch moment
92
93
self .plot2d (
93
94
title = '{name}: Basic Pitch Moment Coefficient' ,
@@ -129,24 +130,24 @@ def common_plots(self):
129
130
x_name = 'alpha' , x_label = 'Alpha, deg' ,
130
131
y_name = 'dCn_YawRate' , y_label = 'dCn' )
131
132
132
- def plot2d (self , title ,
133
+ def plot2d (self , title ,
133
134
x_name , x_label ,
134
135
y_name , y_label ):
135
136
fig = plt .figure ()
136
137
ax = fig .add_subplot (111 )
137
138
y = self .d [y_name ]
138
139
x = self .d [x_name ][:len (y )]
139
- ax .plot (x ,y )
140
+ ax .plot (x , y )
140
141
ax .set_xlabel (x_label .format (** self .d ))
141
142
ax .set_ylabel (y_label .format (** self .d ))
142
143
ax .set_title (title .format (** self .d ))
143
144
ax .grid ()
144
145
plt .savefig (os .path .join (self .figpath ,
145
146
os .path .join (self .figpath ,
146
- title .format (** self .d )+ '.pdf' )))
147
+ title .format (** self .d ) + '.pdf' )))
147
148
plt .close (fig )
148
149
149
- def plot3d (self , title ,
150
+ def plot3d (self , title ,
150
151
x_name , x_label ,
151
152
y_name , y_label ,
152
153
z_name , z_label ):
@@ -163,14 +164,14 @@ def plot3d(self, title,
163
164
#print 'len Z2:', len(Z[0])
164
165
#print 'len x:', len(x)
165
166
#print 'len y:', len(y)
166
- X , Y = np .meshgrid (x ,y )
167
+ X , Y = np .meshgrid (x , y )
167
168
surf = ax .plot_surface (X , Y , Z ,
168
169
cmap = cm .jet , rstride = 1 , cstride = 1 )
169
170
fig .colorbar (surf , shrink = 0.5 , aspect = 5 )
170
171
ax .grid ()
171
172
plt .savefig (os .path .join (self .figpath ,
172
173
os .path .join (self .figpath ,
173
- title .format (** self .d )+ '.pdf' )))
174
+ title .format (** self .d ) + '.pdf' )))
174
175
plt .close (fig )
175
176
176
177
@staticmethod
@@ -186,6 +187,6 @@ def command_line():
186
187
parser = DatcomParser (args .datcom_file )
187
188
plotter = DatcomPlotter (parser .get_common ())
188
189
plotter .common_plots ()
189
-
190
+
190
191
if __name__ == "__main__" :
191
192
DatcomPlotter .command_line ()
0 commit comments