-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathadc_all_calibrations.py
95 lines (81 loc) · 3.88 KB
/
adc_all_calibrations.py
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
import logging
import logging.config
import logging.handlers
import corr
import time
import datetime
import sys
import os
from optparse import OptionParser
import AdcCalLoggingFileHandler
from ADCCalibrations import ADCCalibrations
def main():
p = OptionParser()
p.set_usage('%prog [options]')
p.set_description(__doc__)
p.add_option('-v', '--verbosity', dest='verbosity',type='int', default=1,
help='Verbosity level. Default: 1')
p.add_option('-r', '--roaches', dest='roaches',type='str', default='srbsr2-1',
help='Comma-separated list of roach hostnames. Default: srbsr2-1')
p.add_option('-M', '--n_mmcm_trials', dest='n_mmcm_trials',type='int', default=5,
help='Number of mmcm trials. Default: 5')
p.add_option('-N', '--n_trials', dest='n_trials',type='int', default=10,
help='Number of snap/fit trials. Default: 10')
p.add_option('-f', '--testfreq', dest='testfreq', type='float', default=18.3105,
help='sine wave test frequency input in MHz. Default = 18.3105')
p.add_option('-l', '--ampl', dest='ampl', type='float', default=3.0,
help='Power level of test tone input in dBm. Default = 3.0')
p.add_option('-g', '--gpibaddr', dest='gpibaddr', type='str', default='10.16.96.174',
help='IP Address of the GPIB. Current default is set to tape room machine. Default = 10.16.96.174')
p.add_option('-d', '--data_dir', dest='data_dir', type='str', default='.',
help='name of directory to put all files')
p.add_option('-c', '--conf_dir', dest='conf_dir', type='str', default='.',
help='name of directory where configuration files are found')
p.add_option('-m', '--manual', dest='manual', action='store_true', default=False,
help='Manual control of the calibration process. Default=False')
p.add_option('-O', '--ogp_only', dest='ogp_only', action='store_true', default=False,
help='Don t do MMCMs, just OGPs. Default=False')
p.add_option('-C', '--mmcm_only', dest='mmcm_only', action='store_true', default=False,
help='Don t do OGPs, just MMCMs. Default=False')
opts, args = p.parse_args(sys.argv[1:])
# setup log file name:
current_time = datetime.datetime.now().strftime('%Y-%m%d-%H%M%S')
timestamp = "_all_%s"%current_time
AdcCalLoggingFileHandler.timestamp = timestamp
# load log config file
if opts.conf_dir is not None:
conf_dir = opts.conf_dir
else:
# if they haven't specified configuration directory, try to use env
var = "YGOR_TELESCOPE"
conf_dir = '.' if not os.environ.has_key(var) else os.path.join(os.environ[var], "etc/config")
conffile = "%s/%s" % (conf_dir, 'adc_cal_logging.conf')
if not os.path.isfile(conffile):
print "Cannot find config file for logging: %s" % conffile
sys.exit(0)
logging.config.fileConfig(conffile)
logger = logging.getLogger('adc5gLogging')
logger.info("Started")
if not opts.verbosity:
logger.setLevel(logging.INFO)
logger.info("opts :\n\t" + str(opts))
logger.info("args :\n\t" + str(args))
logger.info("log file name:\n\t" + AdcCalLoggingFileHandler.logfilename)
roaches = [s.strip() for s in opts.roaches.split(",")]
# Time to make our worker class
cal = ADCCalibrations(data_dir = opts.data_dir
, conf_dir = conf_dir
, roaches = roaches
, gpib_addr = opts.gpibaddr
, mmcm_trials = opts.n_mmcm_trials
, ogp_trials = opts.n_trials
, test_tone = opts.testfreq
, ampl = opts.ampl
, manual = opts.manual
, do_ogps = not opts.mmcm_only
, do_mmcms = not opts.ogp_only
)
# and use it
cal.find_all_calibrations()
if __name__ == "__main__":
main()