namespace eval optics { array set AttRotLookupTable { 0 { 0.0 1 } 30 { 1.3 0.498782 } 60 { 3.3 0.176433 } 90 { 4.9 0.0761367 } 120 { 6.4 0.0353985 } 150 { 8.3 0.0137137 } 180 { 9.6 0.00614167 } 210 {11.2 0.00264554 } 240 {13.1 0.000994504 } 270 {15.0 0.000358897 } 300 {18.0 7.2845e-05 } 330 {25.0 1.67827e-06 } } array set EApLookupTable { 0 { 5 circ} 30 {10 circ} 60 {20 circ} 90 {30 circ} 120 {40 circ} 150 {50 circ} 180 {50 squ } 210 {open open} 240 {open open} 270 {open open} 300 {open open} 330 {open open} } } proc ::optics::AttRotLookup {angle column tol} { variable AttRotLookupTable set catch_status [ catch { set foundit false foreach vangle [array names AttRotLookupTable] { if {$vangle >= [expr {$angle-$tol}] && $vangle <= [expr {$angle+$tol}]} { set foundit true break } } if {$foundit == true} { switch $column { "plex" { set index 0 } "attfactor" { set index 1 } default { error "$column is unknown, allowed values are plex or attfactor" } } return [lindex $AttRotLookupTable($vangle) $index] } else { return -1 } } message ] handle_exception $catch_status $message } proc ::optics::EApLookUp {angle param tol} { variable EApLookupTable set foundit false if [ catch { if {$param == "size"} { set cgf [SplitReply [GuideConfig]] if {[string first $cgf "g1 g2 g3 g4 g5 g6 g7 g8 g9 p1 p2 p3 p4 p5 p6 p7 p8 p9"] != -1} { return 50 } } switch $param { "size" {set index 0} "shape" {set index 1} default { error "ERROR: Invalid lookup parameter $param" } } foreach vangle [array names EApLookupTable] { if {$vangle >= [expr {$angle-$tol}] && $vangle <= [expr {$angle+$tol}]} { set foundit true break } } if {$foundit == true} { return [lindex $EApLookupTable($vangle) $index] } else { switch $param { "size" {return 0} "shape" {return "UNKNOWN"} } } } message ] { if {$::errorCode == "NONE"} {return $message} return -code error "$message" } }