コード例 #1
0
def get_line_parallels(pts, rngkm):
    from obspy.core.util.geodetics import gps2DistAzimuth
    from mapping_tools import reckon
    '''
    pts are an N x [lon, lat] matrix, i.e.:
                   [[lon1, lat1],
                    [lon2, lat2]]
    '''
    # set outputs
    posazpts = []
    negazpts = []

    for j, pt in enumerate(pts):
        # if 1st point
        if j == 0:
            rngm, az, baz = gps2DistAzimuth(pts[j][1], pts[j][0], \
                                            pts[j+1][1], pts[j+1][0])

        # if last point
        elif j == len(pts) - 1:
            rngm, az, baz = gps2DistAzimuth(pts[j-1][1], pts[j-1][0], \
                                            pts[j][1], pts[j][0])

        # use points either side (assumes evenly spaced)
        else:
            rngm, az, baz = gps2DistAzimuth(pts[j-1][1], pts[j-1][0], \
                                            pts[j+1][1], pts[j+1][0])

        # get azimuth for new points
        azpos = az + 90.
        azneg = az - 90.
        # get points
        posazpts.append(reckon(pts[j][1], pts[j][0], rngkm, azpos))
        negazpts.append(reckon(pts[j][1], pts[j][0], rngkm, azneg))
    '''    
    # for testing only
    x=[]
    y=[]
    xx=[]
    yy=[]
    xxx=[]
    yyy=[]
    for j, pt in enumerate(pts):
        x.append(pt[0])
        y.append(pt[1])
        xx.append(posazpts[j][0])
        yy.append(posazpts[j][1])
        xxx.append(negazpts[j][0])
        yyy.append(negazpts[j][1])
        
    plt.plot(x,y,'b-')
    plt.plot(xx,yy,'r-')
    plt.plot(xxx,yyy,'g-')
    plt.show()
    '''
    return posazpts, negazpts
コード例 #2
0
def get_centre_ray(elon, elat, slon, slat):
    """ locates the centre point of a ray.  An alternitive to this
    would be to locate the deepest point of the ray, but this is
    unessecery
    """
    from mapping_tools import distance, reckon
    
    rngkm, az, baz = distance(elat, elon, slat, slon)
    clon, clat = reckon(elat, elon, rngkm/2., az)
    
    return clon, clat
コード例 #3
0
def get_centre_ray(elat, elon, slat, slon, evdp):
    """ locates the centre point of a ray.  An alternitive to this
    would be to locate the deepest point of the ray, but this is
    unessecery
    """
    '''
    ray = calculate_ray(elat, elon, slat, slon, evdp)
    centre_idx = int(len(ray)/2)
    '''

    rngkm, az, baz = distance(elat, elon, slat, slon)
    lonlat = reckon(elat, elon, rngkm / 2., az)

    return lonlat
コード例 #4
0
from mapping_tools import reckon, distance

lon1 = 131.0
lat1 = -11.5
lon2 = 134.5
lat2 = -17.0

rngkm, az, baz = distance(lat1, lon1, lat2, lon2)

# get inc distance
npts = 16
inckm = rngkm / (npts - 1)

plats = []
plons = []
csvtxt = ''

for i in range(0, npts):

    lon2d, lat2d = reckon(lat1, lon1, i * inckm, az)
    plats.append(lat2d)
    plons.append(lon2d)

    csvtxt += ','.join((str('%0.4f' % lon2d), str('%0.4f' % lat2d))) + '\n'

f = open('north_aus_profile.csv', 'wb')
f.write(csvtxt)
f.close()
コード例 #5
0
 
 x, y = m(array(stlo), array(stla))
 m.scatter(x, y, c=vel, marker='o', s=40, cmap='seismic', norm=norm, alpha=1.0, zorder=1000)
 
 # add p/s wave trains
 if mt >= 0.0:
    # add epicentre star
    x, y = m(ev['lon'], ev['lat'])
    m.plot(x, y, 'r*', ms=25, label='Epicentre')
    
    # add p-wave
    p_radius = interp(mt, ptimes, kmrng)
    px = []
    py = []
    for az in azimuths:
        xy = reckon(ev['lat'], ev['lon'], p_radius, az)
        px.append(xy[0])
        py.append(xy[1])
    
    x, y = m(px, py)
    m.plot(x, y, '-', c='royalblue', lw=1.5, label='P-Phase')
    
    # add s-wave
    s_radius = interp(mt, stimes, kmrng)
    px = []
    py = []
    for az in azimuths:
        xy = reckon(ev['lat'], ev['lon'], s_radius, az)
        px.append(xy[0])
        py.append(xy[1])
    
コード例 #6
0
    discLon = []
    discLat = []
    discAzm = []
    remainder = discLen  #+ discLen/2.
    for poly in flolas:
        for i in range(1, len(poly[0])):
            # get dist from point 1 to point 2
            rng, az, baz = distance(poly[1][i - 1], poly[0][i - 1], poly[1][i],
                                    poly[0][i])

            lens = arange(discLen - remainder, rng, discLen)

            # get xy locs for lens
            if len(lens) > 0:
                for l in lens:
                    discPos = reckon(poly[1][i - 1], poly[0][i - 1], l, az)
                    discLon.append(discPos[0])
                    discLat.append(discPos[1])
                    discAzm.append(az)

                remainder = rng - lens[-1]
            else:
                remainder += rng

    # now, at each point, make dip triangle
    for dlo, dla, daz in zip(discLon, discLat, discAzm):
        # pt1
        triLons = [reckon(dla, dlo, halfTriLen, daz)[0]]
        triLats = [reckon(dla, dlo, halfTriLen, daz)[1]]

        # pt2
コード例 #7
0
# make 50-km grid the ugly way
###############################################################################

cell_size = 30.
min_nresp = 2

grd_lons = []
grd_lats = []
grd_geom = []
grd_mmi = []
grd_count = []
lon_grd = minlon

while lon_grd < maxlon:
    lat_grd = minlat
    nxt_lon, tmp_lat = reckon(lat_grd, lon_grd, cell_size * 0.95, 90)

    while lat_grd < maxlat:
        tmp_lon, nxt_lat = reckon(lat_grd, lon_grd, cell_size, 0)

        # fill grids
        geom = [[lon_grd, lat_grd], [lon_grd, nxt_lat], [nxt_lon, nxt_lat],
                [nxt_lon, lat_grd], [lon_grd, lat_grd]]
        grd_geom.append(geom)

        # check if mmi data exists
        min_nresp = 2
        idx1 = where((cent_lonlist >= lon_grd) & (cent_lonlist < nxt_lon) & (cent_mmi >= 2.) \
                    & (cent_latlist >= lat_grd) & (cent_latlist < nxt_lat) & (cent_nresp >= min_nresp))[0]

        idx2 = where((cent_lonlist >= lon_grd) & (cent_lonlist < nxt_lon) & \
コード例 #8
0
pftxt = ''
nftxt = ''

h_rng = (rupwid / 2.) * cos(radians(dip))
v_rng = (rupwid / 2.) * sin(radians(dip))
d_rng = sqrt(h_rng**2 + (ruplen / 2.)**2)
ztor = dep - v_rng
zbor = dep + v_rng

# get surf projection
az = degrees(arctan((ruplen / 2.) / h_rng))
baz = 90 - az
ang = stk - 180 + baz

crn = reckon(lat, lon, d_rng, ang)
ftxt = '\t'.join(
    (str('%0.4f' % crn[0]), str('%0.4f' % crn[1]), str('%0.2f' % ztor))) + '\n'
ln1 = ftxt.strip('\n')

ang = stk - baz
crn = reckon(lat, lon, d_rng, ang)
ftxt += '\t'.join(
    (str('%0.4f' % crn[0]), str('%0.4f' % crn[1]), str('%0.2f' % ztor))) + '\n'

ang = stk + baz
crn = reckon(lat, lon, d_rng, ang)
ftxt += '\t'.join(
    (str('%0.4f' % crn[0]), str('%0.4f' % crn[1]), str('%0.2f' % zbor))) + '\n'

ang = stk - 180 - baz
コード例 #9
0
oq_dist = []
for la, lo in zip(shla, shlo):
    oq_dist.append(distance(la, lo, loc_lat, loc_lon)[0])

# plt pts within cutoff
oq_dist = array(oq_dist)
idx = where(oq_dist <= dist_cutoff)[0]
x, y = m(shlo[idx], shla[idx])
m.plot(x, y, 'r+', ms=10, mew=1.5)

# draw cut-off boundary
cutaz = arange(0, 360, 0.5)
cutla = []
cutlo = []
for az in cutaz:
    cutlo.append(reckon(loc_lat, loc_lon, dist_cutoff, az)[0])
    cutla.append(reckon(loc_lat, loc_lon, dist_cutoff, az)[1])
cutlo.append(cutlo[0])
cutla.append(cutla[0])

# plt ring
x, y = m(cutlo, cutla)
m.plot(x, y, '-', c='seagreen', lw=3)

# plt site
x, y = m(loc_lon, loc_lat)
m.plot(x, y, 'r*', ms=30)

#plt.title('OpenQuake-engine', fontsize=22)
#plt.savefig('oq_schematic.png', fmt='png', bbox_inches='tight')