automatically cleans up data before generating the graph
This commit is contained in:
parent
441f4237a5
commit
d5324377fd
@ -1,5 +1,8 @@
|
||||
{
|
||||
"identifier" : "65C0B698-D114-41B3-8F58-13D74F7D3E93",
|
||||
"ignoredFilePatterns" : [
|
||||
"data.csv"
|
||||
],
|
||||
"remotePath" : "\/home\/phlaym\/jwst-plotter",
|
||||
"server" : "Phlaym",
|
||||
"usesPublishing" : true
|
||||
|
@ -6,5 +6,5 @@
|
||||
}
|
||||
},
|
||||
"identifier" : "EADBCF2F-F2FC-418C-9C08-EBAE9F98C8BD",
|
||||
"openLogOnRun" : "fail"
|
||||
"openLogOnRun" : "start"
|
||||
}
|
||||
|
33
graph.py
33
graph.py
@ -13,8 +13,41 @@ FILTER_DEPLOYMENTS = True
|
||||
|
||||
plt.rcParams["figure.autolayout"] = True
|
||||
plt.rcParams['figure.figsize'] = (16, 10)
|
||||
|
||||
data_frame = pd.read_csv("data.csv", delimiter=';')
|
||||
|
||||
# Filter rows, so that only the following will be kept:
|
||||
# First and last rows,
|
||||
# rows which have a different temperature than the one before,
|
||||
# and rows which have a different temperature than the one after.
|
||||
#
|
||||
# Basically: If the temperatures don't change for a few rows, keep only the first
|
||||
# and last of that run
|
||||
last_row = None
|
||||
timestamps_to_keep = []
|
||||
for row in data_frame.iterrows():
|
||||
# row is actually a tuple with index at 0 and the row data at 1. We care only about the row data
|
||||
row = row[1]
|
||||
# First row: Always keep it
|
||||
if last_row is None:
|
||||
last_row = row
|
||||
timestamps_to_keep.append(row['timestamp'])
|
||||
continue
|
||||
# Any temp changed?
|
||||
keep_row = (last_row['tempWarmSide1C'] != row['tempWarmSide1C'] or
|
||||
last_row['tempWarmSide2C'] != row['tempWarmSide2C'] or
|
||||
last_row['tempCoolSide1C'] != row['tempCoolSide1C'] or
|
||||
last_row['tempCoolSide2C'] != row['tempCoolSide2C'])
|
||||
# Keep this and the previous row
|
||||
if keep_row:
|
||||
timestamps_to_keep.append(last_row['timestamp'])
|
||||
timestamps_to_keep.append(row['timestamp'])
|
||||
last_row = row
|
||||
# Always keep the last row
|
||||
timestamps_to_keep.append(data_frame.iloc[-1:]['timestamp'])
|
||||
# Filter rows by the timestamps we just saved
|
||||
data_frame = data_frame[data_frame.timestamp.isin(timestamps_to_keep)]
|
||||
|
||||
# Subplot, to move legend next to plot
|
||||
# 1 row, 1 col, index: 1
|
||||
plt.subplot(1, 1, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user