Документ взят из кэша поисковой машины. Адрес оригинального документа : 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
Кодировка:

Поисковые слова: galactic collision
TUI:Scripts:Scripting Tutorial:Loops

Loops

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.

DISCals script

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: