def dWtophatkspacedR ( kR ,R ) : """ Returns the derivative of the Fourier Transform of the real space top hat window function which is 1 when r < R, and 0 otherwise with respect to R. args: kR : unit less quantity. R : Radius returns: array like derivative of Wtophatkspace with respect to R """ filt = 3.0 *( np.sin(kR) / kR - Wtophatkspace (kR )) if tu.isiterable(R): x = filt.transpose()/R #returns an array whose elesements are k values for each R return x.transpose() else: return filt /R
def drawxband(refval , xlims = None, color = 'gray', bandwidths = [-0.1,0.1], ua = None ): """ draw a shaded band of color color of certain width around a single reference value refval args: refval : float , mandatory scalar (single) reference value, Example: refval = 1.0 xlims : list of two floats, optional, defaults to None min and max x values through which the band will be drawn if None, these values are set from the limits of the supplied axessubplot. If axessubplots is not supplied this will raise an error color : python color style, optional,defaults to 'gray' color of the band bandwidths : list of two floats, optional default to [-0.1, 0.1] width of the band to be shaded. ua : optional, axes.subplot object on which to draw, defaults to None axes object to use returns: axes object example usage: >>> #To use an existing axes subplot object >>> drawxband (refval = 60., bandwidths = [-20.,20.], color = 'green', ua = myax0) >>> #No axes object is available >>> drawxband (refval = 60., xlims = [4., 8.] , bandwidths = [-20.,20.],color = 'green') status: Tests in plot_utils main. tested R. Biswas, Fri Apr 18 08:29:54 CDT 2014 """ if ua == None: ua = plt.gca() else: plt.sca(ua) xl ,xh = ua.get_xlim() if xlims == None: xlims = [ xl , xh ] #really started this conditional statement to make it general, #but have not finished, will always go to the else condition #in current implementation if xlims == None: if not tu.isiterable(refval): raise ValueError("To draw band supply either refval as numpy array or xlims over which it should be drawn") else: xvals = np.linspace(xlims[0], xlims[1],2) #refvals = refval *np.ones(len(xvals) #plot reference value ua.axhline(refval,color ='k',lw =2.0) #draw band ua.fill_between (xvals , refval + bandwidths[0], refval + bandwidths[1], color = color , alpha = 0.25) return ua