plt.ylabel('Ampl [dBm]')
        plt.xlabel('freq [MHz]')
        plt.grid()
        title = 'Average_' + time_freq
        plt.title(title)

        plt.savefig(outdir + title, dpi=600)  #, bbox_inches='tight')

    if selection == '5':  #Percentiles00
        perc = input('Percentile = ')

        print('Calculating %s percentile' % (perc))

        title = 'MRO data ' + time_freq
        perc = int(perc)
        RFI.plot_percentile(freqs, D, perc, outdir, 'dBm', title)

    if selection == '6':  #Occupancy
        print('Calculating occupancy...')
        title = 'Occupancy_' + time_freq
        Normalized, S_occupancy = RFI.spectral_occupancy(
            freqs, D, outdir, title, 2)
        #        threshold = int(input('Calculate BW loss greater than (percent of the time):  '))
        threshold = (1, 2, 5, 10, 30, 50, 80, 90, 100)
        for j in threshold:
            BW_loss = np.sum(((S_occupancy > j))) / len(S_occupancy) * 100
            print('%0.3f%% of the BW is lost %d%% of the time' % (BW_loss, j))

#    os.system('clear')
    selection = input(
        '\n\nSelect action:\n1: change frequency range\n2: Histogram\n3: Integrated Power\n4: Average\n5: Percentiles\n6: Occupancy\n0: exit\n\nSelect: '
plt.plot(z, 'r--', z2, 'r', y, 'k')
plt.legend(('noisy signal', 'lfilter, once', 'lfilter, twice', 'filtfilt'),
           loc='best')

[freq, P_orig] = RFI.fft_calc(td_data[ind, :], 800e6, 1, 0)
[freq, P_filt] = RFI.fft_calc(y, 800e6, 1, 0)

plt.figure()
plt.plot(freq, 10 * np.log10(P_orig), 'r', freq, 10 * np.log10(P_filt), 'b')

#%% maximum values

f = SKALA4_freq
data = SKALA4_pow
title = 'Max values - Phase0 - SKALA4.0 - 20190331'
RFI.plot_percentile(f, data, 100, directory, title='Maximum values - ' + title)

#(freq,data,percentile,outdir,dataunits='dBm',title=''):
#%% percentiles
perc = 100
f = SKALA4_freq
data = SKALA4_pow
title = 'Phase0 - SKALA4.0 - 20190331'
RFI.plot_percentile(f, data, perc, title)

#%% Spectrogram
Fstart = 0
Fstop = 400
time = SKALA4_time
f = SKALA4_freq
data = SKALA4_pow
Beispiel #3
0
        plt.ylabel('Ampl [dB]')
        plt.xlabel('freq [MHz]')
        plt.grid()
        title = 'Average_' + time_freq
        plt.title(title)

        plt.savefig(outdir + title, bbox_inches='tight')

    if selection == '5':  #Percentiles00
        perc = input('Percentile = ')

        print('Calculating %s percentile' % (perc))

        title = 'Phase0 data ' + time_freq
        perc = float(perc)
        RFI.plot_percentile(freqs, 10 * np.log10(D), perc, '', 'dBm', title)

    if selection == '6':  #Occupancy
        print('Calculating occupancy...')
        title = 'Occupancy_' + time_freq
        #        Normalized, S_occupancy =  RFI.spectral_occupancy(freqs,D,outdir,title,3)
        S_occupancy = occupancy(freqs, maskFreq, D, 1.3, plot_figs=1)

        #        threshold = int(input('Calculate BW loss greater than (percent of the time):  '))
        threshold = [2, 25, 50, 75, 90, 98, 99.9]
        print('Freq range %d MHz to %d MHz' % (freqs[0], freqs[-1]))
        for j in threshold:
            BW_loss = np.sum(((S_occupancy >= j))) / len(S_occupancy) * 100
            print('%0.3f%% of the BW is lost %.2f%% of the time' %
                  (BW_loss, j))
    np.savez_compressed(root_dir + 'SKALA2_Pos1_Input1',
                        Pos1_Input1=Pos1_Input1)
    np.savez_compressed(root_dir + 'SKALA2_Pos1_Input2',
                        Pos1_Input2=Pos1_Input2)
else:
    Pos1_Input1 = np.load(root_dir + 'SKALA2_Pos1_Input1.npz')['Pos1_Input1']
    Pos1_Input2 = np.load(root_dir + 'SKALA2_Pos1_Input2.npz')['Pos1_Input2']

SKALA2_2013_P1_I1 = 10**(np.transpose(Pos1_Input1) / 10)
SKALA2_2013_P1_I2 = 10**(np.transpose(Pos1_Input2) / 10)

#%% maximum values

RFI.plot_percentile(
    freq3,
    SKALA2_2013_P1_I1,
    100,
    title='Maximum values - SKALA2 measurements in 2013 - Pos1 Input1')
RFI.plot_percentile(
    freq3,
    SKALA2_2013_P1_I2,
    100,
    title='Maximum values - SKALA2 measurements in 2013 - Pos1 Input2')

#%% percentiles
RFI.plot_percentile(freq3,
                    SKALA2_2013_P1_I1,
                    98,
                    title=str(perc) +
                    ' percentile - SKALA2 in 2013 - Pos1 Input1')
RFI.plot_percentile(freq3,