Beispiel #1
0
 def pre(self):        
     self.htable = lib_file.htmltable(ncol=2)
Beispiel #2
0
 def plot(self):
     """
     Create the plots.
     For this purpose, self.data has to be rearranged.
     """
     try:
         import matplotlib
         matplotlib.use('Agg')
         import pylab
     except:
         print("pylab/matplotlib not installed - plotting not possible")
         raise
     
     hfname = 'graphs.html'
     hfile = lib_file.htmlfile(hfname)
     hfile.pre('Property graphs')
     
     htable = lib_file.htmltable(ncol=4)
     
     #set1 = self.data[0][self['state_labels'][0]] # not used anywhere??
     
     matplotlib.rc('font', size=self['fsize'])
     
     for key in self.main_header[1:]:
         if key == 'fname': continue
         
         print('Plotting %s ...'%key)
         pylab.figure(figsize=(6,4))
         
         for state in self['state_labels']:
             ylist = []
             for iana_dir in range(len(self['ana_dirs'])):
                 try:
                     ylist.append(self.data[iana_dir][state][key])
                 except KeyError:
                     print(" ... not able to plot %s for %s."%(key, state))
                     break
             else:
                 pylab.plot(list(range(len(ylist))), ylist, 'x-', label=state)
         
         pylab.title(key)
         
         numx = len(self['ana_dirs'])
         pylab.xticks(range(numx), self['ana_dirs'], rotation=30)
         #pylab.margins(0.20)
         pylab.subplots_adjust(bottom=0.15)
         pylab.xlim((-0.5, numx+1.5))
         
         pylab.ylabel(key)
         pylab.legend()
         
         pname = '%s.%s'%(key, self['output_format'])
         pylab.savefig(pname)
         
         tel  = '<img src="%s", border="1" width="400">'%pname
         htable.add_el(tel)
             
     hfile.write(htable.ret_table()) 
     hfile.post()
     
     print(" HTML file %s containing the property graphs written."%hfname)
Beispiel #3
0
    def plot(self):
        hfname = 'OmFrag.html'
        hfile = lib_file.htmlfile(hfname)
        hfile.pre('Electron-hole correlation plots')
        hfile.write('<h2>Electron-hole correlation plots of the Omega matrices for the individual states.</h2>')
        
        htable = lib_file.htmltable(ncol=4)
        
        matplotlib.rc('font', size=self['fsize'])
        
        for state in self.state_list:
            if self['plot_type'] == 1:
                plot_arr = state['OmFrag']
            elif self['plot_type'] == 2:
                plot_arr = numpy.sqrt(state['OmFrag'])
            else:
                raise error_handler.ElseError(str(self['plot_type']), 'plot_type')
            
            if self['sscale']:
                vmax = self['vmax']
            else:
                vmax = state['OmFrag'].max()
            
            pylab.figure(figsize=(2,2))
            pylab.pcolor(plot_arr, cmap=pylab.get_cmap(name=self['cmap']), vmin=0., vmax=vmax)
            
            if self['axis']:
                pylab.axis('on')
                if self['ticks']:
                    pylab.xticks([x + 0.5 for x in range(len(plot_arr))], [x + 1 for x in range(len(plot_arr))])
                    pylab.yticks([y + 0.5 for y in range(len(plot_arr))], [y + 1 for y in range(len(plot_arr))])
                else:
                    pylab.xticks([])
                    pylab.yticks([])                    
            else:
                pylab.axis('off')
            
            if self['cbar']: pylab.colorbar()
            
            pname = 'pcolor_%s.%s'%(state['name'], self['output_format'])
            print("Writing %s ..."%pname)
            pylab.savefig(pname, dpi=self['plot_dpi'])
            
            tel  = '<img src="%s", border="1" width="200">\n'%pname
            tel += '<br>%s'%state['name']
            htable.add_el(tel)
        
        # create a plot with the e/h axes and optionally the scale
        pylab.figure(figsize=(2,2))        
        ax = pylab.axes()
        ax.arrow(0.15, 0.15, 0.5, 0., head_width=0.05, head_length=0.1, fc='k', ec='k')
        ax.text(0.20, 0.05, 'hole')
        ax.arrow(0.15, 0.15, 0., 0.5, head_width=0.05, head_length=0.1, fc='k', ec='k')    
        ax.text(0.02, 0.20, 'electron', rotation='vertical')

        if self['sscale']:
#            pylab.figure(figsize=(2,2))
            
            pylab.pcolor(numpy.zeros([1, 1]), cmap=pylab.get_cmap(name=self['cmap']), vmin=0., vmax=self.maxOm)
            
            pylab.colorbar()
            
        pylab.axis('off')            
        pylab.savefig('axes.%s'%self['output_format'], dpi=self['plot_dpi'])
            
        tel  = '<img src="axes.%s", border="1" width="200">\n'%self['output_format']
        tel += '<br>Axes / Scale'
        htable.add_el(tel)
            
        hfile.write(htable.ret_table())    
        hfile.post()
        
        print(" HTML file %s containing the electron-hole correlation plots written."%hfname)
Beispiel #4
0
    def plot(self):
        """
        Create the plots.
        For this purpose, self.data has to be rearranged.
        """
        try:
            import matplotlib
            matplotlib.use('Agg')
            import pylab
        except:
            print("pylab/matplotlib not installed - plotting not possible")
            raise

        hfname = 'graphs.html'
        hfile = lib_file.htmlfile(hfname)
        hfile.pre('Property graphs')

        htable = lib_file.htmltable(ncol=4)

        #set1 = self.data[0][self['state_labels'][0]] # not used anywhere??

        matplotlib.rc('font', size=self['fsize'])

        for key in self.main_header[1:]:
            if key == 'fname': continue

            print('Plotting %s ...' % key)
            pylab.figure(figsize=(6, 4))

            for state in self['state_labels']:
                ylist = []
                for iana_dir in range(len(self['ana_dirs'])):
                    try:
                        ylist.append(self.data[iana_dir][state][key])
                    except KeyError:
                        print(" ... not able to plot %s for %s." %
                              (key, state))
                        break
                else:
                    pylab.plot(list(range(len(ylist))),
                               ylist,
                               'x-',
                               label=state)

            pylab.title(key)

            numx = len(self['ana_dirs'])
            pylab.xticks(range(numx), self['ana_dirs'], rotation=30)
            #pylab.margins(0.20)
            pylab.subplots_adjust(bottom=0.15)
            pylab.xlim((-0.5, numx + 1.5))

            pylab.ylabel(key)
            pylab.legend()

            pname = '%s.%s' % (key, self['output_format'])
            pylab.savefig(pname)

            tel = '<img src="%s", border="1" width="400">' % pname
            htable.add_el(tel)

        hfile.write(htable.ret_table())
        hfile.post()

        print(" HTML file %s containing the property graphs written." % hfname)
Beispiel #5
0
    def plot(self):
        hfname = 'OmFrag.html'
        hfile = lib_file.htmlfile(hfname)
        hfile.pre('Electron-hole correlation plots')
        hfile.write(
            '<h2>Electron-hole correlation plots of the Omega matrices for the individual states.</h2>'
        )

        htable = lib_file.htmltable(ncol=4)

        matplotlib.rc('font', size=self['fsize'])

        for state in self.state_list:
            if self['plot_type'] == 1:
                plot_arr = state['OmFrag']
            elif self['plot_type'] == 2:
                plot_arr = numpy.sqrt(state['OmFrag'])
            else:
                raise error_handler.ElseError(str(self['plot_type']),
                                              'plot_type')

            if self['sscale']:
                vmax = self['vmax']
            else:
                vmax = state['OmFrag'].max()

            pylab.figure(figsize=(2, 2))
            pylab.pcolor(plot_arr,
                         cmap=pylab.get_cmap(name=self['cmap']),
                         vmin=0.,
                         vmax=vmax)

            if self['axis']:
                pylab.axis('on')
                if self['ticks']:
                    pylab.xticks([x + 0.5 for x in range(len(plot_arr))],
                                 [x + 1 for x in range(len(plot_arr))])
                    pylab.yticks([y + 0.5 for y in range(len(plot_arr))],
                                 [y + 1 for y in range(len(plot_arr))])
                else:
                    pylab.xticks([])
                    pylab.yticks([])
            else:
                pylab.axis('off')

            if self['cbar']: pylab.colorbar()

            pname = 'pcolor_%s.%s' % (state['name'], self['output_format'])
            print("Writing %s ..." % pname)
            pylab.savefig(pname, dpi=self['plot_dpi'])

            tel = '<img src="%s", border="1" width="200">\n' % pname
            tel += '<br>%s' % state['name']
            htable.add_el(tel)

        # create a plot with the e/h axes and optionally the scale
        pylab.figure(figsize=(2, 2))
        ax = pylab.axes()
        ax.arrow(0.15,
                 0.15,
                 0.5,
                 0.,
                 head_width=0.05,
                 head_length=0.1,
                 fc='k',
                 ec='k')
        ax.text(0.20, 0.05, 'hole')
        ax.arrow(0.15,
                 0.15,
                 0.,
                 0.5,
                 head_width=0.05,
                 head_length=0.1,
                 fc='k',
                 ec='k')
        ax.text(0.02, 0.20, 'electron', rotation='vertical')

        if self['sscale']:
            #            pylab.figure(figsize=(2,2))

            pylab.pcolor(numpy.zeros([1, 1]),
                         cmap=pylab.get_cmap(name=self['cmap']),
                         vmin=0.,
                         vmax=self.maxOm)

            pylab.colorbar()

        pylab.axis('off')
        pylab.savefig('axes.%s' % self['output_format'], dpi=self['plot_dpi'])

        tel = '<img src="axes.%s", border="1" width="200">\n' % self[
            'output_format']
        tel += '<br>Axes / Scale'
        htable.add_el(tel)

        hfile.write(htable.ret_table())
        hfile.post()

        print(
            " HTML file %s containing the electron-hole correlation plots written."
            % hfname)