Skip to content
Snippets Groups Projects
Commit a9996217 authored by Kien Le's avatar Kien Le
Browse files

Add tests for functions in plottingData.py

parent 5c99a818
No related branches found
No related tags found
1 merge request!19Add tests for function in plottingData.py
...@@ -7,7 +7,6 @@ import math ...@@ -7,7 +7,6 @@ import math
from obspy import UTCDateTime from obspy import UTCDateTime
from sohstationviewer.conf import constants as const from sohstationviewer.conf import constants as const
maxInt = 1E100 maxInt = 1E100
maxFloat = 1.0E100 maxFloat = 1.0E100
...@@ -36,10 +35,12 @@ def getMassposValueColors(rangeOpt, chan_id, cMode, processing_log, ...@@ -36,10 +35,12 @@ def getMassposValueColors(rangeOpt, chan_id, cMode, processing_log,
if rangeOpt.lower() not in MassPosVoltRanges.keys(): if rangeOpt.lower() not in MassPosVoltRanges.keys():
processing_log.append( processing_log.append(
f"{chan_id}: The current selected Mass Position color range is " (
f"'{rangeOpt}' isn't allowable. The accept ranges are: " f"{chan_id}: The current selected Mass Position color range is"
f"{', '.join(MassPosVoltRanges.keys())}", f" '{rangeOpt}' isn't allowable. The accept ranges are: "
"error" f"{', '.join(MassPosVoltRanges.keys())}",
"error"
)
) )
return return
massPosVoltRange = MassPosVoltRanges[rangeOpt] massPosVoltRange = MassPosVoltRanges[rangeOpt]
...@@ -54,7 +55,8 @@ def getMassposValueColors(rangeOpt, chan_id, cMode, processing_log, ...@@ -54,7 +55,8 @@ def getMassposValueColors(rangeOpt, chan_id, cMode, processing_log,
if i == len(massPosVoltRange) - 1: if i == len(massPosVoltRange) - 1:
if retType == 'str': if retType == 'str':
valueColors.append( valueColors.append(
"%s:+%s" % (massPosVoltRange[i], massPosColorPallet[i+1])) "%s:+%s" % (
massPosVoltRange[i], massPosColorPallet[i + 1]))
else: else:
valueColors.append( valueColors.append(
(massPosVoltRange[i], massPosColorPallet[i + 1])) (massPosVoltRange[i], massPosColorPallet[i + 1]))
...@@ -102,7 +104,7 @@ def getTitle(key, minTime, maxTime, dateMode): ...@@ -102,7 +104,7 @@ def getTitle(key, minTime, maxTime, dateMode):
:return: title for the plot - str :return: title for the plot - str
""" """
diff = maxTime - minTime diff = maxTime - minTime
hours = diff/3600 hours = diff / 3600
return ("%s %s to %s (%s)" % return ("%s %s to %s (%s)" %
(key, (key,
formatTime(minTime, dateMode, "HH:MM:SS"), formatTime(minTime, dateMode, "HH:MM:SS"),
...@@ -193,10 +195,10 @@ def getDayTicks(): ...@@ -193,10 +195,10 @@ def getDayTicks():
""" """
times = list(range(const.NO_5M_1H, const.NO_5M_DAY, const.NO_5M_1H)) times = list(range(const.NO_5M_1H, const.NO_5M_DAY, const.NO_5M_1H))
majorTimes = list(range(4*const.NO_5M_1H, majorTimes = list(range(4 * const.NO_5M_1H,
const.NO_5M_DAY, const.NO_5M_DAY,
4*const.NO_5M_1H)) 4 * const.NO_5M_1H))
majorTimeLabels = ["%02d" % int(t/const.NO_5M_1H) for t in majorTimes] majorTimeLabels = ["%02d" % int(t / const.NO_5M_1H) for t in majorTimes]
return times, majorTimes, majorTimeLabels return times, majorTimes, majorTimeLabels
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment