Skip to content

Commit a22a2cf

Browse files
Pv 2362 increase test coverage (#266)
* Add coveragerc Only include test, seismic and util directories for testing. Exclude legacy etc * Show coverage for develop branch * Add build status * Fix coveragerc * Stream processing zerophase resampling tests * Run tests * Just test stream processing * Change test directory * Remove main * Add files * Add coveralls * Check root directory * Verbose coveralls * Debug coveralls * Run coverage * Add parenthesis * ./ * Add other parenthesis * Revert to --cov * Fix syntax errors * run coverage * xml coverage report * Run all tests in codecov * Test zerophase resampling when resample_hz < sampling rate * Test trace ordering when trace channel not in ordering array * Run all tests * Exclude import statements from coverage * Simplify invalid type zerophase resampling test * Exclude from * Exclude lines from report * Remove files from codecov * Remove old coverage.xml * List files * Verbose codecov * list files twice * Cat xml files * Grep coverage.xml * Specify coveragerc file * Absolute path to coveragerc * Don't cache home/runner * Remove commands for missing coverage.xml file when cache not used * Run all tests * Add PhasePApy to cache * Remove test changes * Cache hiperseis directory * Check cache working
1 parent f395124 commit a22a2cf

15 files changed

+58
-52
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
source =
3+
seismic
4+
utils
5+
tests
6+
branch = True
7+
[report]
8+
exclude_lines =
9+
import
10+
from

.github/workflows/hiperseis_main_ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/cache@main
2222
with:
2323
path: |
24-
/home/runner
24+
/home/runner/work/hiperseis
2525
/usr/share/miniconda/envs/hiperseis
2626
key: anaconda
2727
- name: Setting up environment
@@ -42,7 +42,8 @@ jobs:
4242
eval "$(conda shell.bash hook)"
4343
conda init
4444
conda activate hiperseis
45-
pytest --cov --cov-report=xml ./tests
45+
coverage run -m pytest tests
46+
coverage xml
4647
- name: Upload coverage reports to Codecov
4748
uses: codecov/codecov-action@main
4849
with:

README.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
HiPerSeis: High Performance Software Package for Seismology Data/Metadata Processing and Analysis
22
=================================================================================================
33

4-
|Build Status| |Coverage Status| |Documentation Status|
4+
.. image:: https://github.com/GeoscienceAustralia/hiperseis/actions/workflows/hiperseis_main_ci.yml/badge.svg
5+
:target: https://github.com/GeoscienceAustralia/hiperseis/actions/workflows/hiperseis_main_ci.yml
6+
:alt: Github Actions
7+
8+
.. image:: https://codecov.io/gh/GeoscienceAustralia/hiperseis/branch/develop/graph/badge.svg
9+
:target: https://codecov.io/gh/GeoscienceAustralia/hiperseis
10+
:alt: codecov
11+
12+
.. image:: https://readthedocs.org/projects/hiperseis/badge/?version=develop
13+
:target: http://hiperseis.readthedocs.io/en/develop/
14+
:alt: readthedocs
515

616
How to Cite
717
===========
@@ -62,10 +72,3 @@ License
6272

6373
HiPerSeis is licensed under the GPL version 3
6474

65-
66-
.. |Coverage Status| image:: https://coveralls.io/repos/github/GeoscienceAustralia/hiperseis/badge.svg
67-
:target: https://coveralls.io/github/GeoscienceAustralia/hiperseis
68-
69-
.. |Documentation Status| image:: https://readthedocs.org/projects/hiperseis/badge/?version=develop
70-
:target: http://hiperseis.readthedocs.io/en/develop/
71-

seismic/ml_classifier/data_harvester/cataloguing-ISC-noise.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
dist=float(pick[-1].strip())
4545
#get all S picks
4646
if ph=='S' and dist > 10:
47-
print ph
47+
print(ph)
4848
Sctr+=1
4949
ch=pick[1].strip()
5050

@@ -103,12 +103,12 @@
103103
wf.write(saveDir+str(wfctr)+'_N.pkl',format="PICKLE")
104104
np.save(saveDir+str(wfctr)+'_N.npy',wf.data)
105105
succ=True
106-
print "Got a rotated horizontal waveform"
106+
print("Got a rotated horizontal waveform")
107107

108108

109109
except Exception as e:
110110
#handle data missing
111-
print >> sys.stderr, e
111+
print(sys.stderr, e)
112112
stream=None
113113
else:
114114
wf=getWave(irisclient,st,ch,starttime,endtime,saveDir=saveDir)

seismic/ml_classifier/data_harvester/cataloguing-ISC.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
dist=float(pick[-1].strip())
4545
#get all S picks
4646
if ph=='S' and dist > 10:
47-
print ph
47+
print(ph)
4848
Sctr+=1
4949
ch=pick[1].strip()
5050

@@ -104,12 +104,12 @@
104104
wf.write(saveDir+str(wfctr)+'_S.pkl',format="PICKLE")
105105
np.save(saveDir+str(wfctr)+'_S.npy',wf.data)
106106
succ=True
107-
print "Got a rotated horizontal waveform"
107+
print("Got a rotated horizontal waveform")
108108

109109

110110
except Exception as e:
111111
#handle data missing
112-
print >> sys.stderr, e
112+
print(sys.stderr, e)
113113
stream=None
114114
else:
115115
wf=getWave(irisclient,st,ch,starttime,endtime,saveDir=saveDir)

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

0 commit comments

Comments
 (0)