changes made to have better control of the output directory
This commit is contained in:
parent
08df7c3304
commit
4962561d6c
@ -270,19 +270,20 @@ def picks_from_picksdict(picks):
|
||||
return picks_list
|
||||
|
||||
|
||||
def reassess_pilot_db(root_dir, out_dir=None, fn_param=None, verbosity=0):
|
||||
def reassess_pilot_db(root_dir, db_dir, out_dir=None, fn_param=None, verbosity=0):
|
||||
import glob
|
||||
|
||||
evt_list = glob.glob1(root_dir,'e????.???.??')
|
||||
db_root = os.path.join(root_dir, db_dir)
|
||||
evt_list = glob.glob1(db_root,'e????.???.??')
|
||||
|
||||
for evt in evt_list:
|
||||
if verbosity > 0:
|
||||
print('Reassessing event {0}'.format(evt))
|
||||
reassess_pilot_event(root_dir, evt, out_dir, fn_param, verbosity)
|
||||
reassess_pilot_event(root_dir, db_dir, evt, out_dir, fn_param, verbosity)
|
||||
|
||||
|
||||
|
||||
def reassess_pilot_event(root_dir, event_id, out_dir=None, fn_param=None, verbosity=0):
|
||||
def reassess_pilot_event(root_dir, db_dir, event_id, out_dir=None, fn_param=None, verbosity=0):
|
||||
from obspy import read
|
||||
|
||||
from pylot.core.io.inputs import AutoPickParameter
|
||||
@ -294,7 +295,7 @@ def reassess_pilot_event(root_dir, event_id, out_dir=None, fn_param=None, verbos
|
||||
|
||||
default = AutoPickParameter(fn_param, verbosity)
|
||||
|
||||
search_base = os.path.join(root_dir, event_id)
|
||||
search_base = os.path.join(root_dir, db_dir, event_id)
|
||||
phases_file = glob.glob(os.path.join(search_base, 'PHASES.mat'))
|
||||
if not phases_file:
|
||||
return
|
||||
@ -335,7 +336,9 @@ def reassess_pilot_event(root_dir, event_id, out_dir=None, fn_param=None, verbos
|
||||
continue
|
||||
sel_st = select_for_phase(st, phase)
|
||||
if not sel_st:
|
||||
warnings.warn('no waveform data found for station {station}'.format(station=station), RuntimeWarning)
|
||||
msg = 'no waveform data found for station {station}'.format(station=station)
|
||||
warnings.warn(msg, RuntimeWarning)
|
||||
continue
|
||||
stime, etime = getGlobalTimes(sel_st)
|
||||
rel_pick = mpp - stime
|
||||
epp, lpp, spe = earllatepicker(sel_st,
|
||||
@ -367,8 +370,11 @@ def reassess_pilot_event(root_dir, event_id, out_dir=None, fn_param=None, verbos
|
||||
evt.picks = picks_from_picksdict(picks_dict)
|
||||
# write phase information to file
|
||||
if not out_dir:
|
||||
fnout_prefix = os.path.join(root_dir, event_id, '{0}.'.format(event_id))
|
||||
fnout_prefix = os.path.join(root_dir, db_dir, event_id, '{0}.'.format(event_id))
|
||||
else:
|
||||
out_dir = os.path.join(out_dir, db_dir)
|
||||
if not os.path.isdir(out_dir):
|
||||
os.makedirs(out_dir)
|
||||
fnout_prefix = os.path.join(out_dir, '{0}.'.format(event_id))
|
||||
evt.write(fnout_prefix + 'xml', format='QUAKEML')
|
||||
#evt.write(fnout_prefix + 'cnv', format='VELEST')
|
||||
|
@ -19,8 +19,10 @@ if __name__ == '__main__':
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'dbroot', type=str, help='specifies the root directory (in '
|
||||
'most cases PILOT database folder)'
|
||||
'root', type=str, help='specifies the root directory'
|
||||
)
|
||||
parser.add_argument(
|
||||
'db', type=str, help='specifies the database name'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--output', '-o', type=str, help='path to the output directory',
|
||||
@ -36,4 +38,4 @@ if __name__ == '__main__':
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
reassess_pilot_db(args.dbroot, args.output, args.parfile, args.verbosity)
|
||||
reassess_pilot_db(args.root, args.db, args.output, args.parfile, args.verbosity)
|
||||
|
@ -19,8 +19,10 @@ if __name__ == '__main__':
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'dbroot', type=str, help='specifies the root directory (in '
|
||||
'most cases PILOT database folder)'
|
||||
'root', type=str, help='specifies the root directory'
|
||||
)
|
||||
parser.add_argument(
|
||||
'db', type=str, help='specifies the database name'
|
||||
)
|
||||
parser.add_argument(
|
||||
'id', type=str, help='PILOT event identifier'
|
||||
@ -33,4 +35,4 @@ if __name__ == '__main__':
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
reassess_pilot_event(args.dbroot, args.id, args.output, args.parfile)
|
||||
reassess_pilot_event(args.root, args.db, args.id, args.output, args.parfile)
|
||||
|
Loading…
Reference in New Issue
Block a user