Exemplo n.º 1
0
def makeparamdicts(beamlist, radarname, simparams):
    curpath = Path(__file__[0]).parent

    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 = Path(simparams['startfile'][0]).expanduser()
        if not relpath.is_absolute():
            fullfilepath = curpath / simparams['startfile']
            simparams['startfile'] = fullfilepath
        stext = simparams['startfile'].is_file()

        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)
Exemplo n.º 2
0
def main(argv):

    kinput=1
    try:
      opts, args = getopt.getopt(argv,"hp:o:",["pulses=","ofile="])
    except getopt.GetoptError:
      print('radarsystools.py -p <number of pulses> -o <outputfile>')
      sys.exit(2)
    for opt, arg in opts:
      if opt == '-h':
         print('radarsystools.py -p <number of pulses> -o <outputfile>')
         sys.exit()
      elif opt in ("-p", "--pulses"):
         kinput = int(arg)
      elif opt in ("-o", "--ofile"):
          print("Still have to add output file feature. I'm working on it... may be...")

    print("Without angle")
    sensdict = sensconst.getConst('risr')
    sensdict['tau'] = 320e-6
    r_sys = RadarSys(sensdict,Kpulse = kinput)
    r_sys.printsnr(ne = np.array([1e11,2e11]),te=np.array([1e3,2e11]),ti=np.array([1e3,2e11]))
    r_sys.printrms(ne = np.array([1e11,2e11]),te=np.array([1e3,2e11]),ti=np.array([1e3,2e11]))
    r_sys.printfracrms(ne = np.array([1e11,2e11]),te=np.array([1e3,2e11]),ti=np.array([1e3,2e11]))
    print("\n\n")


    angles = [(90,85)]
    ang_data = np.array([[iout[0],iout[1]] for iout in angles])
    sensdict = sensconst.getConst('risr',ang_data)
    sensdict['tau'] = 320e-6

    print("With Angle")
    r_sys = RadarSys(sensdict,Kpulse = kinput)
    r_sys.printsnr(ne = np.array([1e11,2e11]),te=np.array([1e3,2e11]),ti=np.array([1e3,2e11]))
    r_sys.printrms(ne = np.array([1e11,2e11]),te=np.array([1e3,2e11]),ti=np.array([1e3,2e11]))
    r_sys.printfracrms(ne = np.array([1e11,2e11]),te=np.array([1e3,2e11]),ti=np.array([1e3,2e11]))
Exemplo n.º 3
0
def makeparamdicts(beamlist,radarname,simparams):
    curpath = Path(__file__[0]).parent

    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 = Path(simparams['startfile'][0]).expanduser()
        if not relpath.is_absolute():
            fullfilepath = curpath / simparams['startfile']
            simparams['startfile'] = fullfilepath
        stext = simparams['startfile'].is_file()

        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)
Exemplo n.º 4
0
def readconfigfile(fname):
    """
        This funciton will read in the pickle files that are used for configuration.

        Args:
            fname - A string containing the file name and location.

        Returns:
            sensdict - A dictionary that holds the sensor parameters.
            simparams - A dictionary that holds the simulation parameters.
    """

    fname = Path(fname).expanduser()
    if not fname.is_file():
        raise IOError('{} not found'.format(fname))

    ftype = fname.suffix
    curpath = fname.parent
    if ftype == '.pickle':
        with fname.open('r') as f:
            dictlist = pickle.load(f)

        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]
    elif ftype == '.yml':
        with fname.open('r') as f:
            dictlist = yaml.load(f)

        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()
        config.read(str(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 = Path(simparams['startfile'])
        if not relpath.is_absolute():
            # Some times the ini files may split the strings of the start file because of white space in file names.
            if type(simparams['startfile']) is list:
                startfile = " ".join(simparams['startfile'])
            else:
                startfile = simparams['startfile']

            fullfilepath = curpath.joinpath(startfile)
            simparams['startfile'] = str(fullfilepath)

        else:
            fullfilepath = simparams['startfile']
        stext = Path(fullfilepath).is_file()
        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)
Exemplo n.º 5
0
def readconfigfile(fname):
    """
        This funciton will read in the pickle files that are used for configuration.

        Args:
            fname - A string containing the file name and location.

        Returns:
            sensdict - A dictionary that holds the sensor parameters.
            simparams - A dictionary that holds the simulation parameters.
    """

    fname = Path(fname).expanduser()
    if not fname.is_file():
        raise IOError('{} not found'.format(fname))

    ftype = fname.suffix
    curpath = fname.parent

    if ftype=='.yml':
        with fname.open('r') as f:
            dictlist = yaml.load(f)

        angles = sensconst.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]
    elif ftype=='.ini':

        config = ConfigParser()
        config.read(str(fname))
        beamlist = config.get('section 1','beamlist').split()
        beamlist = [float(i) for i in beamlist]
        radarname = config.get('section 1','radarname').split()[0]
        angles = sensconst.getangles(beamlist, 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, _) = makepulse(simparams['Pulsetype'], simparams['Pulselength'], sensdict['t_s'])
    simparams['Pulse'] = pulse
    psamps = len(pulse)
    simparams['amb_dict'] = make_amb(sensdict['fs'], int(simparams['ambupsamp']),
                                     sensdict['t_s']*len(pulse), pulse, simparams['numpoints'])
    simparams['angles'] = angles

    simparams['Timevec'] = sp.arange(0, time_lim, simparams['Fitinter'])

    rng_samp = simparams['t_s']*v_C_0*1e-3/2.
    ipp_samps = sp.floor(simparams['IPP']*sensdict['fs'])
    ipp_rng = sp.arange(0, ipp_samps, dtype=float)*rng_samp
    rng_lims = simparams['RangeLims']

    # XXX Set up range gates differently
    min_rng = sp.where(ipp_rng >= rng_lims[0])[0][0]
    max_rng = sp.where(ipp_rng <= rng_lims[1])[0][-1]
    rng_all = sp.arange(min_rng-(psamps-1), max_rng+(psamps-1), dtype=float)*rng_samp
    rng_all[rng_all <= 0] = rng_samp


    simparams['Rangegates'] = rng_all
    simparams['Rangegatesfinal'] = sp.arange(min_rng,max_rng,dtype=float)*rng_samp
    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()-1
    # n_pulse = len(pulse)
    # arback = -sp.floor(sp.arange(0, n_pulse/2.0, 0.5)).astype(int)
    # arfor = sp.ceil(sp.arange(0, n_pulse/2.0, 0.5)).astype(int)
    # rnglist = [sp.mean(rng_gates[irng+arback]**2+ rng_gates[irng+arfor]**2)
    #            for irng in range(minrg, maxrg)]



    if ('startfile' in simparams.keys() and len(simparams['startfile']) > 0 ) and simparams['Pulsetype'].lower() !=' barker':
        relpath = Path(simparams['startfile'])
        if not relpath.is_absolute():
            # Some times the ini files may split the strings of the start file
            # because of white space in file names.
            if type(simparams['startfile']) is list:
                startfile = " ".join(simparams['startfile'])
            else:
                startfile = simparams['startfile']

            fullfilepath = curpath.joinpath(startfile)
            simparams['startfile'] = str(fullfilepath)

        else:
            fullfilepath = simparams['startfile']
        stext = Path(fullfilepath).is_file()
        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)
Exemplo n.º 6
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."""

    fname = Path(fname).expanduser()
    if not fname.is_file():
        raise IOError('{0} not found'.format(str(fname)))
    
    ftype = fname.suffix
    curpath = fname.parent
    if ftype=='.pickle':
        pickleFile = file(str(fname),'r')
        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]
    elif ftype=='.yml':
        yamlFile = file(str(fname),'r')
        dictlist = yaml.load(yamlFile)
        yamlFile.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()
        config.read(str(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 = Path(simparams['startfile'])
        if not relpath.is_absolute():
            fullfilepath = curpath.joinpath(simparams['startfile'])
            simparams['startfile'] = str(fullfilepath)
            
        else:
            fullfilepath=simparams['startfile']
        stext = Path(fullfilepath).is_file()
        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)