Given a stream of sensor data from a solar field, write a function to detect and filter out anomalous temperature spikes within a sliding window.
Use the previous retained readings as the window. A reading is anomalous when its absolute difference from the window average is greater than threshold; retain all initial readings until the window is full. Return the retained readings in order.
Function: def filter_temperature_spikes(temperatures, window_size, threshold): Input is a list of numbers, a positive window size, and a non-negative numeric threshold. Output is a list of retained numbers.
def filter_temperature_spikes(temperatures, window_size, threshold):