[bugfixes] location/magnitude w ludger

This commit is contained in:
Marcel Paffrath 2018-06-28 15:22:40 +02:00
parent 5870843a03
commit 4cb3f72ba8
4 changed files with 18 additions and 44 deletions

View File

@ -2498,7 +2498,6 @@ class MainWindow(QMainWindow):
'iplot': 0, 'iplot': 0,
'fig_dict': None, 'fig_dict': None,
'fig_dict_wadatijack': self.fig_dict_wadatijack, 'fig_dict_wadatijack': self.fig_dict_wadatijack,
'locflag': 0,
'savexml': False, 'savexml': False,
'obspyDMT_wfpath': wfpath} 'obspyDMT_wfpath': wfpath}
# init pick thread # init pick thread
@ -2756,55 +2755,28 @@ class MainWindow(QMainWindow):
""" """
if not self.okToContinue(): if not self.okToContinue():
return return
settings = QSettings() parameter = self._inputs
# get location tool hook loctool = 'nll'
loctool = settings.value("loc/tool", "nll")
lt = locateTool[loctool] lt = locateTool[loctool]
# get working directory # get working directory
locroot = settings.value("{0}/rootPath".format(loctool), None) locroot = parameter['nllocroot']
if locroot is None: if locroot is None:
self.PyLoTprefs() self.PyLoTprefs()
self.locate_event() self.locate_event()
infile = settings.value("{0}/inputFile".format(loctool), None) ctrfile = parameter['ctrfile']
if not infile: ttt = parameter['ttpatter']
caption = 'Select {0} input file'.format(loctool) outfile = parameter['outpatter']
filt = "Supported file formats" \
" (*.in *.ini *.conf *.cfg)"
ans = QFileDialog().getOpenFileName(self, caption=caption,
filter=filt, dir=locroot)
if ans[0]:
infile = ans[0]
else:
QMessageBox.information(self,
self.tr('No infile selected'),
self.tr('Inputfile necessary for localization.'))
return
settings.setValue("{0}/inputFile".format(loctool), infile)
settings.sync()
if loctool == 'nll':
ttt = settings.value("{0}/travelTimeTables", None)
ok = False
if ttt is None:
while not ok:
text, ok = QInputDialog.getText(self, 'Pattern for travel time tables',
'Base name of travel time tables',
echo=QLineEdit.Normal,
text="ttime")
ttt = text
outfile = settings.value("{0}/outputFile".format(loctool),
os.path.split(os.tempnam())[-1])
eventname = self.get_current_event_name() eventname = self.get_current_event_name()
obsdir = os.path.join(self._inputs['rootpath'], self._inputs['datapath'], self._inputs['database'], eventname) obsdir = os.path.join(self._inputs['rootpath'], self._inputs['datapath'], self._inputs['database'], eventname)
self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs') self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs')
filename = 'PyLoT_' + eventname filename = 'PyLoT_' + eventname
locpath = os.path.join(locroot, 'loc', filename) locpath = os.path.join(locroot, 'loc', filename)
phasefile = os.path.join(obsdir, filename + '.obs') phasefile = os.path.join(obsdir, filename + '.obs')
lt.modify_inputs(infile, locroot, filename, phasefile, ttt) lt.modify_inputs(ctrfile, locroot, filename, phasefile, ttt)
try: try:
lt.locate(infile) lt.locate(ctrfile)
except RuntimeError as e: except RuntimeError as e:
print(e.message) print(e.message)
#finally: #finally:

View File

@ -94,7 +94,6 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
fig_dict = None fig_dict = None
fig_dict_wadatijack = None fig_dict_wadatijack = None
locflag = 1
if input_dict and isinstance(input_dict, dict): if input_dict and isinstance(input_dict, dict):
if 'parameter' in input_dict: if 'parameter' in input_dict:
parameter = input_dict['parameter'] parameter = input_dict['parameter']
@ -110,8 +109,6 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
eventid = input_dict['eventid'] eventid = input_dict['eventid']
if 'iplot' in input_dict: if 'iplot' in input_dict:
iplot = input_dict['iplot'] iplot = input_dict['iplot']
if 'locflag' in input_dict:
locflag = input_dict['locflag']
if 'savexml' in input_dict: if 'savexml' in input_dict:
savexml = input_dict['savexml'] savexml = input_dict['savexml']
if 'obspyDMT_wfpath' in input_dict: if 'obspyDMT_wfpath' in input_dict:
@ -153,7 +150,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
datastructure.setExpandFields(exf) datastructure.setExpandFields(exf)
# check if default location routine NLLoc is available # check if default location routine NLLoc is available
if real_None(parameter['nllocbin']) and locflag: if real_None(parameter['nllocbin']):
locflag = 1
# get NLLoc-root path # get NLLoc-root path
nllocroot = parameter.get('nllocroot') nllocroot = parameter.get('nllocroot')
# get path to NLLoc executable # get path to NLLoc executable
@ -178,7 +176,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
print(" !!! ") print(" !!! ")
wfpath_extension = '' wfpath_extension = ''
if obspyDMT_wfpath not in [None, False, 'False']: if obspyDMT_wfpath not in [None, False, 'False', '']:
wfpath_extension = obspyDMT_wfpath wfpath_extension = obspyDMT_wfpath
print('Using obspyDMT structure. There will be no restitution, as pre-processed data are expected.') print('Using obspyDMT structure. There will be no restitution, as pre-processed data are expected.')
if wfpath_extension != 'processed': if wfpath_extension != 'processed':

View File

@ -122,7 +122,13 @@ class Magnitude(object):
def net_magnitude(self, magscaling=None): def net_magnitude(self, magscaling=None):
if self: if self:
if magscaling is not None and str(magscaling) is not '[0.0, 0.0]': if magscaling == None:
scaling = False
elif magscaling[0] != 0 and magscaling[1] != 0:
scaling = False
else:
scaling = True
if scaling:
# scaling necessary # scaling necessary
print("Scaling network magnitude ...") print("Scaling network magnitude ...")
mag = ope.Magnitude( mag = ope.Magnitude(
@ -141,7 +147,6 @@ class Magnitude(object):
station_count=len(self.magnitudes), station_count=len(self.magnitudes),
azimuthal_gap=self.origin_id.get_referred_object().quality.azimuthal_gap) azimuthal_gap=self.origin_id.get_referred_object().quality.azimuthal_gap)
return mag return mag
return None
class LocalMagnitude(Magnitude): class LocalMagnitude(Magnitude):

View File

@ -3419,7 +3419,6 @@ class TuneAutopicker(QWidget):
'eventid': [self.get_current_event_fp()], 'eventid': [self.get_current_event_fp()],
'iplot': 2, 'iplot': 2,
'fig_dict': self.fig_dict, 'fig_dict': self.fig_dict,
'locflag': 0,
'savexml': False, 'savexml': False,
'obspyDMT_wfpath': wfpath} 'obspyDMT_wfpath': wfpath}
for key in self.fig_dict.keys(): for key in self.fig_dict.keys():