From 6ebad273a9c380837483a3acf6eedb1063e717ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 23 Jun 2017 10:10:45 +0200 Subject: [PATCH 1/3] Improved screen output. --- autoPyLoT.py | 36 ++++++++++++++++++++++++++---------- pylot/RELEASE-VERSION | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/autoPyLoT.py b/autoPyLoT.py index 7841487d..7569d814 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -243,7 +243,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even # get latest NLLoc-location file if several are available nllocfile = max(glob.glob(locsearch), key=os.path.getctime) evt = read_events(nllocfile)[0] - # calculating seismic moment Mo and moment magnitude Mw + # calculate seismic moment Mo and moment magnitude Mw moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'), parameter.get('Qp'), parameter.get('rho'), True, \ @@ -255,14 +255,22 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even net_mw = moment_mag.net_magnitude() print("Network moment magnitude: %4.1f" % net_mw.mag) # calculate local (Richter) magntiude + WAscaling = parameter.get('WAscaling') + magscaling = parameter.get('magscaling') local_mag = LocalMagnitude(corr_dat, evt, - parameter.get('sstop'), parameter.get('WAscaling'), \ - True, iplot) + parameter.get('sstop'), + WAscaling, True, iplot) for station, amplitude in local_mag.amplitudes.items(): picks[station]['S']['Ao'] = amplitude.generic_amplitude - evt = local_mag.updated_event(parameter.get('magscaling')) - net_ml = local_mag.net_magnitude() + print("Local station magnitudes scaled with:") + print("log(Ao) + %f * log(r) + %f * r + %f" % (WAscaling[0], + WAscaling[1], + WAscaling[2])) + evt = local_mag.updated_event(magscaling) + net_ml = local_mag.net_magnitude(magscaling) print("Network local magnitude: %4.1f" % net_ml.mag) + print("Network local magnitude scaled with:") + print("%f * Ml + %f" % (magscaling[0], magscaling[1])) else: print("autoPyLoT: No NLLoc-location file available!") print("No source parameter estimation possible!") @@ -306,7 +314,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even nlloccounter = maxnumit evt = read_events(nllocfile)[0] if locflag < 2: - # calculating seismic moment Mo and moment magnitude Mw + # calculate seismic moment Mo and moment magnitude Mw moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'), parameter.get('Qp'), parameter.get('rho'), True, \ @@ -318,14 +326,22 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even net_mw = moment_mag.net_magnitude() print("Network moment magnitude: %4.1f" % net_mw.mag) # calculate local (Richter) magntiude + WAscaling = parameter.get('WAscaling') + magscaling = parameter.get('magscaling') local_mag = LocalMagnitude(corr_dat, evt, - parameter.get('sstop'), parameter.get('WAscaling'), \ - True, iplot) + parameter.get('sstop'), + WAscaling, True, iplot) for station, amplitude in local_mag.amplitudes.items(): picks[station]['S']['Ao'] = amplitude.generic_amplitude - evt = local_mag.updated_event(parameter.get('magscaling')) - net_ml = local_mag.net_magnitude(parameter.get('magscaling')) + print("Local station magnitudes scaled with:") + print("log(Ao) + %f * log(r) + %f * r + %f" % (WAscaling[0], + WAscaling[1], + WAscaling[2])) + evt = local_mag.updated_event(magscaling) + net_ml = local_mag.net_magnitude(magscaling) print("Network local magnitude: %4.1f" % net_ml.mag) + print("Network local magnitude scaled with:") + print("%f * Ml + %f" % (magscaling[0], magscaling[1])) else: print("autoPyLoT: No NLLoc-location file available! Stop iteration!") locflag = 9 diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 31812905..0d836703 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -8e8b-dirty +33d8-dirty From 5958e05f3bdab30be1b30fea5afda941cf734c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 23 Jun 2017 10:26:49 +0200 Subject: [PATCH 2/3] Cosmetics. --- pylot/core/io/default_parameters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylot/core/io/default_parameters.py b/pylot/core/io/default_parameters.py index 22d0268b..18baca6c 100644 --- a/pylot/core/io/default_parameters.py +++ b/pylot/core/io/default_parameters.py @@ -284,7 +284,7 @@ defaults = {'rootpath': {'type': str, 'magscaling': {'type': (float, float), 'tooltip': 'Scaling relation for derived local magnitude [a*Ml+b]. \ - If zeros are set, no scaling is of network magnitude is applied.', + If zeros are set, no scaling of network magnitude is applied!', 'value': (0., 0.)} } From 27597e6b4b4909e53506862c81d2ed8dd6c68a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 23 Jun 2017 11:32:08 +0200 Subject: [PATCH 3/3] Take into account parameter extent when writing header for PyLoT-input file. --- pylot/RELEASE-VERSION | 2 +- pylot/core/io/inputs.py | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 0d836703..cd4206e8 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -33d8-dirty +5958-dirty diff --git a/pylot/core/io/inputs.py b/pylot/core/io/inputs.py index 3653b828..9aa9b5d2 100644 --- a/pylot/core/io/inputs.py +++ b/pylot/core/io/inputs.py @@ -221,24 +221,23 @@ class PylotParameter(object): # for key, value in self.iteritems(): # lines.append('{key}\t{value}\n'.format(key=key, value=value)) # fid_out.writelines(lines) - header = ('%This is a parameter input file for PyLoT/autoPyLoT.\n'+ '%All main and special settings regarding data handling\n'+ '%and picking are to be set here!\n'+ - '%Parameters are optimized for local data sets!\n') - seperator = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n' + '%Parameters are optimized for %{} data sets!\n'.format(self.get_main_para_names()['pick'][0])) + separator = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n' fid_out.write(header) self.write_section(fid_out, self.get_main_para_names()['dirs'], - 'main settings', seperator) + 'main settings', separator) self.write_section(fid_out, self.get_main_para_names()['nlloc'], - 'NLLoc settings', seperator) + 'NLLoc settings', separator) self.write_section(fid_out, self.get_main_para_names()['smoment'], - 'parameters for seismic moment estimation', seperator) + 'parameters for seismic moment estimation', separator) self.write_section(fid_out, self.get_main_para_names()['localmag'], - 'settings local magnitude', seperator) + 'settings local magnitude', separator) self.write_section(fid_out, self.get_main_para_names()['pick'], - 'common settings picker', seperator) + 'common settings picker', separator) fid_out.write(('#special settings for calculating CF#\n'+ '%!!Edit the following only if you know what you are doing!!%\n')) self.write_section(fid_out, self.get_special_para_names()['z'], @@ -250,9 +249,9 @@ class PylotParameter(object): self.write_section(fid_out, self.get_special_para_names()['quality'], 'quality assessment', None) - def write_section(self, fid, names, title, seperator): - if seperator: - fid.write(seperator) + def write_section(self, fid, names, title, separator): + if separator: + fid.write(separator) fid.write('#{}#\n'.format(title)) l_val = 50 l_name = 15