def post_process(self, engine, source, statics): campaign = gnss.GNSSCampaign() for ista in range(self.ntargets): north = gnss.GNSSComponent( shift=float(statics['displacement.n'][ista])) east = gnss.GNSSComponent( shift=float(statics['displacement.e'][ista])) up = gnss.GNSSComponent( shift=-float(statics['displacement.d'][ista])) coords = self.coords5 station = gnss.GNSSStation( lat=float(coords[ista, 0]), lon=float(coords[ista, 1]), east_shift=float(coords[ista, 2]), north_shift=float(coords[ista, 3]), elevation=float(coords[ista, 4]), north=north, east=east, up=up) campaign.add_station(station) return meta.GNSSCampaignResult(result=statics, campaign=campaign)
def load_ascii_gnss_globk(filedir, filename, components=['east', 'north', 'up']): """ Load ascii file columns containing: station name, Lon, Lat, ve, vn, vu, sigma_ve, sigma_vn, sigma_vu location [decimal deg] measurement unit [mm/yr] Returns ------- :class:`pyrocko.model.gnss.GNSSCampaign` """ from pyrocko.model import gnss filepath = os.path.join(filedir, filename) skiprows = 3 if os.path.exists(filepath): names = num.loadtxt(filepath, skiprows=skiprows, usecols=[12], dtype='str') d = num.loadtxt(filepath, skiprows=skiprows, usecols=range(12), dtype='float') elif len(os.path.splitext(filepath)[1]) == 0: logger.info('File %s is not an ascii text file!' % filepath) return else: raise ImportError('Did not find data under: %s' % filepath) component_to_idx_map = {'east': (2, 6), 'north': (3, 7), 'up': (9, 11)} # velocity_idxs = [2, 3, 9] # std_idxs = [6, 7, 11] if names.size != d.shape[0]: raise Exception('Number of stations and available data differs!') data = gnss.GNSSCampaign(name=filename) for i, name in enumerate(names): #code = str(name.split('_')[0]) # may produce duplicate sites code = str(name) gnss_station = gnss.GNSSStation(code=code, lon=float(d[i, 0]), lat=float(d[i, 1])) for j, comp in enumerate(components): vel_idx, std_idx = component_to_idx_map[comp] setattr( gnss_station, comp, gnss.GNSSComponent(shift=float(d[i, vel_idx] / km), sigma=float(d[i, std_idx] / km))) logger.debug('Loaded station %s' % gnss_station.code) data.add_station(gnss_station) return data
campaign = gnss.GNSSCampaign(name='Ridgecrest coseismic (UNR)') print('Loading Ridgecrest GNSS data from %s (max_dist = %.1f km)' % (fname, DIST_MAX / km)) # load station names and data with open(fname, 'r') as f: for header in range(2): next(f) names = [line.split(' ')[0] for line in f] gnss_data = num.loadtxt(fname, skiprows=2, usecols=(1, 2, 3, 4, 5, 6, 7, 8)) for ista, sta_data in enumerate(gnss_data): name = names[ista] lon, lat, de, dn, du, sde, sdn, sdu = map(float, sta_data) station = gnss.GNSSStation(code=name, lat=lat, lon=lon, elevation=0.) if station.distance_to(RIDGECREST_EQ) > DIST_MAX: continue station.east = gnss.GNSSComponent(shift=de, sigma=sde) station.north = gnss.GNSSComponent(shift=dn, sigma=sdn) station.up = gnss.GNSSComponent(shift=du, sigma=sdu) campaign.add_station(station) print('Selected %d stations, saving to ridgecrest_coseis_gnss.yml' % (campaign.nstations)) campaign.dump(filename='2019-ridgecrest_gnss_unr.yml') print('Creating map...')
fn_displacements = 'GPS_Data-Northridge-1994_Hudnut.csv' get_example_data(fn_stations) get_example_data(fn_displacements) campaign = gnss.GNSSCampaign(name='Northridge 1994') # Load the stations with open(fn_stations, 'r') as f: for line in f: if line.startswith('#'): continue row = line.split(',') sta = gnss.GNSSStation( code=row[0].strip(), lat=float(row[1]), lon=float(row[2]), elevation=float(row[3])) campaign.add_station(sta) # Load the displacements with open(fn_displacements, 'r') as f: for line in f: if line.startswith('#'): continue row = line.split(',') station_id = row[0].strip() station = campaign.get_station(station_id) station.east = gnss.GNSSComponent(