Example #1
0
    def readInData(self):
        f = open(self.inifn,'w')
        f.write(str(self.ConfigBox.toPlainText()))
        f.close()
        
        gpsloc = str(self.GPSBox.text())
        isrloc = str(self.ISRBox.text())
        asloc = str(self.AllSkyBox.text())
        self.PC = PlotClass(self.inifn,GPSloc=gpsloc,ASloc=asloc,ISRloc=isrloc)
        
        self.strlist = [insertinfo( str(j)+' $tmdy $thmsehms',posix=i[0],posixend=i[1]) for j, i in enumerate(self.PC.Regdict['Time'])]
        self.TimeSlider.setMaximum(len(self.strlist)-1)
        self.TimeSlider.setTracking(False)
        self.TimeSlider.setTickPosition(1)

        self.figs=[]
        self.axs=[]
        for t in range(len(self.strlist)):
            print(self.strlist[t])
            self.figs.append(Figure(figsize=(16,10)))
            self.axs.append(self.figs[t].add_subplot(111))
            m=self.PC.plotmap(self.figs[t],self.axs[t])
            (allhands,cbarsax)=self.PC.plotsingle(m,self.axs[t],self.figs[t],timenum=t,icase=0)
        self.rmmpl()
        self.addmpl(self.figs[0])
Example #2
0
def plotopticsonly(allsky_data,plotdir,m,ax,fig,latlim,lonlim):
    """ Make a set of pots when only all sky is avalible."""
    maxplot = len(allsky_data.times)
    strlen = int(sp.ceil(sp.log10(maxplot))+1)
    fmstr = '{0:0>'+str(strlen)+'}_'
    optictimes = allsky_data.times
    plotnum=0
    firstbar = True
    optbnds = [300,1100]
    for iop in range(len(optictimes)):
        (slice3,cbar3) = slice2DGD(allsky_data,'alt',150,optbnds,title='',
                            time = iop,cmap='gray',gkey = 'image',fig=fig,ax=ax,cbar=True,m=m)

        slice3.set_norm(colors.PowerNorm(gamma=0.6,vmin=optbnds[0],vmax=optbnds[1]))
        if firstbar:
            firstbar=False
            cbaras = plt.colorbar(slice3,ax=ax,orientation='horizontal')
            cbaras.set_label('All Sky Scale')

        plt.title(insertinfo('All Sky $tmdy $thmsehms',posix=allsky_data.times[iop,0],posixend=allsky_data.times[iop,1]))
        print('Ploting {0} of {1} plots'.format(plotnum,maxplot))
        plt.savefig(os.path.join(plotdir,fmstr.format(plotnum)+'ASonly.png'))

        plotnum+=1
        slice3.remove()
Example #3
0
def plotgpswoptics(allsky_data,TEClist,allskylist,gpslist,plotdir,m,ax,fig,latlim,lonlim):
    """ Make a set of plots when given both all sky ad GPS are given.
        Inputs
            allsky_data - The all sky data as a GeoData object.
            TEClist - The of GeoData objects derived from the ionofiles.
            allskylist - A list of list which determines which allsky times are used."""
    maxplot = len(allsky_data.times)
    maxplot = sp.array([len(i) for i in allskylist]).sum()
    strlen = int(sp.ceil(sp.log10(maxplot))+1)
    fmstr = '{0:0>'+str(strlen)+'}_'
    plotnum=0
    firstbar = True
    optbnds = [300,1100]
    for (optic_times,gps_cur)in zip(allskylist,gpslist):
        gpshands = []
        gpsmin = sp.inf
        gpsmax = -sp.inf
        for igpsn, (igps,igpslist) in enumerate(zip(TEClist,gps_cur)):
            print('Plotting GPS data from rec {0} of {1}'.format(igpsn,len(gps_cur)))
            # check if there's anything to plot
            if len(igpslist)==0:
                continue

            (sctter,scatercb) = scatterGD(igps,'alt',3.5e5,vbounds=[0,20],time = igpslist,gkey = 'vTEC',cmap='plasma',fig=fig,
                  ax=ax,title='',cbar=True,err=.1,m=m)
            gpsmin = sp.minimum(igps.times[igpslist,0].min(),gpsmin)
            gpsmax = sp.maximum(igps.times[igpslist,0].max(),gpsmax)
            gpshands.append(sctter)
        scatercb.set_label('vTEC in TECu')
        #change he z order
        minz = gpshands[0].get_zorder()
        for i in reversed(gpshands):
            i.set_zorder(i.get_zorder()+1)

        for iop in optic_times:
            (slice3,cbar3) = slice2DGD(allsky_data,'alt',150,optbnds,title='',
                                time = iop,cmap='gray',gkey = 'image',fig=fig,ax=ax,cbar=False,m=m)
            slice3.set_norm(colors.PowerNorm(gamma=0.6,vmin=optbnds[0],vmax=optbnds[1]))

            if firstbar:
                firstbar=False
                cbaras = plt.colorbar(slice3,ax=ax,orientation='horizontal')
                cbaras.set_label('All Sky Scale')
            slice3.set_zorder(minz)
            plt.title(insertinfo('GPS $tmdy $thmsehms',posix=gpsmin,posixend=gpsmax)+'\n'+insertinfo('All Sky $tmdy $thmsehms',posix=allsky_data.times[iop,0],posixend=allsky_data.times[iop,1]))
            print('Ploting {0} of {1} plots'.format(plotnum,maxplot))
            plt.savefig(os.path.join(plotdir,fmstr.format(plotnum)+'ASwGPS.png'))

            plotnum+=1
            slice3.remove()
        for i in reversed(gpshands):
            i.remove()
def plotting(risr_classred,risr_class,omti_class,reglistfinal,odir=None):

    figcount = 0
    for iomti,ilist in enumerate(reglistfinal):
        for irisr in ilist:
            omtitime = iomti
            risrtime =  irisr

            try:
                mfig = mlab.figure(fgcolor=(1, 1, 1), bgcolor=(1, 1, 1))
                surflist1 = plot3Dslice(omti_class, omtislices, vbounds[0],
                            time = omtitime,cmap='gray',gkey = 'optical',fig=mfig)
                arr = plot3Dslice(risr_classred, risrslices, vbounds[1],
                            time = risrtime,cmap='jet',gkey = 'ne',fig=mfig,units = 'm^{-3}',colorbar = True,view=[50,60],outimage=True)
                titlestr1 = '$N_e$ and OMTI at $thm'
                newtitle = insertinfo(titlestr1,'',risr_classred.times[risrtime,0],risr_classred.times[risrtime,1])
            except Exception as e:
                logging.error('trouble with 3D plot  {}'.format(e))

            (figmplf, [[ax1,ax2],[ax3,ax4]]) = plt.subplots(2, 2,figsize=(16, 12), facecolor='w')

            try:
                ax1.imshow(arr)
                ax1.set_title(newtitle)
                ax1.axis('off')
            except:
                pass

            (slice2,cbar2) = slice2DGD(risr_classred,'z',400,vbounds[1],title='$N_e$ at $thm',
                        time = risrtime,cmap='jet',gkey = 'ne',fig=figmplf,ax=ax2)
            cbar2.set_label('$N_e$ in $m^{-3}$')

            (slice3,cbar3) = slice2DGD(omti_class,'z',omtislices[-1][0],vbounds[0],title='OMTI at $thm',
                        time = omtitime,cmap='Greys',gkey = 'optical',fig=figmplf,ax=ax3,cbar=False)
            plt.hold(True)

            (slice4,cbar4) = contourGD(risr_classred,'z',400,vbounds[1],title='$N_e$ at $thm',
                        time = risrtime,cmap='jet',gkey = 'ne',fig=figmplf,ax=ax3)
            cbar4.set_label('$N_e$ in $m^{-3}$')
            bmpos = plotbeamposGD(risr_class)

            if odir is not None:
                figname = os.path.join(odir,'figure{0:0>2}.png'.format(figcount))
                figmplf.savefig(figname,format='png',dpi = 400)
                plt.close(figmplf)
                figcount=figcount+1
Example #5
0
 def readindata(self):
     """ This will create the plot class object that will be used to plot all of the data. """
     if self.fn is None:
         return
     gpsloc = self.input['GPS']['entries'].get()
     ASloc = self.input['AllSky']['entries'].get()
     ISRloc=self.input['ISR']['entries'].get()
     
     self.PC = PlotClass(self.fn,GPSloc=gpsloc,ASloc=ASloc,ISRloc=ISRloc)
     self.m=self.PC.plotmap(self.fig,self.sp)
     for ihand in self.allhands:
         if hasattr(ihand, "__len__"):
             for ihand2 in ihand:
                 ihand2.remove()
         elif hasattr(ihand,'collections'):
             for ihand2 in ihand.collections:
                 ihand2.remove()
         else:
             ihand.remove()
     (self.allhands,self.cbarsax)=self.PC.plotsingle(self.m,self.sp,self.fig,timenum=0,icase=0)
     self.canvas.draw()
     strlist = [insertinfo( str(j)+' $tmdy $thmsehms',posix=i[0],posixend=i[1]) for j, i in enumerate(self.PC.Regdict['Time'])]
     timearr = np.arange(len(strlist))
     paramar = np.zeros(len(strlist))
     self.times['list'] = timearr
     self.times['var'].set('')
     self.times['menu']['menu'].delete(0, 'end')
     for choice in strlist:
         self.times['menu']['menu'].add_command(label=choice, command=Tk._setit(self.times['var'], choice))
         self.times['var'].set(strlist[0])
     # deal with case with no isr data        
     if not self.PC.GDISR is None and   len(self.PC.params['paramheight'])>0:
         nparams = len(self.PC.params['paramheight'])
         paramar = np.arange(nparams)
         
         strlist2 = []
         for i, icase in enumerate(self.PC.params['paramheight']):
             stradd = str(i) +' '+ icase[0] +' at ' + str(int(icase[1])) +' km'
             strlist2.append(stradd)
         self.radarparam['list'] = paramar
         self.radarparam['var'].set('')
         self.radarparam['menu']['menu'].delete(0, 'end')
         for choice in strlist2:
             self.radarparam['menu']['menu'].add_command(label=choice, command=Tk._setit(self.radarparam['var'], choice))
         self.radarparam['var'].set(strlist2[0])
Example #6
0
def getSRIhdf5(filename,times,pnheights,xycoords,newcordname,vbounds,pltdir =None):
    """ Plots a set of ISR data in SRI's data format."""
    paramstr = ['Ne','Ti','Te']
    SRIh5 = GeoData(readSRI_h5,(filename,paramstr))
    (dt1,dt2) = parser.parse(times[0]),parser.parse(times[1])
    dt1 =dt1.replace(tzinfo=pytz.utc)
    dt2 = dt2.replace(tzinfo=pytz.utc)
    dt1ts = (dt1 -datetime(1970,1,1,0,0,0,tzinfo=pytz.utc)).total_seconds()
    dt2ts = (dt2 -datetime(1970,1,1,0,0,0,tzinfo=pytz.utc)).total_seconds()

    timelist = sp.where((SRIh5.times[:,0]>=dt1ts)&(SRIh5.times[:,0]<=dt2ts))[0]

    if len(timelist)==0:
        return

    SRIh5 = SRIh5.timeslice(timelist)

    hset = sp.array([i[1] for i in pnheights])
    uh,uhs =sp.unique(hset,return_inverse=True)

        # interpolation
    ncoords = xycoords.shape[0]
    uhall = sp.repeat(uh,ncoords)

    coords = sp.tile(xycoords,(len(uh),1))
    coords = sp.column_stack((coords,uhall))


    SRIh5.interpolate(coords,newcordname,method='linear')


    maxplot = len(timelist)
    strlen = int(sp.ceil(sp.log10(maxplot))+1)
    fmstr = '{0:0>'+str(strlen)+'}_'
    for itn in range(len(timelist)):
        fig, axmat = plt.subplots(nrows=len(pnheights),ncols=1)
        axvec = axmat.flatten()


        for icase,(iparam,iheight) in enumerate(pnheights):
           (plth,cbh) =  slice2DGD(SRIh5,'z',uhs[icase],vbounds=vbounds[icase],time = itn,gkey = iparam,cmap='jet',fig=fig,
                  ax=axvec[icase],title=iparam + ' at {0} km'.format(iheight),cbar=True)
           if iparam.lower()!='ne':
               ntics = sp.linspace(vbounds[icase][0],vbounds[icase][1],5)
               cbh.set_ticks(ntics)
               cbh.formatter.fmt = '%d'
               cbh.update_ticks()
           else:
               ntics = sp.linspace(vbounds[icase][0],vbounds[icase][1],5)
               cbh.set_ticks(ntics)
               cbh.formatter.fmt = '%.1e'
               cbh.update_ticks()
        outstr = insertinfo('ISR Data at $tmdy $thmsehms',posix=SRIh5.times[itn,0],posixend = SRIh5.times[itn,1])
        plt.suptitle(outstr)
        fname = 'SRIData'+fmstr.format(itn)+'.png'
        plt.tight_layout()
        plt.subplots_adjust(top=0.85)
        if not pltdir is None:
            fname=os.path.join(pltdir,fname)
        print('saving {}'.format(fname))
        plt.savefig(fname)
        plt.close(fig)
Example #7
0
    def plotsingle(self,m,ax,fig,timenum=0,icase=0,cbarax=[]):
        """ Make single plot given the desired time and number associated with
            the desired ISR param.
            Inputs
                m - The map handle that is used to plot everything.
                fig - The figure handle for the plots.
                ax - The axes handle that the map will be plotted over.
                timenum - The of GeoData objects derived from the ionofiles.
                icase - A list of list which determines which allsky times are used.
                cbarax - The list of color bar axes.
            Outputs
                allhands - The list handles of the plotted data.
                cbarax - A list of
        """


        optbnds = self.params['aslim']
        gam=self.params['asgamma']

        curwin=self.Regdict['Time'][timenum]

        allhands = [[]]

        titlelist = []
        if len(cbarax)==0:
            wid = .3/self.numGD
            cbarax=[fig.add_axes([.7+i*wid,.3,wid/2.,.4]) for i in range(self.numGD)]
            fig.tight_layout(rect=[0,.05,.7,.95])
        cbcur=0
        if not self.GDGPS is None:
            gpshands = []
            gpsbounds = self.params['gpslim']
            for igps,igpslist in zip(self.GDGPS,self.Regdict['TEC'][timenum]):
                # check if there's anything to plot
                if len(igpslist)==0:
                    continue
                (sctter,scatercb) = scatterGD(igps,'alt',1.5e5,vbounds=gpsbounds,time = igpslist,gkey = 'TEC',cmap=defmap,fig=fig, ax=ax,title='',cbar=False,err=.1,m=m)

                gpshands.append(sctter)
                """
		Plot Position of Mah8
                y = 64.971
		x = 212.567-360
		xd,yd = m(x,y)
		gpshands.append(ax.plot(xd,yd,'rx',markersize=15)[0])
		"""
                if('lol' in igps.data):
                    for i in igpslist:
                        if(igps.data['lol'][i].any()):
                            ydata = igps.dataloc[i][0]
                            xdata = igps.dataloc[i][1]
                            Xdata,Ydata = m(xdata,ydata)
                            gpshands.append(ax.plot(Xdata,Ydata,'kx',markersize=12)[0])


            # If no gps data plots dont try to plot the color bar
            if len(gpshands)>0:
                scatercb = plt.colorbar(sctter,cax=cbarax[cbcur])

                scatercb.set_label('vTEC in TECu')
            cbcur+=1
            allhands[0]=gpshands
            titlelist.append( insertinfo('GPS $tmdy $thmsehms',posix=curwin[0],posixend=curwin[1]))
            #change he z order

            allhands[0]=gpshands

        if not self.GDAS is None:

            iop = self.Regdict['AS'][timenum]
            (slice3,cbar3) = slice2DGD(self.GDAS,'alt',150,optbnds,title='',
                                time = iop,cmap='gray',gkey = 'image',fig=fig,ax=ax,cbar=False,m=m)
            slice3.set_norm(colors.PowerNorm(gamma=gam,vmin=optbnds[0],vmax=optbnds[1]))
            titlelist.append(insertinfo('All Sky $tmdy $thmsehms',posix=self.GDAS.times[iop,0],posixend=self.GDAS.times[iop,1]))
            cbaras = plt.colorbar(slice3,cax=cbarax[cbcur])
            cbcur+=1
            cbaras.set_label('All Sky Scale')
            minz=slice3.get_zorder()
            for i in reversed(allhands[0]):
                minz=sp.minimum(minz,i.get_zorder())
                i.set_zorder(i.get_zorder()+1)
            slice3.set_zorder(minz)
            allhands.append(slice3)
        if not self.GDISR is None:
            itn=self.Regdict['ISR'][timenum]
            curph=self.params['paramheight'][icase]
            vbounds = self.params['paramlim']
            iparam=curph[0]
            if iparam.lower()!='ne':
                levels = sp.logspace(sp.log10(vbounds[icase][0]),sp.log10(vbounds[icase][1]),5)
            else:
                levels = sp.linspace(vbounds[icase][0],vbounds[icase][1],5)
            (plth,cbh) =  contourGD(self.GDISR,'alt',curph[1],vbounds=vbounds[icase],time = itn,gkey = iparam,cmap='jet',fig=fig,
                  ax=ax,cbar=False,m=m,levels = levels)
            cbh = plt.colorbar(plth,cax=cbarax[cbcur])
            cbh.set_label(iparam)
            if iparam.lower()!='ne':

                fmt= '%d'


            else:

                plth.set_norm(colors.LogNorm(vmin=vbounds[icase][0],vmax=vbounds[icase][1]))
                fmt = '%.1e'
            titlelist.append( insertinfo('ISR Data at $tmdy $thmsehms',posix=self.GDISR.times[itn,0],posixend = self.GDISR.times[itn,1]))
#            minz=plth.get_zorder()
#            for i in reversed(allhands[0]):
#                minz=sp.minimum(minz,i.get_zorder)
#                i.set_zorder(i.get_zorder()+1)
#            plth.set_zorder(minz)
            cbh = plt.colorbar(plth,cax=cbarax[cbcur],format=fmt)
            cbh.set_label(iparam)
            allhands.append(plth)
        ax.set_title('\n'.join(titlelist) )
        return allhands,cbarax
Example #8
0
    def plotCircle(self,ax,fig,timenum,cbarax): #CONSIDER DONIG THIS WITH POLAR PLOT/INTERPOLATION

        allhands=[[]]
        curwin=self.Regdict['Time'][timenum]
        optbnds = self.params['aslim']
        titlelist = []
        if len(cbarax)==0:
            wid = .3/self.numGD
            cbarax=[fig.add_axes([.7+i*wid,.3,wid/2.,.4]) for i in range(self.numGD)]
            fig.tight_layout(rect=[0,.05,.7,.95])
        cbcur=0

        #Plot AllSky Image
        if not self.GDAS is None:
            iop = self.Regdict['AS'][timenum]
            [r,az,el] = self.GDAS.dataloc.T
            az = az%360
            rel = 90-el
            x = rel*np.sin(az*np.pi/180)
            y = -rel*np.cos(az*np.pi/180)
            grid_x, grid_y = np.mgrid[-80:80:400j, -80:80:400j]
            asimg = griddata(np.array([x,y]).T,
                             self.GDAS.data['image'].T[iop],
                             (grid_x,grid_y),
                             method='linear')

            slice3 = ax.pcolormesh(grid_x,grid_y,asimg,cmap='summer',
                                   vmin=optbnds[0],vmax=optbnds[1],
                                   figure=fig)

            ax.axis([-85,85,-85,85])
            ax.axis('off')

            titlelist.append(insertinfo('All Sky $tmdy $thmsehms',posix=self.GDAS.times[iop,0],posixend=self.GDAS.times[iop,1]))
            cbaras = plt.colorbar(slice3,cax=cbarax[cbcur])
            cbcur+=1
            cbaras.set_label('All Sky Scale')

            allhands.append(slice3)

        #Draw Polar Lines On Top
       # lines = []
        ang = np.arange(0,180,.5)/np.pi
        for i in np.arange(80,0,-20):
            r = (y[np.logical_and(abs(x)<.5,abs(el-i)<.5)][0])
            allhands.append(ax.plot(r*np.cos(ang),r*np.sin(ang),'k-',lw=.5,alpha=.5))
            allhands.append(ax.text(0,abs(r)-3,str(i),alpha=.5))

        angles = np.arange(0,180,30)
        textangles = {iang:(str(np.mod(270+iang,360)),str(np.mod(90+iang,360))) for iang in angles}
        maxy = np.max(y)
        for iang in angles:
            iangr = iang*np.pi/180
            xs = np.array([maxy*np.cos(iangr+np.pi),-maxy*np.cos(iangr+np.pi)])
            ys = np.array([maxy*np.sin(iangr+np.pi),-maxy*np.sin(iangr+np.pi)])
            allhands.append(ax.plot(xs,ys,'k-',alpha=.5,lw=.5))
            allhands.append(ax.text(1.05*xs[0]-2,1.05*ys[0]-2,textangles[iang][0],alpha=.5))
            allhands.append(ax.text(1.05*xs[1]-2,1.05*ys[1]-2,textangles[iang][1],alpha=.5))


        #Plot GPS Scatter
        if not self.GDGPS is None:
            gpshands = []
            gpsbounds = self.params['gpslim']
            for igps,igpslist in zip(self.GDGPS,self.Regdict['TEC'][timenum]):
                # check if there's anything to plot
                if len(igpslist)==0:
                    continue
                az = igps.data['az2sat'] % 360
                rel = 90-igps.data['el2sat']
                x = rel*np.sin(az*np.pi/180)
                y = -rel*np.cos(az*np.pi/180)
                sctter = ax.scatter(x[igpslist],y[igpslist],
                                    c=igps.data['TEC'][igpslist],
                                    cmap=defmap,vmin=gpsbounds[0],
                                    vmax=gpsbounds[1],figure=fig)
                satnames=[]
                for i in igpslist:
                    if igps.data['satnum'][i] in satnames: continue
                    allhands.append(ax.text(x[i]+1,y[i]+1,str(int(igps.data['satnum'][i]))))
                gpshands.append(sctter)

                if('lol' in igps.data):
                    for i in igpslist:
                        if(igps.data['lol'][i].any()):
                            Xdata = x[i]
                            Ydata = y[i]
                            gpshands.append(ax.plot(Xdata,Ydata,'kx',markersize=12)[0])

            if len(gpshands)>0:
                scatercb = plt.colorbar(sctter,cax=cbarax[cbcur])

                scatercb.set_label('TEC in TECu')
            cbcur+=1
            allhands[0]=gpshands

            titlelist.append( insertinfo('GPS $tmdy $thmsehms',posix=curwin[0],posixend=curwin[1]))


        ax.set_title('\n'.join(titlelist) )
        return allhands,cbarax
Example #9
0
def plotting(risr_classred, risr_class, omti_class, reglistfinal, odir=None):

    figcount = 0
    for iomti, ilist in enumerate(reglistfinal):
        for irisr in ilist:
            omtitime = iomti
            risrtime = irisr

            try:
                mfig = mlab.figure(fgcolor=(1, 1, 1), bgcolor=(1, 1, 1))
                surflist1 = plot3Dslice(omti_class,
                                        omtislices,
                                        vbounds[0],
                                        time=omtitime,
                                        cmap='gray',
                                        gkey='optical',
                                        fig=mfig)
                arr = plot3Dslice(risr_classred,
                                  risrslices,
                                  vbounds[1],
                                  time=risrtime,
                                  cmap='jet',
                                  gkey='ne',
                                  fig=mfig,
                                  units='m^{-3}',
                                  colorbar=True,
                                  view=[50, 60],
                                  outimage=True)
                titlestr1 = '$N_e$ and OMTI at $thm'
                newtitle = insertinfo(titlestr1, '',
                                      risr_classred.times[risrtime, 0],
                                      risr_classred.times[risrtime, 1])
            except Exception as e:
                logging.error('trouble with 3D plot  {}'.format(e))

            (figmplf, [[ax1, ax2], [ax3,
                                    ax4]]) = plt.subplots(2,
                                                          2,
                                                          figsize=(16, 12),
                                                          facecolor='w')

            try:
                ax1.imshow(arr)
                ax1.set_title(newtitle)
                ax1.axis('off')
            except:
                pass

            (slice2, cbar2) = slice2DGD(risr_classred,
                                        'z',
                                        400,
                                        vbounds[1],
                                        title='$N_e$ at $thm',
                                        time=risrtime,
                                        cmap='jet',
                                        gkey='ne',
                                        fig=figmplf,
                                        ax=ax2)
            cbar2.set_label('$N_e$ in $m^{-3}$')

            (slice3, cbar3) = slice2DGD(omti_class,
                                        'z',
                                        omtislices[-1][0],
                                        vbounds[0],
                                        title='OMTI at $thm',
                                        time=omtitime,
                                        cmap='Greys',
                                        gkey='optical',
                                        fig=figmplf,
                                        ax=ax3,
                                        cbar=False)
            plt.hold(True)

            (slice4, cbar4) = contourGD(risr_classred,
                                        'z',
                                        400,
                                        vbounds[1],
                                        title='$N_e$ at $thm',
                                        time=risrtime,
                                        cmap='jet',
                                        gkey='ne',
                                        fig=figmplf,
                                        ax=ax3)
            cbar4.set_label('$N_e$ in $m^{-3}$')
            bmpos = plotbeamposGD(risr_class)

            if odir is not None:
                figname = os.path.join(odir,
                                       'figure{0:0>2}.png'.format(figcount))
                figmplf.savefig(figname, format='png', dpi=400)
                plt.close(figmplf)
                figcount = figcount + 1