Collection of scripts and small programs used by the EVN Support Scientists at JIVE during the regular data processing of EVN observations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

102 line
4.1 KiB

  1. #!/usr/bin/env python
  2. #Prints the gaps between each scan for each telescope, along with a summary
  3. #Supports python2.7 and python3.4
  4. #V1.0 14/10/2016 JMB
  5. from __future__ import print_function
  6. #import numpy as np #np.array and nm.linspace
  7. import argparse #command line parsing
  8. import sys #for sys.exit()
  9. from datetime import datetime,timedelta
  10. #parse inputs
  11. parser = argparse.ArgumentParser(description='List gaps for each telescope in a SCHED keyin file. Note, stations with continuous cal will be reported but have an asterix in front of them')
  12. parser.add_argument('sum_file', help="the .sum file to read. Must have early as a 'bottom' sumitem or by itself (last)")
  13. parser.add_argument('-e', '--early', help="seconds antenna must be on source before scan start to count as sufficient for tsys. Defaults to 11", type=int, default=11)
  14. args = parser.parse_args()
  15. earlyTimes=[] #initialise empty list
  16. inEarlySection=False #when reading file we start not in the slewing section
  17. with open(args.sum_file,"rt") as infile: #open file
  18. for line in infile:
  19. if line.strip() == 'Bottom item is: Seconds antenna is on source before scan start.':
  20. inEarlySection = True #we are now reading the early section
  21. if inEarlySection:
  22. if line.strip().startswith('SCAN SUMMARY'):
  23. inEarlySection = False #maybe new page, maybe end of section
  24. if line.strip() == 'TIME RANGE OF RECORDINGS and TOTAL BYTES:':
  25. break #stop reading if we hit the next item in the sum file
  26. if line.strip().startswith('STOP UT'): #this line has telescope info (codes), we actually read this multiple times but it should not change I think so no biggie...
  27. telescopes=line.strip().split()
  28. try:
  29. if(line.strip()[0].isdigit()): #if first character is a digit we have a start time
  30. earlyTimes.append(line.strip().split())
  31. except IndexError:
  32. pass
  33. if len(earlyTimes) == 0:
  34. #if we made it all the way through without finding the slew section it means that that info is not in the sum summary
  35. print ("early is not a sumitem in the summary file. Can not continue.")
  36. sys.exit(1)
  37. telescopes=telescopes[2:] #cut out the parts that are not telescope names
  38. earlyTimes = earlyTimes[1::2] #every second line
  39. # print ('Time',end=" ")
  40. # for scope in telescopes:
  41. # print (scope.rjust(5),end="")
  42. # print()
  43. # for line in earlyTimes:
  44. # print (line[1],end=" ")
  45. # for item in line[4:]:
  46. # print (item.rjust(5), end="")
  47. # print('')
  48. # lots of loops now, first for each telescope. This could be easily optimised but I'm going to be lazy I think
  49. for i,scope in enumerate(telescopes):
  50. #loop through the early times and keep track of gaps
  51. #print(earlyTimes[0][0] + '/' + (earlyTimes[0][1]))
  52. lastGap = (earlyTimes[0][0] + '/' + earlyTimes[0][1])
  53. foundGap = False
  54. continuousCal = ('O8', 'Ys', 'Ef', 'Ro', 'Jb', 'Tr')
  55. contStationText = ''
  56. if scope in continuousCal:
  57. contStationText = '*'
  58. for scan in earlyTimes:
  59. try:
  60. if float((scan[4+i])) >= args.early:
  61. #print (scope, map(int,scan[1].split(':')))
  62. currentTime=(scan[0]+'/'+scan[1])
  63. # print(lastGap, currentTime)
  64. tDiff = datetime.strptime(currentTime, '%j/%H:%M:%S') - datetime.strptime(lastGap, '%j/%H:%M:%S')
  65. if tDiff.total_seconds()/60.0 > 15.0:
  66. print("%s%s, %s to %s, Interval = %.1f minutes" % (contStationText, scope, lastGap, currentTime, (tDiff.total_seconds()/60)))
  67. lastGap = currentTime
  68. foundGap = True
  69. except ValueError:
  70. if (scan[4+i] == '---D'):
  71. currentTime=(scan[0]+'/'+scan[1])
  72. lastGap = currentTime
  73. else:
  74. pass
  75. if ':' in scan[1]:
  76. currentTime=(scan[0]+'/'+scan[1])
  77. else:
  78. currentTime=(scan[1]+'/'+scan[2])
  79. # print(lastGap, currentTime)
  80. tDiff = datetime.strptime(currentTime, '%j/%H:%M:%S') - datetime.strptime(lastGap, '%j/%H:%M:%S')
  81. if tDiff.total_seconds()/60.0 > 15.0:
  82. print("%s%s, %s to %s, Interval = %.1f minutes" % (contStationText, scope, lastGap, currentTime, (tDiff.total_seconds()/60)))
  83. if foundGap == False:
  84. print ("No Tsys at all for %s" % scope)
  85. print()
  86. print("Stations with an * use continuous cal and can be ignored\n")