Ejemplo n.º 1
0
def well_geometry_sparrow_export(file, folder, name):
    import utm
    from pyproj import Proj
    from pyrocko.model import Geometry
    data = num.loadtxt(file, delimiter=",")
    utmx = data[:, 0]
    utmy = data[:, 1]
    z = data[:, 2]

    proj_gk4 = Proj(init="epsg:31467")  # GK-projection
    lons, lats = proj_gk4(utmx, utmy, inverse=True)
    ev = event.Event(lat=num.mean(lats), lon=num.mean(lons), depth=num.mean(z),
                     time=util.str_to_time("2000-01-01 01:01:01"))

    ncorners = 4
    verts = []
    xs = []
    ys = []
    dist = 200.
    for i in range(0, len(z)):
        try:
            x = lats[i]
            y = lons[i]
            x1 = lats[i+1]
            y1 = lons[i+1]
            depth = z[i]
            depth1 = z[i+1]
            xyz = ([dist/2.8, dist/2.8, depth], [dist/2.8, dist/2.8, depth1],
                   [dist/2.8, -dist/2.8, depth1], [dist/2.8, -dist/2.8, depth])
            latlon = ([x, y], [x1, y1], [x1, y1], [x, y])
            patchverts = num.hstack((latlon, xyz))
            verts.append(patchverts)
        except Exception:
            pass

    vertices = num.vstack(verts)

    npatches = int(len(vertices))
    faces1 = num.arange(ncorners * npatches, dtype='int64').reshape(
        npatches, ncorners)
    faces2 = num.fliplr(faces1)
    faces = num.hstack((faces2, faces1))
    srf_semblance_list = []

    srf_semblance = num.ones(num.shape(data[:, 2]))
    srf_semblance = duplicate_property(srf_semblance)
    srf_semblance_list.append(srf_semblance)

    srf_semblance = num.asarray(srf_semblance_list).T
    srf_times = num.linspace(0, 1, 1)
    geom = Geometry(times=srf_times, event=ev)
    geom.setup(vertices, faces)
    sub_headers = tuple([str(i) for i in srf_times])
    geom.add_property((('semblance', 'float64', sub_headers)), srf_semblance)
    dump(geom, filename='geom_gtla1.yaml')
Ejemplo n.º 2
0
    def get_pyrocko_event(self):
        lat, lon, depth = self.position_values()
        otime = self.time.value
        if self.creation_info:
            cat = self.creation_info.agency_id
        else:
            cat = None

        return event.Event(name=self.public_id,
                           lat=lat,
                           lon=lon,
                           time=otime,
                           depth=depth,
                           catalog=cat,
                           region=self.region)
Ejemplo n.º 3
0
    def pyrocko_event(self):
        '''Considers only the *preferred* origin and magnitude'''
        lat, lon, depth = self.preferred_origin.position_values()
        otime = self.preferred_origin.time.value
        reg = self.region
        foc_mech = self.preferred_focal_mechanism
        if foc_mech is not None:
            mrr = foc_mech.moment_tensor_list[0].tensor.mrr.value
            mtt = foc_mech.moment_tensor_list[0].tensor.mtt.value
            mpp = foc_mech.moment_tensor_list[0].tensor.mpp.value
            mrt = foc_mech.moment_tensor_list[0].tensor.mrt.value
            mrp = foc_mech.moment_tensor_list[0].tensor.mrp.value
            mtp = foc_mech.moment_tensor_list[0].tensor.mtp.value
            mt = moment_tensor.MomentTensor(m_up_south_east=num.matrix(
                [[mrr, mrt, mrp], [mrt, mtt, mtp], [mrp, mtp, mpp]]))
        else:
            mt = None
        pref_mag = self.preferred_magnitude
        if pref_mag is None:
            mag = self.magnitude_list[0].mag.value
        else:
            mag = pref_mag.mag.value

        cat = None
        if self.preferred_origin.creation_info is not None:
            cat = self.preferred_origin.creation_info.agency_id

        reg = None
        if self.description_list:
            reg = self.description_list[0].text

        return event.Event(name=self.public_id,
                           lat=lat,
                           lon=lon,
                           time=otime,
                           depth=depth,
                           magnitude=mag,
                           region=reg,
                           moment_tensor=mt,
                           catalog=cat)
Ejemplo n.º 4
0
def from_palantiri():
    km = 1000.
    try:
        path = sys.argv[3]
        evpath = path
    except:
        path = None
        evpath = 'events/' + str(sys.argv[1])

    C = config.Config(evpath)
    Origin = C.parseConfig('origin')
    Config = C.parseConfig('config')
    cfg = ConfigObj(dict=Config)
    step = cfg.UInt('step')
    step2 = cfg.UInt('step_f2')
    duration = cfg.UInt('duration')
    forerun = cfg.UInt('forerun')
    deltat = step
    deltat2 = step2
    rel = 'events/' + str(sys.argv[1]) + '/work/semblance/'

    dimx = int(Config['dimx'])
    dimy = int(Config['dimy'])

    origin = OriginCfg(Origin)
    depth = origin.depth() * 1000.
    ev = event.Event(lat=origin.lat(),
                     lon=origin.lon(),
                     depth=depth,
                     time=util.str_to_time(origin.time()))
    data, data_int, data_boot, data_int_boot, path_in_str, maxs, datamax, n_files = load(
        0, path=path)
    values_orig = data[:, 2]
    values_orig = num.append(values_orig, num.array([0., 0.]))

    lat_orig = data[:, 1]
    lon_orig = data[:, 0]

    ncorners = 4
    lon_grid_orig = num.linspace(num.min(lat_orig), num.max(lat_orig), (dimy))
    lat_grid_orig = num.linspace(num.min(lon_orig), num.max(lon_orig), dimx)

    if path is None:
        ntimes = int((forerun + duration) / step)
    else:
        ntimes = n_files

    verts = []
    lon_diff = ((lon_orig)[dimy + 1] - (lon_orig)[0]) / 4.
    lat_diff = ((lat_orig)[1] - (lat_orig)[0]) / 4.

    dist = orthodrome.distance_accurate50m(lat_grid_orig[1], lon_grid_orig[1],
                                           lat_grid_orig[0], lon_grid_orig[0])

    for x, y in zip(lon_orig, lat_orig):

        xyz = ([dist / 2., dist / 2.,
                depth], [-dist / 2., dist / 2.,
                         depth], [-dist / 2., -dist / 2.,
                                  depth], [dist / 2., -dist / 2., depth])
        latlon = ([x, y], [x, y], [x, y], [x, y])
        patchverts = num.hstack((latlon, xyz))
        verts.append(patchverts)

    vertices = num.vstack(verts)

    npatches = int(len(vertices))  #*2?
    faces1 = num.arange(ncorners * npatches,
                        dtype='int64').reshape(npatches, ncorners)
    faces2 = num.fliplr(faces1)
    faces = num.vstack((faces2, faces1))
    srf_semblance_list = []
    for i in range(0, ntimes):
        if len(sys.argv) < 4:
            print("missing input arrayname")
        else:
            data, data_int, data_boot, data_int_boot, path_in_str, maxsb, datamaxb, n_files = load(
                0, step=i, path=path)
            srf_semblance = data[:, 2]
            srf_semblance = num.append(srf_semblance, num.array([0., 0.]))
            srf_semblance = duplicate_property(srf_semblance)
            srf_semblance_list.append(srf_semblance)

    srf_semblance = num.asarray(srf_semblance_list).T
    srf_times = num.linspace(0, forerun + duration, ntimes)
    geom = Geometry(times=srf_times, event=ev)
    geom.setup(vertices, faces)
    sub_headers = tuple([str(i) for i in srf_times])
    geom.add_property((('semblance', 'float64', sub_headers)), srf_semblance)
    dump(geom, filename='geom.yaml')