Example #1
0
    orientations[inds] = numpy.nan

    pylab.draw()
    fig = pylab.figure()
    fig.set_facecolor('w')
    pylab.suptitle(fly['fileName'])
    for i, cT in enumerate(sky['changeTimes'][:-1]):
        pylab.subplot(5,4,1+i,polar=True)
        ax=pylab.gca()
        inds = (times > cT) & (times < sky['changeTimes'][i+1])
        ors = orientations[inds]
        ors = ors[~numpy.isnan(ors)]
        if len(ors)>0:
            orw,n,b,bc,ax = flypod.rose(ors,360)
            m=circmean(ors,high=180,low=-180)
            v=circvar(ors*numpy.pi/180,high=numpy.pi,low=-numpy.pi)
            hold('on')
            polar([0,numpy.pi/2-m*numpy.pi/180],[0,ax.get_rmax()*(1-v)])
            ax.set_rmax(.4)
            ax.set_rgrids([1],'')
            ax.set_thetagrids([0,90,180,270],['','','',''])
            title(sky['directions'][i])
            #ax.set_axis_bgcolor(COLORS[sky['directions'][i]])
            ax.axesPatch.set_facecolor(COLORS[sky['directions'][i]])
            ax.axesPatch.set_alpha(0.4)
            
            totals[sky['directions'][i]] = numpy.concatenate((totals[sky['directions'][i]],ors))
        
    pylab.draw()
        
    fig = pylab.figure()
import arcpy
from scipy.stats import morestats

raster_path = "data/aspect_raster.tif"
r = arcpy.RasterToNumPyArray(raster_path)

# can't take a log of 0, offset values
r += 0.01

print("""Circular Mean:\t\t\t{}
Circular Std. Dev.:\t\t\t{}
Circular Variance:\t\t\t{}
""".format(
    morestats.circmean(r),
    morestats.circstd(r),
    morestats.circvar(r)))
Example #3
0
 inds = (times - times[0]) > MAX_TIME
 orientations[inds] = numpy.nan
 
 for i, cT in enumerate(sky['changeTimes'][:-1]):
     inds = (times > cT+POSTCHANGE_BUFFER) & (times < sky['changeTimes'][i+1]-PRECHANGE_BUFFER)
     ors = orientations[inds]
     ors = ors[~numpy.isnan(ors)]
     if len(ors)>0:
         totals[sky['directions'][i]] = numpy.concatenate((totals[sky['directions'][i]],ors))
 
 for i, d in enumerate(COLORS):
     worldTotals = numpy.concatenate((worldTotals,totals[d]+ROTATIONS[d]))
 
 if totalTimeRecording[dNum] > MIN_TIME and (totalTimeRecording[dNum] - timeStopped[dNum]) > MIN_TIME*.8:
     M[dNum]=circmean(worldTotals,high=180,low=-180)
     V[dNum]=circvar(worldTotals*numpy.pi/180,high=numpy.pi,low=-numpy.pi)
     #meanAngSp[dNum] = numpy.mean(abs(numpy.diff(numpy.unwrap(orientations[~numpy.isnan(orientations)],180))))
     #V[dNum]=numpy.mean(abs(numpy.diff(worldTotals)))
     #fig = pylab.figure()
     pylab.subplot(4,5,dNum+1,polar=True)
     plotArgs = dict(color='k',linewidth=2)
     orw,n,b,bc,ax = flypod.rose(worldTotals,plotArgs=plotArgs)
     pylab.hold('on')
     
     #n={}
     for i, d in enumerate(COLORS):
         plotArgs = dict(color=COLORS[d],linewidth=.5)
         flypod.rose(totals[d]+ROTATIONS[d],plotArgs=plotArgs)
         #NUMBINS = 8
         #n[d], bins, patches = pylab.hist(numpy.mod(totals[d]+ROTATIONS[d],360),bins=numpy.arange(NUMBINS+1)*360/NUMBINS,range=(0,360),normed=True,visible=False)
         #bins[:-1]+numpy.diff(bins)/2.0
Example #4
0
import arcpy
from scipy.stats import morestats

raster_path = "data/aspect_raster.tif"
r = arcpy.RasterToNumPyArray(raster_path)

# can't take a log of 0, offset values
r += 0.01

print("""Circular Mean:\t\t\t{}
Circular Std. Dev.:\t\t\t{}
Circular Variance:\t\t\t{}
""".format(morestats.circmean(r), morestats.circstd(r), morestats.circvar(r)))