From c8d8525c11f2683480ef40625704434b5ea1d539 Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Thu, 15 Sep 2016 14:51:11 +0200 Subject: [PATCH] [bugs fixed and found] dataprocessing doesn't work as expected, np.bool_ substituted by bool --- pylot/core/analysis/magnitude.py | 2 +- pylot/core/util/dataprocessing.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index a22dbeba..41cfd590 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -353,7 +353,7 @@ def calcsourcespec(wfstream, onset, inventory, vp, delta, azimuth, incidence, qp wf_copy = wfstream.copy() [cordat, restflag] = restitute_data(wf_copy, inventory) - if restflag == 1: + if restflag is True: zdat = cordat.select(component="Z") if len(zdat) == 0: zdat = cordat.select(component="3") diff --git a/pylot/core/util/dataprocessing.py b/pylot/core/util/dataprocessing.py index fb739fab..f59afbf1 100644 --- a/pylot/core/util/dataprocessing.py +++ b/pylot/core/util/dataprocessing.py @@ -155,7 +155,7 @@ def evt_head_check(root_dir, out_dir = None): print(nfiles) -def restitute_data(data, path_to_inventory, unit='VEL', force=False): +def restitute_data(data, path_to_inventory, unit='VEL', force=True): """ takes a data stream and a path_to_inventory and returns the corrected waveform data stream @@ -163,7 +163,7 @@ def restitute_data(data, path_to_inventory, unit='VEL', force=False): :param path_to_inventory: path to inventory folder or file :param unit: unit to correct for (default: 'VEL') :param force: force restitution for already corrected traces (default: - False) + True) :return: corrected data stream """ @@ -193,6 +193,10 @@ def restitute_data(data, path_to_inventory, unit='VEL', force=False): for tr in data: seed_id = tr.get_id() # check, whether this trace has already been corrected + # TODO read actual value of processing key in Trace's stats instead + # of just looking for thr key: if processing is setit doesn't + # necessarily mean that the trace has been corrected so far but only + # processed in some way, e.g. normalized if 'processing' in tr.stats.keys() and not force: print("Trace {0} has already been corrected!".format(seed_id)) continue @@ -225,6 +229,9 @@ def restitute_data(data, path_to_inventory, unit='VEL', force=False): else: finv = invlist[0] inventory = read_inventory(finv, format='STATIONXML') + else: + restflag.append(False) + continue # apply restitution to data if invtype in ['resp', 'dless']: tr.simulate(**kwargs) @@ -237,7 +244,7 @@ def restitute_data(data, path_to_inventory, unit='VEL', force=False): # better try restitution for smaller subsets of data (e.g. station by # station) if len(restflag) > 0: - restflag = np.all(restflag) + restflag = bool(np.all(restflag)) else: restflag = False return data, restflag