From 2252ac06b716e68526cc9056b077193e56ef00b1 Mon Sep 17 00:00:00 2001 From: Daniel van der Schuur <schuur@astron.nl> Date: Tue, 5 Dec 2017 07:30:05 +0000 Subject: [PATCH] Add new pointing script for ARTS Remove old ARTS pointing scripts Addded Cyg.A on/off to TechnicalCommissioning --- .../arts/commissioning/point_array.py | 213 ++++++++++++++++++ .../sc1/TechnicalCommissioning.py | 8 +- .../arts/commissioning/sc1/point_array.py | 111 --------- .../commissioning/sc1/point_array_byradec.py | 92 -------- 4 files changed, 219 insertions(+), 205 deletions(-) create mode 100644 applications/arts/commissioning/point_array.py delete mode 100644 applications/arts/commissioning/sc1/point_array.py delete mode 100644 applications/arts/commissioning/sc1/point_array_byradec.py diff --git a/applications/arts/commissioning/point_array.py b/applications/arts/commissioning/point_array.py new file mode 100644 index 0000000000..84b2e75d19 --- /dev/null +++ b/applications/arts/commissioning/point_array.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +# +# Point the array using the message bus +# Author: L. Oostrum +# +# Send parset to system with: +#ssh arts@ccu-corr.apertif +#. /opt/apertif/apertifinit.sh +#send_file <parset_file> + +import sys +import socket +sys.path.insert(0, '/opt/apertif/lib/python2.7/site-packages/') +sys.path.insert(1, '/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/sc1') +import numpy as np +import datetime +from time import sleep +import TechnicalCommissioning as tcx +import subprocess + + +def get_ra_dec(ra, dec): + ra = ra.split(':') + ra = (float(ra[0]) + float(ra[1])/60 + float(ra[2])/3600) * 15 + # Remove + from positive DEC if present + if dec[0] == '+': + dec = dec[1:] + dec = dec.split(':') + dec = float(dec[0]) + float(dec[1])/60 + float(dec[2])/3600 + return ra, dec + + +def pointarray(pos_RA, pos_dec, telescopes): + ## stop any other running pointing (remove entry from database) + stoppointingarray(telescopes) + ## start new pointing + # make parset + f = open('/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/direction.parset', 'w') + f.write('_msg.system_name = APERTIF\n') + f.write('_msg.message_type = CommandMessage\n') + f.write('_msg.recipients = [\'DirectionControl\']\n') + f.write('\n') + f.write('_control.command.type = start_observation\n') + f.write('_control.command.execution_time = utcnow()\n') + f.write('\n') + f.write('# Task related\n') + f.write('task.taskID = 00001\n') + f.write('task.taskGroupID = 0000018\n') + t_start = datetime.datetime.now() + t_start = t_start + datetime.timedelta(seconds=2) + t_stop = t_start + datetime.timedelta(hours=12) + f.write('task.startTime = %s\n' % t_start.strftime("%Y-%m-%d %H:%M:%S")) + f.write('task.stopTime = %s\n' % t_stop.strftime("%Y-%m-%d %H:%M:%S")) + f.write('task.telescopes = [%s]\n' %', '.join(telescopes).upper()) + f.write('\n') + f.write('task.directionReferenceFrame = J2000\n') + for tel in telescopes: + f.write('task.telescope.%s.pointing = [%s, %s]\n' % (tel.upper(), str(pos_RA), str(pos_dec))) + f.write(' \n') + f.close() + # send parset + LCUPATH = '/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/' + cmd = '". /opt/apertif/apertifinit.sh; send_file ' + LCUPATH + '/direction.parset"' + ccu = 'ccu-corr' + print('Pointing array to (RA, DEC) = (%f, %f) degree' % (pos_RA, pos_dec)) + subprocess.call('ssh -tY %s %s' % (ccu, cmd), shell=True) + # pause to make sure start time has passed + sleep(5) + + +def stoppointingarray(telescopes): + # make parset + f = open('/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/direction.parset', 'w') + f.write('_msg.system_name = APERTIF\n') + f.write('_msg.message_type = CommandMessage\n') + f.write('_msg.recipients = [\'DirectionControl\']\n') + f.write('\n') + f.write('_control.command.type = stop_observation\n') + f.write('_control.command.execution_time = utcnow()\n') + f.write('\n') + f.write('# Task related\n') + f.write('task.taskID = 00001\n') + f.write('task.taskGroupID = 0000018\n') + f.write('task.telescopes = [%s]\n' %', '.join(telescopes).upper()) + f.write(' \n') + f.close() + # send parset + LCUPATH = '/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/' + cmd = '". /opt/apertif/apertifinit.sh; send_file ' + LCUPATH + '/direction.parset"' + ccu = 'ccu-corr' + subprocess.call('ssh -tY %s %s' % (ccu, cmd), shell=True) + # pause to make sure start time has passed + sleep(5) + + +def stowarray(telescopes, stow_pos='park'): + """stow_pos = string that selects the position + 'zenith' = Zenith pointing + 'north' = North + 'east' = East + 'south' = South + 'west' = West + 'fework' = "Werkstand", pointing for work on frontend + 'park' = Default park pointing (default) + 'storm' = Storm pointing + 'refpos' = "Afstelstand", positioning reference pointing + 'none' = if not called stop_observation, resume running observation + """ + ## stop pointing + stoppointingarray(telescopes) + # make parset + f = open('/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/direction.parset', 'w') + f.write('_msg.system_name = APERTIF\n') + f.write('_msg.message_type = CommandMessage\n') + f.write('_msg.recipients = [\'DirectionControl\']\n') + f.write('\n') + f.write('_control.command.type = stow_telescope\n') + f.write('_control.command.execution_time = utcnow()\n') + f.write('\n') + f.write('# Task related\n') + f.write('task.taskID = 00001\n') + f.write('task.taskGroupID = 0000018\n') + f.write('task.telescopes = [%s]\n' %', '.join(telescopes).upper()) + f.write('task.directionStow = %s\n' % stow_pos) + f.write(' \n') + f.close() + # send parset + LCUPATH = '/home/arts/SVN/RadioHDL/trunk/applications/arts/commissioning/' + cmd = '". /opt/apertif/apertifinit.sh; send_file ' + LCUPATH + '/direction.parset"' + ccu = 'ccu-corr' + subprocess.call('ssh -tY %s %s' % (ccu, cmd), shell=True) + # pause to make sure start time has passed + sleep(5) + + +def main(): + mode = None + # Get source coordinates + if len(sys.argv) < 3: + print "Supply either RA and DEC or a source name from the following list, plus dishes in comma-separated format." + print "Known source names:" + for src in ['1933', '0329', '0950', '2020', '0531', '0248', '1900', '1901', '1937', '1713', '1855', '1908', \ + '2303', 'Coff1', 'Coff2', 'Cas.A']: + print src + sys.exit() + + # Assign source based on passed argument, or might be a stow command + elif len(sys.argv) == 3: + mode = 'source' + if sys.argv[1]=='stow': mode = 'stow' + elif sys.argv[1]=='stop': mode = 'stop' + elif sys.argv[1]=='1933': source = 'PSR B1933+16' + elif sys.argv[1]=='0329': source = 'PSR B0329+54' + elif sys.argv[1]=='0950': source = 'PSR B0950+08' + elif sys.argv[1]=='2020': source = 'PSR B2020+28' + elif sys.argv[1]=='0531': source = 'Crab' + elif sys.argv[1]=='0248': source = 'J0248+6021' + elif sys.argv[1]=='1900': source = 'B1900+01' + elif sys.argv[1]=='1901': source = 'J1901+0435' + elif sys.argv[1]=='1937': source = 'PSR B1937+21' + elif sys.argv[1]=='1713': source = 'J1713+0747' + elif sys.argv[1]=='1855': source = 'B1855+09' + elif sys.argv[1]=='1908': source = 'B1908+00A' + elif sys.argv[1]=='2303': source = 'B2303+46' + elif sys.argv[1]=='Coff1': source = 'Coff1' + elif sys.argv[1]=='Coff2': source = 'Coff2' + elif sys.argv[1]=='Cas.A': source = 'Cas.A' + else: + print 'Invalid source argument:', source + sys.exit() + if mode == 'source': + tcx.output('Selected source: %s' % source) + (RA, DEC, sky_freq) = tcx.getsourcestats(source) + tcx.output('Determined source coordinates: (RA, DEC) = (%d, %d) degree' % (RA, DEC)) + + # Assign RA and DEC + else: + mode = 'radec' + RA, DEC = get_ra_dec(sys.argv[1], sys.argv[2]) + tcx.output('Selected (RA, DEC) = (%s %s)' % (str(RA), str(DEC))) + + # Assing telescopes + if mode in ['source', 'stop', 'stow']: + telescopes = sys.argv[2] + elif mode == 'radec': + telescopes = sys.argv[3] + else: + # Shouldn't be able to get here + print "Mode unknown:", mode + # convert telescopes to list, making sure they start with 'rt' + if telescopes[0].isdigit(): + # only numbers provided + telescopes = ['rt'+i for i in telescopes.split(',')] + else: + telescopes = [i for i in telescopes.split(',')] + + # set sys.argv to default as it is passed to tcx in e.g. execute_ssh which interprets negative DEC as an option + sys.argv = [''] + # check running on correct machine + tcx.check_host() + + if mode == 'stow': + tcx.output('Stowing dishes {}'.format(telescopes)) + stowarray(telescopes) + elif mode == 'stop': + tcx.output('Stop tracking dishes {}'.format(telescopes)) + stoppointingarray(telescopes) + else: + tcx.output("Pointing dishes {} to (RA, DEC) = ({}, {})".format(telescopes, RA, DEC)) + pointarray(RA, DEC, telescopes) + +if __name__ == '__main__': + exit(main()) diff --git a/applications/arts/commissioning/sc1/TechnicalCommissioning.py b/applications/arts/commissioning/sc1/TechnicalCommissioning.py index 2bc27a5936..f845d94e5a 100644 --- a/applications/arts/commissioning/sc1/TechnicalCommissioning.py +++ b/applications/arts/commissioning/sc1/TechnicalCommissioning.py @@ -835,9 +835,13 @@ def getsourcestats(source): src_RA = 350.8600 src_dec = 58.8267 sky_freq = 1400e6 - elif source == 'Cas.A_off': + elif source == 'Coff1': src_RA = 350.8600 - src_dec = 48.8267 + src_dec = 53.8267 + sky_freq = 1400e6 + elif source == 'Coff2': + src_RA = 350.8600 + src_dec = 63.8267 sky_freq = 1400e6 elif source == 'Cygnus.A': src_RA = -60.1283 diff --git a/applications/arts/commissioning/sc1/point_array.py b/applications/arts/commissioning/sc1/point_array.py deleted file mode 100644 index d81cdc3087..0000000000 --- a/applications/arts/commissioning/sc1/point_array.py +++ /dev/null @@ -1,111 +0,0 @@ -#! /usr/bin/env python -# -# Boudewijn Hut, hut@astron.nl -''' -This script orchestrates APERTIFs full field of view experiment -''' - -import sys -import socket -sys.path.insert(0, '/opt/apertif/lib/python2.7/site-packages/') -from apertif.drivers.dcu.DCUBoards import DCUBoards -from apertif.drivers.log.LOGBoards import LOGBoards -#import apertif.drivers.noisesrc.NoiseSource -from apertif.drivers.uniboard.UniBoards import UniBoards -from lofar.parameterset import parameterset; -import numpy -import time -import pickle -import os -from apertif.common.converters import convert_2_int_list -import matplotlib.pyplot as plt -import numpy as np -import TechnicalCommissioning as tcx -import itertools -import struct -import scipy.io as spio -import pickle - -DO_STOW = False -DO_POINT = True - -def main(): - # Assign source based on passed argument - if sys.argv[1]=='1933': source= 'PSR B1933+16' - elif sys.argv[1]=='0329': source= 'PSR B0329+54' - elif sys.argv[1]=='0950': source= 'PSR B0950+08' - elif sys.argv[1]=='2020': source= 'PSR B2020+28' - elif sys.argv[1]=='0531': source= 'Crab' - elif sys.argv[1]=='0248': source= 'J0248+6021' - elif sys.argv[1]=='1900': source= 'B1900+01' - elif sys.argv[1]=='1901': source= 'J1901+0435' - elif sys.argv[1]=='1937': source= 'PSR B1937+21' - elif sys.argv[1]=='1713': source= 'J1713+0747' - elif sys.argv[1]=='1855': source= 'B1855+09' - elif sys.argv[1]=='1908': source= 'B1908+00A' - elif sys.argv[1]=='2303': source= 'B2303+46' - else: - print 'Invalid source argument:', source - sys.exit() - - # Assign user passed dishes - telescopes = None # implicit whole array - tel = 'rta' - if len(sys.argv)==3: - s = sys.argv[2] - telescopes = [i for i in s.split(',')] - tel = telescopes[0] - - print 'Source:', source - - # check running on correct machine - tcx.check_host() - - exit_status = 0 - try: - - if DO_STOW: - tcx.stowarray('park') - - if DO_POINT: -# source = 'Cas.A' -# source = 'Cygnus.A' -# source = 'Cas.A_off' -# source = '3C293' -# source = 'PSR B0329+54' -# source = 'Virgo.A' -# source = 'PSR B0950+08' -# source = 'PSR B2020+28' -# source = 'PSR B1933+16' -# source = 'PSR B0329+54' -# source = 'Galactic H1 2' -# source = '3C286' -# source = '3C147' -# source = '3C147' -# source = '3C343_OFF' - tcx.output('Selected source: %s' % source) - (src_RA, src_dec, sky_freq) = tcx.getsourcestats(source) - tcx.output('Determined source coordinates: (RA, dec) = (%d, %d) degree' % (src_RA, src_dec)) -# src_dec = src_dec - 10. # uncomment to point to cold position (for Cas.A) -# tcx.output('Determined source coordinates: (RA, dec) = (%d, %d) degree' % (src_RA, src_dec)) - tcx.output('Pointing telescopes RT2-RTD to %s: (RA, dec) = (%d, %d) degree' % (source, src_RA, src_dec)) -# telescopes=['rt2','rtc'] - tcx.pointarray(src_RA, src_dec, telescopes) - - tcx.output('Checking %s to be on position' % tel.upper()) - # check on-pos for a single telescope - tcx.wait_till_array_on_pointing([tel]) - tcx.output('%s is on position now' % tel.upper()) - - except Exception, ex: - print sys.argv[0] + ' Exception: ' + str(ex) - raise - exit_status = 1 - finally: - print sys.argv[0] + ' Finished' - - return exit_status - -if __name__ == '__main__': - #from sys import exit - exit(main()) diff --git a/applications/arts/commissioning/sc1/point_array_byradec.py b/applications/arts/commissioning/sc1/point_array_byradec.py deleted file mode 100644 index 06f43f81de..0000000000 --- a/applications/arts/commissioning/sc1/point_array_byradec.py +++ /dev/null @@ -1,92 +0,0 @@ -#! /usr/bin/env python -# -# Boudewijn Hut, hut@astron.nl -# Edited to accept RA, DEC by Leon Oostrum, oostrum@astron.nl -''' -This script orchestrates APERTIFs full field of view experiment -''' - -import sys -import socket -sys.path.insert(0, '/opt/apertif/lib/python2.7/site-packages/') -from apertif.drivers.dcu.DCUBoards import DCUBoards -from apertif.drivers.log.LOGBoards import LOGBoards -#import apertif.drivers.noisesrc.NoiseSource -from apertif.drivers.uniboard.UniBoards import UniBoards -from lofar.parameterset import parameterset; -import numpy -import time -import pickle -import os -from apertif.common.converters import convert_2_int_list -import matplotlib.pyplot as plt -import numpy as np -import TechnicalCommissioning as tcx -import itertools -import struct -import scipy.io as spio -import pickle - -DO_STOW = False -DO_POINT = True - -def get_ra_dec(ra, dec): - ra = ra.split(':') - ra = (float(ra[0]) + float(ra[1])/60 + float(ra[2])/3600) * 15 - dec = dec.split(':') - dec = float(dec[0]) + float(dec[1])/60 + float(dec[2])/3600 - return ra, dec - -def main(): - # Assign source based on passed argument - try: - src_ra, src_dec = sys.argv[1:3] - except ValueError: - print 'Both RA and DEC should be supplied' - sys.exit() - if (not src_ra[:1].isdigit()) or (not src_dec[:1].isdigit()): - print 'Could not parse RA and/or DEC:', src_ra, src_dec - sys.exit() - - # Assign user passed dishes - telescopes = None # implicit whole array - tel = 'rta' - if len(sys.argv)==4: - s = sys.argv[3] - telescopes = [i for i in s.split(',')] - tel = telescopes[0] - - print 'RA, DEC:', src_ra, src_dec - - # check running on correct machine - tcx.check_host() - - exit_status = 0 - try: - - if DO_STOW: - tcx.stowarray('park') - - if DO_POINT: - tcx.output('Selected RA, DEC: %s %s' % (src_ra, src_dec)) - src_ra, src_dec = get_ra_dec(src_ra, src_dec) - tcx.output('Pointing telescopes to (RA, dec) = (%d, %d) degree' % (src_ra, src_dec)) - tcx.pointarray(src_ra, src_dec, telescopes) - - tcx.output('Checking %s to be on position' % tel.upper()) - # check on-pos for a single telescope - tcx.wait_till_array_on_pointing([tel]) - tcx.output('%s is on position now' % tel.upper()) - - except Exception, ex: - print sys.argv[0] + ' Exception: ' + str(ex) - raise - exit_status = 1 - finally: - print sys.argv[0] + ' Finished' - - return exit_status - -if __name__ == '__main__': - #from sys import exit - exit(main()) -- GitLab