combining beams

Moderators: cyao, michael_borland

Post Reply
Philippe Piot
Posts: 83
Joined: 20 Aug 2008, 13:18
Location: Northern Illinois University & Argonne National Laboratory
Contact:

combining beams

Post by Philippe Piot » 14 Dec 2010, 16:16

Hello,
I am trying to generate a beam consisting of an array of beamlet separated in x and y by XOff and y Off; see script below. I use the script below and am wondering if there is a more efficient way of doing this (this script is VERY slow especially as the $input.total file start to get bigger and bigger). Thanks! -- Philippe.


----------------------------------------------
#!/bin/sh
# \
exec tclsh "$0" "$@"
if [llength $argv]!=3 {
return -code error
}

set input [lindex $argv 0]
set xOff [lindex $argv 1]
set yOff [lindex $argv 2]

puts "input \t $input"

set ind 0
for { set i -11 } { $i <= 11 } { incr i } {
for { set j -11 } { $j <= 11 } { incr j } {
puts "$i $j"
if {$ind == 0} {
set xIOff [expr $xOff*$i]
set yIOff [expr $yOff*$j]
exec sddsprocess $input.bun $input.temp "-redefine=col,x,x $xIOff +"
exec sddsprocess $input.temp $input.temp2 "-redefine=col,y,y $yIOff +"
exec cp $input.temp2 $input.temp3
}
if {$ind > 0} {
set xIOff [expr $xOff*$i]
set yIOff [expr $yOff*$j]
exec sddsprocess $input.bun $input.temp "-redefine=col,x,x $xIOff +"
exec sddsprocess $input.temp $input.temp2 "-redefine=col,y,y $yIOff +"
exec sddscombine -merge -overwrite $input.temp2 $input.temp3 $input.total
exec cp $input.total $input.temp3
}
set ind [expr $ind + 1]
}
}

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: combining beams

Post by michael_borland » 14 Dec 2010, 17:15

Philippe,

I was able to speed it up quite a bit by removing all the SDDS programs from inside the loop. It should be about 50x faster.

--Michael
Attachments
script3.tcl
(718 Bytes) Downloaded 773 times

Philippe Piot
Posts: 83
Joined: 20 Aug 2008, 13:18
Location: Northern Illinois University & Argonne National Laboratory
Contact:

Re: combining beams

Post by Philippe Piot » 16 Dec 2010, 08:38

Thank you very much Michael. -- Philippe.

Post Reply