Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.apo.nmsu.edu/35m_operations/TUI/Scripts/ScriptingTutorial/Loops.html
Дата изменения: Sat Sep 6 02:16:02 2014 Дата индексирования: Sun Apr 10 06:31:29 2016 Кодировка: Поисковые слова: р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п |
Often you will want to execute the same commands many times with different parameters. This is where python lists and for loops come in handy. This script also shows a simple but crude way of displaying more feedback while operating: it opens the DIS Expose window. We'll see how to display the feedback directly in the script window, plus a better way of formatting exposure commands, in the next lesson.
As always, get permission to use DIS before commanding it.
import TUI.TUIModel def init(sr): """Open the DIS Expose window so the user can see what's going on.""" tuiModel = TUI.TUIModel.getModel() tuiModel.tlSet.makeVisible("None.DIS Expose") def run(sr): """Sample script to take a series of DIS calibration images and demonstrate looping through data in Python. The exposure times and # of iterations are short so the demo runs quickly. """ # typeTimeNumList is a list of calibration info # each element of the list is a list of: # - exposure type # - exposure time (sec) # - number of exposures typeTimeNumList = [ ["flat", 1, 2], ["flat", 5, 2], ["bias", 0, 2], ["dark", 1, 2], ["dark", 5, 2], ] for expType, expTime, numExp in typeTimeNumList: if expType == "bias": # bias, so cannot specify time cmdStr = "%s n=%d name=dis%s" % (expType, numExp, expType) else: cmdStr = "%s time=%s n=%d name=dis%s" % (expType, expTime, numExp, expType) yield sr.waitCmd( actor = "disExpose", cmdStr = cmdStr, abortCmdStr = "abort", )
Comments:
init(sr)
runs once, when the script is first loaded. It is often used to add widgets to the script display, but in this case it opens the DIS Expose window to give you feedback as your script runs. We'll use init(sr) to add feedback widgets (eliminating the need to open the DIS Expose window) in the Refinements lesson (NiceDISCals script).
for expTypeTimeNum in typeTimeNumList: expType, expTime, numExp = expTypeTimeNum