示例#1
0
    def plots_1d(self, ts, outpath, prefix=''):
        """ Plots several 1D plots.  User passes in ts w/ proper iunit.
            outpath: filepath (str)
            prefix: str
               Put in front of file name (eg outpath/prefix_area.png) for area plot
        """
        
        # Set plot and tick size larger than defaul
        sizeargs = {'labelsize': self._plot_fontsize, 
                    'ticksize':15, 
                    'titlesize':self._plot_fontsize}
        
    
        ts.plot(**sizeargs)
        self.plt_clrsave(op.join(outpath, prefix +'_spectrum'))

        # Area plot using simpson method of integration
        areaplot(ts, 
                 ylabel='Power',
                 xlabel='Time ('+ts.timeunit+')',
                 legend=False,
                 title='Spectral Power vs. Time (%i - %i %s)' % 
                    (min(ts.index), max(ts.index), ts.specunit), color='r', **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix +'_area'))

        # Normalized area plot (divided by number x units)       
        areaplot(ts/len(ts.index),
                 ylabel='Power per unit %s' % ts.specunit,
                 xlabel='Time (' + ts.timeunit+')', 
                 legend=False, 
                 title='Normalized Spectral Power vs. Time (%i - %i %s)' % 
                     (min(ts.index), max(ts.index), ts.specunit), color='orange', **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix +'_area_normal'))
        
        # Normalized ABSOLUTE areaplot (divided by number x units)       
        areaplot(np.absolute(ts)/len(ts.index), 
                 ylabel='Power per unit %s' % ts.specunit, 
                 xlabel='Time (' + ts.timeunit+')', 
                 legend=False, 
                 title='Normalized ABSOLUTE Power vs. Time (%i - %i %s)' % 
                     (min(ts.index), max(ts.index), ts.specunit), color='purple', **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix +'_area_normal'))        
        
        # Lambda max vs. t plot
        
        # XXXXXX?

        # Ranged time plot
        try:
            uv_ranges = self.params.uv_ranges
        except (KeyError):
            uv_ranges = 8   
            logger.warn('Uv_ranges parameter not found: setting to 8.')
                
        # Time averaged plot, not scaled to 1 (relative intenisty dependson bin width and actual intensity)
        tssliced = ts.wavelength_slices(uv_ranges, apply_fcn='mean')
        range_timeplot(tssliced, ylabel='Average Intensity', xlabel = 
                       'Time ('+ts.timeunit+')', **sizeargs ) #legstyle =1 for upper left
        self.plt_clrsave(op.join(outpath, prefix +'_strip'))        
示例#2
0
 def area_thirds_plot(self, ts):
     # Special areaplot of normalized raw area in thirds
     # Should work on USB650, but untested.  Slices data into thirds to 
     # find limits, so should be independent.
     def _scaleto1(tslice):
         return np.divide(tslice, tslice[0])
     
     ax = areaplot(_scaleto1(ts.area()), linewidth=2, alpha=1, ls='--', padding=None)
     
     tspace = (ts.index.max() - ts.index.min()) /3
     tim = ts.index.min()
     
     short = ts.nearby[:tim+tspace].area()
     mid = ts.nearby[tim+tspace:tim+2*tspace].area()
     longer = ts.nearby[2*tspace+tim:].area()
     
     for t, color in [(short, 'b'), (mid, 'g'), (longer, 'r')]:
         ax = range_timeplot(_scaleto1(t), ax=ax, color=color, 
                             linewidth=4, alpha=.4, padding=None)
     
     def _shortname(string):
         """ Rounds name of format 324.23:960.32 to int, 324:960"""
         ints = [int(round(float(i),0)) for i in string.split(':')]
         return '%s:%s' % (ints[0], ints[1])    
         
     plt.title('Area slices %s: normalized at t=0' % ts.specunit)
         
     plt.legend(['All $\lambda$', 
                 _shortname(short.index[0]), 
                 _shortname(mid.index[0]), 
                 _shortname(longer.index[0])],
                 ncol=4, 
                 fontsize='10')        
示例#3
0
 def area_thirds_plot(self, ts):
     # Special areaplot of normalized raw area in thirds
     # Should work on USB650, but untested.  Slices data into thirds to 
     # find limits, so should be independent.
     def _scaleto1(tslice):
         return np.divide(tslice, tslice[0])
     
     ax = areaplot(_scaleto1(ts.area()), linewidth=2, alpha=1, ls='--', custompadding=None)
     
     tspace = (ts.index.max() - ts.index.min()) /3
     tim = ts.index.min()
     
     short = ts.nearby[:tim+tspace].area()
     mid = ts.nearby[tim+tspace:tim+2*tspace].area()
     longer = ts.nearby[2*tspace+tim:].area()
     
     # Store slice ranges for plt.legend() below
     label_short = '%s:%s'% (ts.index[0], tim+tspace)
     label_mid = '%s:%s' % (tim+tspace, tim+2*tspace)
     label_long = '%s:%s' % (2*tspace+tim, ts.index[-1])
     
     for t, color in [(short, 'b'), (mid, 'g'), (longer, 'r')]:
         ax = range_timeplot(_scaleto1(t), ax=ax, color=color, 
                             linewidth=4, alpha=.4, custompadding=None)
     
     plt.title('Area slices %s: normalized at t=0' % ts.specunit)    
     plt.legend(['All $\lambda$', label_short, label_mid, label_long],
                 ncol=4, 
                 fontsize='10')        
示例#4
0
    def area_thirds_plot(self, ts):
        # Special areaplot of normalized raw area in thirds
        # Should work on USB650, but untested.  Slices data into thirds to
        # find limits, so should be independent.
        def _scaleto1(tslice):
            return np.divide(tslice, tslice[0])

        ax = areaplot(_scaleto1(ts.area()),
                      linewidth=2,
                      alpha=1,
                      ls='--',
                      custompadding=None)

        tspace = (ts.index.max() - ts.index.min()) / 3
        tim = ts.index.min()

        short = ts.nearby[:tim + tspace].area()
        mid = ts.nearby[tim + tspace:tim + 2 * tspace].area()
        longer = ts.nearby[2 * tspace + tim:].area()

        # Store slice ranges for plt.legend() below
        label_short = '%s:%s' % (ts.index[0], tim + tspace)
        label_mid = '%s:%s' % (tim + tspace, tim + 2 * tspace)
        label_long = '%s:%s' % (2 * tspace + tim, ts.index[-1])

        for t, color in [(short, 'b'), (mid, 'g'), (longer, 'r')]:
            ax = range_timeplot(_scaleto1(t),
                                ax=ax,
                                color=color,
                                linewidth=4,
                                alpha=.4,
                                custompadding=None)

        plt.title('Area slices %s: normalized at t=0' % ts.specunit)
        plt.legend(['All $\lambda$', label_short, label_mid, label_long],
                   ncol=4,
                   fontsize='10')
示例#5
0
    def plots_1d(self, ts, outpath, prefix=''):
        """ Plots several 1D plots.  User passes in ts w/ proper iunit.
            outpath: filepath (str)
            prefix: str
               Put in front of file name (eg outpath/prefix_area.png) for area plot
        """

        # Set plot and tick size larger than defaul
        sizeargs = {
            'labelsize': self._plot_fontsize,
            'ticksize': 15,
            'titlesize': self._plot_fontsize
        }

        ts.plot(**sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_spectrum'))

        # Area plot using simpson method of integration
        areaplot(ts,
                 ylabel='Power',
                 xlabel='Time (' + ts.varunit + ')',
                 legend=False,
                 title='Spectral Power vs. Time (%i - %i %s)' %
                 (min(ts.index), max(ts.index), ts.specunit),
                 color='black',
                 **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_area'))

        # Short wavelengths min:525nm
        areaplot(ts.loc[:525.0, :],
                 ylabel='Power',
                 xlabel='Time (' + ts.varunit + ')',
                 legend=False,
                 title='Short Wavelengths vs. Time (%i - %i %s)' %
                 (min(ts.index), 525.0, ts.specunit),
                 color='b',
                 **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_area_short'))

        # Middle wavelengths 525:590nm
        areaplot(ts.loc[525.0:590.0, :],
                 ylabel='Power',
                 xlabel='Time (' + ts.varunit + ')',
                 legend=False,
                 title='Medium Wavelengths vs. Time (%i - %i %s)' %
                 (525.0, 590.0, ts.specunit),
                 color='g',
                 **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_area_middle'))

        # Long wavelenghts 590.0nm:
        areaplot(ts.loc[590.0:, :],
                 ylabel='Power',
                 xlabel='Time (' + ts.varunit + ')',
                 legend=False,
                 title='Long Wavelengths vs. Time (%i - %i %s)' %
                 (590.0, max(ts.index), ts.specunit),
                 color='r',
                 **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_area_long'))

        # Normalized area plot (divided by number x units)
        areaplot(ts / len(ts.index),
                 ylabel='Power per unit %s' % ts.specunit,
                 xlabel='Time (' + ts.varunit + ')',
                 legend=False,
                 title='Normalized Spectral Power vs. Time (%i - %i %s)' %
                 (min(ts.index), max(ts.index), ts.specunit),
                 color='orange',
                 **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_area_normal'))

        # Normalized ABSOLUTE areaplot (divided by number x units)
        areaplot(np.absolute(ts) / len(ts.index),
                 ylabel='Power per unit %s' % ts.specunit,
                 xlabel='Time (' + ts.varunit + ')',
                 legend=False,
                 title='Normalized ABSOLUTE Power vs. Time (%i - %i %s)' %
                 (min(ts.index), max(ts.index), ts.specunit),
                 color='purple',
                 **sizeargs)
        self.plt_clrsave(op.join(outpath, prefix + '_area_normal'))

        # Lambda max vs. t plot

        # XXXXXX?

        # Ranged time plot
        try:
            uv_ranges = self.params.uv_ranges
        except (KeyError):
            uv_ranges = 8
            logger.warn('Uv_ranges parameter not found: setting to 8.')

        # Time averaged plot, not scaled to 1 (relative intenisty dependson bin width and actual intensity)
        tssliced = ts.wavelength_slices(uv_ranges, apply_fcn='mean')
        range_timeplot(tssliced,
                       ylabel='Average Intensity',
                       xlabel='Time (' + ts.varunit + ')',
                       **sizeargs)  #legstyle =1 for upper left
        self.plt_clrsave(op.join(outpath, prefix + '_strip'))