print subset_expr
		dictorigin, n = modgiseis.dbgetorigins(catalogpath, subset_expr)
		print "- number of events in past week = {}".format(n)

		# if > 0, load all time history and bin them 
		if n > 0:
			subset_expr = "time > %f && deg2km(distance(lat, lon, %s, %s))<20.0" % (epoch1989, lat[c], lon[c])
			print "'%s'" % subset_expr
                	dictorigin, n = modgiseis.dbgetorigins(catalogpath, subset_expr)
			print "- number of events in all-time = {}".format(n)
			time = dictorigin['time']
			time_firstevent = time[0] # assuming they are sorted
			if verbose:
				print 'firstevent: %s' % modgiseis.datenum2datestr(time_firstevent)
				print 'lastevent: %s' % modgiseis.datenum2datestr(time[-1])
			bin_edges, snum, enum = modgiseis.compute_bins(dictorigin, time_firstevent, datenumnow, 7.0) # function name is a misnomer - we are computing bin_edges

			# now we get our array of counts per week
			counts = modgiseis.bin_counts(dictorigin['time'], bin_edges)
        		energy = modgiseis.ml2energy(dictorigin['ml'])
        		binned_energy = modgiseis.bin_irregular(dictorigin['time'], energy, bin_edges)
			binned_ml = modgiseis.energy2ml(binned_energy)

			# check again that we really do have events in the last week
			if sum(counts[-2:-1]) > 0:
			#if sum(counts) > 0:
				if verbose:
					for index in [0, -2, -1]:
						print 'edge %d: %s' % (index, modgiseis.datenum2datestr(bin_edges[index]))
				VOLCANO.append(place[c])
				BIN_EDGES.append(bin_edges)
Example #2
0
		# 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

		# save the figure to outfile
		print "- saving to " + outfile
		fig1.savefig(outfile)
        # if > 0, load all time history and bin them
        if n > 0:
            subset_expr = "time > %f && deg2km(distance(lat, lon, %s, %s))<20.0" % (
                epoch1989, lat[c], lon[c])
            print "'%s'" % subset_expr
            dictorigin, n = modgiseis.dbgetorigins(catalogpath, subset_expr)
            print "- number of events in all-time = {}".format(n)
            time = dictorigin['time']
            time_firstevent = time[0]  # assuming they are sorted
            if verbose:
                print 'firstevent: %s' % modgiseis.datenum2datestr(
                    time_firstevent)
                print 'lastevent: %s' % modgiseis.datenum2datestr(time[-1])
            bin_edges, snum, enum = modgiseis.compute_bins(
                dictorigin, time_firstevent, datenumnow, 7.0
            )  # function name is a misnomer - we are computing bin_edges

            # now we get our array of counts per week
            counts = modgiseis.bin_counts(dictorigin['time'], bin_edges)
            energy = modgiseis.ml2energy(dictorigin['ml'])
            binned_energy = modgiseis.bin_irregular(dictorigin['time'], energy,
                                                    bin_edges)
            binned_ml = modgiseis.energy2ml(binned_energy)

            # check again that we really do have events in the last week
            if sum(counts[-2:-1]) > 0:
                #if sum(counts) > 0:
                if verbose:
                    for index in [0, -2, -1]:
                        print 'edge %d: %s' % (
Example #4
0
        # 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

        # save the figure to outfile
        print "- saving to " + outfile