Skip to content

Commit 91bfddd

Browse files
Merge branch 'master' of github.com:ska-sa/katsdpscripts into fitting_fix_point_source_reduction
Conflicts: katsdpscripts/reduction/analyse_point_source_scans.py
2 parents 4783ccc + 5b17e3c commit 91bfddd

File tree

105 files changed

+5843
-1661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+5843
-1661
lines changed

AR1/MKAIV-186/MKAIV-186.py

+547
Large diffs are not rendered by default.

AR1/MKAIV-186/README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MKAIV-186.py is the reduction program for baseline phase stability. This code can run on any file that has a track of a point source. it will assume any tracks are point sources , it will use the flags in the file as well as a spectral mask if it is avalible.

AR1/MKAIV-187/MKAIV-187.py

+529
Large diffs are not rendered by default.

AR1/MKAIV-209/T_sys_T_nd_red.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/python
2+
import argparse
3+
from katsdpscripts.reduction import diodelib
4+
5+
def parse_arguments():
6+
parser = argparse.ArgumentParser(description=" This produces a pdf file with graphs verifying the ND model and Tsys for each antenna in the file")
7+
parser.add_argument("-o","--output_dir", default='.', help="Output directory for pdfs. Default is cwd")
8+
parser.add_argument("--pdf", action='store_true',default=True, help="Print the output to a PDF")
9+
parser.add_argument("--Ku", action='store_true',default=False, help="The specified file is a Ku band observation")
10+
parser.add_argument("-v","--verbose", action='store_true',default=False, help="Print some debugging information")
11+
parser.add_argument("--error_bars", action='store_true',default=False, help="Include error bars - Still in development")
12+
parser.add_argument("--off_target", default='off1', help="which of the two off targets to use")
13+
parser.add_argument("--write_nd", action='store_true', default=False, help="Write the Noise Diode temp to a file")
14+
parser.add_argument("filename", nargs=1)
15+
16+
args,unknown = parser.parse_known_args()
17+
18+
if args.filename[0] == '':
19+
raise RuntimeError('Please specify an h5 file to load.')
20+
21+
return args,unknown
22+
23+
24+
25+
if __name__ == "__main__":
26+
args,unknown = parse_arguments()
27+
print unknown
28+
kwargs = dict(zip(unknown[0::2],unknown[1::2]))
29+
diodelib.read_and_plot_data(args.filename[0],args.output_dir,args.pdf,args.Ku,args.verbose,args.error_bars,args.off_target,args.write_nd,**kwargs)
30+
31+
32+
33+

AR1/Phase_Amplitude_Closure/Phase & amplitude closure.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"N_ants = len(h5.ants)\n",
5050
"antA = [h5.inputs.index(inpA) for inpA, inpB in h5.corr_products]\n",
5151
"antB = [h5.inputs.index(inpB) for inpA, inpB in h5.corr_products]\n",
52-
"full_vis = (np.concatenate((h5.vis[:], (h5.vis[:]).conj()), axis=-1))\n",
52+
"vis = h5.vis[:]\n",
53+
"full_vis = np.concatenate((vis, vis.conj()), axis=-1)\n",
5354
"full_antA = np.r_[antA, antB]\n",
5455
"full_antB = np.r_[antB, antA]\n",
5556
"corrprods = zip(full_antA,full_antB)\n",

AR1/Phase_Amplitude_Closure/phase_amp_closure.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def plot_amp_freq(channel_freqs,a1234,title=''):
111111
antA = [h5.inputs.index(inpA) for inpA, inpB in h5.corr_products]
112112
antB = [h5.inputs.index(inpB) for inpA, inpB in h5.corr_products]
113113

114-
full_vis = (np.concatenate((h5.vis[:], (h5.vis[:]).conj()), axis=-1))
114+
vis = h5.vis[:]
115+
full_vis = np.concatenate((vis, vis.conj()), axis=-1)
115116
full_antA = np.r_[antA, antB]
116117
full_antB = np.r_[antB, antA]
117118
corrprods = zip(full_antA,full_antB)

AR1/UHF_scan.py

-23
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ def __exit__(self, type, value, traceback):
3232
parser.add_option('-m', '--max-duration', type='float', default=None,
3333
help='Maximum duration of the script in seconds, after which script will end '
3434
'as soon as the current track finishes (no limit by default)')
35-
parser.add_option('--no-delays', action="store_true", default=False,
36-
help='Do not use delay tracking, and zero delays')
3735
parser.add_option('--siggen-ip', default='192.168.14.61',
3836
help='Signal Generator IP adress (default=%default)')
3937
parser.add_option('--siggen-port', type='int', default=5025,
@@ -89,33 +87,12 @@ def __exit__(self, type, value, traceback):
8987
with verify_and_connect(opts) as kat:
9088
observation_sources = collect_targets(kat, args)
9189
if opts.force_siggen and kat.dry_run: user_logger.warning("The signal generator commands are being used during a dry-run")
92-
if not kat.dry_run and kat.ants.req.mode('STOP') :
93-
user_logger.info("Setting Antenna Mode to 'STOP', Powering on Antenna Drives.")
94-
time.sleep(10)
95-
else:
96-
user_logger.error("Unable to set Antenna mode to 'STOP'.")
97-
9890
# Quit early if there are no sources to observe
9991
if len(observation_sources.filter(el_limit_deg=opts.horizon)) == 0:
10092
user_logger.warning("No targets are currently visible - please re-run the script later")
10193
else:
10294
# Start capture session, which creates HDF5 file
10395
with start_session(kat, **vars(opts)) as session:
104-
#if not opts.no_delays and not kat.dry_run :
105-
# if session.dbe.req.auto_delay('on'):
106-
# user_logger.info("Turning on delay tracking.")
107-
# else:
108-
# user_logger.error('Unable to turn on delay tracking.')
109-
#elif opts.no_delays and not kat.dry_run:
110-
# if session.dbe.req.auto_delay('off'):
111-
# user_logger.info("Turning off delay tracking.")
112-
# else:
113-
# user_logger.error('Unable to turn off delay tracking.')
114-
# if session.dbe.req.zero_delay():
115-
# user_logger.info("Zeroed the delay values.")
116-
# else:
117-
# user_logger.error('Unable to zero delay values.')
118-
11996
user_logger.info("Setting up the signal Generator ip:port %s:%i."%(siggen_ip,siggen_port))
12097
if not kat.dry_run or opts.force_siggen : # prevent verifiing script from messing with things and failing to connect
12198
sigconn=SCPI.SCPI(siggen_ip,siggen_port)

AR1/catalogues/DEEP2.csv

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1934-638 ,radec bpcal ,19:39:25.03,-63:42:45.63
2-
0408-65 ,radec bpcal ,04:08:20.38,-65:45:09.1
3-
0637-752 ,radec gaincal ,06:35:46.51,-75:16:16.81
1+
1934-638 ,radec delaycal bpcal ,19:39:25.03,-63:42:45.63
2+
0408-65 ,radec delaycal bpcal gaincal ,04:08:20.38,-65:45:09.1
3+
0252-712 ,radec delaycal gaincal ,02:52:46.15,-71:04:35.26
44
DEEP_2 ,radec target ,04:13:26.40,-80:00:00.00

AR1/catalogues/DEEP2_cals.csv

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0408-65 ,radec delaycal bpcal ,04:08:20.38,-65:45:09.08
2+
0637-752 ,radec delaycal gaincal ,06:35:46.51,-75:16:16.81
3+
0252-712 ,radec delaycal gaincal ,02:52:46.15,-71:04:35.26

AR1/catalogues/EQU_COMM_TEST.csv

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1934-638 ,radec bpcal delaycal ,19:39:25.03,-63:42:45.63
2+
EQU_COMM_TEST ,radec target ,23:10:00.00,-00:15:00.00
3+
2243-123 ,radec gaincal delaycal ,22:46:18.23,-12:06:51.28
4+
2158-150 ,radec gaincal delaycal ,21:58:06.28,-15:01:09.33

AR1/catalogues/G330_maser.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
0408-65, radec bpcal delaycal, 04:08:20.38,-65:45:09.1
21
1934-638 , radec bpcal delaycal, 19:39:25.026 , -63:42:45.63
32
1613-586, radec gaincal, 16:17:17.88951,-58:48:07.8604
43
G330.89-0.36, radec target, 16:10:20.54, -52:06:14.94
4+
3C286, radec bpcal polcal, 13:31:08.29, 30:30:33.0

AR1/catalogues/IC5264.csv

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PKS1934-638, radec bpcal fluxcal delaycal, 19:39:25.03, -63:42:45.63
2+
ATCA2259-375, radec gaincal, 23:02:23.894778, -37:18:06.82368
3+
IC5264, radec target, 22:56:53.035, -36:33:14.91
4+
0408-65, radec bpcal delaycal, 04:08:20.38,-65:45:09.1

AR1/catalogues/M83.csv

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
0408-65 ,radec bpcal ,04:08:20.38,-65:45:09.1
2+
PKS 1934-638,radec bpcal,19:39:25.03,-63:42:45.63
3+
PKS 1313-333,radec gaincal,13:16:07.97,-33:38:59.17
4+
M83_0,radec target, 13:35:22.49,-30:28:40.04
5+
M83_1,radec target, 13:33:45.26,-29:51:55.50
6+
M83_2,radec target, 13:35:23.69,-29:15:10.96
7+
M83_3,radec target, 13:38:39.41,-30:28:40.04
8+
M83_4,radec target, 13:37:00.95,-29:51:55.50
9+
M83_5,radec target, 13:38:38.21,-29:15:10.96
10+
M83_6,radec target, 13:40:16.64,-29:51:55.50

AR1/catalogues/NGC3621.csv

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NGC 3621, radec target, 11:18:16.5, -32:48:51
2+
0407-658 | J0408-6545, radec bpcal delaycal, 04:08:20.380, -65:45:09.08
3+
PKS 1934-638, radec delaycal bpcal, 19:39:25.03,-63:42:45.63
4+
1117-248, radec gaincal, 11:20:09.120788, -25:08:07.608300

AR1/catalogues/SCP_imaging.csv

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3C138 ,radec bpcal ,05:21:09.90,+16:38:22.10
2+
PKS 1934-638 ,radec bpcal ,19:39:25.03,-63:42:45.63
3+
PKS 1607-841 ,radec gaincal,16:19:33.97,-84:18:19.10
4+
SCP ,radec target ,00:00:00.00,-90:00:00.00
5+
6+

AR1/catalogues/cenA.csv

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1315-46 , radec gaincal, 13:18:30.064, -46:20:34.90
2+
1421-490 , radec gaincal, 14:24:32.23734, -49:13:49.7437
3+
PKS1934-638 , radec bpcal fluxcal, 19:39:25.03, -63:42:45.63
4+
3C138 , radec bpcal fluxcal, 05:21:09.90,+16:38:22.10
5+
cenA , radec target, 13:25:27.61507, -43:01:08.8053

AR1/catalogues/gaincal_l_5jy.csv

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
PKS 0023-263, radec gaincal, 00:25:49.15625, -26:02:12.6168
2+
PKS 0134+439 | *3C48, radec gaincal, 01:37:41.299431, 33:09:35.132990
23
PKS 0237-233, radec gaincal, 02:40:08.174510, -23:09:15.730850
4+
PKS 0252-712, radec gaincal, 02:52:46.155968, -71:04:35.2741510
5+
PKS 0316+162, radec gaincal, 03:18:57.802658, 16:28:32.698500
36
PKS 0407-658, radec gaincal, 04:08:20.380, -65:45:09.08
7+
PKS 0410-752, radec gaincal, 04:08:49.07, -75:07:13.7
48
PKS 0518+165 | *3C138, radec gaincal, 05:21:09.886021, 16:38:22.051220
5-
PKS 0624-058 | *3C161, radec gaincal, 06:27:10.0960, -05:53:04.768
9+
PKS 0637-752, radec gaincal, 06:35:46.507915, -75:16:16.8148730
610
PKS 0741-063, radec gaincal, 07:44:21.6605, -06:29:35.888
711
PKS 0823-500, radec gaincal, 08:25:26.869, -50:10:38.49
8-
PKS 1226+023 | *3C273, radec gaincal, 12:29:06.699729, 02:03:08.598190
12+
PKS 1005+077 | *3C237, radec gaincal, 10:08:00.0160, 7:30:16.552
13+
PKS 1127-145, radec gaincal, 11:30:07.0525, -14:49:27.388
914
PKS 1253-055 | *3C279, radec gaincal, 12:56:11.166560, -05:47:21.524580
1015
PKS 1328+307 | *3C286, radec gaincal, 13:31:08.287984, 30:30:32.958850
1116
PKS 1421-490, radec gaincal, 14:24:32.23734, -49:13:49.7437
1217
PKS 1740-517, radec gaincal, 17:44:25.45534, -51:44:43.7611
1318
PKS 1814-637, radec gaincal, 18:19:35.002381, -63:45:48.18906
19+
PKS 1827-360, radec gaincal, 18:30:58.8829, -36:02:30.132
1420
PKS 1830-210, radec gaincal, 18:33:39.9150, -21:03:40.050
1521
PKS 1921-293, radec gaincal, 19:24:51.055957, -29:14:30.121150
1622
PKS 1934-638, radec gaincal, 19:39:25.026, -63:42:45.63
23+
PKS 2203-188, radec gaincal, 22:06:10.4170, -18:35:38.746
1724
PKS 2223-052 | *3C446, radec gaincal, 22:25:47.259291, -04:57:01.390730
1825
PKS 2230+114, radec gaincal, 22:32:36.408914, 11:43:50.904100
1926
PKS 2251+158 | *3C454.3, radec gaincal, 22:53:57.747932, 16:08:53.560890

AR1/catalogues/pks1814.csv

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PKS 1934-638, radec gaincal, 19:39:25.03, -63:42:45.63
2+
PKS 1814-63, radec target, 18:19:34, -63:45:48

AR1/drive_antennas/Move_RI.py

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
#!/usr/bin/env python
2+
# Exercise the indexer at various elevations.
3+
4+
import time
5+
import katpoint
6+
7+
from katcorelib import (standard_script_options,
8+
verify_and_connect,
9+
user_logger)
10+
11+
12+
def wait_until_sensor_equals(timeout, sensorname, value,
13+
sensortype=str, places=5, pollperiod=0.5):
14+
15+
stoptime = time.time() + timeout
16+
success = False
17+
18+
if sensortype == float:
19+
cmpfun = lambda got, exp: abs(got - exp) < 10 ** -places
20+
else:
21+
cmpfun = lambda got, exp: got == exp
22+
23+
lastval = None
24+
while time.time() < stoptime:
25+
lastval = kat.sensors.get(sensorname, None).get_value()
26+
27+
if cmpfun(lastval, value):
28+
success = True
29+
break
30+
time.sleep(pollperiod)
31+
return (success, lastval)
32+
33+
34+
def track(ant, target, ridx_position='l', duration=10, dry_run=False):
35+
36+
# TODO: make the indexer timeout configurable parameter
37+
indexer_timeout = 120
38+
# send this target to the antenna.
39+
ant.req.target(target.description)
40+
user_logger.info("Target description: '%s' " % target.description)
41+
ant.req.mode("POINT")
42+
43+
if not dry_run:
44+
# Added sleep to wait for AP brakes to disengage
45+
time.sleep(8)
46+
47+
# TODO: more meaningful indication of the target
48+
# (where no name is specified)
49+
user_logger.info("Slewing %s to target: %s" % (ant.name, target.name))
50+
# Wait for antenna to lock onto target
51+
if not dry_run:
52+
if ant.wait('lock', True, timeout=300):
53+
user_logger.info("%s on target... "
54+
"Wait for %d seconds "
55+
"before starting indexer cycle" %
56+
(ant.name, duration))
57+
time.sleep(duration)
58+
else:
59+
user_logger.error("Antennas failed to reach target.")
60+
61+
ant.req.mode('STOP')
62+
if not dry_run:
63+
# Added sleep to wait for AP brakes to engage
64+
time.sleep(2)
65+
result = wait_until_sensor_equals(5.0, ant.name + '_mode', 'STOP')
66+
if result[0] == False:
67+
user_logger.error("Failed to set AP to 'STOP' mode. "
68+
"Indexer commands will not be processed.")
69+
return
70+
71+
user_logger.info("Setting initial RI on %s to position : %s " %
72+
(ant.name, ridx_position.upper()))
73+
74+
ant.req.ap_set_indexer_position(ridx_position)
75+
if not dry_run:
76+
result = wait_until_sensor_equals(indexer_timeout,
77+
ant.name + '_ap_indexer_position',
78+
ridx_position)
79+
else:
80+
result = (True, ridx_position)
81+
82+
if result[0] == False:
83+
ridx_position_raw = kat.sensors.get(ant.name + '_ap_indexer_position_raw', None).get_value()
84+
user_logger.error("Timed out while waiting %s seconds for "
85+
"indexer to reach '%s' position. "
86+
"Last position reading was %s degrees." %
87+
(indexer_timeout,
88+
ridx_position.upper(),
89+
ridx_position_raw))
90+
91+
# TODO: make this sequence easier to configure
92+
ridx_sequence = ['u', 'l', 'x', 's', 'l', 'u', 's', 'x',
93+
'u', 'l', 's', 'x', 'l', 'u', 'x', 's',
94+
'u', 'x', 'l', 's', 'l', 's']
95+
96+
# Cycling indexer positions
97+
if not dry_run:
98+
for pos in ridx_sequence:
99+
ridx_last_position = kat.sensors.get(ant.name + '_ap_indexer_position', None).get_value()
100+
ridx_movement_start_time = time.time()
101+
user_logger.info("--- Moving RI to position: '%s' ---" %
102+
pos.upper())
103+
ant.req.ap_set_indexer_position(pos)
104+
105+
result = wait_until_sensor_equals(indexer_timeout,
106+
ant.name + '_ap_indexer_position',
107+
pos)
108+
user_logger.debug("Request result: '%s', "
109+
"last sensor reading: '%s'" %
110+
(result[0], result[1]))
111+
112+
if result[0] == False:
113+
ridx_position_raw = kat.sensors.get(ant.name + '_ap_indexer_position_raw', None).get_value()
114+
ridx_brakes_released = kat.sensors.get(ant.name + '_ap_ridx_brakes_released', None).get_value()
115+
116+
user_logger.error("Timed out while waiting %s seconds "
117+
"for indexer to reach '%s' position. "
118+
"Last position reading was %s degrees. "
119+
"Brakes released: '%s'. " %
120+
(indexer_timeout, pos.upper(),
121+
ridx_position_raw,
122+
ridx_brakes_released))
123+
124+
ridx_current_position = kat.sensors.get(ant.name + '_ap_indexer_position', None).get_value()
125+
time_to_index = time.time() - ridx_movement_start_time
126+
if ridx_current_position in ['undefined']:
127+
user_logger.warning("Movement ended in undefined position")
128+
else:
129+
user_logger.info("RIDX from '%s' to '%s' position "
130+
"took '%s' seconds." %
131+
(ridx_last_position.upper(),
132+
ridx_current_position.upper(),
133+
time_to_index))
134+
135+
# 60 seconds comes from the antenna specification
136+
if (time_to_index > 60.0):
137+
user_logger.warning("Indexer took longer than 60 seconds!")
138+
139+
user_logger.info("Dwell for %s seconds before "
140+
"going to next position." % duration)
141+
time.sleep(duration)
142+
143+
user_logger.info("Pattern complete. Heading to next sky target.")
144+
145+
146+
# Set up standard script options
147+
148+
parser = standard_script_options(usage="%prog [options] <'target/catalogue'> [<'target/catalogue'> ...]",
149+
description="Exercise the receiver indexer drive at different elevations.")
150+
151+
parser.add_option('--dwell-time', type='float',
152+
default=5.0,
153+
help='Time between changing indexer positions in seconds (default=%default)')
154+
parser.add_option('--num-repeat', type='int',
155+
default=1,
156+
help='The number of times to repeat the sequence (once by by default)')
157+
parser.add_option('--ap', type='str',
158+
default="m036",
159+
help='Receptor under test (default is m036)')
160+
161+
# Parse the command line
162+
opts, args = parser.parse_args()
163+
164+
if opts.observer is None:
165+
raise RuntimeError("No observer provided script")
166+
167+
if len(args) == 0:
168+
raise RuntimeError("No targets and indexer positions"
169+
"provided to the script")
170+
171+
receptor = None
172+
targetlist = []
173+
174+
for argstr in args:
175+
temp, taz, tel, band = argstr.split(',')
176+
print "azimuth : %r elevation : %r indexer : %s" % (taz, tel, band)
177+
targetlist.append([taz, tel, band])
178+
179+
# Check options and build KAT configuration, connecting to proxies and devices
180+
with verify_and_connect(opts) as kat:
181+
182+
for ant in kat.ants:
183+
if opts.ap in [ant.name]:
184+
receptor = ant
185+
186+
if receptor is None:
187+
raise RuntimeError("Receptor under test is not in controlled array")
188+
189+
# Set sensor strategies"
190+
kat.ants.set_sampling_strategy("lock", "event")
191+
kat.ants.set_sampling_strategy("ap.indexer-position", "event")
192+
193+
if not kat.dry_run and receptor.req.mode('STOP'):
194+
user_logger.info("Setting Antenna Mode to 'STOP', "
195+
"Powering on Antenna Drives.")
196+
time.sleep(2)
197+
else:
198+
if not kat.dry_run:
199+
user_logger.error("Unable to set Antenna mode to 'STOP'.")
200+
201+
for taz, tel, band in targetlist:
202+
for i in range(int(opts.num_repeat)):
203+
target = katpoint.Target('Name, azel, %s, %s' % (taz, tel))
204+
track(receptor, target, ridx_position=band,
205+
duration=opts.dwell_time, dry_run=kat.dry_run)
206+
user_logger.info("Elevation: '%s' "
207+
"Patterns attempted: '%s' "
208+
"Contractual cycles: '%s'." %
209+
(tel, i+1, 11*(i+1)))

0 commit comments

Comments
 (0)