lon_0=lon_0,
            lat_0=lat_0)

plt.figure(1)
ax1 = plt.subplot(111)
xpt_eq, ypt_eq = m(mSeis[1][sel], mSeis[2][sel])
ax1 = plt.scatter(xpt_eq, ypt_eq)
print("Please click %i times" % (dPar['nClicks']))
tCoord = plt.ginput(dPar['nClicks'])
print("clicked", tCoord)
plt.show()

aLon = np.array(tCoord).T[0] / 1000
aLat = np.array(tCoord).T[1] / 1000

#I cannot figure out how to do an equal distance coordinate system using basemap :(
#instead im plotting the coordinates the user put in? Not sure what the question is asking me to do

plt.figure(2)
ax2 = plt.subplot(111)
ax2 = plt.plot(aLat, aLon)
plt.show()

#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
#TODO: compute area using eis_utils.area_poly
A_seis = funcs.area_poly(aLon, aLat)
print('total area affected by seismicity: ', A_seis)
print('fraction of area of OK', A_seis / (dPar['areaOK']))  # about 1/3
Example #2
0
aLon =  np.array( tCoord).T[0]
aLat =  np.array( tCoord).T[1]


# project into equal area coordinate system
lon_0, lat_0 = .5*( dPar['xmin']+dPar['xmax']), .5*( dPar['ymin']+dPar['ymax'])
m = Basemap(llcrnrlon = dPar['xmin'], urcrnrlon=dPar['xmax'],
            llcrnrlat = dPar['ymin'], urcrnrlat=dPar['ymax'],
            projection=dPar['projection'], lon_0 = lon_0, lat_0 = lat_0)
#TODO: project into equal area coordinate system
m.drawstates()
aX, aY = m(aLon, aLat)
plt.plot(aX, aY)



#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
#TODO: compute area using seis_utils.area_poly
A_seis = seis_utils.area_poly(aLon*111, aLat*111)
print('total area affected by seismicity: ', A_seis)
print('fraction of area of OK', A_seis/(dPar['areaOK'])) # about 1/3







Example #3
0
# project into equal area coordinate system
mLoc = np.genfromtxt( file_eq, skip_header = 1, usecols=(7,8,10), dtype = float).T
# sort according to year of occurrence
sort_id = aTime.argsort()
aYr = aTime[sort_id]
mLoc= mLoc.T[sort_id].T


lon_0, lat_0 = .5*( dPar['xmin']+dPar['xmax']), .5*( dPar['ymin']+dPar['ymax'])
m = Basemap(llcrnrlon = dPar['xmin'], urcrnrlon=dPar['xmax'],
            llcrnrlat = dPar['ymin'], urcrnrlat=dPar['ymax'],
            projection=dPar['projection'], lon_0 = lon_0, lat_0 = lat_0)

m.drawcoastlines()
m.drawcountries()

#TODO: project into equal area coordinate system

aX, aY = m(  mLoc[0][sel_eq], mLoc[1][sel_eq])
plt.plot(  aX, aY, 'ro', ms = 2, mew = 1.5, mfc = 'none')

#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
#TODO: compute area using eis_utils.area_poly
A_seis = seis_utils.area_poly()
print ('total area affected by seismicity: ', A_seis)
print ('fraction of area of OK', A_seis/(dPar['areaOK'])) # about 1/3

Example #4
0
ax = plt.gca()
for y in np.linspace(m.ymax / 2, 19 * m.ymax / 2, 10):
    for x in np.linspace(m.xmax / 1, 19 * m.xmax / 1, 12):
        lon, lat = m(x, y, inverse=True)
        poly = m.tissot(lon,
                        lat,
                        2,
                        100,
                        facecolor='green',
                        zorder=5,
                        alpha=0.5)

plt.show()


def eq_rate(at, k_win):
    aS = np.arange(0, at.shape[0] - k_win, 1)
    aBin, aRate = np.zeros(aS.shape[0]), np.zeros(aS.shape[0])
    iS = 0
    for s in aS:
        i1, i2 = s, s + k_win
        aBin[iS] = (at[i1] + at[i2]) / 2
        aRate[iS] = k_win / (at[i2] - at[i1])
        iS += 1
    return aBin, aRate


A_seis = seis_utils.area_poly(mSeis, mWells)
print('total area affected by seismicity: ', A_seis)
print('fraction of area of OK', A_seis / (dPar['areaOK']))  # about 1/3
Example #5
0
            urcrnrlon=dPar['xmax'],
            llcrnrlat=dPar['ymin'],
            urcrnrlat=dPar['ymax'],
            projection=dPar['projection'],
            lon_0=lon_0,
            lat_0=lat_0)
#TODO: project into equal area coordinate system
m.drawstates()
m.drawparallels(np.arange(33, 38, 1), fmt='%i', labels=[1, 0, 0, 0])
m.drawmeridians(np.arange(-100, -92, 2), fmt='%i', labels=[0, 0, 0, 1])
ax = plt.gca()
for y in np.linspace(m.ymax / 20, 19 * m.ymax / 20, 10):
    for x in np.linspace(m.xmax / 20, 19 * m.xmax / 20, 12):
        lon, lat = m(x, y, inverse=True)
        poly = m.tissot(lon,
                        lat,
                        1.25,
                        100,
                        facecolor='green',
                        zorder=10,
                        alpha=0.5)
plt.show()

#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
#TODO: compute area using eis_utils.area_poly
A_seis = seis_utils.area_poly(aX, aY)
print('total area affected by seismicity: ', A_seis)
print('fraction of area of OK', A_seis / (dPar['areaOK']))  # about 1/3
m.drawstates()

plot4 = plt.scatter(xearth, yearth, c="red")
plot5 = plt.scatter(xwell, ywell, c="black")

tCoord = plt.ginput(n=-1, show_clicks=True)
X = np.array(tCoord).T[0]
Y = np.array(tCoord).T[1]

lon, lat = m(X, Y, inverse=True)

m = Basemap(
    llcrnrlon=dPar['xmin'],
    urcrnrlon=dPar['xmax'],
    llcrnrlat=dPar['ymin'],
    urcrnrlat=dPar['ymax'],
    lon_0=lon_0,
    lat_0=lat_0,
    resolution='l',
    projection='aea',
)

xconv, yconv = m(lon, lat)

xconv /= 1000
yconv /= 1000

area = seis_utils.area_poly(xconv, yconv)
print("The area encompassed is " + str(area) + " square kilometers which is " +
      str(area / 1800) + "% of the state!")
ax1 = plt.subplot(111)
ax1.plot(mWells[2], mWells[3], 'bv', ms=2, mew=1.5, mfc='none', alpha=.5)
ax1.plot(mSeis[1], mSeis[2], 'ro', ms=5, mew=1.5, mfc='none')
print("Please click %i times" % (dPar['nClicks']))
tCoord = plt.ginput(dPar['nClicks'])
print("clicked", tCoord)
plt.show()

aLon = np.array(tCoord).T[0]
aLat = np.array(tCoord).T[1]

# project into equal area coordinate system
lon_0, lat_0 = .5 * (dPar['xmin'] + dPar['xmax']), .5 * (dPar['ymin'] +
                                                         dPar['ymax'])
m = Basemap(llcrnrlon=dPar['xmin'],
            urcrnrlon=dPar['xmax'],
            llcrnrlat=dPar['ymin'],
            urcrnrlat=dPar['ymax'],
            projection=dPar['projection'],
            lon_0=lon_0,
            lat_0=lat_0)

aX, aY = m(aLon, aLat)

#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
A_seis = seis_utils.area_poly(aX * 1e-3, aY * 1e-3)
print 'total area affected by seismicity: ', A_seis
print 'fraction of area of OK', A_seis / (181 * 1e3)  # about 1/3
#TODO: plot seismicity
x,y = m(mSeis[1], mSeis[2])
seisPlot = plt.scatter(x,y, c=mSeis[3], s=np.exp(mSeis[3]))

print("Please click %i times"%(dPar['nClicks']))
tCoord = plt.ginput(dPar['nClicks'])
print("clicked", tCoord)
plt.show()

aLon = np.array(tCoord).T[0]
aLat = np.array(tCoord).T[1]
area = [aLon[0::]/1e3,aLat[0::]/ 1e3] #conversion to kilometers


#TODO: project into equal area coordinate system

#I'm not sure how to use equal area coordinate systems
polyPlot = plt.scatter(aLon,aLat)
plt.show()
        
#---------------------COMPUTE AFFECTED AREA--------------------
#TODO: compute area using seis_utils.area_poly
A_seis = seis_utils.area_poly(area[0],area[1])
print('total area affected by seismicity: ', A_seis)
print('fraction of area of OK', A_seis/(dPar['areaOK'])) #about 1/3





Example #9
0
        ax2.plot(xpt[j], ypt[j], 'ro')
print("Please click %i times" % (dPar['nClicks']))
tCoord = plt.ginput(dPar['nClicks'])
print("clicked", tCoord)
plt.show()

aLon = np.array(tCoord).T[0]
aLat = np.array(tCoord).T[1]

# project into equal area coordinate system
lon_0, lat_0 = .5 * (dPar['xmin'] + dPar['xmax']), .5 * (dPar['ymin'] +
                                                         dPar['ymax'])
m = Basemap(llcrnrlon=dPar['xmin'],
            urcrnrlon=dPar['xmax'],
            llcrnrlat=dPar['ymin'],
            urcrnrlat=dPar['ymax'],
            projection=dPar['projection'],
            lon_0=lon_0,
            lat_0=lat_0)

#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
# compute area using eis_utils.area_poly

A_seis = np.array([])
for n in range(0, len(mSeis[1])):
    A_seis = np.append(A_seis, seis_utils.area_poly(mSeis[1][n], mSeis[2][n]))
print('total area affected by seismicity: ', A_seis)
print('fraction of area of OK', A_seis / (dPar['areaOK']))  # about 1/3
Example #10
0
aLon =  np.array( tCoord).T[0]
aLat =  np.array( tCoord).T[1]


# project into equal area coordinate system
lon_0, lat_0 = .5*( dPar['xmin']+dPar['xmax']), .5*( dPar['ymin']+dPar['ymax'])
m = Basemap(llcrnrlon = dPar['xmin'], urcrnrlon=dPar['xmax'],
            llcrnrlat = dPar['ymin'], urcrnrlat=dPar['ymax'],
            projection=dPar['projection'], lon_0 = lon_0, lat_0 = lat_0)
#TODO: project into equal area coordinate system
???


#--------------------------3---------------------------------------------
#               compute affected area
#------------------------------------------------------------------------
#TODO: compute area using eis_utils.area_poly
xWell = np.genfromtxt( mWells, skip_header = 1, usecols=(3), delimiter=' ', dtype = int)
yWell = np.genfromtxt( mWells, skip_header = 1, usecols=(4), delimiter=' ', dtype = int)
A_seis = seis_utils.area_poly(xWell, yWell)
print 'total area affected by seismicity: ', A_seis
print 'fraction of area of OK', A_seis/(dPar['areaOK']) # about 1/3