Example #1
0
def makeparamdicts(beamlist, radarname, simparams):
    curpath = os.path.dirname(
        os.path.abspath(inspect.getfile(inspect.currentframe())))

    angles = getangles(beamlist, radarname)
    ang_data = sp.array([[iout[0], iout[1]] for iout in angles])
    sensdict = sensconst.getConst(radarname, ang_data)

    if 't_s' in simparams.keys():
        sensdict['t_s'] = simparams['t_s']
        sensdict['fs'] = 1.0 / simparams['t_s']
        sensdict[
            'BandWidth'] = sensdict['fs'] * 0.5  #used for the noise bandwidth

    simparams['Beamlist'] = beamlist
    time_lim = simparams['TimeLim']
    (pulse, simparams['Pulselength']) = makepulse(simparams['Pulsetype'],
                                                  simparams['Pulselength'],
                                                  sensdict['t_s'])
    simparams['Pulse'] = pulse

    simparams['amb_dict'] = make_amb(sensdict['fs'],
                                     int(simparams['ambupsamp']),
                                     sensdict['t_s'] * len(pulse), pulse,
                                     simparams['numpoints'])
    simparams['angles'] = angles
    rng_lims = simparams['RangeLims']
    rng_gates = sp.arange(rng_lims[0], rng_lims[1],
                          sensdict['t_s'] * v_C_0 * 1e-3)
    simparams['Timevec'] = sp.arange(0, time_lim, simparams['Fitinter'])
    simparams['Rangegates'] = rng_gates
    sumrule = makesumrule(simparams['Pulsetype'], simparams['Pulselength'],
                          sensdict['t_s'])
    simparams['SUMRULE'] = sumrule
    minrg = -sumrule[0].min()
    maxrg = len(rng_gates) - sumrule[1].max()

    simparams['Rangegatesfinal'] = sp.array([
        sp.mean(rng_gates[irng + sumrule[0, 0]:irng + sumrule[1, 0] + 1])
        for irng in range(minrg, maxrg)
    ])
    if 'startfile' in simparams.keys(
    ) and simparams['Pulsetype'].lower() != 'barker':
        relpath = simparams['startfile'][0] != os.path.sep
        if relpath:
            fullfilepath = os.path.join(curpath, simparams['startfile'])
            simparams['startfile'] = fullfilepath
        stext = os.path.isfile(simparams['startfile'])
        if not stext:
            warnings.warn('The given start file does not exist', UserWarning)

    elif simparams['Pulsetype'].lower() != 'barker':
        warnings.warn('No start file given', UserWarning)
    return (sensdict, simparams)
Example #2
0
def makeparamdicts(beamlist,radarname,simparams):
    curpath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))

    angles = getangles(beamlist,radarname)
    ang_data = sp.array([[iout[0],iout[1]] for iout in angles])
    sensdict = sensconst.getConst(radarname,ang_data)

    if 't_s' in simparams.keys():
        sensdict['t_s'] = simparams['t_s']
        sensdict['fs'] =1.0/simparams['t_s']
        sensdict['BandWidth'] = sensdict['fs']*0.5 #used for the noise bandwidth
#    pdb.set_trace()
    simparams['Beamlist']=beamlist
    time_lim = simparams['TimeLim']
    (pulse,simparams['Pulselength'])  = makepulse(simparams['Pulsetype'],simparams['Pulselength'],sensdict['t_s'])
    simparams['Pulse'] = pulse
#    pdb.set_trace()
    simparams['amb_dict'] = make_amb(sensdict['fs'],int(simparams['ambupsamp']),
        sensdict['t_s']*len(pulse),len(pulse),simparams['numpoints'])
    simparams['angles']=angles
    rng_lims = simparams['RangeLims']
    rng_gates = sp.arange(rng_lims[0],rng_lims[1],sensdict['t_s']*v_C_0*1e-3)
    simparams['Timevec']=sp.arange(0,time_lim,simparams['Fitinter'])
    simparams['Rangegates']=rng_gates
    sumrule = makesumrule(simparams['Pulsetype'],simparams['Pulselength'],sensdict['t_s'])
    simparams['SUMRULE'] = sumrule
    minrg = -sumrule[0].min()
    maxrg = len(rng_gates)-sumrule[1].max()

    simparams['Rangegatesfinal'] = sp.array([ sp.mean(rng_gates[irng+sumrule[0,0]:irng+sumrule[1,0]+1]) for irng in range(minrg,maxrg)])
    if 'startfile' in simparams.keys() and simparams['Pulsetype'].lower()!='barker':
        relpath = simparams['startfile'][0] !=os.path.sep
        if relpath:
            fullfilepath = os.path.join(curpath,simparams['startfile'])
            simparams['startfile'] = fullfilepath
        stext = os.path.isfile(simparams['startfile'])
        if not stext:
            warnings.warn('The given start file does not exist',UserWarning)

    elif simparams['Pulsetype'].lower()!='barker':
        warnings.warn('No start file given',UserWarning)
    return(sensdict,simparams)
Example #3
0
def readconfigfile(fname):
    """This funciton will read in the pickle files that are used for configuration.
    Inputs
        fname - A string containing the file name and location.
    Outputs
        sensdict - A dictionary that holds the sensor parameters.
        simparams - A dictionary that holds the simulation parameters."""

    assert isinstance(fname, str), "fname is not a valid string  %r" % fname
    assert os.path.isfile(fname), "fname is not a valid file %r" % fname
    ftype = os.path.splitext(fname)[-1]
    curpath = os.path.split(fname)[0]
    if ftype == '.pickle':
        pickleFile = open(fname, 'rb')
        dictlist = pickle.load(pickleFile)
        pickleFile.close()
        angles = getangles(dictlist[0]['beamlist'], dictlist[0]['radarname'])
        beamlist = [float(i) for i in dictlist[0]['beamlist']]
        ang_data = sp.array([[iout[0], iout[1]] for iout in angles])
        sensdict = sensconst.getConst(dictlist[0]['radarname'], ang_data)

        simparams = dictlist[1]
    if ftype == '.ini':

        config = ConfigParser.ConfigParser()
        config.read(fname)
        beamlist = config.get('section 1', 'beamlist').split()
        beamlist = [float(i) for i in beamlist]
        angles = getangles(beamlist, config.get('section 1', 'radarname'))
        ang_data = sp.array([[iout[0], iout[1]] for iout in angles])
        sensdict = sensconst.getConst(config.get('section 1', 'radarname'),
                                      ang_data)

        simparams = {}
        for param in config.options('simparams'):
            rname = config.get('simparamsnames', param)
            simparams[rname] = config.get('simparams', param)

        for param in simparams:
            if simparams[param] == "<type 'numpy.complex128'>":
                simparams[param] = sp.complex128
            elif simparams[param] == "<type 'numpy.complex64'>":
                simparams[param] = sp.complex64
            elif param == 'outangles':
                outlist1 = simparams[param].split(',')
                simparams[param] = [[
                    float(j) for j in i.lstrip().rstrip().split(' ')
                ] for i in outlist1]
            else:
                simparams[param] = simparams[param].split(" ")
                if len(simparams[param]) == 1:
                    simparams[param] = simparams[param][0]
                    try:
                        simparams[param] = float(simparams[param])
                    except:
                        pass
                else:
                    for a in range(len(simparams[param])):
                        try:
                            simparams[param][a] = float(simparams[param][a])
                        except:
                            pass

    if 't_s' in simparams.keys():
        sensdict['t_s'] = simparams['t_s']
        sensdict['fs'] = 1.0 / simparams['t_s']
        sensdict[
            'BandWidth'] = sensdict['fs'] * 0.5  #used for the noise bandwidth

    for ikey in sensdict.keys():
        if ikey in simparams.keys():
            sensdict[ikey] = simparams[ikey]
#            del simparams[ikey]
    simparams['Beamlist'] = beamlist
    time_lim = simparams['TimeLim']
    (pulse, simparams['Pulselength']) = makepulse(simparams['Pulsetype'],
                                                  simparams['Pulselength'],
                                                  sensdict['t_s'])
    simparams['Pulse'] = pulse
    simparams['amb_dict'] = make_amb(sensdict['fs'],
                                     int(simparams['ambupsamp']),
                                     sensdict['t_s'] * len(pulse), pulse,
                                     simparams['numpoints'])
    simparams['angles'] = angles
    rng_lims = simparams['RangeLims']
    rng_gates = sp.arange(rng_lims[0], rng_lims[1],
                          sensdict['t_s'] * v_C_0 * 1e-3 / 2.)
    simparams['Timevec'] = sp.arange(0, time_lim, simparams['Fitinter'])
    simparams['Rangegates'] = rng_gates
    if not 'lagtype' in simparams.keys():
        simparams['lagtype'] = 'centered'
    sumrule = makesumrule(simparams['Pulsetype'], simparams['Pulselength'],
                          sensdict['t_s'], simparams['lagtype'])
    simparams['SUMRULE'] = sumrule
    minrg = -sumrule[0].min()
    maxrg = len(rng_gates) - sumrule[1].max()

    simparams['Rangegatesfinal'] = sp.array([
        sp.mean(rng_gates[irng + sumrule[0, 0]:irng + sumrule[1, 0] + 1])
        for irng in range(minrg, maxrg)
    ])

    if ('startfile' in simparams.keys() and len(simparams['startfile']) > 0
        ) and simparams['Pulsetype'].lower() != 'barker':
        relpath = simparams['startfile'][0] != os.path.sep
        if relpath:
            fullfilepath = os.path.join(curpath, simparams['startfile'])
            simparams['startfile'] = fullfilepath
        stext = os.path.isfile(simparams['startfile'])
        if not stext:
            warnings.warn('The given start file does not exist', UserWarning)

    elif simparams['Pulsetype'].lower() != 'barker':
        warnings.warn('No start file given', UserWarning)
    return (sensdict, simparams)
Example #4
0
def readconfigfile(fname):
    """This funciton will read in the pickle files that are used for configuration.
    Inputs
        fname - A string containing the file name and location.
    Outputs
        sensdict - A dictionary that holds the sensor parameters.
        simparams - A dictionary that holds the simulation parameters."""

    ftype = os.path.splitext(fname)[-1]
    curpath = os.path.split(fname)[0]
    if ftype=='.pickle':
        pickleFile = open(fname, 'rb')
        dictlist = pickle.load(pickleFile)
        pickleFile.close()
        angles = getangles(dictlist[0]['beamlist'],dictlist[0]['radarname'])
        beamlist = [float(i) for i in dictlist[0]['beamlist']]
        ang_data = sp.array([[iout[0],iout[1]] for iout in angles])
        sensdict = sensconst.getConst(dictlist[0]['radarname'],ang_data)

        simparams = dictlist[1]
    if ftype=='.ini':

        config = ConfigParser.ConfigParser()
        config.read(fname)
        beamlist = config.get('section 1','beamlist').split()
        beamlist = [float(i) for i in beamlist]
        angles = getangles(beamlist,config.get('section 1','radarname'))
        ang_data = sp.array([[iout[0],iout[1]] for iout in angles])
        sensdict = sensconst.getConst(config.get('section 1','radarname'),ang_data)

        simparams = {}
        for param in config.options('simparams'):
            rname  = config.get('simparamsnames',param)
            simparams[rname] = config.get('simparams',param)

        for param in simparams:
            if simparams[param]=="<type 'numpy.complex128'>":
                simparams[param]=sp.complex128
            elif simparams[param]=="<type 'numpy.complex64'>":
                simparams[param]=sp.complex64
            else:
                simparams[param]=simparams[param].split(" ")
                if len(simparams[param])==1:
                    simparams[param]=simparams[param][0]
                    try:
                        simparams[param]=float(simparams[param])
                    except:
                        pass
                else:
                    for a in range(len(simparams[param])):
                        try:
                            simparams[param][a]=float(simparams[param][a])
                        except:
                            pass

    if 't_s' in simparams.keys():
        sensdict['t_s'] = simparams['t_s']
        sensdict['fs'] =1.0/simparams['t_s']
        sensdict['BandWidth'] = sensdict['fs']*0.5 #used for the noise bandwidth
#    pdb.set_trace()
    simparams['Beamlist']=beamlist
    time_lim = simparams['TimeLim']
    (pulse,simparams['Pulselength'])  = makepulse(simparams['Pulsetype'],simparams['Pulselength'],sensdict['t_s'])
    simparams['Pulse'] = pulse
#    pdb.set_trace()
    simparams['amb_dict'] = make_amb(sensdict['fs'],int(simparams['ambupsamp']),
        sensdict['t_s']*len(pulse),len(pulse),simparams['numpoints'])
    simparams['angles']=angles
    rng_lims = simparams['RangeLims']
    rng_gates = sp.arange(rng_lims[0],rng_lims[1],sensdict['t_s']*v_C_0*1e-3)
    simparams['Timevec']=sp.arange(0,time_lim,simparams['Fitinter'])
    simparams['Rangegates']=rng_gates
    sumrule = makesumrule(simparams['Pulsetype'],simparams['Pulselength'],sensdict['t_s'])
    simparams['SUMRULE'] = sumrule
    minrg = -sumrule[0].min()
    maxrg = len(rng_gates)-sumrule[1].max()

    simparams['Rangegatesfinal'] = sp.array([ sp.mean(rng_gates[irng+sumrule[0,0]:irng+sumrule[1,0]+1]) for irng in range(minrg,maxrg)])
    if 'startfile' in simparams.keys() and simparams['Pulsetype'].lower()!='barker':
        relpath = simparams['startfile'][0] !=os.path.sep
        if relpath:
            fullfilepath = os.path.join(curpath,simparams['startfile'])
            simparams['startfile'] = fullfilepath
        stext = os.path.isfile(simparams['startfile'])
        if not stext:
            warnings.warn('The given start file does not exist',UserWarning)

    elif simparams['Pulsetype'].lower()!='barker':
        warnings.warn('No start file given',UserWarning)
    return(sensdict,simparams)