Commit 99be895c authored by marc's avatar marc
Browse files

draft create pointins

parent 1608f7cb
.project
.pydevproject
.settings
pointings.dat
__pycache__
......@@ -5,23 +5,24 @@ from astropy import units as u
from astropy.coordinates import SkyCoord
import sys
import logging
import math
'''
Setup logging
'''
logger = logging.getLogger('root')
FORMAT = "[%(asctime)s%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s,filename='dtobsgui.log',filemode='w'"
FORMAT = "[%(asctime)s%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s,filename='createpointings.log',filemode='w'"
logging.basicConfig(format=FORMAT)
logger.setLevel(logging.DEBUG)
class CreatePointings(Ui_FormCreatePoinings):
def __init__(self, formCreatePointings):
logging.info('CreatePointings Intialized')
logger.info('CreatePointings Intialized')
Ui_FormCreatePoinings.__init__(self)
self.setupUi(formCreatePointings)
self.target = SkyCoord(0 * u.radian,0 * u.radian)
try:
#self.target = SkyCoord.from_name(self.comboBox.currentText())
self.target = SkyCoord.from_name(self.comboBox.currentText())
(self.raStr, self.decStr) = self.target.to_string('hmsdms').split()
self.lineEditRA.setText(self.raStr)
self.lineEditDec.setText(self.decStr)
......@@ -34,19 +35,61 @@ class CreatePointings(Ui_FormCreatePoinings):
Define slot and connections for GUI
'''
self.comboBox.currentIndexChanged.connect(self.updateRADEC)
logging.debug('Target changed')
self.buttonBoxCreatePointings.accepted.connect(self.createPointings)
#self.buttonBoxCreatePointings.rejected.connect(sys.exit(app.exec_()))
def updateRADEC(self):
logging.debug('Target changed')
self.target = SkyCoord.from_name(self.comboBox.currentText())
(self.raStr, self.decStr) = self.target.to_string('hmsdms').split()
self.lineEditRA.setText(self.raStr)
self.lineEditDec.setText(self.decStr)
logging.info('New target is: {}'.format(self.target))
logger.info('New target is: {}'.format(self.target))
def createPointings(self):
logger.debug('Start createPointings')
n = int(self.spinBoxStepsRA.text())
m = int(self.spinBoxStepsDec.text())
stepSize = float(self.doubleSpinBoxDistanceDec.text())
measList = []
centrePoint = SkyCoord.from_name(self.comboBox.currentText())
raCentrePoint=centrePoint.ra.degree
decCentrePoint=centrePoint.dec.degree
logger.debug('centrePoint is: {}:{} and RADec steps are: {}:{}'.format(raCentrePoint,decCentrePoint, n, m))
pointings=0
raSign=-1
# m x n matrix of pointings with stepsSize steps
for decStep in range (-m,m):
decOffset=decCentrePoint+decStep*stepSize
raSign=-raSign
for raStep in range(-n,n):
if raSign==1:
raOffset=raCentrePoint+((stepSize*raStep*raSign)/math.cos(math.radians(decOffset)))
else:
#raOffset=raCentrePoint+((stepSize*raStep+stepSize/2)*raSign)/math.cos(math.radians(decOffset))
raOffset=raCentrePoint+((stepSize*(raStep+1))*raSign)/math.cos(math.radians(decOffset))
logger.debug('raOffset: {0} raSign {1}'.format(raOffset,raSign))
measList.append(SkyCoord(ra=raOffset*u.degree,dec=decOffset*u.degree,frame='icrs'))
pointings+=1
return (measList)
def writePointings(self, measList):
logger.debug('Start writePointings')
index=0
with open('pointings.dat','w') as f:
for pointing in measList:
f.write('{}\t{}\t{}\n'.format(index, measList[index].ra.deg, measList[index].dec.deg) )
logger.debug('{}\t{}\t{}\n'.format(index, measList[index].ra.deg, measList[index].dec.deg) )
index+=1
f.flush()
logger.debug('End createPointings')
f.close()
if __name__ == '__main__':
app = QApplication(sys.argv)
formCreatePointings = QWidget()
myForm = CreatePointings(formCreatePointings)
formCreatePointings.show()
myList = myForm.createPointings()
myForm.writePointings(myList)
sys.exit(app.exec_())
......@@ -11,11 +11,10 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_FormCreatePoinings(object):
def setupUi(self, FormCreatePoinings):
FormCreatePoinings.setObjectName("FormCreatePoinings")
FormCreatePoinings.resize(590, 270)
FormCreatePoinings.setMinimumSize(QtCore.QSize(590, 270))
FormCreatePoinings.resize(475, 264)
FormCreatePoinings.setMaximumSize(QtCore.QSize(590, 270))
self.layoutWidget = QtWidgets.QWidget(FormCreatePoinings)
self.layoutWidget.setGeometry(QtCore.QRect(11, 11, 571, 245))
self.layoutWidget.setGeometry(QtCore.QRect(11, 11, 461, 245))
self.layoutWidget.setObjectName("layoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget)
self.gridLayout.setObjectName("gridLayout")
......@@ -94,11 +93,13 @@ class Ui_FormCreatePoinings(object):
self.spinBoxStepsRA = QtWidgets.QSpinBox(self.layoutWidget)
self.spinBoxStepsRA.setAlignment(QtCore.Qt.AlignCenter)
self.spinBoxStepsRA.setMaximum(30)
self.spinBoxStepsRA.setProperty("value", 1)
self.spinBoxStepsRA.setObjectName("spinBoxStepsRA")
self.gridLayout.addWidget(self.spinBoxStepsRA, 3, 1, 1, 1)
self.spinBoxStepsDec = QtWidgets.QSpinBox(self.layoutWidget)
self.spinBoxStepsDec.setAlignment(QtCore.Qt.AlignCenter)
self.spinBoxStepsDec.setMaximum(30)
self.spinBoxStepsDec.setProperty("value", 1)
self.spinBoxStepsDec.setObjectName("spinBoxStepsDec")
self.gridLayout.addWidget(self.spinBoxStepsDec, 3, 2, 1, 1)
......
......@@ -219,6 +219,9 @@
<property name="maximum">
<number>30</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="2">
......@@ -229,6 +232,9 @@
<property name="maximum">
<number>30</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
......
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