Ejemplo n.º 1
0
def zoomedscan(config, args):
    if 'scans' in config:
        for scanlevel in config['scans']:
            if scanlevel['scanfromstations']:
                stations = loadJSON(scanlevel['stationsfilename'])
                confirmed_station = []
                for station in stations['stations']:
                    if 'name' in station:
                        confirmed_station.append(station)
                for station in confirmed_station:
                    freq_left = commons.hz2Float(station['freq_center']) - commons.hz2Float(scanlevel['windows'] / 2)
                    executeRTLPower(args, config, scanlevel, freq_left)
Ejemplo n.º 2
0
def zoomedscan(config, args):
    if 'scans' in config:
        for scanlevel in config['scans']:
            if scanlevel['scanfromstations']:
                stations = loadJSON(scanlevel['stationsfilename'])
                confirmed_station = []
                for station in stations['stations']:
                    if 'name' in station:
                        confirmed_station.append(station)
                for station in confirmed_station:
                    freq_left = commons.hz2Float(
                        station['freq_center']) - commons.hz2Float(
                            scanlevel['windows'] / 2)
                    executeRTLPower(args, config, scanlevel, freq_left)
Ejemplo n.º 3
0
def generateSpectres(config, args):
    if 'scans' in config:
        for scanlevel in config['scans']:
            range = np.linspace(scanlevel['freq_start'],scanlevel['freq_end'], num=scanlevel['nbstep'], endpoint=False)
            for left_freq in range:
                executeSpectre(args, config, scanlevel, left_freq)

            # For scanlevel with stationsfilename
            if 'stationsfilename' in scanlevel:
                stations = loadJSON(scanlevel['stationsfilename'])
                confirmed_station = []
                for station in stations['stations']:
                    if 'name' in station:
                        confirmed_station.append(station)
                for station in confirmed_station:
                    freq_left = commons.hz2Float(station['freq_center']) - commons.hz2Float(scanlevel['windows'] / 2)
                    executeSpectre(args, config, scanlevel, freq_left)
Ejemplo n.º 4
0
def generateSpectres(config, args):
    if 'scans' in config:
        for scanlevel in config['scans']:
            range = np.linspace(scanlevel['freq_start'],
                                scanlevel['freq_end'],
                                num=scanlevel['nbstep'],
                                endpoint=False)
            for left_freq in range:
                executeSpectre(args, config, scanlevel, left_freq)

            # For scanlevel with stationsfilename
            if 'stationsfilename' in scanlevel:
                stations = loadJSON(scanlevel['stationsfilename'])
                confirmed_station = []
                for station in stations['stations']:
                    if 'name' in station:
                        confirmed_station.append(station)
                for station in confirmed_station:
                    freq_left = commons.hz2Float(
                        station['freq_center']) - commons.hz2Float(
                            scanlevel['windows'] / 2)
                    executeSpectre(args, config, scanlevel, freq_left)
Ejemplo n.º 5
0
def searchStation(scanlevel, stations, summaries, samples, limitmin, limitmax):

    #search_limit = sorted(limit_list)
    freqstep = summaries['freq']['step']
    stations['stations'] = sorted(
        stations['stations'],
        key=lambda x: commons.hz2Float(x['freq_center']) - commons.hz2Float(
            (x['bw'])))

    bwmin = commons.hz2Float(scanlevel['minscanbw'])
    bwmax = commons.hz2Float(scanlevel['maxscanbw'])

    limits = np.linspace(limitmin, limitmax, 5)
    for limit in limits:
        # Search peak upper than limit
        startup = -1
        foundlower = False
        for idx in np.arange(len(samples)):
            powerdb = samples[idx]
            isup = powerdb > limit

            # Search first lower limit signal
            if not foundlower:
                if not isup:
                    foundlower = True
                else:
                    continue

            # Find first upper
            if startup == -1:
                if isup:
                    startup = idx
                    maxidx = startup
                    maxdb = powerdb
            else:
                # If upper, check if db is upper
                if isup:
                    if powerdb > maxdb:
                        maxdb = powerdb
                        maxidx = idx
                # If lower, calc bandwidth and max db
                else:
                    endup = idx - 1

                    bw_nbstep = endup - startup
                    bw = bw_nbstep * freqstep
                    freqidx = startup + int(bw_nbstep / 2)
                    # TODO: compare with freqidx, set % error ?
                    freq_center = summaries['freq']['start'] + (maxidx *
                                                                freqstep)
                    freq_center = summaries['freq']['start'] + (freqidx *
                                                                freqstep)
                    freq_left = freq_center - bw

                    deltadb = (maxdb - limit)
                    if bwmin <= bw <= bwmax and deltadb > scanlevel[
                            'minrelativedb']:

                        print "Freq:%s / Bw:%s / Abs: %s dB / From ground:%.2f dB" % (
                            commons.float2Hz(freq_center),
                            commons.float2Hz(bw), maxdb, maxdb - limitmax)

                        found = False
                        for station in stations['stations']:
                            if freq_center >= commons.hz2Float(
                                    station['freq_center']
                            ) - bw and freq_center <= commons.hz2Float(
                                    station['freq_center']) + bw:
                                found = True
                                break

                        if not found:

                            stations['stations'].append({
                                'freq_center':
                                commons.float2Hz(freq_center),
                                'bw':
                                commons.float2Hz(bw),
                                'powerdb':
                                float("%.2f" % maxdb),
                                'relativedb':
                                float("%.2f" % (maxdb - limitmin))
                            })
                            stations['stations'] = sorted(
                                stations['stations'],
                                key=lambda x: commons.hz2Float(x[
                                    'freq_center']) - commons.hz2Float(x['bw']
                                                                       ))

                    startup = -1
Ejemplo n.º 6
0
def searchStation(scanlevel, stations, summaries, samples, limitmin, limitmax):

    #search_limit = sorted(limit_list)
    freqstep = summaries['freq']['step']
    stations['stations'] = sorted(stations['stations'], key=lambda x: commons.hz2Float(x['freq_center']) - commons.hz2Float((x['bw'])))

    bwmin = commons.hz2Float(scanlevel['minscanbw'])
    bwmax = commons.hz2Float(scanlevel['maxscanbw'])

    limits = np.linspace(limitmin, limitmax, 5)
    for limit in limits:
        # Search peak upper than limit
        startup = -1
        foundlower = False
        for idx in np.arange(len(samples)):
            powerdb = samples[idx]
            isup = powerdb > limit

            # Search first lower limit signal
            if not foundlower:
                if not isup:
                    foundlower = True
                else:
                    continue


            # Find first upper
            if startup == -1:
                if isup:
                    startup = idx
                    maxidx = startup
                    maxdb = powerdb
            else:
                # If upper, check if db is upper
                if isup:
                    if powerdb > maxdb:
                        maxdb = powerdb
                        maxidx = idx
                # If lower, calc bandwidth and max db
                else:
                    endup = idx - 1

                    bw_nbstep = endup - startup
                    bw = bw_nbstep * freqstep
                    freqidx = startup + int(bw_nbstep / 2)
                    # TODO: compare with freqidx, set % error ?
                    freq_center = summaries['freq']['start'] + (maxidx * freqstep)
                    freq_center = summaries['freq']['start'] + (freqidx * freqstep)
                    freq_left = freq_center - bw

                    deltadb = (maxdb - limit)
                    if bwmin <= bw <= bwmax and deltadb > scanlevel['minrelativedb']:

                        print "Freq:%s / Bw:%s / Abs: %s dB / From ground:%.2f dB" % (commons.float2Hz(freq_center), commons.float2Hz(bw), maxdb, maxdb - limitmax)

                        found = False
                        for station in stations['stations']:
                            if freq_center >= commons.hz2Float(station['freq_center']) - bw and freq_center <= commons.hz2Float(station['freq_center']) + bw:
                                found = True
                                break

                        if not found:

                            stations['stations'].append(
                                {'freq_center': commons.float2Hz(freq_center),
                                  'bw': commons.float2Hz(bw),
                                  'powerdb': float("%.2f" % maxdb),
                                  'relativedb': float("%.2f" % (maxdb - limitmin))
                                }
                            )
                            stations['stations'] = sorted(stations['stations'], key=lambda x: commons.hz2Float(x['freq_center']) - commons.hz2Float(x['bw']))


                    startup = -1