Ejemplo n.º 1
0
    def on_scan_jpl(self):

        # when invoke this dialog, pause live lockin monitor in the main panel
        self.liaMonitor.stop()

        # if it is test mode, or real-run mode with instrument correctly connected
        if self.testModeAction.isChecked() or (self.synHandle
                                               and self.liaHandle):
            dconfig = ScanLockin.JPLScanConfig(main=self)
            entry_settings = None
            dconfig_result = dconfig.exec_()
        else:
            # instrument handle is None, pop up error
            msg = Shared.MsgError(
                self, 'Instrument Offline!',
                'Connect to the synthesizer and lockin first before proceed.')
            msg.exec_()
            return None

        # this loop makes sure the config dialog does not disappear
        # unless the settings are all valid / or user hits cancel
        while dconfig_result:  # if dialog accepted
            entry_settings, filename = dconfig.get_settings()
            if entry_settings:
                total_time = Shared.jpl_scan_time(entry_settings)
                now = datetime.datetime.today()
                length = datetime.timedelta(seconds=total_time)
                then = now + length
                text = 'This batch job is estimated to take {:s}.\nIt is expected to finish at {:s}.'.format(
                    str(length), then.strftime('%I:%M %p, %m-%d-%Y (%a)'))
                q = Shared.MsgInfo(self, 'Time Estimation', text)
                q.addButton(QtGui.QMessageBox.Cancel)
                qres = q.exec_()
                if qres == QtGui.QMessageBox.Ok:
                    break
                else:
                    dconfig_result = dconfig.exec_()
            else:
                dconfig_result = dconfig.exec_()

        if entry_settings and dconfig_result:
            dscan = ScanLockin.JPLScanWindow(entry_settings,
                                             filename,
                                             main=self)
            dscan.exec_()
        else:
            pass
Ejemplo n.º 2
0
    def export_lwa(self):

        outputfile, _ = QtGui.QFileDialog.getSaveFileName(
            self, 'Save Data', '', 'SMAP File (*.lwa)')

        # prevent from overwriting
        if outputfile == self.filename:
            msg = Shared.MsgError(
                self, 'Cannot save!',
                'Output file shall not overwrite source file')
            msg.exec_()
        elif outputfile:
            lwaparser.export(list(set(self.entry_id_to_export)),
                             self.hd_line_num,
                             src=self.filename,
                             output=outputfile)
        else:
            pass
Ejemplo n.º 3
0
    def get_settings(self):
        ''' Read batch settings from entries and proceed.
            Returns a list of seting tuples in the format of
            (comment, start_freq <MHz>, stop_freq <MHz>, step <MHz>,
             averages [int], sens_index [int], timeConst [int],
             waittime <ms>, mod Mode index [int], mod freq <Hz>, mod Amp [float], harmonics [int], phase [float])
        '''

        vdi_index = self.main.synCtrl.bandSel.currentIndex()

        entry_settings = []
        no_error = True

        if self.filename == '':
            no_error = False
        else:
            # get settings from entry
            for entry in self.entryWidgetList:
                # if all validation status in this entry are True
                if (not list(entry.status.values()).count(False)):
                    no_error *= True
                    # read settings
                    entry_setting = (entry.commentFill.text(), entry.startFreq,
                                     entry.stopFreq, entry.step, entry.avg,
                                     entry.sensSel.currentIndex(),
                                     entry.tcSel.currentIndex(),
                                     entry.waittime,
                                     entry.modModeSel.currentIndex(),
                                     entry.modFreq, entry.modAmp,
                                     entry.refHarm, entry.refPhase)
                    # put the setting tuple into a list
                    entry_settings.append(entry_setting)
                else:
                    no_error *= False
        if no_error:
            return entry_settings, self.filename
        else:
            msg = Shared.MsgError(
                self.main, 'Invalid input!',
                'Please fix invalid inputs before proceeding.')
            msg.exec_()
            return None, None
Ejemplo n.º 4
0
 def save_data(self):
     try:
         filename, _ = QtGui.QFileDialog.getSaveFileName(
             self, 'Save Data', './test_pressure.txt', 'Data File (*.txt)')
         if filename:
             np.savetxt(
                 filename,
                 self.data,
                 comments='#',
                 fmt=['%g', '%.3e'],
                 header=
                 'Data collection starts at {:s} \ntime({:s}) pressure({:s})'
                 .format(
                     self.data_start_time.strftime(
                         '%I:%M:%S %p, %m-%d-%Y (%a)'),
                     self.updateRateUnitSel.currentText(),
                     self.currentUnit.text()))
         else:
             pass
     except AttributeError:
         msg = Shared.MsgError(self, Shared.btn_label('error'),
                               'No data has been collected!')
         msg.exec_()