| 477 def average_profile(self): |
477 def average_profile(self): |
| 478 """ Return the average profile (NOT range corrected) for all the duration of the measurement. """ |
478 """ Return the average profile (NOT range corrected) for all the duration of the measurement. """ |
| 479 prof = np.mean(self.matrix, axis = 0) |
479 prof = np.mean(self.matrix, axis = 0) |
| 480 return prof |
480 return prof |
| 481 |
481 |
| 482 def plot(self, signal_type = 'rc', filename = None, zoom = [0,12000,0,-1], show_plot = True, cmap = plt.cm.jet): |
482 def plot(self, signal_type = 'rc', filename = None, zoom = [0,12000,0,-1], show_plot = True, cmap = plt.cm.jet, z0 = None, title = None, vmin = 0, vmax = 1.3 * 10 ** 7): |
| 483 #if filename is not None: |
483 #if filename is not None: |
| 484 # matplotlib.use('Agg') |
484 # matplotlib.use('Agg') |
| 485 |
485 |
| 486 fig = plt.figure() |
486 fig = plt.figure() |
| 487 ax1 = fig.add_subplot(111) |
487 ax1 = fig.add_subplot(111) |
| 488 self.draw_plot(ax1, cmap = cmap, signal_type = signal_type, zoom = zoom) |
488 self.draw_plot(ax1, cmap = cmap, signal_type = signal_type, zoom = zoom, z0 = z0, vmin = vmin, vmax = vmax) |
| 489 ax1.set_title("%s signal - %s" % (signal_type.upper(), self.name)) |
489 |
| |
490 if title: |
| |
491 ax1.set_title(title) |
| |
492 else: |
| |
493 ax1.set_title("%s signal - %s" % (signal_type.upper(), self.name)) |
| 490 |
494 |
| 491 if filename is not None: |
495 if filename is not None: |
| 492 pass |
496 pass |
| 493 #plt.savefig(filename) |
497 #plt.savefig(filename) |
| 494 else: |
498 else: |
| 495 if show_plot: |
499 if show_plot: |
| 496 plt.show() |
500 plt.show() |
| 497 #plt.close() ??? |
501 #plt.close() ??? |
| 498 |
502 |
| 499 def draw_plot(self,ax1, cmap = plt.cm.jet, signal_type = 'rc', zoom = [0,12000,0,-1]): |
503 def draw_plot(self,ax1, cmap = plt.cm.jet, signal_type = 'rc', zoom = [0,12000,0,-1], z0 = None, cmap_label = 'a.u.', vmin = 0, vmax = 1.3 * 10 ** 7): |
| 500 |
504 |
| 501 if signal_type == 'rc': |
505 if signal_type == 'rc': |
| 502 if len(self.rc) == 0: |
506 if len(self.rc) == 0: |
| 503 self.calculate_rc() |
507 self.calculate_rc() |
| 504 data = self.rc |
508 data = self.rc |
| 505 else: |
509 else: |
| 506 data = self.matrix |
510 data = self.matrix |
| 507 |
511 |
| 508 hmax_idx = self.index_at_height(zoom[1]) |
512 hmax_idx = self.index_at_height(zoom[1]) |
| 509 |
513 |
| 510 ax1.set_ylabel('Altitude (km)') |
514 # If z0 is given, then the plot is a.s.l. |
| 511 ax1.set_xlabel('Time UTC') |
515 if z0: |
| |
516 ax1.set_ylabel('Altitude a.s.l. [km]') |
| |
517 else: |
| |
518 ax1.set_ylabel('Altitude a.g.l. [km]') |
| |
519 z0 = 0 |
| |
520 |
| |
521 ax1.set_xlabel('Time UTC [hh:mm]') |
| 512 #y axis in km, xaxis /2 to make 30s measurements in minutes. Only for 1064 |
522 #y axis in km, xaxis /2 to make 30s measurements in minutes. Only for 1064 |
| 513 #dateFormatter = mpl.dates.DateFormatter('%H.%M') |
523 #dateFormatter = mpl.dates.DateFormatter('%H.%M') |
| 514 #hourlocator = mpl.dates.HourLocator() |
524 #hourlocator = mpl.dates.HourLocator() |
| 515 |
525 |
| 516 #dayFormatter = mpl.dates.DateFormatter('\n\n%d/%m') |
526 #dayFormatter = mpl.dates.DateFormatter('\n\n%d/%m') |
| 517 #daylocator = mpl.dates.DayLocator() |
527 #daylocator = mpl.dates.DayLocator() |
| 518 hourFormatter = mpl.dates.DateFormatter('%H.%M') |
528 hourFormatter = mpl.dates.DateFormatter('%H:%M') |
| 519 hourlocator = mpl.dates.AutoDateLocator(interval_multiples=True) |
529 hourlocator = mpl.dates.AutoDateLocator(interval_multiples=True) |
| 520 |
530 |
| 521 |
531 |
| 522 #ax1.axes.xaxis.set_major_formatter(dayFormatter) |
532 #ax1.axes.xaxis.set_major_formatter(dayFormatter) |
| 523 #ax1.axes.xaxis.set_major_locator(daylocator) |
533 #ax1.axes.xaxis.set_major_locator(daylocator) |
| 531 |
541 |
| 532 im1 = ax1.imshow(data.transpose()[zoom[0]:hmax_idx,zoom[2]:zoom[3]], |
542 im1 = ax1.imshow(data.transpose()[zoom[0]:hmax_idx,zoom[2]:zoom[3]], |
| 533 aspect = 'auto', |
543 aspect = 'auto', |
| 534 origin = 'lower', |
544 origin = 'lower', |
| 535 cmap = cmap, |
545 cmap = cmap, |
| 536 #vmin = 0, |
546 vmin = vmin, |
| 537 vmin = data[:,10:400].max() * 0.1, |
547 #vmin = data[:,10:400].max() * 0.1, |
| 538 #vmax = 1.4*10**7, |
548 vmax = vmax, |
| 539 vmax = data[:,10:400].max() * 0.9, |
549 #vmax = data[:,10:400].max() * 0.9, |
| 540 extent = [ts1,ts2,self.z[zoom[0]]/1000.0, self.z[hmax_idx]/1000.0], |
550 extent = [ts1,ts2,self.z[zoom[0]]/1000.0 + z0/1000., self.z[hmax_idx]/1000.0 + z0/1000.], |
| 541 ) |
551 ) |
| 542 |
552 |
| 543 cb1 = plt.colorbar(im1) |
553 cb1 = plt.colorbar(im1) |
| 544 cb1.ax.set_ylabel('a.u.') |
554 cb1.ax.set_ylabel(cmap_label) |
| 545 |
555 |
| 546 def index_at_height(self, height): |
556 def index_at_height(self, height): |
| 547 idx = np.array(np.abs(self.z - height).argmin()) |
557 idx = np.array(np.abs(self.z - height).argmin()) |
| 548 if idx.size >1: |
558 if idx.size >1: |
| 549 idx =idx[0] |
559 idx =idx[0] |