### Hot pixel removal test code, Will Burrows, 13 10 2016 ########################################### ###Using scipy import numpy as np import pyfits import matplotlib.pyplot as plt from scipy.ndimage import median_filter f = pyfits.open("Calib_Cd_6.50.fit") d = f[0].data h = f[0].header gain = h.get("EGAIN") px = d.sum(0) py = d.sum(1) gx = px * gain gy = py * gain filtered = median_filter(d, size=4) fpx = filtered.sum(0) fpy = filtered.sum(1) fgx = fpx * gain fgy = fpy * gain fig = plt.figure() ax1a = fig.add_subplot(221) plt.plot(np.linspace(0, 765, 765), gx) ax1b = fig.add_subplot(222) im1 = plt.imshow(d, cmap='hot') ax2a = fig.add_subplot(223) plt.plot(np.linspace(0, 765, 765), fgx) ax2b = fig.add_subplot(224) im2 = plt.imshow(filtered, cmap='hot') plt.show() ########################################### ###Using CV2 import numpy as np import matplotlib.pyplot as plt import cv2 import pyfits f = pyfits.open("Calib_Cd_6.50.fit") d = f[0].data h = f[0].header gain = h.get("EGAIN") px = d.sum(0) py = d.sum(1) gx = px * gain gy = py * gain filtered = cv2.medianBlur(d, 3) fpx = filtered.sum(0) fpy = filtered.sum(1) fgx = fpx * gain fgy = fpy * gain fig = plt.figure() ax1a = fig.add_subplot(221) plt.plot(np.linspace(0, 765, 765), gx) ax1b = fig.add_subplot(222) im1 = plt.imshow(d, cmap='hot') ax2a = fig.add_subplot(223) plt.plot(np.linspace(0, 765, 765), fgx) ax2b = fig.add_subplot(224) im2 = plt.imshow(filtered, cmap='hot') plt.show()