<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Function sobel
Synopse
Sobel edge detection.
mag,theta = sobel(f)
mag,theta
Step1:  Description
Computes the edge detection by Sobel. Compute magnitude and angle.
Examples
Step2:  Numerical Example
Step3:  Image examples
Example 1.
Step4:  Example 2.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
def sobel(f):
    from pconv import pconv
    
    Sx = np.array([[1.,2.,1.],
                   [0.,0.,0.],
                   [-1.,-2.,-1.]])
    Sy = np.array([[1.,0.,-1.],
                   [2.,0.,-2.],
                   [1.,0.,-1.]])
    
    fx = pconv(f, Sx)
    fy = pconv(f, Sy)
    
    mag = np.abs(fx + fy*1j)
    theta = np.arctan2(fy,fx)
    
    return mag,theta
Explanation: Function sobel
Synopse
Sobel edge detection.
mag,theta = sobel(f)
mag,theta: Magnitude and angle.
f: Image. input image
End of explanation
testing = (__name__ == "__main__")
if testing:
    ! jupyter nbconvert --to python sobel.ipynb
    import numpy as np
    import sys,os
    ia898path = os.path.abspath('../../')
    if ia898path not in sys.path:
        sys.path.append(ia898path)
    import ia898.src as ia
    
    import matplotlib.image as mpimg
Explanation: Description
Computes the edge detection by Sobel. Compute magnitude and angle.
Examples
End of explanation
if testing:
    f = np.array([[0,1,0,0],
                  [0,0,0,0],
                  [0,0,0,0]],dtype='uint8')
    m,t = ia.sobel(f)
    print('m:\n',m)
    print('t:\n',t)
Explanation: Numerical Example
End of explanation
if testing:
    f = mpimg.imread('../data/cameraman.tif')
    
    (g,a) = ia.sobel(f)
    
    nb = ia.nbshow(2)
    nb.nbshow(ia.normalize(g),title='Sobel')
    nb.nbshow(ia.normalize(np.log(g+1)),title='Log of sobel')
    nb.nbshow()
Explanation: Image examples
Example 1.
End of explanation
if testing:
    f = ia.circle([200,300], 90, [100,150])
    m,t = ia.sobel(f)
    
    dt = np.select([m > 2], [t])
    
    nb = ia.nbshow(3)
    nb.nbshow(f,title='Image f')
    nb.nbshow(ia.normalize(m), title='Magnitude of Sobel filtering')    
    nb.nbshow(ia.normalize(dt), title='Angle of edges with magnitude above 2')
    nb.nbshow()
Explanation: Example 2.
End of explanation
<END_TASK>