Commit 0ac2a6ce authored by marc's avatar marc
Browse files

included backend in DTObs

parent bfcfd5a7
telescope telescope
measurements measurements
ui/__pycache__ backend
metadata
ui/__pycache__/
...@@ -21,6 +21,7 @@ from astropy.coordinates import SkyCoord ...@@ -21,6 +21,7 @@ from astropy.coordinates import SkyCoord
from telescope import telescope from telescope import telescope
from measurements import Measurements from measurements import Measurements
from metadata import MetaData from metadata import MetaData
from backend import Backend
''' '''
Setup config ini Setup config ini
...@@ -87,15 +88,20 @@ class DTObservationProgram(Ui_mainWindow): ...@@ -87,15 +88,20 @@ class DTObservationProgram(Ui_mainWindow):
def __init__(self, mainWindow): def __init__(self, mainWindow):
logger.info('Initialization of DTObsGUI') logger.info('Initialization of DTObsGUI')
self.myDT = telescope(setmode='J2000', consoleHost='consoledemo.dmz.camras.nl') self.TelescopeEnabled = config.get('TestConfig','myDT')
if self.TelescopeEnabled == True:
self.myDT = telescope(setmode='J2000', consoleHost='consoledemo.dmz.camras.nl')
self.myMeas = Measurements() self.myMeas = Measurements()
self.myMetaData = MetaData() self.myMetaData = MetaData()
self.myBackend = Backend(setmode='Pulsar')
self.radec = None self.radec = None
self.measProgramma = None self.measProgramma = None
self.integrationTime = None self.integrationTime = None
self.outputDir = None self.outputDir = None
self.outputFile = None self.outputFile = None
self.GUIbackendMode = None
Ui_mainWindow.__init__(self) Ui_mainWindow.__init__(self)
self.setupUi(mainWindow) self.setupUi(mainWindow)
...@@ -107,6 +113,7 @@ class DTObservationProgram(Ui_mainWindow): ...@@ -107,6 +113,7 @@ class DTObservationProgram(Ui_mainWindow):
self.pushButtonOutputDirectory.clicked.connect(self.selectOutputDirectory) self.pushButtonOutputDirectory.clicked.connect(self.selectOutputDirectory)
self.homedir = os.environ['HOME'] self.homedir = os.environ['HOME']
self.lineEditOutputDir.setText(self.homedir) self.lineEditOutputDir.setText(self.homedir)
''' '''
Read the available tools from measurement Class and store them in the Read the available tools from measurement Class and store them in the
comboBoxProgramma for selection. comboBoxProgramma for selection.
...@@ -173,26 +180,27 @@ class DTObservationProgram(Ui_mainWindow): ...@@ -173,26 +180,27 @@ class DTObservationProgram(Ui_mainWindow):
''' '''
#self.tableWidgetPointings.item(meas_num, 3).setText(measFile.name)) #self.tableWidgetPointings.item(meas_num, 3).setText(measFile.name))
for column in range(4): for column in range(3):
self.tableWidgetPointings.item(meas_num,column).setBackground(colors[status]) self.tableWidgetPointings.item(meas_num,column).setBackground(colors[status])
self.tableWidgetPointings.resizeColumnsToContents() self.tableWidgetPointings.resizeColumnsToContents()
def goToSetpoints(self, setpoints, oneSetpointCompleteSignal=None, progressSignal=None): def goToSetpoints(self, setpoints, oneSetpointCompleteSignal=None, progressSignal=None):
""" Send a list of setpoints to the telescope """ """ Send a list of setpoints to the telescope """
for setpoint_nr, setpoint in enumerate(setpoints): for setpoint_nr, setpoint in enumerate(setpoints):
self.myDT.setRaDec(setpoint) if self.TelescopeEnabled == True:
oneSetpointCompleteSignal.emit(setpoint_nr, 'Slewing') self.myDT.setRaDec(setpoint)
time.sleep(3) oneSetpointCompleteSignal.emit(setpoint_nr, 'Slewing')
dist = np.sqrt(self.myDT.dist_el**2+self.myDT.dist_az**2) time.sleep(3)
firstDist = dist
while not dist < 0.01*u.deg:
percentSlew = max(100 - dist/firstDist*100, 0)
progressSignal.emit(setpoint_nr, percentSlew, "{:.3f}°".format(dist.value))
#print("{:.3f}".format(dist))
#print("{:2.0f}".format(percentSlew.value))
self.myDT.getDistance(waitForUpdate=True)
dist = np.sqrt(self.myDT.dist_el**2+self.myDT.dist_az**2) dist = np.sqrt(self.myDT.dist_el**2+self.myDT.dist_az**2)
firstDist = dist
while not dist < 0.01*u.deg:
percentSlew = max(100 - dist/firstDist*100, 0)
progressSignal.emit(setpoint_nr, percentSlew, "{:.3f}°".format(dist.value))
#print("{:.3f}".format(dist))
#print("{:2.0f}".format(percentSlew.value))
self.myDT.getDistance(waitForUpdate=True)
dist = np.sqrt(self.myDT.dist_el**2+self.myDT.dist_az**2)
oneSetpointCompleteSignal.emit(setpoint_nr, 'Measuring') oneSetpointCompleteSignal.emit(setpoint_nr, 'Measuring')
self.doMeasurement(setpoint_nr, progressSignal=progressSignal) self.doMeasurement(setpoint_nr, progressSignal=progressSignal)
oneSetpointCompleteSignal.emit(setpoint_nr, 'Completed') oneSetpointCompleteSignal.emit(setpoint_nr, 'Completed')
...@@ -222,12 +230,16 @@ class DTObservationProgram(Ui_mainWindow): ...@@ -222,12 +230,16 @@ class DTObservationProgram(Ui_mainWindow):
self.myMetaData.outputDirectory = self.outputDir self.myMetaData.outputDirectory = self.outputDir
self.myMetaData.outputFile = self.outputFile self.myMetaData.outputFile = self.outputFile
self.myMetaData.RaDEC = self.radec self.myMetaData.RaDEC = self.radec
self.myMetaData.refactionEnabled = self.checkBoxRefractionEnabled.checkStateSet() self.myMetaData.refractionEnabled = self.checkBoxRefraction.isChecked()
self.myMetaData.DTModelEnabled = self.checkBoxDTModel.checkStateSet() logging.debug('checkBoxRefraction Setting is {}:'.format(self.checkBoxRefraction.isChecked()))
self.myMetaData.DTModelEnabled = self.checkBoxDTModel.isChecked()
self.myMetaData.mode = self.GUIbackendMode
self.myMetaData.LSREnabled = self.radioButtonLSR.isChecked()
def writeMetaData(self,file): def writeMetaData(self,file):
for key, value in self.myMetaData.getMetaData().items(): for key, value in self.myMetaData.getMetaData().items():
file.write('#' + str(key) + '\t' + str(value) + '\n') #file.write('#' + str(key) + ':' + '\t' + str(value) + '\n')
file.write('#key: {}\t value: {}\n'.format(key,value))
logging.info('#key: {}\t value: {}'.format(key,value)) logging.info('#key: {}\t value: {}'.format(key,value))
def doMeasurement(self, measnum, progressSignal=None): def doMeasurement(self, measnum, progressSignal=None):
...@@ -257,10 +269,29 @@ class DTObservationProgram(Ui_mainWindow): ...@@ -257,10 +269,29 @@ class DTObservationProgram(Ui_mainWindow):
remainstring += "{:02}".format((self.integrationTime-sec)%60) remainstring += "{:02}".format((self.integrationTime-sec)%60)
progressSignal.emit(measnum, int(float(sec)/self.integrationTime*100), remainstring) progressSignal.emit(measnum, int(float(sec)/self.integrationTime*100), remainstring)
time.sleep(1) time.sleep(1)
measFile.close() measFile.close()
def readGUIBackendMode(self):
'''
Read the selected Backend mode from the GUI backend checkbox group
'''
if self.checkBoxPulsar.isChecked():
self.GUIbackendMode = 'Pulsar'
if self.checkBoxHI.isChecked():
self.GUIbackendMode = 'Hydrogen'
if self.checkBoxSDR.isChecked():
self.GUIbackendMode = 'SDR'
if self.checkBoxRaw.isChecked():
self.GUIbackendMode = 'Raw'
def startMeasurement(self): def startMeasurement(self):
print("Measurement started") '''
Put backend in proper mode
'''
logging.info('Start Measurement')
self.readGUIBackendMode()
self.myBackend.setMode(self.GUIbackendMode)
setpoints = [] setpoints = []
for meas in range(0,self.tableWidgetPointings.rowCount()): for meas in range(0,self.tableWidgetPointings.rowCount()):
ra = self.tableWidgetPointings.item(meas, 0).text() ra = self.tableWidgetPointings.item(meas, 0).text()
...@@ -278,7 +309,7 @@ class DTObservationProgram(Ui_mainWindow): ...@@ -278,7 +309,7 @@ class DTObservationProgram(Ui_mainWindow):
self.threadpool.start(worker) self.threadpool.start(worker)
def stopMeasurement(self): def stopMeasurement(self):
print("Measurement stopped") logging.info("Measurement stopped")
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) app = QApplication(sys.argv)
......
[Application] [Application]
LogLevel: INFO LogLevel: INFO
[TestConfig]
myDT: False
\ No newline at end of file
...@@ -171,12 +171,12 @@ class Ui_mainWindow(object): ...@@ -171,12 +171,12 @@ class Ui_mainWindow(object):
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout_2.setObjectName("verticalLayout_2")
self.checkBoxRefraction = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBoxRefraction.setObjectName("checkBoxRefraction")
self.verticalLayout_2.addWidget(self.checkBoxRefraction)
self.checkBoxDTModel = QtWidgets.QCheckBox(self.verticalLayoutWidget) self.checkBoxDTModel = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBoxDTModel.setObjectName("checkBoxDTModel") self.checkBoxDTModel.setObjectName("checkBoxDTModel")
self.verticalLayout_2.addWidget(self.checkBoxDTModel) self.verticalLayout_2.addWidget(self.checkBoxDTModel)
self.checkBoxRefractionEnabled = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBoxRefractionEnabled.setObjectName("checkBoxRefractionEnabled")
self.verticalLayout_2.addWidget(self.checkBoxRefractionEnabled)
self.toolBox.addItem(self.toolBoxMeasurement, "") self.toolBox.addItem(self.toolBoxMeasurement, "")
self.toolBoxBackEnd = QtWidgets.QWidget() self.toolBoxBackEnd = QtWidgets.QWidget()
self.toolBoxBackEnd.setGeometry(QtCore.QRect(0, 0, 280, 426)) self.toolBoxBackEnd.setGeometry(QtCore.QRect(0, 0, 280, 426))
...@@ -191,9 +191,14 @@ class Ui_mainWindow(object): ...@@ -191,9 +191,14 @@ class Ui_mainWindow(object):
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setObjectName("verticalLayout")
self.checkBoxPulsar = QtWidgets.QCheckBox(self.groupBox)
self.checkBoxPulsar.setChecked(True)
self.checkBoxPulsar.setAutoExclusive(True)
self.checkBoxPulsar.setObjectName("checkBoxPulsar")
self.verticalLayout.addWidget(self.checkBoxPulsar)
self.checkBoxHI = QtWidgets.QCheckBox(self.groupBox) self.checkBoxHI = QtWidgets.QCheckBox(self.groupBox)
self.checkBoxHI.setEnabled(True) self.checkBoxHI.setEnabled(True)
self.checkBoxHI.setChecked(True) self.checkBoxHI.setChecked(False)
self.checkBoxHI.setAutoExclusive(True) self.checkBoxHI.setAutoExclusive(True)
self.checkBoxHI.setObjectName("checkBoxHI") self.checkBoxHI.setObjectName("checkBoxHI")
self.verticalLayout.addWidget(self.checkBoxHI) self.verticalLayout.addWidget(self.checkBoxHI)
...@@ -201,10 +206,6 @@ class Ui_mainWindow(object): ...@@ -201,10 +206,6 @@ class Ui_mainWindow(object):
self.checkBoxSDR.setAutoExclusive(True) self.checkBoxSDR.setAutoExclusive(True)
self.checkBoxSDR.setObjectName("checkBoxSDR") self.checkBoxSDR.setObjectName("checkBoxSDR")
self.verticalLayout.addWidget(self.checkBoxSDR) self.verticalLayout.addWidget(self.checkBoxSDR)
self.checkBoxPulsar = QtWidgets.QCheckBox(self.groupBox)
self.checkBoxPulsar.setAutoExclusive(True)
self.checkBoxPulsar.setObjectName("checkBoxPulsar")
self.verticalLayout.addWidget(self.checkBoxPulsar)
self.checkBoxRaw = QtWidgets.QCheckBox(self.groupBox) self.checkBoxRaw = QtWidgets.QCheckBox(self.groupBox)
self.checkBoxRaw.setAutoExclusive(True) self.checkBoxRaw.setAutoExclusive(True)
self.checkBoxRaw.setTristate(False) self.checkBoxRaw.setTristate(False)
...@@ -346,14 +347,14 @@ class Ui_mainWindow(object): ...@@ -346,14 +347,14 @@ class Ui_mainWindow(object):
self.comboBoxProgramma.setItemText(3, _translate("mainWindow", "rawrecord")) self.comboBoxProgramma.setItemText(3, _translate("mainWindow", "rawrecord"))
self.label_3.setText(_translate("mainWindow", " Integration Time: ")) self.label_3.setText(_translate("mainWindow", " Integration Time: "))
self.pushButtonOutputDirectory.setText(_translate("mainWindow", "Output Dir")) self.pushButtonOutputDirectory.setText(_translate("mainWindow", "Output Dir"))
self.checkBoxDTModel.setText(_translate("mainWindow", "Refraction enabled")) self.checkBoxRefraction.setText(_translate("mainWindow", "Refraction enabled"))
self.checkBoxRefractionEnabled.setText(_translate("mainWindow", "DT Model enagled")) self.checkBoxDTModel.setText(_translate("mainWindow", "DT Model enabled"))
self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxMeasurement), _translate("mainWindow", "Measurement Settings")) self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxMeasurement), _translate("mainWindow", "Measurement Settings"))
self.groupBox.setTitle(_translate("mainWindow", "Mode")) self.groupBox.setTitle(_translate("mainWindow", "Mode"))
self.checkBoxPulsar.setText(_translate("mainWindow", "Pulsar (default)"))
self.checkBoxHI.setText(_translate("mainWindow", "Hydrogen Line")) self.checkBoxHI.setText(_translate("mainWindow", "Hydrogen Line"))
self.checkBoxSDR.setText(_translate("mainWindow", "SDR Mode")) self.checkBoxSDR.setText(_translate("mainWindow", "Software Defined Radio"))
self.checkBoxPulsar.setText(_translate("mainWindow", "Pulsar Mode")) self.checkBoxRaw.setText(_translate("mainWindow", "Raw"))
self.checkBoxRaw.setText(_translate("mainWindow", "Raw Mode"))
self.radioButtonLSR.setText(_translate("mainWindow", "Local &Standard of Rest Compensation")) self.radioButtonLSR.setText(_translate("mainWindow", "Local &Standard of Rest Compensation"))
self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxBackEnd), _translate("mainWindow", "BackEnd Settings")) self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxBackEnd), _translate("mainWindow", "BackEnd Settings"))
self.menuFile.setTitle(_translate("mainWindow", "Fi&le")) self.menuFile.setTitle(_translate("mainWindow", "Fi&le"))
......
...@@ -427,16 +427,16 @@ ...@@ -427,16 +427,16 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QCheckBox" name="checkBoxDTModel"> <widget class="QCheckBox" name="checkBoxRefraction">
<property name="text"> <property name="text">
<string>Refraction enabled</string> <string>Refraction enabled</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxRefractionEnabled"> <widget class="QCheckBox" name="checkBoxDTModel">
<property name="text"> <property name="text">
<string>DT Model enagled</string> <string>DT Model enabled</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -484,12 +484,9 @@ ...@@ -484,12 +484,9 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QCheckBox" name="checkBoxHI"> <widget class="QCheckBox" name="checkBoxPulsar">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>Hydrogen Line</string> <string>Pulsar (default)</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
...@@ -500,9 +497,15 @@ ...@@ -500,9 +497,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxSDR"> <widget class="QCheckBox" name="checkBoxHI">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string>SDR Mode</string> <string>Hydrogen Line</string>
</property>
<property name="checked">
<bool>false</bool>
</property> </property>
<property name="autoExclusive"> <property name="autoExclusive">
<bool>true</bool> <bool>true</bool>
...@@ -510,9 +513,9 @@ ...@@ -510,9 +513,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxPulsar"> <widget class="QCheckBox" name="checkBoxSDR">
<property name="text"> <property name="text">
<string>Pulsar Mode</string> <string>Software Defined Radio</string>
</property> </property>
<property name="autoExclusive"> <property name="autoExclusive">
<bool>true</bool> <bool>true</bool>
...@@ -522,7 +525,7 @@ ...@@ -522,7 +525,7 @@
<item> <item>
<widget class="QCheckBox" name="checkBoxRaw"> <widget class="QCheckBox" name="checkBoxRaw">
<property name="text"> <property name="text">
<string>Raw Mode</string> <string>Raw</string>
</property> </property>
<property name="autoExclusive"> <property name="autoExclusive">
<bool>true</bool> <bool>true</bool>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment