Skip to content

Commit 1720b2c

Browse files
author
product1
committed
V.2.0.0 updates
1 parent adc360f commit 1720b2c

17 files changed

+142
-67
lines changed

ME.README

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242

4343
See usage document for a particular script by executing it without any call arguments
4444
See the package Wiki page for instructions and examples:
45-
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Microseism-Energy-(ME)-package
45+
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Microseism-Energy-(ME)-package-V.2
4646

4747
NOTES
4848

4949
- for more information:
5050
. visit IRIS DMC Noise Toolkit Data Product web page at: http://ds.iris.edu/ds/products/noise-toolkit/
51-
. visit product's Wiki page (https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Microseism-Energy-(ME)-package)
51+
. visit product's Wiki page (https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Microseism-Energy-(ME)-package-V.2)
5252

5353
HISTORY
5454

POLAR.README

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
RUNNING THE SCRIPTS:
4444

4545
see the package SeisCode Wiki page for instructions and examples:
46-
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Polarization-Attributes-package
46+
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Polarization-Attributes-package-V.2
4747

4848
NOTES
4949

5050
- for more information:
5151
.visit data product's web page at:
5252
http://ds.iris.edu/ds/products/noise-toolkit-polarization/
5353
.visit data product's Wiki page at:
54-
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Polarization-Attributes-package
54+
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Polarization-Attributes-package-V.2
5555

5656
HISTORY
5757
- 2020-11-16 V.2.0.0: Python 3, use of Fedcatalog and adoption of PEP 8 style guide

PSD.README

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
RUNNING THE SCRIPTS:
4444

4545
see the package Wiki page for instructions and examples:
46-
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-PDF-PSD-bundle
46+
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-PDF-PSD-package-V.2
4747

4848
NOTES
4949

5050
- for more information:
5151
. visit data product's web page at:
5252
http://ds.iris.edu/ds/products/noise-toolkit-pdf-psd/
5353
. visit data product's Wiki page at:
54-
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-PDF-PSD-bundle
54+
https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-PDF-PSD-package-V.2
5555

5656

5757
HISTORY

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Noise Toolkit (NTK)
55

66
2020-11-16\
7-
V.2.0 for Python 3
7+
V.2.0.0 for Python 3
88

99
------------------------------------------------------------------------------------------------------------------------
1010

@@ -37,7 +37,7 @@ Python 3 /ObsPy scripts to:
3737
- perform frequency dependent polarization analysis of the waveform data (Noise Toolkit Polarization
3838
Analysis package)
3939

40-
**PDF/PSD package** (Wiki page, https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-PDF-PSD-package-2)
40+
**PDF/PSD package** (Wiki page, https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-PDF-PSD-package-V.2)
4141

4242
The PDF/PSD package provides three highly configurable Python 3 scripts to calculate waveform spectra. This package takes advantage of FDSN Web service client for ObsPy to retrieve necessary waveform data, and it also allows users to process waveform data from their local files. This package provides PSD file collections similar to popular PQLX package (McNamara and Boaz, 2005, https://www.usgs.gov/software/pqlx-a-software-tool-evaluate-seismic-station-performance). The scripts included in this package are:
4343

@@ -51,7 +51,7 @@ The PDF/PSD package provides three highly configurable Python 3 scripts to calcu
5151
(the output is similar to PQLX's exPSDhour script, https://pubs.usgs.gov/of/2010/1292/)
5252
- ntk_binPsdDay.py - bins PSD's to daily files for a given channel and bounding parameters.
5353

54-
**Microseism Energy (ME) package** (Wiki page, https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Microseism-Energy-(ME)-package-2)
54+
**Microseism Energy (ME) package** (Wiki page, https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Microseism-Energy-(ME)-package-V.2)
5555

5656
Microseism Energy (ME) package is a collection of three Python 3 scripts that are configurable and allow users to conveniently calculate and plot microseism energy temporal variations in the period band of interest using the available PSD values. By default, the package is configured to to calculate ME over 1-5 s band, targeting smaller local storms for coastal stations, 5-10 s for the secondary microseisms, 11-30 s for the primary microseisms and the 50-200 s band for the Earth hum using PSDs of three-component broadband seismic data (BH channels). The stored microseism energy values will be smoothed using a median sliding time window (e.g. 6 hours, 12 hours, 1 day, 4 days, and 16 days, etc.).
5757

@@ -67,7 +67,7 @@ PSDs of seismic station waveform data needed for computation of the microseism e
6767
- the PDF-PSD package above
6868
- PSDs computed by IRIS’s MUSTANG noise-psd Web Service (http://service.iris.edu/mustang/noise-psd/1/)
6969

70-
**Polarization Attributes (POLAR) package** (Wiki page, https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Polarization-Attributes-package-2)
70+
**Polarization Attributes (POLAR) package** (Wiki page, https://github.com/iris-edu/noise-toolkit/wiki/Noise-Toolkit-Polarization-Attributes-package-V.2)
7171

7272
The Polarization package of the Noise Toolkit is based on the eigen-decomposition of the spectra covariance matrix of a sliding window of three-component seismic data, as described by Koper and Hawley (2010). The derived frequency dependent polarization attributes are:
7373

bin/ntk_binPolarDay.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def usage():
105105
f'\n\nExamples:'
106106
f'\n\n\t-usage:'
107107
f'\n\tpython {script}'
108-
f'\n\n\t- assuming that you already have executed the following command to generate polarization files:'
108+
f'\n\n\t- assuming that you already have executed the following command "successfully" to generate '
109+
f'polarization files:'
109110
f'\n\tpython ntk_computePolarization.py net=NM sta=SLM loc=DASH '
110111
f'start=2009-01-01T01:00:00 end=2009-01-01T03:00:00 xtype=frequency verbose=0'
111112
f'\n\n\tyou can bin the polarization parameters into daily files: '
@@ -157,13 +158,23 @@ def usage():
157158

158159
# We always want to start from the beginning of the day, so we discard user hours, if any
159160
start_date_time = utils_lib.get_param(args, 'start', None, usage)
160-
start_datetime, start_year, start_month, start_day, start_doy = utils_lib.time_info(start_date_time)
161+
try:
162+
start_datetime, start_year, start_month, start_day, start_doy = utils_lib.time_info(start_date_time)
163+
except Exception as ex:
164+
usage()
165+
code = msg_lib.error(f'Invalid start ({start_date_time})\n{ex}', 2)
166+
sys.exit(code)
161167

162168
# We always want to start from the beginning of the day, so we discard user hours, if any.
163169
end_date_time = utils_lib.get_param(args, 'end', None, usage)
164170

165171
# end_date_time is included.
166-
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
172+
try:
173+
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
174+
except Exception as ex:
175+
usage()
176+
code = msg_lib.error(f'Invalid end ({end_date_time})\n{ex}', 2)
177+
sys.exit(code)
167178

168179
duration = end_datetime - start_datetime
169180

bin/ntk_binPsdDay.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def usage():
109109
f'\n\nExamples:'
110110
f'\n\n\t- usage:'
111111
f'\n\tpython {script}'
112-
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example:'
112+
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example "successfully":'
113113
f'\n\tpython ntk_computePSD.py net=TA sta=O18A loc=DASH start=2008-08-14T12:00:00 end=2008-08-14T13:30:00'
114114
f'\n\n\tyou can perform binning via:'
115115
f'\n\tpython {script} net=TA sta=O18A loc=DASH chan=BHZ start=2008-08-14T12:00:00 end=2008-08-14T13:30:00 '
@@ -157,12 +157,22 @@ def usage():
157157
start_date_time = utils_lib.get_param(args, 'start', None, usage)
158158
start_date_time = start_date_time.split('T')[0]
159159
start_year, start_month, start_day = start_date_time.split('-')
160-
start_datetime = UTCDateTime(start_date_time)
160+
try:
161+
start_datetime = UTCDateTime(start_date_time)
162+
except Exception as ex:
163+
usage()
164+
code = msg_lib.error(f'Invalid start ({start_date_time})\n{ex}', 2)
165+
sys.exit(code)
161166

162167
end_date_time = utils_lib.get_param(args, 'end', None, usage)
163168
end_date_time = end_date_time.split('T')[0]
164169
end_year, end_month, end_day = end_date_time.split('-')
165-
end_datetime = UTCDateTime(end_date_time) + 86400
170+
try:
171+
end_datetime = UTCDateTime(end_date_time) + 86400
172+
except Exception as ex:
173+
usage()
174+
code = msg_lib.error(f'Invalid end ({end_date_time})\n{ex}', 2)
175+
sys.exit(code)
166176

167177
delta = date(int(end_year), int(end_month), int(end_day)) - \
168178
date(int(start_year), int(start_month), int(start_day))

bin/ntk_computePSD.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def usage():
173173
f'start=2009-03-01T00:00:00 end=2009-03-31T00:00:00 xtype=period plot=0 verbose=0'
174174
f'\n\n\t- try other stations and time intervals:'
175175
f'\n\tpython {script} net=NM sta=SLM loc=DASH chan=BHZ start=2009-11-01T12:00:00 '
176-
f'end=2009-11-01T13:00:00 xtype=period plot=1'
176+
f'end=2009-11-01T14:00:00 xtype=period plot=1'
177177
f'\n\tpython {script} param=computePSD net=TA sta=959A loc=DASH start=2013-10-01T11:00:00 '
178178
f'end=2013-10-01T13:00:00 xtype=period plot=1'
179179
f'\n\n\t- BHZ channel for GR.BFO with data from a data center other than IRIS:'
@@ -328,18 +328,28 @@ def usage():
328328
# Less than 3 characters station name triggers wildcards.
329329
if len(request_station) <= 2:
330330
if request_client == 'IRIS':
331-
msg_lib.error('Invalid station name (for IRIS client, wildcards are not accepted. '
332-
'Please use full station name)', 2)
333-
sys.exit()
331+
code = msg_lib.error('Invalid station name (for IRIS client, wildcards are not accepted. '
332+
'Please use full station name)', 2)
333+
sys.exit(code)
334334

335335
request_station = f'*{request_station}*'
336336

337337
# Specific start and end date and times from user.
338338
request_start_date_time = utils_lib.get_param(args, 'start', None, usage)
339-
request_start_datetime = UTCDateTime(request_start_date_time)
339+
try:
340+
request_start_datetime = UTCDateTime(request_start_date_time)
341+
except Exception as ex:
342+
usage()
343+
code = msg_lib.error(f'Invalid start ({request_start_date_time})\n{ex}', 2)
344+
sys.exit(code)
340345

341346
request_end_date_time = utils_lib.get_param(args, 'end', None, usage)
342-
request_end_datetime = UTCDateTime(request_end_date_time)
347+
try:
348+
request_end_datetime = UTCDateTime(request_end_date_time)
349+
except Exception as ex:
350+
usage()
351+
code = msg_lib.error(f'Invalid end ({request_end_date_time})\n{ex}', 2)
352+
sys.exit(code)
343353

344354
if timing:
345355
t0 = utils_lib.time_it('request info', t0)
@@ -352,9 +362,9 @@ def usage():
352362
try:
353363
plot_index = utils_lib.param(param, 'xtype').xtype.index(xtype)
354364
except Exception as e:
355-
msg_lib.error(f'Invalid plot type ({xtype})\n{e}', 2)
356365
usage()
357-
sys.exit()
366+
code = msg_lib.error(f'Invalid plot type ({xtype})\n{e}', 2)
367+
sys.exit(code)
358368

359369
if timing:
360370
t0 = utils_lib.time_it('parameters', t0)
@@ -679,8 +689,7 @@ def usage():
679689
param, 'namingConvention').namingConvention, filePath, tagList)
680690
msg_lib.message(f'OUTPUT: writing to {output_file_name}')
681691

682-
with open(output_file_name,
683-
'w') as output_file:
692+
with open(output_file_name, 'w') as output_file:
684693

685694
# Output the header.
686695
output_file.write('%s %s\n' % (xUnits, powerUnits))

bin/ntk_computePolarization.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,20 @@ def usage():
332332

333333
# Specific start and end date and times from user.
334334
request_start_date_time = utils_lib.get_param(args, 'start', None, usage)
335-
request_start_datetime = UTCDateTime(request_start_date_time)
335+
try:
336+
request_start_datetime = UTCDateTime(request_start_date_time)
337+
except Exception as ex:
338+
usage()
339+
code = msg_lib.error(f'Invalid start ({request_start_date_time})\n{ex}', 2)
340+
sys.exit(code)
336341

337342
request_end_date_time = utils_lib.get_param(args, 'end', None, usage)
338-
request_end_datetime = UTCDateTime(request_end_date_time)
343+
try:
344+
request_end_datetime = UTCDateTime(request_end_date_time)
345+
except Exception as ex:
346+
usage()
347+
code = msg_lib.error(f'Invalid end ({request_end_datetime})\n{ex}', 2)
348+
sys.exit(code)
339349

340350
if timing:
341351
t0 = utils_lib.time_it('request info', t0)

bin/ntk_computePower.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
PDF files
4343
4444
HISTORY:
45-
2020-11-16 Manoch: V.2.0.0 Python and adoption of PEP 8 style guide.
45+
2020-11-16 Manoch: V.2.0.0 Python 3 and adoption of PEP 8 style guide.
4646
2015-04-22 Manoch: file name correction
4747
2014-11-24 Manoch: Beta release (V.0.5) to compute power based on a combined PSD file
4848
with format similar to output of the ntk_extractPsdHour.py script (see NTK PSD/PDF bundle)
@@ -102,7 +102,7 @@ def usage():
102102
f'\n\nExamples:'
103103
f'\n\n\t-usage:'
104104
f'\n\tpython {script}'
105-
f'\n\n\t- assuming that you already have executed the following command to generate PSD files:'
105+
f'\n\n\t- assuming that you already have executed the following command "successfully" to generate PSD files:'
106106
f'\n\tpython ntk_extractPsdHour.py net=TA sta=O18A loc=DASH chan=BHZ start=2008-08-14T12:00:00 '
107107
f'end=2008-08-14T12:30:00 xtype=period'
108108
f'\n\n\tcompute power via:'

bin/ntk_extractPolarHour.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ def usage():
102102
f'\n\nExamples:'
103103
f'\n\n\t- usage:'
104104
f'\n\tpython {script}'
105-
f'\n\n\t- assuming that you already have executed the following command to generate polarization files:'
105+
f'\n\n\t- assuming that you already have executed the following command "successfully" to generate '
106+
f'polarization files:'
106107
f'\n\tpython ntk_computePolarization.py net=NM sta=SLM loc=DASH '
107108
f'start=2009-01-01T01:00:00 end=2009-01-01T03:00:00 xtype=frequency verbose=0'
108109
f'\n\n\tyou can perform extraction via:'
109110
f'\n\tpython {script} param=extractPolarHour net=NM sta=SLM loc=DASH chandir=BHZ_BHE_BHN '
110-
f'start=2009-01-01T01:00:00 end=2009-01-01T0:00:00 xtype=frequency verbose=0'
111+
f'start=2009-01-01T01:00:00 end=2009-01-02T0:00:00 xtype=frequency verbose=0'
111112
f'\n\n\n\n')
112113

113114

@@ -161,13 +162,23 @@ def usage():
161162

162163
# We always want to start from the beginning of the day, so we discard user hours, if any
163164
start_date_time = utils_lib.get_param(args, 'start', None, usage)
164-
start_datetime, start_year, start_month, start_day, start_doy = utils_lib.time_info(start_date_time)
165+
try:
166+
start_datetime, start_year, start_month, start_day, start_doy = utils_lib.time_info(start_date_time)
167+
except Exception as ex:
168+
usage()
169+
code = msg_lib.error(f'Invalid start ({start_date_time})\n{ex}', 2)
170+
sys.exit(code)
165171

166172
# We always want to start from the beginning of the day, so we discard user hours, if any.
167173
end_date_time = utils_lib.get_param(args, 'end', None, usage)
168174

169175
# end_date_time is included.
170-
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
176+
try:
177+
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
178+
except Exception as ex:
179+
usage()
180+
code = msg_lib.error(f'Invalid end ({end_date_time})\n{ex}', 2)
181+
sys.exit(code)
171182

172183
duration = end_datetime - start_datetime
173184

@@ -181,9 +192,9 @@ def usage():
181192
data_day_list.append(this_day.strftime("%Y/%j"))
182193

183194
if duration <= 0 or len(data_day_list) <= 0:
184-
msg_lib.error(f'bad start/end times [{start_date_time}, {end_date_time}]', 2)
185195
usage()
186-
sys.exit()
196+
code = msg_lib.error(f'bad start/end times [{start_date_time}, {end_date_time}]', 2)
197+
sys.exit(code)
187198

188199
xType = utils_lib.get_param(args, 'type', 'frequency', usage) # what the x-axis should represent
189200

bin/ntk_extractPsdHour.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def usage():
109109
f'\n\nExamples:'
110110
f'\n\n\t- usage:'
111111
f'\n\tpython {script}'
112-
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example:'
112+
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example "successfully":'
113113
f'\n\tpython ntk_computePSD.py net=TA sta=O18A loc=DASH start=2008-08-14T12:00:00 end=2008-08-14T13:30:00'
114114
f'\n\n\tyou can perform PSD extraction via:'
115115
f'\n\tpython {script} net=TA sta=O18A loc=DASH chan=BHZ start=2008-08-14T12:00:00 '
@@ -151,12 +151,22 @@ def usage():
151151
start_date_time = utils_lib.get_param(args, 'start', None, usage)
152152
start_date_time = start_date_time.split('T')[0]
153153
start_year, start_month, start_day = start_date_time.split('-')
154-
start_datetime = UTCDateTime(start_date_time)
154+
try:
155+
start_datetime = UTCDateTime(start_date_time)
156+
except Exception as ex:
157+
usage()
158+
code = msg_lib.error(f'Invalid start ({start_date_time})\n{ex}', 2)
159+
sys.exit(code)
155160

156161
end_date_time = utils_lib.get_param(args, 'end', None, usage)
157162
end_date_time = end_date_time.split('T')[0]
158163
end_year, end_month, end_day = end_date_time.split('-')
159-
end_datetime = UTCDateTime(end_date_time) + 86400
164+
try:
165+
end_datetime = UTCDateTime(end_date_time) + 86400
166+
except Exception as ex:
167+
usage()
168+
code = msg_lib.error(f'Invalid end ({end_date_time})\n{ex}', 2)
169+
sys.exit(code)
160170

161171
delta = date(int(end_year), int(end_month), int(end_day)) - \
162172
date(int(start_year), int(start_month), int(start_day))

bin/ntk_medianPower.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ def usage():
104104
f'\n\nExamples:'
105105
f'\n\n\t- usage:'
106106
f'\n\tpython {script}'
107-
f'\n\n\t- assuming that you have already computed power via:'
107+
f'\n\n\t- assuming that you have already "successfully" computed power via:'
108108
f'\n\tpython ntk_computePower.py param=computePower net=TA sta=O18A loc=DASH chan=BHZ xtype=period verbose=1 '
109109
f'file=TA.O18A.--.BHZ.2008-08-14.2008-08-14.period.txt'
110-
f'\n\n\tthen, compute median power via:'
110+
f'\n\n\tthen, compute median power "successfully" via:'
111111
f'\n\tpython {script} param={default_param_file} net=TA sta=O18A loc=DASH chan=BHZ xtype=period verbose=0 '
112112
f'win=12 start=2008-08-14T00:00:00 end=2008-08-14T23:00:00 '
113113
f'file=TA.O18A.--.BHZ.2008-08-14.2008-08-14.txt'

0 commit comments

Comments
 (0)