| Home | Trees | Indices | Help |
|
|---|
|
|
1 """ 2 Two-dimensional pattern generators drawing from various random distributions. 3 4 $Id: random.py 7861 2008-02-07 06:01:22Z ceball $ 5 """ 6 __version__='$Revision: 7861 $' 7 8 import numpy.oldnumeric.random_array as RandomArray 9 10 from topo.base.parameterizedobject import ParamOverrides 11 from topo.base.parameterclasses import Number,Parameter 12 from topo.base.patterngenerator import PatternGenerator 13 from topo.base.sheetcoords import SheetCoordinateSystem 14 15 from topo.outputfns.basic import IdentityOF 16 1719 """2D random noise pattern generator abstract class.""" 20 21 __abstract = True 22 23 # The standard x, y, and orientation variables are currently ignored, 24 # so they aren't shown in auto-generated lists of parameters (e.g. in the GUI) 25 x = Number(precedence=-1) 26 y = Number(precedence=-1) 27 size = Number(precedence=-1) 28 orientation = Number(precedence=-1) 2953 54 55 61 6231 """Method for subclasses to override with a particular random distribution.""" 32 raise NotImplementedError33 34 # Optimization: We use a simpler __call__ method here to skip the 35 # coordinate transformations (which would have no effect anyway)37 self._check_params(params_to_override) 38 params = ParamOverrides(self,params_to_override) 39 40 shape = SheetCoordinateSystem(params['bounds'],params['xdensity'],params['ydensity']).shape 41 42 result = self._distrib(shape,params) 43 44 mask = params['mask'] 45 if mask is not None: 46 result*=mask 47 48 output_fn = params['output_fn'] 49 if output_fn is not IdentityOF: # Optimization (but may not actually help) 50 output_fn(result) 51 52 return result64 """ 65 2D Gaussian random noise pattern generator. 66 67 Each pixel is chosen independently from a Gaussian distribution 68 of zero mean and unit variance, then multiplied by the given 69 scale and adjusted by the given offset. 70 """ 71 72 scale = Number(default=0.25,softbounds=(0.0,2.0)) 73 offset = Number(default=0.50,softbounds=(-2.0,2.0)) 7477
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Thu Feb 21 15:25:24 2008 | http://epydoc.sourceforge.net |