[merge] changes to correlation picker from different machines that were not committed

This commit is contained in:
Marcel Paffrath 2024-08-07 10:17:35 +02:00
parent 14f01ec46d
commit d5817adc46
6 changed files with 80 additions and 6 deletions

View File

@ -12,3 +12,5 @@ dependencies:
- python=3.8.12 - python=3.8.12
- qt>=5.12.9 - qt>=5.12.9
- scipy=1.8.0 - scipy=1.8.0
- pyaml=6.0.1
- joblib=1.4.2

View File

@ -9,7 +9,7 @@ PyLoT - the Python picking and Localization Tool
This python library contains a graphical user interfaces for picking This python library contains a graphical user interfaces for picking
seismic phases. This software needs ObsPy (http://github.com/obspy/obspy/wiki) seismic phases. This software needs ObsPy (http://github.com/obspy/obspy/wiki)
and the Qt4 libraries to be installed first. and the Qt libraries to be installed first.
PILOT has been developed in Mathworks' MatLab. In order to distribute PILOT has been developed in Mathworks' MatLab. In order to distribute
PILOT without facing portability problems, it has been decided to re- PILOT without facing portability problems, it has been decided to re-

View File

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
#

View File

@ -2,22 +2,27 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
import os
import argparse import argparse
import copy import copy
import logging import logging
import random import random
import traceback import traceback
import glob
import json
from datetime import datetime
from typing import Any from typing import Any
import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import yaml import yaml
from code_base.fmtomo_tools.fmtomo_teleseismic_utils import *
from code_base.util.utils import get_metadata
from joblib import Parallel, delayed from joblib import Parallel, delayed
from obspy import read, Stream, Trace from obspy import read, Stream, UTCDateTime, Trace
from obspy.taup import TauPyModel
from obspy.core.event.base import WaveformStreamID, ResourceIdentifier from obspy.core.event.base import WaveformStreamID, ResourceIdentifier
from obspy.core.event.origin import Pick from obspy.core.event.origin import Pick
from obspy.geodetics.base import gps2dist_azimuth
from obspy.signal.cross_correlation import correlate, xcorr_max from obspy.signal.cross_correlation import correlate, xcorr_max
from pylot.core.io.inputs import PylotParameter from pylot.core.io.inputs import PylotParameter
@ -26,6 +31,8 @@ from pylot.core.pick.autopick import autopickstation
from pylot.core.util.utils import check4rotated from pylot.core.util.utils import check4rotated
from pylot.core.util.utils import identifyPhaseID from pylot.core.util.utils import identifyPhaseID
from pylot.core.util.event import Event as PylotEvent from pylot.core.util.event import Event as PylotEvent
from pylot.correlation.utils import (get_event_id, get_event_pylot, get_event_obspy_dmt, get_picks, write_json,
get_metadata)
class CorrelationParameters: class CorrelationParameters:

View File

@ -0,0 +1,61 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import glob
import json
from obspy import read_events
from pylot.core.util.dataprocessing import Metadata
from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT
def get_event_obspy_dmt(eventdir):
event_pkl_file = os.path.join(eventdir, 'info', 'event.pkl')
if not os.path.exists(event_pkl_file):
raise IOError('Could not find event path for event: {}'.format(eventdir))
event = qml_from_obspyDMT(event_pkl_file)
return event
def get_event_pylot(eventdir, extension=''):
event_id = get_event_id(eventdir)
filename = os.path.join(eventdir, 'PyLoT_{}{}.xml'.format(event_id, extension))
if not os.path.isfile(filename):
return
cat = read_events(filename)
return cat[0]
def get_event_id(eventdir):
event_id = os.path.split(eventdir)[-1]
return event_id
def get_picks(eventdir, extension=''):
event_id = get_event_id(eventdir)
filename = 'PyLoT_{}{}.xml'
filename = filename.format(event_id, extension)
fpath = os.path.join(eventdir, filename)
fpaths = glob.glob(fpath)
if len(fpaths) == 1:
cat = read_events(fpaths[0])
picks = cat[0].picks
return picks
elif len(fpaths) == 0:
print('get_picks: File not found: {}'.format(fpath))
return
print(f'WARNING: Ambiguous pick file specification. Found the following pick files {fpaths}\nFilemask: {fpath}')
return
def write_json(object, fname):
with open(fname, 'w') as outfile:
json.dump(object, outfile, sort_keys=True, indent=4)
def get_metadata(eventdir):
metadata_path = os.path.join(eventdir, 'resp')
metadata = Metadata(inventory=metadata_path, verbosity=0)
return metadata

View File

@ -10,3 +10,5 @@ pyside2=5.13.2
python=3.8.12 python=3.8.12
qt=5.12.9 qt=5.12.9
scipy=1.8.0 scipy=1.8.0
pyaml=6.0.1
joblib=1.4.2