Skip to content

Commit

Permalink
include channel on name + flex de week time
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrasilio committed Dec 3, 2019
1 parent 79d0ee9 commit 100157c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tools/averagePlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
VERSION = '1.0'


def plot_average(periods, average_noise, w3_average_noise, w6_average_noise, network, station, begin, end, show=False):
def plot_average(periods, average_noise, w3_average_noise, w6_average_noise, network, station, channel, week, begin, end, show=False):

t, h = pypqlx.get_nhnm()
t, l = pypqlx.get_nlnm()
Expand All @@ -19,10 +19,10 @@ def plot_average(periods, average_noise, w3_average_noise, w6_average_noise, net
ax.semilogx(periods, average_noise, color='#E91E63', label='Average Noise')

if (len(w3_data) > 0):
ax.semilogx(periods, w3_average_noise, color='#2196F3', label='Last 3 weeks')
ax.semilogx(periods, w3_average_noise, color='#2196F3', label='Last '+ str(week) +' weeks')

if (len(w6_data) > 0):
ax.semilogx(periods, w6_average_noise, color='#00C853', label='Last 6 weeks')
ax.semilogx(periods, w6_average_noise, color='#00C853', label='Last '+ str(week) +' weeks')

ax.legend()
ax.set_xlabel('Period [s]')
Expand All @@ -31,8 +31,8 @@ def plot_average(periods, average_noise, w3_average_noise, w6_average_noise, net
ax.grid()
plt.xlim(0.1, 179)

plt.title('%s %s Average Noise from %s to %s' % (network, station, begin, end))
imgfile = ".".join((network, station, 'png'))
plt.title('%s.%s.%s Average Noise from \n %s to %s' % (network, station,channel, begin, end))
imgfile = ".".join((network, station, channel, 'png'))
plt.savefig(imgfile, dpi=200)
print(imgfile,'generated.')
if show:
Expand Down Expand Up @@ -70,6 +70,9 @@ def make_cmdline_parser():

parser.add_option("-v", "--view", action="store_true", dest="view",
help="Optional. If you want to view generated plots", default=False)

parser.add_option("-w", "--weekdelta", type="int", dest="weekdt",
help="Optional. Choose the week from actual to plot.", default=None)

return parser

Expand Down Expand Up @@ -106,6 +109,7 @@ def make_cmdline_parser():
nslc = options.nslc
stalist = options.stalist
view = options.view
weekdt = options.weekdt
streams = []

if (nslc == None and stalist == None):
Expand All @@ -120,6 +124,9 @@ def make_cmdline_parser():
else:
stream = " ".join((nslc.split('_')))
streams.append(stream)

if weekdt == None:
weekdt = 3

#
## Making plots:
Expand Down Expand Up @@ -150,7 +157,8 @@ def make_cmdline_parser():
#
## get noise data from past 3 weeks
#
delta = datetime.timedelta(weeks=3)
#delta = datetime.timedelta(weeks=3)
delta = datetime.timedelta(weeks=weekdt)
w3_pdf = db.PDF(start - delta, end - delta, net, sta, cha, loc)
w3_data = w3_pdf.average()

Expand All @@ -160,7 +168,8 @@ def make_cmdline_parser():
#
## get noise data from past 6 weeks
#
t = datetime.timedelta(weeks=6)
#t = datetime.timedelta(weeks=6)
t = datetime.timedelta(weeks=weekdt*2)
w6_pdf = db.PDF(start - t, end - t, net, sta, cha, loc)
w6_data = w6_pdf.average()

Expand All @@ -176,8 +185,10 @@ def make_cmdline_parser():
w6_average_noise=w6_data,
network=net,
station=sta,
channel=cha,
begin=start.date(),
end=end.date(),
week=weekdt,
show=view)

db.close()
Expand Down

0 comments on commit 100157c

Please sign in to comment.