Skip to content

Commit 37b0123

Browse files
committed
added file saving in SAC format
1 parent 538e2ac commit 37b0123

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

obstools/atacr/classes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from pkg_resources import resource_filename
3333
from pathlib import Path
3434
np.seterr(all='ignore')
35-
np.set_printoptions(threshold=sys.maxsize)
35+
#np.set_printoptions(threshold=sys.maxsize)
3636

3737

3838
class Power(object):

obstools/scripts/atacr_correct_event.py

+29
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,21 @@ def main(args=None):
442442
file = correctpath / eventfile.stem
443443
eventstream.save(str(file) + '.day.pkl')
444444

445+
# Now save as SAC files
446+
for key, value in tfaverage.tf_list.items():
447+
if value and eventstream.ev_list[key]:
448+
nameZ = '.sta.' + key + '.'
449+
nameZ += sta.channel+'Z.SAC'
450+
fileZ = correctpath / (eventfile.stem + nameZ)
451+
trZ = eventstream.sth.select(component='Z')[0].copy()
452+
trZ.data = eventstream.correct[key]
453+
trZ = utils.update_stats(trZ,
454+
sta.latitude, sta.longitude,
455+
sta.elevation, 'Z')
456+
trZ.write(str(fileZ), format='SAC')
457+
458+
459+
445460
# This case refers to the "daily" spectral averages
446461
else:
447462
if not args.skip_daily:
@@ -483,6 +498,20 @@ def main(args=None):
483498
file = correctpath / eventfile.stem
484499
eventstream.save(str(file) + '.sta.pkl')
485500

501+
# Now save as SAC files
502+
for key, value in tfaverage.tf_list.items():
503+
if value and eventstream.ev_list[key]:
504+
nameZ = '.day.' + key + '.'
505+
nameZ += sta.channel+'Z.SAC'
506+
fileZ = correctpath / (eventfile.stem + nameZ)
507+
trZ = eventstream.sth.select(component='Z')[0].copy()
508+
trZ.data = eventstream.correct[key]
509+
trZ = utils.update_stats(trZ,
510+
sta.latitude, sta.longitude,
511+
sta.elevation, 'Z')
512+
trZ.write(str(fileZ), format='SAC')
513+
514+
486515
if __name__ == "__main__":
487516

488517
# Run main program

obstools/scripts/atacr_download_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def main(args=None):
515515
'.'+str(time.minute).zfill(2)
516516

517517
# Define file names (to check if files already exist)
518-
filename = eventpath / (tstamp+'.event.pkl')
518+
filename = eventpath / (tstamp+'.pkl')
519519
# Horizontal 1 channel
520520
file1 = eventpath / (tstamp+'.'+sta.channel+'1.SAC')
521521
# Horizontal 2 channel

0 commit comments

Comments
 (0)