Skip to content

Commit a8ef51c

Browse files
committed
Fix syntax errors
1 parent d48d0d9 commit a8ef51c

File tree

9 files changed

+28
-33
lines changed

9 files changed

+28
-33
lines changed

seismic/ml_classifier/data_harvester/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
GA=loadmat("GA.mat")['GA']
66

7-
print GA['picks'].keys()
7+
print(GA['picks'].keys())

seismic/ml_classifier/data_harvester/getwave.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _genTS(fdsnclient,st,ch,starttime,endtime,loc=None,net=None):
2525
loc=statinfo[2]
2626
waveforms=fdsnclient.get_waveforms(net,st,loc,ch,starttime,endtime)
2727
if len(waveforms)>0:
28-
print "Got an IRIS waveform!"
28+
print("Got an IRIS waveform!")
2929
ret=waveforms[0]
3030
else:
3131
ret=None
@@ -34,7 +34,7 @@ def _genTS(fdsnclient,st,ch,starttime,endtime,loc=None,net=None):
3434

3535

3636
if not ret:
37-
print "No waveform found."
37+
print("No waveform found.")
3838

3939
return ret
4040

@@ -46,7 +46,7 @@ def _genTS(fdsnclient,st,ch,starttime,endtime,loc=None,net=None):
4646

4747
def getWave(webclient,st,chloc,starttime,endtime,saveDir="/g/data/ha3/rlt118/neural-datasets/categoriser-teleseismic/",phase='S',ISC=True,network=None):
4848
global wfctr
49-
print starttime
49+
print(starttime)
5050
st=st.strip()
5151
if '?' in chloc:
5252
return False

seismic/ml_classifier/data_harvester/process-traces.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,19 @@ def genTS(net,st,ch,loc,ptime,stime):
105105
stime=UTCDateTime(*(stimeint+[smsec]))
106106
#get a waveform to train against
107107
wf=genTS(net,st,chan,loc,ptime,stime)
108-
if not(wf is None) and len(wf)>100:#discard bad or short waveforms extracted from the database
108+
if not(wf is None) and len(wf)>100:#discard bad or short waveforms extracted from the database
109109
wfctr+=1
110110
#resample the waveforms to 1000 points, detrend and normalise. The extra 0.01 ensures that the resulting trace
111111
#does in fact have 1000 points
112112
wf.resample(1000.01/wf.stats.npts*wf.stats.sampling_rate)
113113
wf.detrend()
114114
wf.normalize()
115-
#generate the pick distributions and normalise them
116-
pdist=np.exp(-np.power(wf.times()-(ptime-wf.times("utcdatetime")[0]),2)/(0.02))#sigma is 0.1
117-
sdist=np.exp(-np.power(wf.times()-(stime-wf.times("utcdatetime")[0]),2)/(0.02))
118-
pdist=pdist/np.sum(pdist)
119-
sdist=sdist/np.sum(sdist)
120-
#plot the resulting final waveform to a file
121-
outfname='wftestplot/'+'_'.join((net,st,chan,loc,ptime.ctime(),stime.ctime()))+'.png'
122-
wf.plot(outfile=outfname)
123-
#pickle the data and save it to a file
124-
125-
126-
127-
128-
115+
#generate the pick distributions and normalise them
116+
pdist=np.exp(-np.power(wf.times()-(ptime-wf.times("utcdatetime")[0]),2)/(0.02))#sigma is 0.1
117+
sdist=np.exp(-np.power(wf.times()-(stime-wf.times("utcdatetime")[0]),2)/(0.02))
118+
pdist=pdist/np.sum(pdist)
119+
sdist=sdist/np.sum(sdist)
120+
#plot the resulting final waveform to a file
121+
outfname='wftestplot/'+'_'.join((net,st,chan,loc,ptime.ctime(),stime.ctime()))+'.png'
122+
wf.plot(outfile=outfname)
123+
#pickle the data and save it to a file

seismic/ml_classifier/data_harvester/save-noise.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def genTS(net,st,ch,loc,starttime,endtime):
7070
wf.normalize()
7171
Sctr+=1
7272
os.system('clear')
73-
print len(wf)
73+
print(len(wf))
7474
wf.write(saveDir+str(Sctr)+'_N.pkl',format="PICKLE")
7575
np.save(saveDir+str(Sctr)+'_N.npy',wf.data)
7676

77-
print str(Sctr)+'/'+str(pSctr)
77+
print(str(Sctr)+'/'+str(pSctr))
7878

7979

80-
print str(Sctr)+'/'+str(pSctr),"waveforms harvested"
80+
print(str(Sctr)+'/'+str(pSctr),"waveforms harvested")

seismic/ml_classifier/data_harvester/save-traces-3D.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def stripChannel(channel):
6161

6262
break
6363

64-
print simulctr
64+
print(simulctr)
6565

6666
"""
6767

seismic/ml_classifier/data_harvester/save-traces-SandP.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def genTS(net,st,ch,loc,starttime,endtime):
2222

2323
#get the trace
24-
print "querying database..."
24+
print("querying database...")
2525
try:
2626
waveforms=fds.get_waveforms(net, st, loc, ch,
2727
starttime, endtime,
@@ -32,7 +32,7 @@ def genTS(net,st,ch,loc,starttime,endtime):
3232
ret=None
3333
except:
3434
ret=None
35-
print "done"
35+
print("done")
3636
return ret
3737

3838

@@ -120,4 +120,4 @@ def genTS(net,st,ch,loc,starttime,endtime):
120120

121121

122122

123-
print str(Sctr)+'/'+str(pSctr),"waveforms harvested"
123+
print(str(Sctr)+'/'+str(pSctr),"waveforms harvested")

seismic/ml_classifier/data_harvester/save-traces-justP.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def genTS(net,st,ch,loc,starttime,endtime):
7070
wf.normalize()
7171
Sctr+=1
7272
os.system('clear')
73-
print len(wf)
73+
print(len(wf))
7474
wf.write(saveDir+str(Sctr)+'_P.pkl',format="PICKLE")
7575
np.save(saveDir+str(Sctr)+'_P.npy',wf.data)
7676

77-
print str(Sctr)+'/'+str(pSctr)
77+
print(str(Sctr)+'/'+str(pSctr))
7878

7979

80-
print str(Sctr)+'/'+str(pSctr),"waveforms harvested"
80+
print(str(Sctr)+'/'+str(pSctr),"waveforms harvested")

seismic/ml_classifier/data_harvester/save-traces-justS.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def genTS(net,st,ch,loc,starttime,endtime):
6969
wf.normalize()
7070
Sctr+=1
7171
os.system('clear')
72-
print len(wf)
72+
print(len(wf))
7373
wf.write(saveDir+str(Sctr)+'_S.pkl',format="PICKLE")
7474
np.save(saveDir+str(Sctr)+'_S.npy',wf.data)
7575

76-
print str(Sctr)+'/'+str(pSctr)
76+
print(str(Sctr)+'/'+str(pSctr))
7777

7878

79-
print str(Sctr)+'/'+str(pSctr),"waveforms harvested"
79+
print(str(Sctr)+'/'+str(pSctr),"waveforms harvested")

seismic/ml_classifier/data_harvester/save-traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def genTS(net,st,ch,loc,ptime,stime):
4141
simulctr=0
4242
allpickdict={}
4343

44-
print len(GA['events'])
44+
print(len(GA['events']))
4545

4646
for picki in range(len(GA['picks']['at'])):
4747
pickarr=np.asarray([GA['picks']['ne'][picki],GA['picks']['st'][picki],GA['picks']['ch'][picki],GA['picks']['ph'][picki]]).T

0 commit comments

Comments
 (0)