Exemplo n.º 1
0
        # Compute the forward difference up to i=final -1
    #    array = array.values
        for idx, value in enumerate(array):
            if idx < len(array)-1:
                new = array[idx+1]
                out = new-value          
                if absolute:
                    out = abs(out)        
                sdiff.append(out)
    
        if cumsum:
            sdiff = list(np.cumsum(sdiff)) 
        sdiff.append(sdiff[-1]) #REPEAST LAST VALUE
        return sdiff

    ts = aunps_glass()

    ts.iunit = None #is the most accurate
    ts.varunit = 'm'
    from pandas import Index
    ts.columns = Index(ts.columns)
    area = ts.area()
    
    DIFF = area.apply(sumdiff, axis=1, raw=False)
    

    # Be careful when generating test data from Pandas Index/DataFrame objects, as this module has overwritten their defaul behavior
    # best to generate them in other modules and import them to simulate realisitc usec ase


    ## For testing 
Exemplo n.º 2
0
    from pyuvvis.core.timespectra import TimeSpectra
    from pandas import date_range, DataFrame, Index

    import numpy as np       
    import matplotlib.pyplot as plt
    from pyuvvis.data import aunps_glass

    spec = SpecIndex(np.arange(400, 700,10), unit='nm' )
    spec2 = SpecIndex(np.arange(400, 700,10), unit='m' )
    
    testdates = date_range(start='3/3/12', periods=30, freq='h')
    testdates2 = date_range(start='3/3/12', periods=30, freq='h')
    
    #ts = TimeSpectra(abs(np.random.randn(30,30)), columns=testdates, index=spec)  
    #t2 = TimeSpectra(abs(np.random.randn(30,30)), columns=testdates2, index=spec2) 
    ts = aunps_glass(style=1)
    t2 = aunps_glass(style=2)
    d = (('d1', ts), ('d2', t2))

    ##x = Panel(d)
    stack = ts.as_iunit('r').split_by(5)
    stack.reference = 0
    #stack.plot(figsize=(8,8), colormap='RdBu')   
    
    #raise SyntaxError

    #def random_noise(curve):
        #from random import randint
        #if randint(1,5) == 5:     #20% chance of choosing 5
            #curve = curve + 25 * np.random.randn(len(curve))
        #return curve
Exemplo n.º 3
0
    from pyuvvis.core.timespectra import TimeSpectra
    from pandas import date_range, DataFrame, Index

    import numpy as np
    import matplotlib.pyplot as plt
    from pyuvvis.data import aunps_glass

    spec = SpecIndex(np.arange(400, 700, 10), unit='nm')
    spec2 = SpecIndex(np.arange(400, 700, 10), unit='m')

    testdates = date_range(start='3/3/12', periods=30, freq='h')
    testdates2 = date_range(start='3/3/12', periods=30, freq='h')

    #ts = TimeSpectra(abs(np.random.randn(30,30)), columns=testdates, index=spec)
    #t2 = TimeSpectra(abs(np.random.randn(30,30)), columns=testdates2, index=spec2)
    ts = aunps_glass(style=1)
    t2 = aunps_glass(style=2)
    d = (('d1', ts), ('d2', t2))

    ##x = Panel(d)
    stack = ts.as_iunit('r').split_by(5)
    stack.reference = 0
    #stack.plot(figsize=(8,8), colormap='RdBu')

    #raise SyntaxError

    #def random_noise(curve):
    #from random import randint
    #if randint(1,5) == 5:     #20% chance of choosing 5
    #curve = curve + 25 * np.random.randn(len(curve))
    #return curve
Exemplo n.º 4
0
    pltkwds.setdefault('xlabel', tunit)  
    pltkwds.setdefault('ylabel', '$\int$ %s d$\lambda$'%ranged_ts.full_iunit)    
    pltkwds.setdefault('title', 'Area: '+ ranged_ts.name )      


    # If shape is wrong, take transpose    
    if ranged_ts.ndim > 1:
        rows, cols = ranged_ts.shape    
        if cols == 1 and rows != 1:
            out = ranged_ts
        else:
            logger.warn("areaplot() forcing transpose on %s for plotting" 
                        % ranged_ts.name)
            # _df.transpose() causes error now because specunit is being transferred!
            out = ranged_ts.transpose()

    # If series, just pass in directly
    else:
        out = ranged_ts
                    
    # Pass in df.tranpose() as hack until I fix specunit (otherwise it tries to
    # assign specunit to the index, which is a time index (this causes error in new pandas)
    return _genplot(out, **pltkwds)   #ts TRANSPOSE
    
if __name__ == '__main__':
    from pyuvvis.data import aunps_glass
    ts = aunps_glass()
#    specplot(ts)
    areaplot(ts)
    plt.show()
Exemplo n.º 5
0
                                   shrink=0.75) 
        
        cb = fig.colorbar(contours, cax=cax,**kw)# ticks=[0,zz.max().max()], **kw)
        cb.locator = mplticker.MaxNLocator(nbins=cbar_nticks+1) #Cuts off one usually
        cb.update_ticks()


    fig.suptitle(title, fontsize='large') # Still overpads
    return (ax1, ax2, ax3, ax4)

if __name__ == '__main__':

    from matplotlib import rc
    from pyuvvis.data import aunps_glass
    
    ts = aunps_glass().as_interval('s')
    ts.specunit = 'ev'
    xx,yy = np.meshgrid(ts.columns, ts.index)

    #_gencorr2d(xx, yy, ts, 
               #fill=True,
               #title='My baller plot',
               #xlabel=ts.full_varunit,
               #ylabel=ts.full_specunit,
               #contours=20,
               #cbar = True,
               #background=False)
 
#    _gen2d(xx, yy, ts, cbar=True, fill=True, contours=20)