setScriptDescription('''Example Script for testing Run Batch''')

case= getParam('case','1','Case number',['1','2','3'])
ncenter=getParam('ncenter',3,'Number of Centers',[1,2,3,4,5])
radius= getParam('radius',0.0,'Radius of ring',{'min':0.,'max':10.})
ann= getParam('annotation','lorem','Annotation',['','lorem','ipsum'])
interference= getParam('interference',0,'interference parameter',[0,1,2])

for p in params:
    print '%s=%s' % ( p, params[p] )

size=600

# multi-threaded runs don't support randomSeed, so just use these pre-computed numbers
c1x= [0.88924 ,0.011089 ,-1.172305703163147 ,-0.21941539645195007 ,0.20088 ]
c2x= [1.5626 ,-0.67933589220047 ,0.60059 ,-0.8308430314064026 ,0.67809  ]
c3x= [-1.1400742530822754 ,0.57592 ,-0.15035440027713776 ,1.8727 ,1.2757 ]
c1y= [0.66160 ,-0.6429134607315063 ,0.77554 ,0.0076137 ,0.28735  ]
c2y= [0.53276 ,-1.4510364532470703 ,-0.6426888704299927 ,-0.4069989323616028 ,0.22426 ]
c3y= [0.98195 ,-0.022875947877764702 ,-1.1886168718338013 ,-2.089637041091919 ,0.66877  ]

if ( case=='1' ):
    randomSeed(0)
    cx=c1x
    cy=c1y
elif ( case=='2' ):
    randomSeed(1)
    cx=c2x
    cy=c2y
elif ( case=='3' ):
    randomSeed(2)
    cx=c3x
    cy=c3y

reset()

result= rand(size,size)/4
for i in xrange(ncenter):
    x= cx[i]*40 + size/2 
    y= cy[i]*40 + size/2 
    result= result + 1/exp( abs(distance( size, size, float(x), float(y), 10, 10 )-radius ) )
    if ann!='':
        if x>size/2:
            apx='W'
            px= x + radius*7.6
        else:
            apx='E'
            px= x - radius*7.6
        if y>size/2:
            apy='S'
            py= y + radius*7.6
        else:
            apy='N'
            py= y - radius*7.6
        ap=apy+apx
        a= annotation(i,text=ann,pointAt=[px,py],anchorType='DATA',
                   xrange=[px,px], yrange=[py,py],borderType='RECTANGLE',fontSize='1em',
                   anchorPosition=ap)
        a.anchorOffset='1em,1em'
plot( result, zrange=[0,2] )

if interference!=0:
    a= annotation(ncenter+1,text=str(interference),anchorType='PLOT',
        anchorPosition='center')
