Merge branch 'develop' of ariadne:/data/git/pylot into develop
This commit is contained in:
		
						commit
						f7af1d0b1b
					
				
							
								
								
									
										26
									
								
								autoPyLoT.py
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								autoPyLoT.py
									
									
									
									
									
								
							@ -357,8 +357,15 @@ if __name__ == "__main__":
 | 
			
		||||
    # parse arguments
 | 
			
		||||
    parser = argparse.ArgumentParser(
 | 
			
		||||
        description='''autoPyLoT automatically picks phase onset times using higher order statistics,
 | 
			
		||||
                       autoregressive prediction and AIC''')
 | 
			
		||||
                       autoregressive prediction and AIC followed by locating the seismic events using 
 | 
			
		||||
                       NLLoc''')
 | 
			
		||||
 | 
			
		||||
    #parser.add_argument('-d', '-D', '--input_dict', type=str,
 | 
			
		||||
    #                    action='store',
 | 
			
		||||
    #                    help='''optional, dictionary containing processing parameters''')
 | 
			
		||||
    #parser.add_argument('-p', '-P', '--parameter', type=str,
 | 
			
		||||
    #                    action='store',
 | 
			
		||||
    #                    help='''parameter file, default=None''')
 | 
			
		||||
    parser.add_argument('-i', '-I', '--inputfile', type=str,
 | 
			
		||||
                        action='store',
 | 
			
		||||
                        help='''full path to the file containing the input
 | 
			
		||||
@ -369,17 +376,18 @@ if __name__ == "__main__":
 | 
			
		||||
    parser.add_argument('-e', '-E', '--eventid', type=str,
 | 
			
		||||
                        action='store',
 | 
			
		||||
                        help='''optional, event path incl. event ID''')
 | 
			
		||||
    # parser.add_argument('-p', '-P', '--plot', action='store',
 | 
			
		||||
    #                     help='show interactive plots')
 | 
			
		||||
    parser.add_argument('-s', '-S', '--spath', type=str,
 | 
			
		||||
                        action='store',
 | 
			
		||||
                        help='''optional, save path for autoPyLoT output''')
 | 
			
		||||
    parser.add_argument('-v', '-V', '--version', action='version',
 | 
			
		||||
                        version='autoPyLoT ' + __version__,
 | 
			
		||||
                        help='show version information and exit')
 | 
			
		||||
    #parser.add_argument('-v', '-V', '--version', action='version',
 | 
			
		||||
    #                    version='autoPyLoT ' + __version__,
 | 
			
		||||
    #                    help='show version information and exit')
 | 
			
		||||
 | 
			
		||||
    cla = parser.parse_args()
 | 
			
		||||
    
 | 
			
		||||
    picks, mainFig = autoPyLoT(inputfile=str(cla.inputfile),
 | 
			
		||||
                               fnames=str(cla.fnames), eventid=str(cla.eventid), 
 | 
			
		||||
                               savepath=str(cla.spath))
 | 
			
		||||
    try:
 | 
			
		||||
        picks, mainFig = autoPyLoT(inputfile=str(cla.inputfile), fnames=str(cla.fnames), 
 | 
			
		||||
                                   eventid=str(cla.eventid), savepath=str(cla.spath))
 | 
			
		||||
    except ValueError:
 | 
			
		||||
        print("autoPyLoT was running in production mode.")
 | 
			
		||||
                             
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ import copy
 | 
			
		||||
import os
 | 
			
		||||
from obspy import read_events
 | 
			
		||||
from obspy.core import read, Stream, UTCDateTime
 | 
			
		||||
from obspy.io.sac import SacIOError
 | 
			
		||||
from obspy.core.event import Event
 | 
			
		||||
from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \
 | 
			
		||||
    picksdict_from_pilot, merge_picks
 | 
			
		||||
@ -230,6 +231,8 @@ class Data(object):
 | 
			
		||||
                    self.wfdata += read(fname, format='GSE2')
 | 
			
		||||
                except Exception as e:
 | 
			
		||||
                    warnmsg += '{0}\n{1}\n'.format(fname, e)
 | 
			
		||||
            except SacIOError as se:
 | 
			
		||||
                    warnmsg += '{0}\n{1}\n'.format(fname, se)
 | 
			
		||||
        if warnmsg:
 | 
			
		||||
            warnmsg = 'WARNING: unable to read\n' + warnmsg
 | 
			
		||||
            print(warnmsg)
 | 
			
		||||
 | 
			
		||||
@ -241,8 +241,12 @@ class AICPicker(AutoPicker):
 | 
			
		||||
                    ax.set_title(self.Data[0].stats.station)
 | 
			
		||||
                return
 | 
			
		||||
 | 
			
		||||
            islope = islope[0][0:imax]
 | 
			
		||||
            dataslope = self.Data[0].data[islope]
 | 
			
		||||
            iislope = islope[0][0:imax]
 | 
			
		||||
            if len(iislope) <= 3:
 | 
			
		||||
                # calculate slope from initial onset to maximum of AIC function
 | 
			
		||||
                imax = np.argmax(aicsmooth[islope])
 | 
			
		||||
                iislope = islope[0][0:imax]
 | 
			
		||||
            dataslope = self.Data[0].data[iislope]
 | 
			
		||||
            # calculate slope as polynomal fit of order 1
 | 
			
		||||
            xslope = np.arange(0, len(dataslope), 1)
 | 
			
		||||
            P = np.polyfit(xslope, dataslope, 1)
 | 
			
		||||
@ -276,12 +280,12 @@ class AICPicker(AutoPicker):
 | 
			
		||||
                ax2.plot(self.Tcf, x, 'k', label='Data')
 | 
			
		||||
                ax1.axvspan(self.Tcf[inoise[0]],self.Tcf[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
 | 
			
		||||
                ax1.axvspan(self.Tcf[isignal[0]],self.Tcf[isignal[-1]], color='b', alpha=0.2, lw=0, label='Signal Window')
 | 
			
		||||
                ax1.axvspan(self.Tcf[islope[0]],self.Tcf[islope[-1]], color='g', alpha=0.2, lw=0, label='Slope Window')
 | 
			
		||||
                ax1.axvspan(self.Tcf[iislope[0]],self.Tcf[iislope[-1]], color='g', alpha=0.2, lw=0, label='Slope Window')
 | 
			
		||||
                
 | 
			
		||||
                ax2.axvspan(self.Tcf[inoise[0]],self.Tcf[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
 | 
			
		||||
                ax2.axvspan(self.Tcf[isignal[0]],self.Tcf[isignal[-1]], color='b', alpha=0.2, lw=0, label='Signal Window')
 | 
			
		||||
                ax2.axvspan(self.Tcf[islope[0]],self.Tcf[islope[-1]], color='g', alpha=0.2, lw=0, label='Slope Window')                
 | 
			
		||||
                ax2.plot(self.Tcf[islope], datafit, 'g', linewidth=2, label='Slope')
 | 
			
		||||
                ax2.axvspan(self.Tcf[iislope[0]],self.Tcf[iislope[-1]], color='g', alpha=0.2, lw=0, label='Slope Window')                
 | 
			
		||||
                ax2.plot(self.Tcf[iislope], datafit, 'g', linewidth=2, label='Slope')
 | 
			
		||||
                
 | 
			
		||||
                ax1.set_title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
 | 
			
		||||
                                                                                self.SNR, self.slope))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user