Commits
Darrell Schiebel authored 85935034b73
1 1 | from __future__ import absolute_import |
2 2 | from __future__ import print_function |
3 3 | |
4 4 | import datetime |
5 5 | import re |
6 6 | |
7 - | from casatasks.private.casa_transition import is_CASA6 |
8 - | if is_CASA6: |
9 - | from urllib.request import urlopen |
10 - | from urllib.error import URLError |
11 - | from casatools import table, quanta |
12 - | from casatasks import casalog |
13 - | from casatools.platform import bytes2str |
7 + | from urllib.request import urlopen |
8 + | from urllib.error import URLError |
9 + | from casatools import table, quanta |
10 + | from casatasks import casalog |
14 11 | |
15 - | _tb = table( ) |
16 - | _qa = quanta( ) |
17 - | else: |
18 - | from urllib2 import urlopen |
19 - | from urllib2 import URLError |
20 - | |
21 - | from taskinit import * |
22 - | |
23 - | (_tb,)=gentools(['tb']) |
24 - | |
25 - | # to make the following code the same as the CASA6 version |
26 - | _qa = qa |
12 + | _tb = table( ) |
13 + | _qa = quanta( ) |
27 14 | |
28 15 | ###################################################################### |
29 16 | def correct_ant_posns_evla (vis_name, print_offsets=False): |
30 17 | ''' |
31 18 | Given an input visibility MS name (vis_name), find the antenna |
32 19 | position offsets that should be applied. This application should |
33 20 | be via the gencal task, using caltype='antpos'. |
34 21 | |
35 22 | If the print_offsets parameter is True, will print out each of |
36 23 | the found offsets (or indicate that none were found), otherwise |
109 96 | # first, see if the internet connection is possible |
110 97 | try: |
111 98 | response = urlopen(URL_BASE + '2010') |
112 99 | except URLError as err: |
113 100 | if print_offsets: |
114 101 | print('No internet connection to antenna position correction URL ', err.reason) |
115 102 | return [2, '', []] |
116 103 | response.close() |
117 104 | for year in range(2010,current_year+1): |
118 105 | response = urlopen(URL_BASE + str(year)) |
119 - | if is_CASA6: |
120 - | html = bytes2str(response.read()) |
121 - | else: |
122 - | html = response.read() |
106 + | html = response.read( ).decode( ) |
123 107 | response.close() |
124 108 | html_lines = html.split('\n') |
125 109 | |
126 110 | for correction_line in html_lines: |
127 111 | if len(correction_line) and correction_line[0] != '<' and correction_line[0] != ';': |
128 112 | for month in MONTHS: |
129 113 | if month in correction_line: |
130 114 | correction_lines.append(str(year)+' '+correction_line) |
131 115 | break |
132 116 | |