Added vmin, vmax as plot parameters.

Fri, 25 Oct 2013 18:41:58 +0200

author
ulalume3 <binietoglou@imaa.cnr.it>
date
Fri, 25 Oct 2013 18:41:58 +0200
changeset 17
74449200826c
parent 16
1122ee9ef151
child 18
6c7505d70090

Added vmin, vmax as plot parameters.

generic.py file | annotate | diff | comparison | revisions
--- a/generic.py	Fri Oct 25 18:41:20 2013 +0200
+++ b/generic.py	Fri Oct 25 18:41:58 2013 +0200
@@ -479,14 +479,18 @@
         prof = np.mean(self.matrix, axis = 0)
         return prof
     
-    def plot(self, signal_type = 'rc', filename = None, zoom = [0,12000,0,-1], show_plot = True, cmap = plt.cm.jet):
+    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):
         #if filename is not None:
         #    matplotlib.use('Agg')
         
         fig = plt.figure()
         ax1 = fig.add_subplot(111)
-        self.draw_plot(ax1, cmap = cmap, signal_type = signal_type, zoom = zoom)
-        ax1.set_title("%s signal - %s" % (signal_type.upper(), self.name)) 
+        self.draw_plot(ax1, cmap = cmap, signal_type = signal_type, zoom = zoom, z0 = z0, vmin = vmin, vmax = vmax)
+        
+        if title:
+            ax1.set_title(title)
+        else:
+            ax1.set_title("%s signal - %s" % (signal_type.upper(), self.name)) 
         
         if filename is not None:
             pass
@@ -496,7 +500,7 @@
                 plt.show()
         #plt.close() ???
     
-    def draw_plot(self,ax1, cmap = plt.cm.jet, signal_type = 'rc', zoom = [0,12000,0,-1]):
+    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):
         
         if signal_type == 'rc':
             if len(self.rc) == 0:
@@ -507,15 +511,21 @@
         
         hmax_idx = self.index_at_height(zoom[1])
         
-        ax1.set_ylabel('Altitude (km)')
-        ax1.set_xlabel('Time UTC')
+        # If z0 is given, then the plot is a.s.l.
+        if z0:
+            ax1.set_ylabel('Altitude a.s.l. [km]')
+        else:
+            ax1.set_ylabel('Altitude a.g.l. [km]')
+            z0 = 0
+            
+        ax1.set_xlabel('Time UTC [hh:mm]')
         #y axis in km, xaxis /2 to make 30s measurements in minutes. Only for 1064
         #dateFormatter = mpl.dates.DateFormatter('%H.%M')
         #hourlocator = mpl.dates.HourLocator()
         
         #dayFormatter = mpl.dates.DateFormatter('\n\n%d/%m')
         #daylocator = mpl.dates.DayLocator()       
-        hourFormatter = mpl.dates.DateFormatter('%H.%M')
+        hourFormatter = mpl.dates.DateFormatter('%H:%M')
         hourlocator = mpl.dates.AutoDateLocator(interval_multiples=True)
 
         
@@ -533,15 +543,15 @@
             aspect = 'auto',
             origin = 'lower',
             cmap = cmap,
-            #vmin = 0,
-            vmin = data[:,10:400].max() * 0.1,
-            #vmax = 1.4*10**7,
-            vmax = data[:,10:400].max() * 0.9,
-            extent = [ts1,ts2,self.z[zoom[0]]/1000.0, self.z[hmax_idx]/1000.0],
+            vmin = vmin,
+            #vmin = data[:,10:400].max() * 0.1,
+            vmax = vmax,
+            #vmax = data[:,10:400].max() * 0.9,
+            extent = [ts1,ts2,self.z[zoom[0]]/1000.0 + z0/1000., self.z[hmax_idx]/1000.0 + z0/1000.],
             )
         
         cb1 = plt.colorbar(im1)
-        cb1.ax.set_ylabel('a.u.')
+        cb1.ax.set_ylabel(cmap_label)
 
     def index_at_height(self, height):
         idx = np.array(np.abs(self.z - height).argmin())

mercurial