Exemplo n.º 1
0
 def initData(self, cdict):
     self.options = cdict
     num = len(cdict)
     self.topFiller.setMinimumSize(400, 40 * num + 50)
     maxh = 40 * num + 50 > 500 and 500 or 40 * num + 50
     self.setFixedHeight(maxh)
     oWidget = QWidget(self.topFiller)
     mm = QVBoxLayout()
     oWidget.setLayout(mm)
     index = 0
     self.opcombox = []
     for op in self.options:
         if self.getDictValue(op, 'default') != "":
             m = QHBoxLayout()
             a = QLabel()
             a.setFixedWidth(200)
             a.setText(op['label'])
             if self.getDictValue(op, "hover"):
                 a.setToolTip(op['hover'])
             m.addWidget(a)
             if self.getDictValue(op, 'options'):
                 b = QComboBox()
                 b.select = True
                 b.index = index
                 b.name = op['name']
                 self.opcombox.append(b)
                 b.setFixedWidth(150)
                 b.setStyleSheet(
                     "QComboBox QAbstractItemView::item { min-height: 25px; min-width: 100px; }"
                 )
                 b.setItemDelegate(QStyledItemDelegate())
                 b.currentIndexChanged.connect(self.selectChange)
                 bd = []
                 for o in op['options']:
                     b.addItem(str(o['description']))
                     bd.append(o['data'])
                 b.data = bd
                 if self.getDictValue(op['options'][b.currentIndex()],
                                      'hover'):
                     b.setToolTip(op['options'][b.currentIndex()]['hover'])
             else:
                 b = QLabel()
                 self.opcombox.append(b)
                 b.select = False
                 b.name = op['name']
                 b.data = op['default']
                 b.setText("请直接修改modinfo.lua")
             m.addWidget(b)
             mm.addLayout(m)
         index += 1
     self.loadExistValue()
Exemplo n.º 2
0
    def initUItab3(self):
        # Create main layout (a Horizontal Layout)
        mainlayout = QHBoxLayout()
        # Create a left and right side (both Vertical Layouts)
        leftlayout = QVBoxLayout()
        rightlayout = QVBoxLayout()

        # Create a table for interacting with parameters
        self.table = QTableView()
        self.table.doubleClicked.connect(self.tblRowClicked)
        # For playing with, I will make a static table of tclean parameters
        tbl = [
            ["Data Selection", "", []],
            ["  vis", "''", []],
            #["  field","''",[]],
            [
                "  spw", "''", [],
                "Spectral Window:\n default: ''=all; examples:\n spw='0~2,4'; spectral windows 0,1,2,4 (all channels)\n spw='0:5~61'; spw 0, channels 5 to 61\n spw='<2';   spectral windows less than 2 (i.e. 0,1)"
            ],
            [
                "  timerange", "''", [],
                "Range of time to select from data\n default: '' (all); examples:\n timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'\n Note: if YYYY/MM/DD is missing date defaults to first day in data set\n timerange='09:14:0~09:54:0' picks 40 min on first day\n timerange='25:00:00~27:30:00' picks 1 hr to 3 hr 30 min on NEXT day\n timerange='09:44:00' pick data within one integration of time\n timerange='> 10:24:00' data after this time"
            ],
            [
                "  uvrange", "''", [],
                "Select data within uvrange (default unit is meters) [default: '' (all)]\n examples:\n uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda\n uvrange='> 4klambda';uvranges greater than 4 kilo lambda"
            ],
            [
                "  antenna", "''", [],
                "Select data on 0-based antenna/baseline index [default: '' (all)]\n examples:\n antenna='0~5,7~12&0~5,7~12'; all baselines not including antenna index 6\n antenna='5&6;7&8'; baselines 5-6 and 7-8\n antenna='5'; all baselines with antenna index 5\n antenna='5,6,9'; all baselines with antenna index numbers 5,6,9"
            ],
            ["  datacolumn", "'data'", ["'data'", "'corrected'", "'model'"]],
            ["Image Definition", "", []],
            ["  imagename", "''", []],
            ["  imsize", "[128,128]", []],
            ["  cellsize", "'2arcsec'", []],
            [
                "  phaseshift", "[0, 0]", [],
                "X, Y offset of center of map from Sun Center"
            ],
            [
                "  stokes", "'XX'",
                ["'XX'", "'YY'", "'I'", "'V'", "'IV'", "'RR'", "'LL'"]
            ],
            ["  startmodel", "''", []],
            ["  specmode", "'mfs'", ["'mfs'", "'cubedata'"]],
            ["Deconvolution Options", "", []],
            [
                "  deconvolver", "'multiscale'",
                [
                    "'hogbom'", "'clark'", "'clarkstokes'", "'multiscale'",
                    "'mem'"
                ]
            ],
            ["  scales", "[1,5,10]", []],
            ["  restoringbeam", "''", []],
            ["  pbcor", "False", ['True', 'False']],
            ["Weighting", "", []],
            [
                "  weighting", "'briggs'",
                ["'natural'", "'uniform'", "'briggs'"]
            ],
            ["  robust", "0.5", []],
            ["  uvtaper", "''", []],
            ["Other Options", "", []],
            ["  niter", "0", []],
            ["  gain", "0.1", []],
            ["  threshold", "0", []],
            ["  interactive", "False", ['True', 'False']],
            ["  mask", "''", []]
        ]

        self.table.verticalHeader().setDefaultSectionSize(
            14)  # Sets height of cells to 14px
        self.table.setModel(TableModel(
            tbl))  # The TableModel class is defined at the top of this file

        # For parameters that have to be only a limited set of fixed values, create a combobox dropdown
        # for editing them.
        for idx in range(len(tbl)):
            if len(tbl[idx]) > 2:
                if len(tbl[idx][2]) > 1:
                    i = self.table.model().index(idx, 2)
                    c = QComboBox()
                    for item in tbl[idx][2]:
                        c.addItem(item)
                    c.currentTextChanged.connect(self.handleCombo)
                    c.index = self.table.model().index(idx, 1)
                    self.table.setIndexWidget(i, c)

        self.table.resizeColumnsToContents()
        self.table.model().dataChanged.connect(self.update_view)

        # Determine the header rows in the table (indicated by NOT starting with a blank space).
        self.headerrows = []
        for i, tblrow in enumerate(tbl):
            if tbl[i][0][0] != ' ':
                self.headerrows.append(i)
                self.table.setSpan(i, 0, 1, 2)
        self.headerrows.append(
            len(tbl))  #Add length of table, for finding length of last section

        titlelayout = QHBoxLayout()
        titlelayout.addWidget(QLabel("TCLEAN Parameters"))
        titlelayout.addSpacing(100)
        updateButton = QPushButton("Update Parameters")
        titlelayout.addWidget(updateButton)
        updateButton.clicked.connect(self.update_params)
        titlelayout.addSpacing(100)
        scriptButton = QPushButton("Save to CASA Script")
        titlelayout.addWidget(scriptButton)
        scriptButton.clicked.connect(self.save2CASAscript)
        titlelayout.addStretch(1)
        tablelayout = QHBoxLayout()
        self.table.setMinimumSize(600, 300)
        tablelayout.addWidget(self.table)
        self.nofits = QCheckBox('Skip conversion to FITS')
        self.nocleanup = QCheckBox('Keep CASA image files')
        tablelayout.addStretch(1)
        leftlayout.addLayout(titlelayout)
        leftlayout.addLayout(tablelayout)
        leftlayout.addWidget(self.nofits)
        leftlayout.addWidget(self.nocleanup)
        self.scriptEdit = QTextEdit()
        #f = QFont("Courier",9)
        #self.infoEdit.setCurrentFont(f)
        self.scriptEdit.setReadOnly(True)
        self.scriptEdit.setMinimumHeight(300)
        self.scriptEdit.setMinimumWidth(550)
        leftlayout.addWidget(QLabel("Generated Script"))
        leftlayout.addWidget(self.scriptEdit)
        execButton = QPushButton('Execute Script')
        execButton.clicked.connect(self.execscript)
        eblayout = QHBoxLayout()
        eblayout.addWidget(execButton)
        eblayout.addStretch(1)
        leftlayout.addLayout(eblayout)
        leftlayout.addStretch(1)
        mainlayout.addLayout(leftlayout)

        self.imgcanvas = FigureCanvas(Figure(figsize=(7, 6)))
        rightlayout.addWidget(self.imgcanvas)
        rightlayout.addWidget(NavigationToolbar(self.imgcanvas, self))
        self.img_ax = self.imgcanvas.figure.subplots()

        mainlayout.addLayout(rightlayout)

        self.tabs.widget(2).setLayout(mainlayout)