Ejemplo n.º 1
0
def plot_small_map_for_F():
    from sito.stations import IPOCStations
    from matplotlib.lines import Line2D

    ipoc = IPOCStations()
    ipoc.pick('PATCX')
    m = map.createIPOCMap(show=False, ll=(-24, -70.9), ur=(-18, -68.5),
                          earthquake='Tocopilla_position', stations=ipoc,
                          cities='Tocopilla')
Ejemplo n.º 2
0
def main():
    ipoc = IPOCStations()
    lats = -25, 17
    lons = -74, -66

    lats = np.linspace(-25, -17, 1500)
    lons = np.linspace(-74, -66, 1500)
    velocity = 3
    #    print 'x, y=', utlGeoKm(lons[0], lats[0], lons[-1], lats[-1])
    #    print 'dx, dy=', utlGeoKm(lons[0], lats[0], lons[-1], lats[-1]) / np.array((len(lons), len(lats)))
    #    print 'wave in km = ', (ms[0].stats.endtime - ms[0].stats.starttime) * 3.0
    #    print 'dx of wave=', ms[0].stats.delta * 3.0

    from mpl_toolkits.basemap import Basemap
    m = Basemap(llcrnrlon=lons[0],
                llcrnrlat=lats[0],
                urcrnrlon=lons[-1],
                urcrnrlat=lats[-1],
                lat_0=-21,
                lon_0=-70,
                projection='stere',
                resolution='l',
                ax=None)
    m.drawcountries(linewidth=0.5)
    m.drawcoastlines()
    #    m.drawmapboundary(fill_color='aqua')
    m.drawmapboundary()
    m.fillcontinents(color='coral', lake_color='aqua', zorder=0)
    # draw parallels and meridians.
    m.drawparallels(np.arange(-90., 120., 1.))
    m.drawmeridians(np.arange(0., 390., 1.))
    ipoc.plot(m)
    #wiggles = dict(PB02=66, PB04=60, PB07=60)
    wiggles2 = dict(PB02=100,
                    PB03=130,
                    PB04=143,
                    PB07=105,
                    PB09=82,
                    PB10=100,
                    PB14=90,
                    PATCX=125)

    #    for st, rad in wiggles.iteritems():
    #        m.plot(*equi(m, ipoc[st].latitude, ipoc[st].longitude, 0.5 * rad * velocity, indeg=False))
    for st, rad in wiggles2.iteritems():
        m.plot(*equi(m,
                     ipoc[st].latitude,
                     ipoc[st].longitude,
                     0.5 * rad * velocity,
                     indeg=False))

    plt.show()
    #plt.savefig('/home/richter/Results/IPOC/xcorr/1bit/migration/migration3_station_%s_2Hz_600x600_interference' % key)
    plt.close()
Ejemplo n.º 3
0
def main():
    ipoc = IPOCStations()
    lats = -25, 17
    lons = -74, -66

    lats = np.linspace(-25, -17, 1500)
    lons = np.linspace(-74, -66, 1500)
    velocity = 3
#    print 'x, y=', utlGeoKm(lons[0], lats[0], lons[-1], lats[-1])
#    print 'dx, dy=', utlGeoKm(lons[0], lats[0], lons[-1], lats[-1]) / np.array((len(lons), len(lats)))
#    print 'wave in km = ', (ms[0].stats.endtime - ms[0].stats.starttime) * 3.0
#    print 'dx of wave=', ms[0].stats.delta * 3.0


    from mpl_toolkits.basemap import Basemap
    m = Basemap(llcrnrlon=lons[0], llcrnrlat=lats[0], urcrnrlon=lons[-1], urcrnrlat=lats[-1],
                lat_0= -21, lon_0= -70, projection='stere', resolution='l', ax=None)
    m.drawcountries(linewidth=0.5)
    m.drawcoastlines()
#    m.drawmapboundary(fill_color='aqua')
    m.drawmapboundary()
    m.fillcontinents(color='coral', lake_color='aqua', zorder=0)
    # draw parallels and meridians.
    m.drawparallels(np.arange(-90., 120., 1.))
    m.drawmeridians(np.arange(0., 390., 1.))
    ipoc.plot(m)
    #wiggles = dict(PB02=66, PB04=60, PB07=60)
    wiggles2 = dict(PB02=100, PB03=130, PB04=143, PB07=105, PB09=82, PB10=100, PB14=90, PATCX=125)

#    for st, rad in wiggles.iteritems():
#        m.plot(*equi(m, ipoc[st].latitude, ipoc[st].longitude, 0.5 * rad * velocity, indeg=False))
    for st, rad in wiggles2.iteritems():
        m.plot(*equi(m, ipoc[st].latitude, ipoc[st].longitude, 0.5 * rad * velocity, indeg=False))


    plt.show()
    #plt.savefig('/home/richter/Results/IPOC/xcorr/1bit/migration/migration3_station_%s_2Hz_600x600_interference' % key)
    plt.close()
Ejemplo n.º 4
0
def createIPOCMap(**kwargs_in):
    dict_basemap_ipoc = dict(lat_0=-21,
                             lon_0=-69.5,
                             projection='stere',
                             resolution='h')
    kwargs = dict(ll=(-25, -72),
                  ur=(-17.5, -68),
                  figsize=(15 / 2.54, 18 * 1.5 / 2.54),
                  margin=(0.15, 0.075, 0.7, 0.85),
                  dict_basemap=dict_basemap_ipoc,
                  grid=True,
                  watercolor=None,
                  fillcontinents=None,
                  stations='ipoc')
    kwargs.update(kwargs_in)
    if kwargs['stations'] == 'ipoc':
        from sito.stations import IPOCStations
        stations = IPOCStations()
        stations['PB13/PB16'] = stations['PB13']
        del stations['PB13']
        del stations['PB16']
        kwargs['stations'] = stations
    return createMap(**kwargs)
Ejemplo n.º 5
0
def main():
    ipoc = IPOCStations()
    ms = read('/home/richter/Results/IPOC/xcorr/1bit/stack/all_stack_-1.QHD')
    setHIDist(ms, ipoc)
    #    for tr in ms:
    #        st = tr.stats.station
    #        if 'PB12' in st or 'PAT' in st or 'HMBC' in st or 'LVC' in st:
    #            ms.remove(tr)
    print(list(set(ms[0].stats.station.split('-'))))[0]
    ms = ms.select(
        "(st.station.split('-'))[0][:-1] in 'PB03 PB04 PB07 PB09 PB10 PB14 PATCX'.split()"
    )
    ms = ms.select(autocorr=True)
    #    ms.plot_(-200, 200, relative='middle', absolutescale=10, annotate=True)
    #    ms.plotXcorrVsDist(-300, 300, absolutescale=200)
    #    ms.plotXcorrVsDist(-300, relative='starttime', absolutescale=500)
    #    plt.show()
    #    ms.filter2(0.05, 0.5)

    #ms = ms.select('st.dist<455')
    ms.addXcorrSides()
    #    for tr in ms:
    #        tr.data = envelope(tr.data)
    #    ms.normalize()
    ms.downsample2(5)
    #    ms.trim2(100 + np.array(ms.getHI('dist')) / 3., None)
    #    ms.plotXcorrVsDist(0, 300, relative='starttime')
    #    ms.plot_(absolutescale=1)
    #    ms = ms[:1]
    #    ms = ms[:1]
    #    ms.plot_()
    #    plt.show()
    #    return
    print ms

    lats = np.linspace(-25, -17, 1500)
    lons = np.linspace(-74, -66, 1500)
Ejemplo n.º 6
0
def plot_results1(map_dic=None, scale=1):
    from sito.stations import IPOCStations
    from matplotlib.lines import Line2D
    # see /home/richter/Results/IPOC/veldrop_vs_groundmotion_stations.txt
    map_dic2 = dict(show=False, ll=(-25, -71.25), ur=(-18, -68.25),
                    slip=get_slipmodel(), cities='ipoc', stations=None)
    if map_dic is not None:
        map_dic2.update(map_dic)
    map_dic = map_dic2
    m = map.createIPOCMap(**map_dic)
    marker = 'o'
    scale2 = 2.
    ipoc = IPOCStations()
    ipoc_no_data = ipoc.pick('PB09 PB10 PB11 PB12 PB13 PB14 PB15', replace=False)
    ipoc_no_data.plot(m, marker=marker, mfc='w', ms=8 * scale, zorder=20)
    #1-3Hz
    ipoc_bad_data = ipoc.pick('MNMCX ', replace=False)
    ipoc_no_signal = ipoc.pick('LVC PB02 PB06 PB08 PSGCX', replace=False)  #<0.2%
    ipoc_small_signal = ipoc.pick('HMBCX PATCX PB01 PB03 PB04 PB05 PB07', replace=False)  #0.2-0.5%
    ipoc_big_signal = ipoc.pick('PB04 PB05', replace=False)  #>0.5%

    ipoc_bad_data.plot(m, marker=marker, mfc='#00FFFF', ms=8 * scale * scale2, zorder=20)
    ipoc_no_signal.plot(m, marker=marker, mfc='y', ms=8 * scale * scale2, zorder=20)
    ipoc_small_signal.plot(m, marker=marker, mfc='orange', ms=8 * scale * scale2, zorder=20)
    ipoc_big_signal.plot(m, marker=marker, mfc='r', ms=8 * scale * scale2, zorder=20)

    #4-6Hz
    ipoc_bad_data = ipoc.pick('', replace=False)
    ipoc_no_signal = ipoc.pick('HMBCX MNMCX PB01 PB06 LVC', replace=False)  #<0.2%
    ipoc_small_signal = ipoc.pick('PB04 PB05 PB07 PB08 PSGCX ', replace=False)  #0.2-0.5%
    ipoc_big_signal = ipoc.pick('PB02 PB03 PATCX', replace=False)  #>0.5%

    ipoc_bad_data.plot(m, marker=marker, mfc='#00FFFF', ms=8 * scale, zorder=21, annotate=False)
    ipoc_no_signal.plot(m, marker=marker, mfc='y', ms=8 * scale, zorder=21, annotate=False)
    ipoc_small_signal.plot(m, marker=marker, mfc='orange', ms=8 * scale, zorder=21, annotate=False)
    ipoc_big_signal.plot(m, marker=marker, mfc='r', ms=8 * scale, zorder=21, annotate=False)

    colors = 'w #00FFFF y orange r'.split()
    labels = 'no data,bad data,<0.2%,0.2-0.5%,>0.5%,1Hz-3Hz\n4Hz-6Hz'.split(',')
    legend_kwargs = dict(loc='center left', bbox_to_anchor=(1.22, 0.5))

    def myhandler(legend, orig_handle, fontsize, handlebox):
        w, h, x, y = handlebox.width, handlebox.height, handlebox.xdescent, handlebox.ydescent
        xm, ym = x + w / 2, y + h / 2
        s1, s2 = 4 * scale, 4 * scale * scale2
        a_list = [Line2D((xm, xm + 0.7 * w), (ym, 0.8 * ym + h), color='k'),
                  Line2D((xm,), (ym,), marker=marker, ms=2 * s2, color='w'),
                  Line2D((xm, xm + 0.7 * w), (ym, ym - 0.5 * h), color='k'),
                  Line2D((xm,), (ym,), marker=marker, ms=2 * s1, color='w')]
        for a in a_list:
            handlebox.add_artist(a)
    mpl.legend.Legend.update_default_handler_map({None: myhandler})
    plt.gca().legend([Line2D((0,), (1,), marker=marker, ls='', mfc=c, ms=8 * scale) for c in colors] +
              [None], labels, numpoints=1, **legend_kwargs)
    mpl.rcParams.update({'lines.linewidth':1.})
    m.drawmapscale(-68.7, -24., -70, -21.5, 50, fontsize=7, yoffset=0.005 * (m.ymax - m.ymin))
    plt.gcf().savefig('/home/richter/Documents/pics/maps/ipoc/ipoc_map_results3.pdf')
Ejemplo n.º 7
0
    ms = stream.copy()
    ms.addXcorrSides()
    for tr in ms:
        tr.data = np.abs(envelope(tr.data))
    dists = ms.getHI('dist')
    maxi = ms.getMaxima()
    v, _ = curve_fit(lambda x, a: x * a, maxi, dists, p0=1)
    return v[0]


#ms = read('/home/richter/Results/IPOC/xcorr/FINAL_filter0.01-0.5_1bit_whitening/stack/day_PB0[12345]Z-PB0[12345]Z_stack_all.QHD')
path = '/home/richter/Results/IPOC/xcorr/FINAL_filter0.01-0.5_1bit_whitening'
ms = read(path + '/stack/day_*_stack_all.QHD')
output = path + '/xcorr_vs_dist.pdf'

ipoc = IPOCStations()
setHIDist(ms, ipoc)

print 'no correlation for pairs:', no_corr_pairs(ms, ipoc)
v = get_vel(ms)
#v = 3.03093386
print 'velocity:', v
fig = plt.figure(figsize=(10, 12))
plot = ms.plotXcorrVsDist(-300,
                          300,
                          scale=10,
                          fig=fig,
                          figtitle='%d cross-correlations' % len(ms))
plot.ax.plot((-300, 0, 300), (300 * v, 0, 300 * v), 'r')

d = 30