Commit 148b7e74 authored by marc's avatar marc
Browse files

added MetaData Class and some clean up

parent 1235eff2
......@@ -15,22 +15,26 @@ from PyQt5.QtCore import QRunnable, QObject, pyqtSignal, pyqtSlot, QThreadPool
from PyQt5.QtWidgets import (QFileDialog, QApplication, QMainWindow, QTableWidgetItem)
from ui.dtobswindow import Ui_mainWindow
from telescope import telescope
from measurements import measurements
from astropy import units as u
from astropy.coordinates import SkyCoord
from telescope import telescope
from measurements import Measurements
from metadata import MetaData
'''
Setup logging
Setup config ini
'''
config = ConfigParser()
config.readfp(open(os.path.join(os.path.dirname(__file__), 'dtobsgui.ini')))
logging.basicConfig(level=logging.DEBUG)
#Define logging
if config['Application']['LogLevel']=='DEBUG':
logging.basicConfig(format='%(asctime)s:%(name)s:%(message)s',filename='dtobsgui.log',filemode='w' ,level=logging.DEBUG)
else:
logging.basicConfig(format='%(asctime)s:%(name)s:%(message)s',filename='dtobsgui.log',filemode='w' ,level=logging.INFO)
'''
Setup logging
'''
logger = logging.getLogger('root')
FORMAT = "[%(asctime)s%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s,filename='dtobsgui.log',filemode='w'"
logging.basicConfig(format=FORMAT)
logger.setLevel(logging.DEBUG)
class WorkerSignals(QObject):
......@@ -79,11 +83,14 @@ class Worker(QRunnable):
self.function_to_run(*self.args, **self.kwargs)
self.signals.allfinished.emit()
class DTObservationProgram(Ui_mainWindow):
class DTObservationProgram(Ui_mainWindow):
def __init__(self, mainWindow):
logging.info('Initialization of DTObsGUI')
self.myDT = telescope(setmode='J2000', consoleHost='consoledemo.dmz.camras.nl')
self.myMeas = measurements()
logger.info('Initialization of DTObsGUI')
#self.myDT = telescope(setmode='J2000', consoleHost='consoledemo.dmz.camras.nl')
self.myMeas = Measurements()
self.myMetaData = MetaData()
self.radec = None
Ui_mainWindow.__init__(self)
self.setupUi(mainWindow)
......@@ -96,7 +103,7 @@ class DTObservationProgram(Ui_mainWindow):
self.homedir = os.environ['HOME']
self.lineEditOutputDir.setText(self.homedir)
'''
Read the available tools from measuremnet Class and store them in the
Read the available tools from measurement Class and store them in the
comboBoxProgramma for selection.
'''
indexNR=0
......@@ -127,6 +134,7 @@ class DTObservationProgram(Ui_mainWindow):
rowPosition += 1
self.tableWidgetPointings.resizeColumnsToContents()
logger.info('Imported {} pointings'.format(rowPosition))
def selectOutputDirectory(self):
'''
......@@ -135,8 +143,7 @@ class DTObservationProgram(Ui_mainWindow):
dialog = QFileDialog()
folder_path = dialog.getExistingDirectory(None, "Select Folder",self.homedir)
self.lineEditOutputDir.setText(folder_path)
def closeMeasurement(self):
for rowPosition in range(self.tableWidgetPointings.rowCount(),-1,-1):
self.tableWidgetPointings.removeRow(rowPosition)
......@@ -196,6 +203,27 @@ class DTObservationProgram(Ui_mainWindow):
#self.tableWidgetPointings.item(meas_num, 2).setText(remaining_str)
self.tableWidgetPointings.item(meas_num, 2).setText(str(progress_percent)+"%")
def setMetaData(self):
'''
Define metadata
'''
self.myMetaData.description = self.textEditDescription.toPlainText()
self.myMetaData.startTime = time.strftime("%Y%m%d-%H%M%S")
self.myMetaData.operator1 = self.lineEditOperator1.text()
self.myMetaData.operator2 = self.lineEditOperator2.text()
self.myMetaData.operator3 = self.lineEditOperator3.text()
self.myMetaData.tool = measProgrammel
self.myMetaData.integrationTime = intgrationTime
self.myMetaData.outputDirectory = outputDir
self.myMetaData.outputFile = outputFile
self.myMetaData.RaDEC = self.radec
self.myMetaData.refactionEnabled = self.checkBoxRefractionEnabled.checkStateSet()
self.myMetaData.refactionEnabled = self.checkBoxDTModelEnabled.checkStateSet()
def writeMetaData(self,file):
for key, value in myData.getMetaData().items():
file.write(str(line))
logging.info('#key: {}\t value: {}'.format(k,v))
def doMeasurement(self, measnum, progressSignal=None):
"""
......@@ -204,14 +232,20 @@ class DTObservationProgram(Ui_mainWindow):
integrationTime: string read from spinBoxIntTime
measurement: result of measurement of which
data: is the stdout result which need to be stored line by line
measFile: result file stroing the stdout results including meta data
measFile: result file storing the stdout results including meta data
"""
integrationTime = self.spinBoxIntTime.value()
measProgramme = self.comboBoxProgramma.currentText()
outputDir = self.lineEditOutputDir.text()
measFile = open(outputDir + '/DT-' + '{:03d}'.format(measnum) + "-" + time.strftime("%Y%m%d") + ".dat",'w')
outputFile = '/DT-' + '{:03d}'.format(measnum) + '-' + time.strftime("%Y%m%d") + '.dat'
measFile = open(outputDir + outputFile,'w')
self.setMetaData(self)
self.writeMetaData(self,measFile)
logging.info("Output to file: {}".format(measFile))
self.myMeas.startMeasurement(measProgramme, integrationTime, measFile, metaData=None)
self.myMeas.startMeasurement(measProgramme, integrationTime, measFile)
for sec in range(integrationTime):
remainstring = str(int((integrationTime-sec)/60)) + ":"
......
......@@ -101,18 +101,30 @@ class Ui_mainWindow(object):
self.gridLayoutWidget_2.setObjectName("gridLayoutWidget_2")
self.gridLayout_3 = QtWidgets.QGridLayout(self.gridLayoutWidget_2)
self.gridLayout_3.setObjectName("gridLayout_3")
self.label_5 = QtWidgets.QLabel(self.gridLayoutWidget_2)
self.label_5.setObjectName("label_5")
self.gridLayout_3.addWidget(self.label_5, 0, 0, 1, 1)
self.label_8 = QtWidgets.QLabel(self.gridLayoutWidget_2)
self.label_8.setObjectName("label_8")
self.gridLayout_3.addWidget(self.label_8, 1, 0, 1, 1)
self.textEditObservers = QtWidgets.QTextEdit(self.gridLayoutWidget_2)
self.textEditObservers.setObjectName("textEditObservers")
self.gridLayout_3.addWidget(self.textEditObservers, 0, 1, 1, 1)
self.gridLayout_3.addWidget(self.label_8, 3, 0, 1, 1)
self.textEditDescription = QtWidgets.QTextEdit(self.gridLayoutWidget_2)
self.textEditDescription.setObjectName("textEditDescription")
self.gridLayout_3.addWidget(self.textEditDescription, 1, 1, 1, 1)
self.gridLayout_3.addWidget(self.textEditDescription, 3, 1, 1, 1)
self.label = QtWidgets.QLabel(self.gridLayoutWidget_2)
self.label.setObjectName("label")
self.gridLayout_3.addWidget(self.label, 2, 0, 1, 1)
self.label_7 = QtWidgets.QLabel(self.gridLayoutWidget_2)
self.label_7.setObjectName("label_7")
self.gridLayout_3.addWidget(self.label_7, 0, 0, 1, 1)
self.label_6 = QtWidgets.QLabel(self.gridLayoutWidget_2)
self.label_6.setObjectName("label_6")
self.gridLayout_3.addWidget(self.label_6, 1, 0, 1, 1)
self.lineEditOperator1 = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
self.lineEditOperator1.setObjectName("lineEditOperator1")
self.gridLayout_3.addWidget(self.lineEditOperator1, 0, 1, 1, 1)
self.lineEditoperator2 = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
self.lineEditoperator2.setObjectName("lineEditoperator2")
self.gridLayout_3.addWidget(self.lineEditoperator2, 1, 1, 1, 1)
self.lineEditOperator3 = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
self.lineEditOperator3.setObjectName("lineEditOperator3")
self.gridLayout_3.addWidget(self.lineEditOperator3, 2, 1, 1, 1)
self.toolBox.addItem(self.toolBoxMetaData, "")
self.toolBoxMeasurement = QtWidgets.QWidget()
self.toolBoxMeasurement.setGeometry(QtCore.QRect(0, 0, 280, 426))
......@@ -142,18 +154,18 @@ class Ui_mainWindow(object):
self.comboBoxProgramma.addItem("")
self.comboBoxProgramma.addItem("")
self.gridLayout_2.addWidget(self.comboBoxProgramma, 0, 1, 1, 1)
self.spinBoxIntTime = QtWidgets.QSpinBox(self.gridLayoutWidget)
self.spinBoxIntTime.setMinimum(1)
self.spinBoxIntTime.setMaximum(3600)
self.spinBoxIntTime.setProperty("value", 120)
self.spinBoxIntTime.setObjectName("spinBoxIntTime")
self.gridLayout_2.addWidget(self.spinBoxIntTime, 2, 1, 1, 1)
self.label_3 = QtWidgets.QLabel(self.gridLayoutWidget)
self.label_3.setObjectName("label_3")
self.gridLayout_2.addWidget(self.label_3, 2, 0, 1, 1)
self.pushButtonOutputDirectory = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButtonOutputDirectory.setObjectName("pushButtonOutputDirectory")
self.gridLayout_2.addWidget(self.pushButtonOutputDirectory, 1, 0, 1, 1)
self.spinBoxIntTime = QtWidgets.QSpinBox(self.gridLayoutWidget)
self.spinBoxIntTime.setMinimum(1)
self.spinBoxIntTime.setMaximum(3600)
self.spinBoxIntTime.setProperty("value", 2)
self.spinBoxIntTime.setObjectName("spinBoxIntTime")
self.gridLayout_2.addWidget(self.spinBoxIntTime, 2, 1, 1, 1)
self.verticalLayoutWidget = QtWidgets.QWidget(self.groupBox_2)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 160, 261, 80))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
......@@ -162,9 +174,9 @@ class Ui_mainWindow(object):
self.checkBoxDTModel = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBoxDTModel.setObjectName("checkBoxDTModel")
self.verticalLayout_2.addWidget(self.checkBoxDTModel)
self.checkBoxCorrection = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBoxCorrection.setObjectName("checkBoxCorrection")
self.verticalLayout_2.addWidget(self.checkBoxCorrection)
self.checkBoxRefractionEnabled = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBoxRefractionEnabled.setObjectName("checkBoxRefractionEnabled")
self.verticalLayout_2.addWidget(self.checkBoxRefractionEnabled)
self.toolBox.addItem(self.toolBoxMeasurement, "")
self.toolBoxBackEnd = QtWidgets.QWidget()
self.toolBoxBackEnd.setGeometry(QtCore.QRect(0, 0, 280, 426))
......@@ -320,8 +332,11 @@ class Ui_mainWindow(object):
item = self.tableWidgetPointings.horizontalHeaderItem(3)
item.setText(_translate("mainWindow", "Result File"))
self.groupBox_3.setTitle(_translate("mainWindow", "GroupBox"))
self.label_5.setText(_translate("mainWindow", "Observer(s):"))
self.label_8.setText(_translate("mainWindow", "Desciption: "))
self.label.setText(_translate("mainWindow", "Operator 3"))
self.label_7.setText(_translate("mainWindow", "Operator 1"))
self.label_6.setText(_translate("mainWindow", "Operator 2"))
self.lineEditOperator1.setText(_translate("mainWindow", "Stichting CAMRAS"))
self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxMetaData), _translate("mainWindow", "Meta Data"))
self.label_2.setText(_translate("mainWindow", " Programme: "))
self.comboBoxProgramma.setCurrentText(_translate("mainWindow", "dumpwide"))
......@@ -332,7 +347,7 @@ class Ui_mainWindow(object):
self.label_3.setText(_translate("mainWindow", " Integration Time: "))
self.pushButtonOutputDirectory.setText(_translate("mainWindow", "Output Dir"))
self.checkBoxDTModel.setText(_translate("mainWindow", "Refraction enabled"))
self.checkBoxCorrection.setText(_translate("mainWindow", "DT Model enagled"))
self.checkBoxRefractionEnabled.setText(_translate("mainWindow", "DT Model enagled"))
self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxMeasurement), _translate("mainWindow", "Measurement Settings"))
self.groupBox.setTitle(_translate("mainWindow", "Mode"))
self.checkBoxHI.setText(_translate("mainWindow", "Hydrogen Line"))
......
......@@ -255,25 +255,49 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Desciption: </string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextEdit" name="textEditDescription"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Operator 3</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Observer(s):</string>
<string>Operator 1</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Desciption: </string>
<string>Operator 2</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QTextEdit" name="textEditObservers"/>
<widget class="QLineEdit" name="lineEditOperator1">
<property name="text">
<string>Stichting CAMRAS</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="textEditDescription"/>
<widget class="QLineEdit" name="lineEditoperator2"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditOperator3"/>
</item>
</layout>
</widget>
......@@ -363,19 +387,6 @@
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxIntTime">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>3600</number>
</property>
<property name="value">
<number>120</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
......@@ -390,6 +401,19 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxIntTime">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>3600</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
......@@ -410,7 +434,7 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxCorrection">
<widget class="QCheckBox" name="checkBoxRefractionEnabled">
<property name="text">
<string>DT Model enagled</string>
</property>
......
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