import numpy as np
import matplotlib.pyplot as plt
# Time, in seconds
time = np.array(range(0, 1000))
switchPeriod = 100
externalTemp = np.zeros(time.size) # Ice water
externalTemp = 50 + 50*np.sin(time / 5)
#externalTemp[time % switchPeriod < switchPeriod/2] = 100 # Probe it put into boiling water
# Now let's simulate the thermocouple
# Assume the rise in temperature is proportional to the temperature difference
measuredTemp = np.zeros(time.size) # Initialize the whole array to zero
measuredTemp[0] = externalTemp[0] # Assume it's stable at room temperature
for i in range(len(time) - 1):
dt = externalTemp[i] - measuredTemp[i]
tempRise = dt * 0.1
measuredTemp[i + 1] = measuredTemp[i] + tempRise
# Make the plot
plt.plot(time, externalTemp, time, measuredTemp)
plt.xlabel('Time [seconds]')
plt.ylabel('Temperature [C]')
plt.legend(['External', 'Measured'])
plt.show()