示例#1
0
def get_cov_time(proj_str, subfolder, num_snapshots, num_synth_els):
    source_freq = get_proj_tones(proj_str)[0]
    fc = ms.get_fc(source_freq, 0)
    t, x = load_x(fc, proj_str, subfolder)
    t, x, rt, rr, vvv, r_interp = deal_with_t_x_r(t, x, source_freq)
    stride = num_snapshots
    r_center, cov_t, K_samps = get_r_super_cov_seq(t, x, num_snapshots,
                                                   r_interp, num_synth_els,
                                                   stride)
    return cov_t
示例#2
0
def run_vel_mfp(proj_str, subfolder, num_snapshots, num_synth_els):
    incoh = False
    wnc = False
    freqs = get_proj_tones(proj_str)
    num_snap_list = [num_snapshots]
    num_freq_list = [13]
    num_synth_el_list = [num_synth_els]
    tilt_angles = np.array([-1])
    dr_runs = DRPRuns(proj_str, subfolder, num_snap_list, num_freq_list,
                      num_synth_el_list, vv, tilt_angles, incoh, wnc)
    dr_runs.run_all()
    dr_runs.save('vel_est_' + str(num_snapshots))
示例#3
0
def get_stacked_bart(proj_str,
                     subfolder,
                     num_synth_els,
                     v,
                     num_snapshots,
                     cov_index,
                     incoh=False,
                     num_freqs=None):
    if type(num_freqs) == type(None):
        tones = get_proj_tones(proj_str)
    else:
        tones = get_proj_tones(proj_str)[:num_freqs]
    for source_freq in tones:
        r, z, r_center, zs, out_db, cov_t = get_single_freq_bart(
            proj_str, subfolder, source_freq, num_synth_els, v, num_snapshots,
            cov_index, incoh)
        out_db += np.max(out_db)
        if source_freq == tones[0]:
            out = out_db
        else:
            out += out_db
    out /= len(tones)
    return r, z, r_center, zs, out, cov_t
示例#4
0
def synth_stacked_bart(drp, **kwargs):
    """
    Run a bartlett proc on the dta from proj_str with num_synth_els synthetic elements
    drp - DataRunParams obj holds errythagn
    """
    wnc = drp.wnc
    freqs = get_proj_tones(drp.proj_str)
    freqs = freqs[:drp.num_freqs]
    if wnc == False:
        r_center, cov_t, r, z, outputs, max_vals = get_outputs(drp)
        return r_center, cov_t, r, z, outputs, max_vals
    if wnc == True:
        r_center, cov_t, r, z, outputs, max_vals, wnc_outs, wnc_max_vals = get_outputs(
            drp, wnc=wnc, **kwargs)
        return r_center, cov_t, r, z, outputs, max_vals, wnc_outs, wnc_max_vals
示例#5
0
def run_tilt_mfp():
    incoh = False
    wnc = False
    proj_str = 's5_deep'
    freqs = get_proj_tones(proj_str)
    subfolder = '2048'
    vv = np.linspace(-1.8, -2.5, 12)
    vv = np.array([round(x, 4) for x in vv])
    num_snap_list = [4]
    num_freq_list = [13]
    num_synth_el_list = [1]
    tilt_angles = np.linspace(0, -2, 21)
    tilt_angles = np.array([round(x, 4) for x in tilt_angles])
    dr_runs = DRPRuns(proj_str, subfolder, num_snap_list, num_freq_list, num_synth_el_list, vv, tilt_angles, incoh, wnc)
    dr_runs.run_all()
    dr_runs.save('tilt_est')
示例#6
0
3/18/2021

Author: Hunter Akins

Institution: Scripps Institution of Oceanography, UC San Diego
"""

base_Nfft = 2048
base_num_snapshots = 36
vv = ms.get_vv()

fig_name = 'snr.png'

proj_str = 's5_deep'

tones = get_proj_tones(proj_str)

fig, ax = plt.subplots(1, 1)
fig.set_size_inches(3.5, 1.75)
plt.grid(linestyle='--', color='k')

freq_count = 0
freqs = [tones[0], tones[4], tones[8], tones[12]]
freqs = freqs[::-1]
num_freqs = len(freqs)
ax_list = []
for freq_count, source_freq in enumerate(freqs):

    cmap = plt.get_cmap('hsv')
    col = cmap(1 * freq_count / (num_freqs))
示例#7
0
Description:

Date: 

Author: Hunter Akins

Institution: UC San Diego, Scripps Institution of Oceanography

'''

proj_str = 's5_quiet_tones'
num_snaps = 2
subfolder = '4096'
rcvr_stride = 4
num_freqs = 10
freqs = get_proj_tones(proj_str)[:num_freqs]
num_synth_els = 1
zs = get_proj_zs(proj_str)
max_val_list = []
#vv = np.linspace(-2.6, -1.8, 15)
vv = [-2.5]
#num_synth_els = 1
output_list = []
max_val_list = []
for v in vv:
    v = round(v, 4)
    drp = DataRunParams(proj_str, num_snaps, v, subfolder, rcvr_stride,
                        num_freqs, num_synth_els)
    r_center, cov_t, r, z, outputs, max_vals = load_results(drp)
    max_val_list.append(max_vals)
    output_list.append(outputs)
示例#8
0
def get_outputs(drp, wnc=False, **kwargs):
    """
    For data run params drp, calculate the 
    stacked ambiguity surface (incoherently sum log 
    outputs over freq), and return the max vals of the amb 
    surf for each freq and time
    By default computes a simple bartlett
    If wnc == True, then also computes wnc
    and wn_gain is a dict key
    """
    freqs = get_proj_tones(drp.proj_str)[:drp.num_freqs]
    zs, zr = get_proj_zs(drp.proj_str), get_proj_zr(drp.proj_str)

    if wnc == True:
        wn_gain = kwargs['wn_gain']

    for freq_ind, source_freq in enumerate(freqs):
        #print('Now processing freq', source_freq)
        fc = ms.get_fc(source_freq, drp.v)
        t, x = load_x(fc, drp.proj_str, drp.subfolder)
        num_rcvrs = x.shape[0]
        if freq_ind == 0:
            rcvr_stride = int(zr.size // num_rcvrs)
            zr = zr[::rcvr_stride]

        t, x, rt, rr, vv, r_interp = deal_with_t_x_r(t, x, source_freq)

        env = get_env(drp.proj_str, source_freq)
        env = populate_env(env, source_freq, zs, zr, rr, fname=drp.proj_str)
        kbar = np.mean(env.modes.k.real)
        delta_k = np.max(env.modes.k.real) - np.min(env.modes.k.real)
        #print('delta_k', delta_k)
        #print('range cell', 2 * np.pi / delta_k)
        time_in_cell = 2 * np.pi / delta_k / 2.5
        #print('time in cell', 2*np.pi / delta_k  / 2.5)

        delta_t = t[1] - t[0]
        #print('good num snaps',  time_in_cell/ delta_t)
        delta_t, stride, T = get_synth_arr_params(source_freq, t,
                                                  drp.num_snapshots)
        #print('stride, T', stride, T)

        r_center, cov_t, K_samps = get_r_super_cov_seq(t,
                                                       x,
                                                       drp.num_snapshots,
                                                       r_interp,
                                                       drp.num_synth_els,
                                                       stride,
                                                       incoh=drp.incoh)

        #print(' num k samps', cov_t.size)
        t_before = time.time()
        r, z, synth_reps = get_mult_el_reps(env,
                                            drp.num_synth_els,
                                            drp.v,
                                            T,
                                            fname=drp.proj_str,
                                            adiabatic=False,
                                            tilt_angle=drp.tilt_angle)
        #print('Time to compute replcias =' , time.time() - t_before)
        if source_freq == freqs[0]:
            bart_outs = np.zeros((len(r_center), z.size, r.size))
            max_vals = np.zeros((len(freqs), len(r_center)))
            if wnc == True:
                wnc_outs = np.zeros((len(r_center), z.size, r.size))
                wnc_max_vals = np.zeros((len(freqs), len(r_center)))
            """ Annoying thing where I need to truncate based on
            first freq 
            """
            num_times = cov_t.size
        """ Compute bartlett """
        t_before = time.time()
        for i in range(num_times):
            K_samp = K_samps[i, ...]
            #plt.figure()
            #plt.imshow((K_samp).imag)
            output, max_val = get_amb_surf(r,
                                           z,
                                           K_samp,
                                           synth_reps,
                                           matmul=True)  # output is in db
            ind = np.argmax(output)
            best_rep = synth_reps[:, ind // r.size, ind % r.size]
            best_rep = best_rep.reshape(best_rep.size, 1)
            #plt.figure()
            #plt.imshow((best_rep.conj()@(best_rep.T)).imag)
            #print('max_val', max_val)
            #print(best_rep.T.conj()@K_samp@best_rep)
            #plt.show()
            """ Remove normalization """
            output += 10 * np.log10(max_val)
            """ Add to bartlett mat """
            bart_outs[i, :, :] += output
            max_vals[freq_ind, i] = max_val
        #print('Time to compute bartlett =' , time.time() - t_before)
        """ Comput wnc if it's a thing  """
        t_before = time.time()
        if wnc == True:
            wnc_out_freq = lookup_run_wnc(K_samps[:num_times, :, :],
                                          synth_reps, wn_gain)
            tmp = wnc_out_freq.reshape(
                num_times, wnc_out_freq.shape[1] * wnc_out_freq.shape[2])
            """ don't normalize """
            #wnc_max_val_freq = np.max(tmp, axis=1)
            #wnc_max_vals[freq_ind, :] = wnc_max_val_freq
            #for i in range(num_times):
            #    wnc_out_freq[i,:,:] /= wnc_max_val_freq[i]
            wnc_out_freq = 10 * np.log10(wnc_out_freq)
            wnc_outs += wnc_out_freq
        #print('Time to compute wnc =' , time.time() - t_before)

    r_center = r_center[:num_times]
    cov_t = cov_t[:num_times]  # make sure we truncate based on first freq
    if wnc == True:
        #wnc_outs /= len(freqs)
        return r_center, cov_t, r, z, bart_outs, max_vals, wnc_outs, wnc_max_vals
    else:
        return r_center, cov_t, r, z, bart_outs, max_vals
示例#9
0
    print(drp_obj.vv)
    return drp_obj


def drp_plots(proj_str, subfolder, drp_name):
    dr_runs = get_drp_runs(proj_str, subfolder, drp_name)
    print('incoh', dr_runs.incoh)
    print('num snaps', dr_runs.num_snap_list)
    #dr_runs.make_amb_mov()
    dr_runs.get_best_range_guesses()
    #dr_runs.show_param_corrs()
    dr_runs.show_vel_best_guess()


if __name__ == '__main__':
    #proj_str = 's5_deep'
    #proj_str = 's5_quiet2'
    for proj_str in ['s5_deep', 's5_quiet1']:  #, 's5_quiet3', 's5_quiet4']:

        #proj_str = 's5_quiet1'
        print(get_proj_tones(proj_str))
        #proj_str = 's5_quiet1'
        #proj_str = 's5_quiet4'

        subfolder = '2048'
        drp_plots(proj_str, subfolder, '4_snaps')
        #drp_plots(proj_str, subfolder, 'beefier_test')
        plt.show()

    #drp_plots(proj_str, subfolder, 'beefier_test')