Skip to content

Commit

Permalink
V.2.0.0 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
product1 committed Nov 16, 2020
1 parent adc360f commit 1720b2c
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 67 deletions.
4 changes: 2 additions & 2 deletions ME.README
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@

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

NOTES

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

HISTORY

Expand Down
4 changes: 2 additions & 2 deletions POLAR.README
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
RUNNING THE SCRIPTS:

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

NOTES

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

HISTORY
- 2020-11-16 V.2.0.0: Python 3, use of Fedcatalog and adoption of PEP 8 style guide
Expand Down
4 changes: 2 additions & 2 deletions PSD.README
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
RUNNING THE SCRIPTS:

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

NOTES

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


HISTORY
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Noise Toolkit (NTK)

2020-11-16\
V.2.0 for Python 3
V.2.0.0 for Python 3

------------------------------------------------------------------------------------------------------------------------

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

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

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:

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

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

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.).

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

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

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:

Expand Down
17 changes: 14 additions & 3 deletions bin/ntk_binPolarDay.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def usage():
f'\n\nExamples:'
f'\n\n\t-usage:'
f'\n\tpython {script}'
f'\n\n\t- assuming that you already have executed the following command to generate polarization files:'
f'\n\n\t- assuming that you already have executed the following command "successfully" to generate '
f'polarization files:'
f'\n\tpython ntk_computePolarization.py net=NM sta=SLM loc=DASH '
f'start=2009-01-01T01:00:00 end=2009-01-01T03:00:00 xtype=frequency verbose=0'
f'\n\n\tyou can bin the polarization parameters into daily files: '
Expand Down Expand Up @@ -157,13 +158,23 @@ def usage():

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

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

# end_date_time is included.
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
try:
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid end ({end_date_time})\n{ex}', 2)
sys.exit(code)

duration = end_datetime - start_datetime

Expand Down
16 changes: 13 additions & 3 deletions bin/ntk_binPsdDay.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def usage():
f'\n\nExamples:'
f'\n\n\t- usage:'
f'\n\tpython {script}'
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example:'
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example "successfully":'
f'\n\tpython ntk_computePSD.py net=TA sta=O18A loc=DASH start=2008-08-14T12:00:00 end=2008-08-14T13:30:00'
f'\n\n\tyou can perform binning via:'
f'\n\tpython {script} net=TA sta=O18A loc=DASH chan=BHZ start=2008-08-14T12:00:00 end=2008-08-14T13:30:00 '
Expand Down Expand Up @@ -157,12 +157,22 @@ def usage():
start_date_time = utils_lib.get_param(args, 'start', None, usage)
start_date_time = start_date_time.split('T')[0]
start_year, start_month, start_day = start_date_time.split('-')
start_datetime = UTCDateTime(start_date_time)
try:
start_datetime = UTCDateTime(start_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid start ({start_date_time})\n{ex}', 2)
sys.exit(code)

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

delta = date(int(end_year), int(end_month), int(end_day)) - \
date(int(start_year), int(start_month), int(start_day))
Expand Down
29 changes: 19 additions & 10 deletions bin/ntk_computePSD.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def usage():
f'start=2009-03-01T00:00:00 end=2009-03-31T00:00:00 xtype=period plot=0 verbose=0'
f'\n\n\t- try other stations and time intervals:'
f'\n\tpython {script} net=NM sta=SLM loc=DASH chan=BHZ start=2009-11-01T12:00:00 '
f'end=2009-11-01T13:00:00 xtype=period plot=1'
f'end=2009-11-01T14:00:00 xtype=period plot=1'
f'\n\tpython {script} param=computePSD net=TA sta=959A loc=DASH start=2013-10-01T11:00:00 '
f'end=2013-10-01T13:00:00 xtype=period plot=1'
f'\n\n\t- BHZ channel for GR.BFO with data from a data center other than IRIS:'
Expand Down Expand Up @@ -328,18 +328,28 @@ def usage():
# Less than 3 characters station name triggers wildcards.
if len(request_station) <= 2:
if request_client == 'IRIS':
msg_lib.error('Invalid station name (for IRIS client, wildcards are not accepted. '
'Please use full station name)', 2)
sys.exit()
code = msg_lib.error('Invalid station name (for IRIS client, wildcards are not accepted. '
'Please use full station name)', 2)
sys.exit(code)

request_station = f'*{request_station}*'

# Specific start and end date and times from user.
request_start_date_time = utils_lib.get_param(args, 'start', None, usage)
request_start_datetime = UTCDateTime(request_start_date_time)
try:
request_start_datetime = UTCDateTime(request_start_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid start ({request_start_date_time})\n{ex}', 2)
sys.exit(code)

request_end_date_time = utils_lib.get_param(args, 'end', None, usage)
request_end_datetime = UTCDateTime(request_end_date_time)
try:
request_end_datetime = UTCDateTime(request_end_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid end ({request_end_date_time})\n{ex}', 2)
sys.exit(code)

if timing:
t0 = utils_lib.time_it('request info', t0)
Expand All @@ -352,9 +362,9 @@ def usage():
try:
plot_index = utils_lib.param(param, 'xtype').xtype.index(xtype)
except Exception as e:
msg_lib.error(f'Invalid plot type ({xtype})\n{e}', 2)
usage()
sys.exit()
code = msg_lib.error(f'Invalid plot type ({xtype})\n{e}', 2)
sys.exit(code)

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

with open(output_file_name,
'w') as output_file:
with open(output_file_name, 'w') as output_file:

# Output the header.
output_file.write('%s %s\n' % (xUnits, powerUnits))
Expand Down
14 changes: 12 additions & 2 deletions bin/ntk_computePolarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,20 @@ def usage():

# Specific start and end date and times from user.
request_start_date_time = utils_lib.get_param(args, 'start', None, usage)
request_start_datetime = UTCDateTime(request_start_date_time)
try:
request_start_datetime = UTCDateTime(request_start_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid start ({request_start_date_time})\n{ex}', 2)
sys.exit(code)

request_end_date_time = utils_lib.get_param(args, 'end', None, usage)
request_end_datetime = UTCDateTime(request_end_date_time)
try:
request_end_datetime = UTCDateTime(request_end_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid end ({request_end_datetime})\n{ex}', 2)
sys.exit(code)

if timing:
t0 = utils_lib.time_it('request info', t0)
Expand Down
4 changes: 2 additions & 2 deletions bin/ntk_computePower.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
PDF files
HISTORY:
2020-11-16 Manoch: V.2.0.0 Python and adoption of PEP 8 style guide.
2020-11-16 Manoch: V.2.0.0 Python 3 and adoption of PEP 8 style guide.
2015-04-22 Manoch: file name correction
2014-11-24 Manoch: Beta release (V.0.5) to compute power based on a combined PSD file
with format similar to output of the ntk_extractPsdHour.py script (see NTK PSD/PDF bundle)
Expand Down Expand Up @@ -102,7 +102,7 @@ def usage():
f'\n\nExamples:'
f'\n\n\t-usage:'
f'\n\tpython {script}'
f'\n\n\t- assuming that you already have executed the following command to generate PSD files:'
f'\n\n\t- assuming that you already have executed the following command "successfully" to generate PSD files:'
f'\n\tpython ntk_extractPsdHour.py net=TA sta=O18A loc=DASH chan=BHZ start=2008-08-14T12:00:00 '
f'end=2008-08-14T12:30:00 xtype=period'
f'\n\n\tcompute power via:'
Expand Down
23 changes: 17 additions & 6 deletions bin/ntk_extractPolarHour.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ def usage():
f'\n\nExamples:'
f'\n\n\t- usage:'
f'\n\tpython {script}'
f'\n\n\t- assuming that you already have executed the following command to generate polarization files:'
f'\n\n\t- assuming that you already have executed the following command "successfully" to generate '
f'polarization files:'
f'\n\tpython ntk_computePolarization.py net=NM sta=SLM loc=DASH '
f'start=2009-01-01T01:00:00 end=2009-01-01T03:00:00 xtype=frequency verbose=0'
f'\n\n\tyou can perform extraction via:'
f'\n\tpython {script} param=extractPolarHour net=NM sta=SLM loc=DASH chandir=BHZ_BHE_BHN '
f'start=2009-01-01T01:00:00 end=2009-01-01T0:00:00 xtype=frequency verbose=0'
f'start=2009-01-01T01:00:00 end=2009-01-02T0:00:00 xtype=frequency verbose=0'
f'\n\n\n\n')


Expand Down Expand Up @@ -161,13 +162,23 @@ def usage():

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

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

# end_date_time is included.
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
try:
end_datetime, end_year, end_month, end_day, end_doy = utils_lib.time_info(end_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid end ({end_date_time})\n{ex}', 2)
sys.exit(code)

duration = end_datetime - start_datetime

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

if duration <= 0 or len(data_day_list) <= 0:
msg_lib.error(f'bad start/end times [{start_date_time}, {end_date_time}]', 2)
usage()
sys.exit()
code = msg_lib.error(f'bad start/end times [{start_date_time}, {end_date_time}]', 2)
sys.exit(code)

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

Expand Down
16 changes: 13 additions & 3 deletions bin/ntk_extractPsdHour.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def usage():
f'\n\nExamples:'
f'\n\n\t- usage:'
f'\n\tpython {script}'
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example:'
f'\n\n\t- Assuming that you already have tried the following ntk_compute_PSD.py example "successfully":'
f'\n\tpython ntk_computePSD.py net=TA sta=O18A loc=DASH start=2008-08-14T12:00:00 end=2008-08-14T13:30:00'
f'\n\n\tyou can perform PSD extraction via:'
f'\n\tpython {script} net=TA sta=O18A loc=DASH chan=BHZ start=2008-08-14T12:00:00 '
Expand Down Expand Up @@ -151,12 +151,22 @@ def usage():
start_date_time = utils_lib.get_param(args, 'start', None, usage)
start_date_time = start_date_time.split('T')[0]
start_year, start_month, start_day = start_date_time.split('-')
start_datetime = UTCDateTime(start_date_time)
try:
start_datetime = UTCDateTime(start_date_time)
except Exception as ex:
usage()
code = msg_lib.error(f'Invalid start ({start_date_time})\n{ex}', 2)
sys.exit(code)

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

delta = date(int(end_year), int(end_month), int(end_day)) - \
date(int(start_year), int(start_month), int(start_day))
Expand Down
4 changes: 2 additions & 2 deletions bin/ntk_medianPower.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def usage():
f'\n\nExamples:'
f'\n\n\t- usage:'
f'\n\tpython {script}'
f'\n\n\t- assuming that you have already computed power via:'
f'\n\n\t- assuming that you have already "successfully" computed power via:'
f'\n\tpython ntk_computePower.py param=computePower net=TA sta=O18A loc=DASH chan=BHZ xtype=period verbose=1 '
f'file=TA.O18A.--.BHZ.2008-08-14.2008-08-14.period.txt'
f'\n\n\tthen, compute median power via:'
f'\n\n\tthen, compute median power "successfully" via:'
f'\n\tpython {script} param={default_param_file} net=TA sta=O18A loc=DASH chan=BHZ xtype=period verbose=0 '
f'win=12 start=2008-08-14T00:00:00 end=2008-08-14T23:00:00 '
f'file=TA.O18A.--.BHZ.2008-08-14.2008-08-14.txt'
Expand Down
Loading

0 comments on commit 1720b2c

Please sign in to comment.