-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_ptuse.py
More file actions
executable file
·125 lines (107 loc) · 4.66 KB
/
make_ptuse.py
File metadata and controls
executable file
·125 lines (107 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
"""Beamformer Schedule Block"""
from katuilib import obsbuild, ScheduleBlockTypes
from optparse import OptionParser
import katconf
import logging
APP_NAME = 'katscripts'
def main(options, args):
# Setup configuration source
katconf.set_config(katconf.environ(options.config))
# Set up Python logging
katconf.configure_logging(options.logging)
logfile = "kat.%s" % APP_NAME
logger = logging.getLogger(logfile)
# Load the configuration
sysconf = katconf.SystemConfig()
db_uri = sysconf.conf.get("katobs","db_uri")
logger.info("Logging started")
logger.info("Katobs obsbuild: db_uri=%s Make a Schedule Block" % db_uri)
obs = obsbuild(user=options.user, db_uri=db_uri)
print "===obs.status()==="
obs.status()
print "===obs.status()==="
#Create a new sb
sb_id_code = obs.sb.new(owner=options.user)
print "===NEW SB CREATED===", sb_id_code
obs.sb.description = "%s" % (options.description)
obs.sb.type = ScheduleBlockTypes.OBSERVATION
instruction_set= "run-obs-script /home/kat/katusescripts/ptuse/beamform_single_pulsar.py --proposal-id='FST-TRNS' --program-block-id='%s' --issue-id='%s' -B 856 -F 1284 -t %d '%s' --horizon 20" % (options.issue,options.issue,options.duration,options.target)
# instruction_set = "run-obs-script /home/kat/katsdpscripts/AR1/observations/beamform_AR1.py --proposal-id='COMM-AR1' --program-block-id='COMM-173' -B %s -F 1284 '%s' -t %d --horizon 20" % (options.bandwidth, options.target, options.duration)
# if options.backend is not None:
# instruction_set += " --backend='%s'" % (options.backend)
# if options.backend_args is not None:
# instruction_set += " --backend-args='%s'" % (options.backend_args)
# if options.drift_scan:
# instruction_set += " --drift-scan"
obs.sb.instruction_set = "%s" % (instruction_set)
obs.sb.antenna_spec = options.antennas
obs.sb.controlled_resources_spec = 'cbf,sdp,ptuse_1'
obs.sb.to_defined()
obs.sb.to_approved()
obs.sb.unload()
#Display the created sb
print "\n===obs.sb==="
print obs.sb
logger.info("Katobs done.")
if __name__ == "__main__":
parser = OptionParser()
parser.add_option('-c', '--config',
dest='config',
type=str,
default="xmlrpc:http://monctl.mkat.karoo.kat.ac.za:2010",
metavar='CONF',
help='look for configuration files in folder CONF (default=%default)' )
parser.add_option('-l', '--logging',
dest='logging',
type=str,
default=None,
metavar='LOGGING',
help='level to use for basic logging or name of logging configuration file; default is /log/log.<SITENAME>.conf')
parser.add_option('-o', '--user',
dest='user',
type=str,
default=None,
help='The obsever/user/owner (non optional option)')
parser.add_option('--issue',
dest='issue',
type=str,
default="MKAIV-388",
help='observation description')
parser.add_option('--description',
dest='description',
type=str,
default="MKAIV-388",
help='observation description')
parser.add_option('--target',
dest='target',
type=str,
default=None,
help='observation target')
parser.add_option('--duration',
dest='duration',
type=int,
default=60,
help='observation duration [seconds] (default=%default)')
parser.add_option('--ants',
dest='antennas',
type=str,
default='available',
help='antennas to use in the observation (default=%default)')
parser.add_option('--bw',
dest='bandwidth',
type=str,
default='856',
help='observational bandwidth [MHz] (default=%default)')
# add groups to options
# make backend a choice
(options, args) = parser.parse_args()
print options
if options.user is None:
print "A obsever/user/owner name is needed for this script"
raise SystemExit(parser.print_usage())
if options.target is None:
print "A target is needed for this script"
raise SystemExit(parser.print_usage())
import string
main(options, args)
# -fin-