Пример #1
0
def cwproc(fn, fsaudio, tlim, fc, ax=None):
    fn = Path(p.fn).expanduser()

    fs = int(p.fs)  # to allow 100e3 on command line
    fsaudio = int(fsaudio)

    dat, t = loadbin(fn, fs, tlim)
    dat = freq_translate(dat, fc, fs)
    dat = downsample(dat, fs, fsaudio)
    # %% play sound
    if 0:  # not for when looping, it will try to play dozens of files at once.
        playaudio(dat, fsaudio, p.outwav)
    #%% plots
    if 0 and dat.size < 500e3:  # plots will crash if too many points
        if ax is None:
            ax = figure().gca()
        ax.plot(t + tlim[0], dat.real[:])
        ax.set_title(f"{fn.name} Fs: {fs} Hz  t={tlim[0]}..{tlim[1]}")
        ax.set_xlabel("time [sec]")
        ax.set_ylabel("amplitude")

    f, tt, Sxx, Sp = spec(dat,
                          fsaudio,
                          p.flim,
                          tlim,
                          be,
                          vlim=p.vlim,
                          zpad=p.zeropad)
    # %% analysis
    Abin = np.empty(be.size - 1)
    for i in range(len(be) - 1):
        ibin = (f < be[i + 1]) & (f > be[i])
        Abin[i] = Sp[ibin].sum()

    return Abin
Пример #2
0
def cwproc(fn, fsaudio, tlim, fc, ax=None):
    fn=Path(p.fn).expanduser()

    fs = int(p.fs) # to allow 100e3 on command line
    fsaudio = int(fsaudio)

    dat,t = loadbin(fn, fs, tlim)
    dat = freq_translate(dat,fc,fs)
    dat = downsample(dat,fs,fsaudio)
# %% play sound
    if 0:  # not for when looping, it will try to play dozens of files at once.
        playaudio(dat, fsaudio, p.outwav)
#%% plots
    if 0 and dat.size < 500e3: # plots will crash if too many points
        if ax is None:
            ax = figure().gca()
        ax.plot(t + tlim[0], dat.real[:])
        ax.set_title(f'{fn.name} Fs: {fs} Hz  t={tlim[0]}..{tlim[1]}')
        ax.set_xlabel('time [sec]')
        ax.set_ylabel('amplitude')

    f,tt,Sxx,Sp = spec(dat, fsaudio, p.flim, tlim, be, vlim=p.vlim, zpad=p.zeropad)
# %% analysis
    Abin = np.empty(be.size-1)
    for i in range(len(be)-1):
        ibin = (f < be[i+1]) & (f > be[i])
        Abin[i] = Sp[ibin].sum()

    return Abin
Пример #3
0
                   type=float,
                   default=0.0)
    p = p.parse_args()

    P = {
        "rxfn": p.fn,
        "rxfs": p.rxfs,
        "txfn": p.txfn,
        "txfs": p.txfs,
        "demod": p.demod,
        "pri": p.pri,
        "Npulse": p.Npulse,
        "again": p.amplitude,
        "fc": p.fc,
        "tlim": p.tlim,
    }

    # %% load data
    rx = getrx(P)
    # %% demodulation (optional)
    aud, fs = dodemod(rx, P)
    # %% RF plots
    spec(rx, fs, zpad=p.zeropad, ttxt="raw ")
    # %% baseband plots
    plotraw(aud, None, fsaudio)
    spec(aud, fsaudio)
    # %% final output
    playaudio(aud, fsaudio, p.wavfn)

    show()
Пример #4
0
                   type=float,
                   default=0.)
    p = p.parse_args()

    P = {
        'rxfn': p.fn,
        'rxfs': p.rxfs,
        'txfn': p.txfn,
        'txfs': p.txfs,
        'demod': p.demod,
        'pri': p.pri,
        'Npulse': p.Npulse,
        'again': p.amplitude,
        'fc': p.fc,
        'tlim': p.tlim
    }

    # %% load data
    rx = getrx(P)
    # %% demodulation (optional)
    aud, fs = dodemod(rx, P)
    # %% RF plots
    spec(rx, fs, zpad=p.zeropad, ttxt='raw ')
    # %% baseband plots
    plotraw(aud, None, fsaudio)
    spec(aud, fsaudio)
    # %% final output
    playaudio(aud, fsaudio, p.wavfn)

    show()
Пример #5
0
    p.add_argument('-v', '--verbose', action='store_true')
    p = p.parse_args()

    quiet = p.quiet

    tx = waveform_to_file(station_id,
                          p.codelen,
                          filt=p.filter,
                          outpath=p.outpath,
                          verbose=p.verbose)

    if p.freqmhz:  # on-air transmission
        from piradar.raspi import transmit_raspi
        transmit_raspi(tx, p.fs, p.freqmhz)
    else:  # simulation only
        #%% transmit spectrum
        if not quiet:
            spec(tx, p.fs)
#%% simulate noisy, reflected signal
        rx = sim_iono(tx, p.fs, dist_m, p.codelen, Nstd, Ajam, station_id,
                      p.filter, p.outpath, p.verbose)
        #%% receive cross-correlate
        distest_m = estimate_range(tx, rx, p.fs, quiet)
        print('estimated one-way distance  {:.1f} km'.format(distest_m / 1e3))
        #%% plot
        Nraw = 100  # arbitrary, just for plotting
        if not quiet:
            raw(tx, rx, p.fs, Nraw)

        show()