Skip to content

Commit

Permalink
Merge pull request #77 from fenrog/sberl/71
Browse files Browse the repository at this point in the history
issue sberl/71: added y axis control to supersid_plot.py command line
  • Loading branch information
sberl authored Jan 17, 2025
2 parents bf43835 + 685e3c1 commit 04d2afa
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions supersid/supersid_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter as ff
import matplotlib.dates
import math
# Internet and Email modules
import mimetypes
import smtplib
Expand Down Expand Up @@ -133,8 +134,7 @@ def get_station_color(self, config, call_sign):
return station['color'] or None
return None

def plot_filelist(self, filelist, showPlot=True, eMail=None, pdf=None,
web=False, config=None):
def plot_filelist(self, filelist, args, config):
"""Read the files in the filelist parameters.
Each data are combine in one plot.
Expand All @@ -143,6 +143,13 @@ def plot_filelist(self, filelist, showPlot=True, eMail=None, pdf=None,
Connection for the given days to NOAA website is possible (web) in
order to draw vetical lines for XRA data.
"""
showPlot=args.showPlot
eMail=args.email
pdf=args.pdffilename
web=args.webData
y_min = args.y_min
y_max = args.y_max

emailText = []

def Tstamp(HHMM):
Expand Down Expand Up @@ -296,6 +303,9 @@ def Tstamp(HHMM):

print("All files read in", clock(), "sec.")

if not math.isnan(y_max):
maxData = y_max

if web: # add the lines marking the retrieved flares from NOAA
alternate = 0
for eventName, BeginTime, MaxTime, EndTime, Particulars in XRAlist:
Expand Down Expand Up @@ -331,6 +341,11 @@ def Tstamp(HHMM):

fig.suptitle(", ".join(figTitle))

# set the y axis limits as passed vai command line arguments
if not math.isnan(y_min):
plt.ylim(bottom=y_min)
if not math.isnan(y_max):
plt.ylim(top=y_max)
plt.legend()
plt.tight_layout()

Expand All @@ -350,10 +365,9 @@ def Tstamp(HHMM):
"""


def do_main(filelist, showPlot=True, eMail=None, pdf=None,
web=False, config=None):
def do_main(filelist, args, config):
ssp = SUPERSID_PLOT()
ssp.plot_filelist(filelist, showPlot, eMail, pdf, web, config)
ssp.plot_filelist(filelist, args, config)


if __name__ == '__main__':
Expand Down Expand Up @@ -425,6 +439,18 @@ def do_main(filelist, showPlot=True, eMail=None, pdf=None,
dest="verbose",
default=False,
help="Print more messages.")
parser.add_argument(
"--y-min",
dest="y_min",
default=float('NaN'),
type=float,
help="y axis minimum; default is auto")
parser.add_argument(
"--y-max",
dest="y_max",
default=float('NaN'),
type=float,
help="y axis maximum; default is auto")
parser.add_argument(
'file_list',
metavar='file.csv',
Expand Down Expand Up @@ -480,11 +506,6 @@ def do_main(filelist, showPlot=True, eMail=None, pdf=None,
print("List of files:", filenames)

if filenames:
do_main(filenames,
showPlot=args.showPlot,
eMail=args.email,
pdf=args.pdffilename,
web=args.webData,
config=config)
do_main(filenames, args, config)
else:
parser.error("No file to plot found.")

0 comments on commit 04d2afa

Please sign in to comment.