In [2]:
from photutils import Background2D, SigmaClip, MedianBackground

from skimage import color
from skimage import exposure

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [4]:
afmdata = np.genfromtxt('../NaRWHAL/Data/UnbackgroundedTXT/500nmGood-0')
afmdata= afmdata*(10**9)
height, width = afmdata.shape

In [5]:
plt.matshow(afmdata, origin='lower', cmap = 'viridis')


Out[5]:
<matplotlib.image.AxesImage at 0x113b47400>

In [6]:
sigma_clip = SigmaClip(sigma=3., iters=10)
bkg_estimator = MedianBackground()
bkg = Background2D(afmdata, (50, 50), filter_size=(3, 3), sigma_clip=sigma_clip, bkg_estimator=bkg_estimator)

In [7]:
plt.matshow(bkg.background, origin='lower', cmap = 'viridis')


Out[7]:
<matplotlib.image.AxesImage at 0x113be6390>

In [8]:
plt.matshow(afmdata - bkg.background, origin='lower', cmap = 'viridis')


Out[8]:
<matplotlib.image.AxesImage at 0x113c599b0>

In [9]:
### This is the Backgrounded image shown two frames up. The frame below is super pale because I'm working
### on the histogram normalization

backgrounded = afmdata - bkg.background
plt.matshow(backgrounded, origin = 'lower', cmap = 'viridis')


Out[9]:
<matplotlib.image.AxesImage at 0x113a85710>

In [11]:
sigma_clip = SigmaClip(sigma=3., iters=10)
bkg_estimator = MedianBackground()
bkg1 = Background2D(backgrounded, (50, 50), filter_size=(3, 3), sigma_clip=sigma_clip, bkg_estimator=bkg_estimator)

In [12]:
plt.matshow(bkg1.background, origin='lower', cmap = 'viridis')


Out[12]:
<matplotlib.image.AxesImage at 0x11277a438>

In [13]:
plt.matshow(backgrounded - bkg1.background, origin='lower', cmap = 'viridis')


Out[13]:
<matplotlib.image.AxesImage at 0x110777160>

In [ ]:


In [14]:
fig = plt.figure(figsize = (8, 8))

fig.add_subplot(131)
plt.matshow(afmdata, origin = 'lower', cmap = 'viridis')
plt.title('Raw Data File')

fig.add_subplot(132)
plt.matshow(backgrounded, origin = 'lower', cmap = 'viridis')
plt.title('Backgounded')

plt.show()



In [ ]:


In [ ]: