Skip to content

Commit 6c75f2b

Browse files
committed
add post-processing tests
1 parent ea491ff commit 6c75f2b

File tree

8 files changed

+276
-94
lines changed

8 files changed

+276
-94
lines changed

pyosp/cirsp/base_cir.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def out_polygon(self):
9292
raise Exception("Empty swath profile, please try reset arguments.")
9393

9494
poly = Polygon(coords)
95-
return poly.buffer(0.001)
95+
return poly
9696

9797
def out_polylines(self):
9898
"Return a shapely polyline object"
@@ -155,9 +155,7 @@ def profile_stat(self):
155155

156156
return [min_z, max_z, mean_z, q1, q3]
157157

158-
def profile_plot(self, ax=None, color='navy',
159-
p_coords=None, p_marker="o", p_size=1,
160-
p_color='C3', p_label=None):
158+
def profile_plot(self, ax=None, color='navy', p_coords=None, **kwargs):
161159
d = np.linspace(0, self.radial_stepsize*self.dat_steps, self.dat_steps,
162160
endpoint=True)
163161
stat = self.profile_stat()
@@ -180,17 +178,15 @@ def profile_plot(self, ax=None, color='navy',
180178
dist_array = np.append(dist_array, dist)
181179
elev_array = np.append(elev_array, elev)
182180

183-
ax.scatter(dist_array, elev_array,
184-
s=p_size, marker=p_marker, color=p_color, label=p_label)
181+
ax.scatter(dist_array, elev_array, **kwargs)
185182

186183
ax.set_xlabel("Distance")
187184
ax.set_ylabel("Elevation")
188185
ax.legend()
189186
plt.tight_layout()
190-
191187
return ax
192188

193-
def slice_plot(self, angle):
189+
def slice_plot(self, angle, ax=None):
194190
"""Plot cross-section of swath data.
195191
196192
:param angle: the angle of cross-section wrt horizontal line
@@ -211,13 +207,16 @@ def slice_plot(self, angle):
211207
d_temp = np.sqrt((point[0]-points[0][0])**2
212208
+(point[1]-points[0][1])**2)
213209
d.append(d_temp)
210+
211+
if ax is None:
212+
fig, ax = plt.subplots()
214213

215-
fig, ax = plt.subplots()
216214
ax.plot(d, values)
217215
ax.set_xlabel("Distance to center")
218216
ax.set_ylabel("Elevation")
219217
ax.grid()
220218
plt.tight_layout()
219+
return ax
221220

222221
def slice_polyline(self, angle):
223222
"""Return the polyline of cross-section
@@ -238,18 +237,21 @@ def slice_polyline(self, angle):
238237
return LineString(line)
239238

240239

241-
def hist(self, bins=50):
240+
def hist(self, bins=50, ax=None):
242241
"Return a histogram plot"
243242
dat = np.hstack(self.dat)
244-
245-
fig, ax = plt.subplots()
246-
ax.hist(dat, bins=bins, histtype='stepfilled', alpha=1, normed=True)
243+
244+
if ax is None:
245+
fig, ax = plt.subplots()
246+
247+
ax.hist(dat, bins=bins, histtype='stepfilled', alpha=1, density=True)
247248
ax.set_xlabel("Elevation")
248249
ax.set_ylabel("PDF")
249250
ax.grid()
250251
plt.tight_layout()
252+
return ax
251253

252-
def slice_hist(self, angle, bins=10):
254+
def slice_hist(self, angle, bins=10, ax=None):
253255
"""Plot the histogram of slice
254256
255257
:param angle: angle of cross-section wrt horizontal line
@@ -265,12 +267,15 @@ def slice_hist(self, angle, bins=10):
265267
ng_ind = np.abs(sector - angle).argmin()
266268
dat = self.dat[ng_ind]
267269

268-
fig, ax = plt.subplots()
269-
ax.hist(dat, bins=bins, histtype='stepfilled', alpha=1, normed=True)
270+
if ax is None:
271+
fig, ax = plt.subplots()
272+
273+
ax.hist(dat, bins=bins, histtype='stepfilled', alpha=1, density=True)
270274
ax.set_xlabel("Elevation")
271275
ax.set_ylabel("PDF")
272276
ax.grid()
273277
plt.tight_layout()
278+
return ax
274279

275280

276281

0 commit comments

Comments
 (0)