[Bugfix]: Check for key S and be sure to get element weight for pick
dictionary.
This commit is contained in:
		
							parent
							
								
									b7795ca562
								
							
						
					
					
						commit
						e64135c7a8
					
				@ -269,21 +269,24 @@ def picksdict_from_picks(evt):
 | 
				
			|||||||
                msg = str(e) + ',\n falling back to symmetric uncertainties'
 | 
					                msg = str(e) + ',\n falling back to symmetric uncertainties'
 | 
				
			||||||
                lpp = mpp + spe
 | 
					                lpp = mpp + spe
 | 
				
			||||||
                epp = mpp - spe
 | 
					                epp = mpp - spe
 | 
				
			||||||
                # get onset weight from uncertainty
 | 
					 | 
				
			||||||
                infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
 | 
					 | 
				
			||||||
                print('Using default input file {}'.format(infile))
 | 
					 | 
				
			||||||
                parameter = PylotParameter(infile)
 | 
					 | 
				
			||||||
                if pick.phase_hint == 'P':
 | 
					 | 
				
			||||||
                    errors = parameter['timeerrorsP']
 | 
					 | 
				
			||||||
                elif pick.phase_hint == 'S':
 | 
					 | 
				
			||||||
                    errors = parameter['timeerrorsS']
 | 
					 | 
				
			||||||
                weight = get_quality_class(spe, errors)
 | 
					 | 
				
			||||||
            warnings.warn(msg)
 | 
					            warnings.warn(msg)
 | 
				
			||||||
        phase['mpp'] = mpp
 | 
					        phase['mpp'] = mpp
 | 
				
			||||||
        phase['epp'] = epp
 | 
					        phase['epp'] = epp
 | 
				
			||||||
        phase['lpp'] = lpp
 | 
					        phase['lpp'] = lpp
 | 
				
			||||||
        phase['spe'] = spe
 | 
					        phase['spe'] = spe
 | 
				
			||||||
        phase['weight'] = weight
 | 
					        try:
 | 
				
			||||||
 | 
					            phase['weight'] = weight
 | 
				
			||||||
 | 
					        except:
 | 
				
			||||||
 | 
					            # get onset weight from uncertainty
 | 
				
			||||||
 | 
					            infile = os.path.join(os.path.expanduser('~'), '.pylot', 'pylot.in')
 | 
				
			||||||
 | 
					            print('Using default input file {}'.format(infile))
 | 
				
			||||||
 | 
					            parameter = PylotParameter(infile)
 | 
				
			||||||
 | 
					            if pick.phase_hint == 'P':
 | 
				
			||||||
 | 
					                errors = parameter['timeerrorsP']
 | 
				
			||||||
 | 
					            elif pick.phase_hint == 'S':
 | 
				
			||||||
 | 
					                errors = parameter['timeerrorsS']
 | 
				
			||||||
 | 
					            weight = get_quality_class(spe, errors)
 | 
				
			||||||
 | 
					            phase['weight'] = weight
 | 
				
			||||||
        phase['channel'] = channel
 | 
					        phase['channel'] = channel
 | 
				
			||||||
        phase['network'] = network
 | 
					        phase['network'] = network
 | 
				
			||||||
        phase['picker'] = picker
 | 
					        phase['picker'] = picker
 | 
				
			||||||
@ -782,7 +785,8 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None):
 | 
				
			|||||||
                    Ponset = arrivals[key]['P']['mpp']
 | 
					                    Ponset = arrivals[key]['P']['mpp']
 | 
				
			||||||
                    Prt = Ponset - stime  # onset time relative to source time
 | 
					                    Prt = Ponset - stime  # onset time relative to source time
 | 
				
			||||||
                    fid.write('%s    %6.3f  1  P\n' % (key, Prt))
 | 
					                    fid.write('%s    %6.3f  1  P\n' % (key, Prt))
 | 
				
			||||||
                    # S onsets
 | 
					            if arrivals[key].has_key('S'):
 | 
				
			||||||
 | 
					                # S onsets
 | 
				
			||||||
                if arrivals[key]['S']['weight'] < 4:
 | 
					                if arrivals[key]['S']['weight'] < 4:
 | 
				
			||||||
                    Sonset = arrivals[key]['S']['mpp']
 | 
					                    Sonset = arrivals[key]['S']['mpp']
 | 
				
			||||||
                    Srt = Sonset - stime  # onset time relative to source time
 | 
					                    Srt = Sonset - stime  # onset time relative to source time
 | 
				
			||||||
 | 
				
			|||||||
@ -316,8 +316,13 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None, linecolor='k'):
 | 
				
			|||||||
            islope2 = np.where((t >= Pick) & (t <= Pick + t[imax2]))
 | 
					            islope2 = np.where((t >= Pick) & (t <= Pick + t[imax2]))
 | 
				
			||||||
            # calculate slope as polynomal fit of order 1
 | 
					            # calculate slope as polynomal fit of order 1
 | 
				
			||||||
            xslope2 = np.arange(0, len(xfilt[islope2]), 1)
 | 
					            xslope2 = np.arange(0, len(xfilt[islope2]), 1)
 | 
				
			||||||
            P2 = np.polyfit(xslope2, xfilt[islope2], 1)
 | 
					            try:
 | 
				
			||||||
            datafit2 = np.polyval(P2, xslope2)
 | 
					                P2 = np.polyfit(xslope2, xfilt[islope2], 1)
 | 
				
			||||||
 | 
					                datafit2 = np.polyval(P2, xslope2)
 | 
				
			||||||
 | 
					            except ValueError as e:
 | 
				
			||||||
 | 
					                emsg = 'fmpicker: polyfit failed: {}'.format(e)
 | 
				
			||||||
 | 
					                print(emsg)
 | 
				
			||||||
 | 
					                return FM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # compare results
 | 
					        # compare results
 | 
				
			||||||
        if P1 is not None and P2 is not None:
 | 
					        if P1 is not None and P2 is not None:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user