Esempio n. 1
0
def plotLoop(myFiles,fbase,tlist,grid,plot,vmax,vwidth,d,dateStr):
	import datetime as dt
	#print args
	#myFiles,fbase,tlist,grid = args
	#create a pygrid item
	myGrid = pygrid()
	#create a MPL figure
	myFig = plt.figure()
	print tlist
	#draw a map
	myMap = drawPygridMap(myFig,myGrid,grid=grid)
	for ctime in tlist:
		
		myGrid.delVecs()
		print ctime
		print 'plotting'
		#read the files we have opened
		for f in myFiles:
			#print 'reading'
			#read a record
			print ctime
			readPygridRec(f,myGrid,datetimeToEpoch(ctime),-1)
			
		t1=dt.datetime.now()
		#get the vectors
		print 'drawing'
		
		circs,lines,intensities = drawPygridVecs(myGrid,myMap,plot=plot,vmax=vmax)

		#add the collection of vectors to the figure
		ccoll = plt.scatter(circs[0],circs[1],s=.5,c='k')
		lcoll = LineCollection(numpy.array(lines),linewidths=vwidth,zorder=10)
		lcoll.set_array(numpy.array(intensities))
		myFig.gca().add_collection(lcoll)
		
		#do the colormapping
		pydarn.plot.plotUtils.genCmap(myMap,lcoll,'grid',[0,vmax],colors='aj',map=1)
		
		txt = plt.figtext(.5,.95,ctime.strftime("%Y/%m/%d  %H:%M:%S"),weight=550,size='large',ha='center')
		t2 = dt.datetime.now()
		myFig.savefig(d+'/'+str(int(datetimeToEpoch(ctime)))+'.'+fbase+'.'+plot+'.svg', bbox_inches=0)
		t3 = dt.datetime.now()
		print 'drawing took', t2-t1
		print 'saving took',t3-t2
		ccoll.remove()
		lcoll.remove()
		myFig.texts.remove(txt)