2021-12-31 11:06:54 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
import pandas as pd
|
|
|
|
from matplotlib import pyplot as plt
|
|
|
|
import matplotlib.dates as md
|
2022-01-15 07:55:38 +00:00
|
|
|
from screeninfo import get_monitors
|
|
|
|
from screeninfo.common import ScreenInfoError
|
2021-12-31 11:06:54 +00:00
|
|
|
|
2022-01-09 07:07:35 +00:00
|
|
|
SHOW_DEPLOYMENTS = True
|
2022-01-09 07:16:16 +00:00
|
|
|
FILTER_DEPLOYMENTS = True
|
2022-01-09 07:07:35 +00:00
|
|
|
|
2021-12-31 11:06:54 +00:00
|
|
|
plt.rcParams["figure.autolayout"] = True
|
2022-01-15 07:55:38 +00:00
|
|
|
plt.rcParams['figure.figsize'] = (16, 10)
|
2022-01-16 08:29:43 +00:00
|
|
|
|
2021-12-31 11:06:54 +00:00
|
|
|
data_frame = pd.read_csv("data.csv", delimiter=';')
|
|
|
|
|
2022-01-16 08:29:43 +00:00
|
|
|
# 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)]
|
|
|
|
|
2021-12-31 11:06:54 +00:00
|
|
|
# Subplot, to move legend next to plot
|
|
|
|
# 1 row, 1 col, index: 1
|
2022-01-02 19:44:04 +00:00
|
|
|
plt.subplot(1, 1, 1)
|
2021-12-31 11:06:54 +00:00
|
|
|
|
|
|
|
# Rotate long date text
|
|
|
|
plt.xticks(rotation=25)
|
|
|
|
|
|
|
|
|
|
|
|
# pyplot doesn't like timestamps
|
|
|
|
# convert them to "date-numbers" and format
|
|
|
|
datenums = md.date2num([datetime.datetime.fromtimestamp(ts) for ts in data_frame.timestamp])
|
|
|
|
xfmt = md.DateFormatter('%Y-%m-%d %H:%M:%S')
|
2022-01-02 19:44:04 +00:00
|
|
|
ax = plt.gca()
|
2021-12-31 11:06:54 +00:00
|
|
|
ax.xaxis.set_major_formatter(xfmt)
|
|
|
|
ax.set_ylabel('Temperature [°C]')
|
|
|
|
|
|
|
|
# Data
|
2022-01-02 19:44:04 +00:00
|
|
|
plt.plot(datenums, data_frame.tempWarmSide1C, label='Warm 1', color='orange', marker='x')
|
|
|
|
for i, j in zip(datenums, data_frame.tempWarmSide1C):
|
|
|
|
ax.annotate(str(round(j, 2)), xy=(i, j), rotation=45)
|
2021-12-31 11:06:54 +00:00
|
|
|
|
2022-01-02 19:44:04 +00:00
|
|
|
plt.plot(datenums, data_frame.tempWarmSide2C, label='Warm 2', color='orangered', marker='x')
|
|
|
|
for i, j in zip(datenums, data_frame.tempWarmSide2C):
|
2022-01-13 13:23:33 +00:00
|
|
|
ax.annotate(str(round(j, 2)), xy=(i, j-30), rotation=300)
|
2021-12-31 11:06:54 +00:00
|
|
|
|
2022-01-02 19:44:04 +00:00
|
|
|
plt.plot(datenums, data_frame.tempCoolSide1C, label='Cool 1', color='blue', marker='x')
|
|
|
|
for i, j in zip(datenums, data_frame.tempCoolSide1C):
|
|
|
|
ax.annotate(str(round(j, 2)), xy=(i, j), rotation=45)
|
|
|
|
|
|
|
|
plt.plot(datenums, data_frame.tempCoolSide2C, label='Cool 2', color='navy', marker='x')
|
|
|
|
for i, j in zip(datenums, data_frame.tempCoolSide2C):
|
2022-01-13 13:23:33 +00:00
|
|
|
ax.annotate(str(round(j, 2)), xy=(i, j-30), rotation=300)
|
2022-01-02 19:44:04 +00:00
|
|
|
|
2022-01-09 05:19:45 +00:00
|
|
|
plt.axhline(y=-223, color='darkblue', linestyle=':', label='Operating temperature')
|
2022-01-13 13:23:33 +00:00
|
|
|
plt.ylim(ymin=-273.15)
|
2022-01-02 19:44:04 +00:00
|
|
|
|
2022-01-09 07:07:35 +00:00
|
|
|
launch_date = datetime.datetime.fromisoformat('2021-12-25T12:20+00:00')
|
|
|
|
deployment_names = [
|
|
|
|
'Sunshield Pallet',
|
|
|
|
'DTA Deployment',
|
|
|
|
'Sunshield Covers Release',
|
|
|
|
'Sunshield Mid-Boom',
|
|
|
|
'Sunshield Layer Tensioning Ongoing',
|
|
|
|
'Sunshield Tensioning Complete',
|
|
|
|
'Secondary Mirror Deployment',
|
|
|
|
'Aft Deployed Instrument Radiator',
|
|
|
|
'Port Primary Mirror Wing',
|
|
|
|
'WEBB IS FULLY DEPLOYED!',
|
|
|
|
'Individual Mirror Segment Movements',
|
|
|
|
'L2 Insertion Burn',
|
|
|
|
'WEBB IS ORBITING L2'
|
|
|
|
]
|
|
|
|
|
|
|
|
# deployment dates, based on "+ X days"
|
|
|
|
deployment_dates = [md.date2num(launch_date + datetime.timedelta(days=x)) for x in [
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
9,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
12,
|
|
|
|
13,
|
|
|
|
14,
|
|
|
|
15,
|
|
|
|
26,
|
|
|
|
29.5]
|
|
|
|
]
|
|
|
|
|
|
|
|
latest_available_temp_date = max(datenums)
|
|
|
|
earliest_available_temp_date = min(datenums)
|
|
|
|
|
|
|
|
deployments_data = zip(deployment_names, deployment_dates)
|
2022-01-09 07:16:16 +00:00
|
|
|
filtered_deployments_data = (filter(lambda tup:
|
|
|
|
tup[1] >= earliest_available_temp_date and
|
|
|
|
tup[1] <= latest_available_temp_date, deployments_data)
|
|
|
|
if FILTER_DEPLOYMENTS else deployments_data)
|
2022-01-09 07:07:35 +00:00
|
|
|
|
|
|
|
max_temp = max(max(data_frame.tempWarmSide1C), max(data_frame.tempWarmSide2C))
|
|
|
|
|
|
|
|
if SHOW_DEPLOYMENTS:
|
|
|
|
for label, date in filtered_deployments_data:
|
|
|
|
plt.axvline(x=date, color='gray', linestyle=':')
|
|
|
|
plt.text(x=date, y=max_temp+30, s=label, rotation=25)
|
|
|
|
|
2022-01-02 19:44:04 +00:00
|
|
|
plt.legend(bbox_to_anchor=(1, 1), loc="upper left")
|
2022-01-15 07:55:38 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
get_monitors()
|
|
|
|
plt.show()
|
|
|
|
except ScreenInfoError:
|
|
|
|
plt.savefig("jwst_tempertature.png", dpi=300)
|