示例#1
0
	# if we loaded some events, create plots
	if numevents > 0:

		###### PLOT DATA HERE 

		# Let matplotlib automatically decide where to put date (x-axis) tick marks, and what style of labels to use
		locator = mpl.dates.AutoDateLocator()
		formatter = mpl.dates.AutoDateFormatter(locator)

		# create the figure canvas
		fig1 = plt.figure()

		# add subplot - ml versus time
		ax1 = fig1.add_subplot(311)
		modgiseis.plot_time_ml(ax1, dictorigin, locator, formatter, snum, enum)

		if numevents > 1:

			# Compute bin_edges based on the first and last event times
			bin_edges, snum, enum = modgiseis.compute_bins(dictorigin, snum, enum)
	
			# add subplot - counts versus time
			ax2 = fig1.add_subplot(312)
			modgiseis.plot_counts(ax2, dictorigin, locator, formatter, bin_edges, snum, enum)
		
			# add subplot - energy versus time
			ax3 = fig1.add_subplot(313)
			modgiseis.plot_energy(ax3, dictorigin, locator, formatter, bin_edges, snum, enum)

		####### SAVE FIGURE
	        ### Last week plot
	        print "- Last week plot"
	        subset_expr = radius_expr + " && ml > -2 && time > " + str(epoch1weekago)
	        print "- subsetting with\n\t" + subset_expr
	        dictorigin = dict();
      		dictorigin, n_week[record['place']] = dbgetorigins(db, subset_expr)
        	if n_week[record['place']] > 0:
			binsize = 1.0
                        #locator = mpl.dates.AutoDateLocator()
                        locator = mpl.dates.DayLocator()
                        #formatter = mpl.dates.AutoDateFormatter(locator)
                        formatter = mpl.dates.DateFormatter('%d\n%b')
			bin_edges = np.arange(snum1weekago, enum, binsize)
        	        ax1 = fig1.add_subplot(221)
        	        giseis.plot_time_ml(ax1, dictorigin, locator, formatter, snum1weekago, enum)
        	        ax2 = fig1.add_subplot(222)
        	        giseis.plot_counts(ax2, dictorigin, locator, formatter, bin_edges, snum1weekago, enum)
	
	        ### Last year plot
	        print "- Last year plot"
	        subset_expr = radius_expr + " && ml > -2 && time > " + str(epoch1yearago)
	        print "- subsetting with\n\t" + subset_expr
	        dictorigin = dict();
	        dictorigin, n_year[record['place']] = dbgetorigins(db, subset_expr)
	        if n_year[record['place']] > 0:
			binsize = 7.0
	                #locator = mpl.dates.AutoDateLocator()
	                locator = mpl.dates.MonthLocator()
                	#formatter = mpl.dates.AutoDateFormatter(locator)
			formatter = mpl.dates.DateFormatter('%b\n%Y')