Exemplo n.º 1
0
class ADCCalibrationsTest(unittest.TestCase):
    'Unit tests for .'

    def setUp(self):
        # setup this class for unit tests
        now =  datetime(2014, 4, 24, 9, 8, 38)
        self.adc = ADCCalibrations(data_dir = 'testdata'
                                 , test = True
                                 , conf_dir = 'testdata'
                                 , mmcm_trials = 1
                                 , roaches = ['noroach']
                                 , now = now
                                  )
        





        # Uncomment this code if you want the logs to stdout 
        #logging.config.fileConfig('adc5g_logging_config.conf')
        #logger = logging.getLogger('adc5gLogging')
        #logger.info("Started")

    # TBF: need to do this still?
    #def tearDown(self):

        # clean up all the generated files
        #files = []
        #basename = "%s/snapshot_raw_%s_z%d_%s.dat.%s" 
        #exts = ["fit", "ogp", "a", "b", "c", "d", "res"]
        #for zdok in [0,1]:
        #    for i in range(10):
        #        for ext in exts:
        #            e = "%d.%s" % (i, ext) 
        #            f = basename % (self.adc.dir, self.adc.roach_name, zdok, self.adc.current_time, e)
        #            files.append(f)
        #for f in files:
        #    if os.path.isfile(f):
        #        os.remove(f)

        # clean up .png's
        #fs = os.listdir(self.adc.dir)

    def test_find_all_mmcms(self):

        self.adc.find_all_mmcms()
Exemplo n.º 2
0
 def setUp(self):
     # setup this class for unit tests
     now =  datetime(2014, 4, 24, 9, 8, 38)
     self.adc = ADCCalibrations(data_dir = 'testdata'
                              , test = True
                              , conf_dir = 'testdata'
                              , mmcm_trials = 1
                              , roaches = ['noroach']
                              , now = now
                               )
Exemplo n.º 3
0
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()