Beispiel #1
0
def make_SS_filters(con,
                    nfilt,
                    nang,
                    npha,
                    freq,
                    scale,
                    tot,
                    fdist,
                    get_grat=False):

    sizes = range(0, int(1 * (fdist + freq)), 1)
    #    sizes = [10,20]

    grats = np.array(
        [test.GRATC(1, 0, freq, s, tot + 2 * fdist + 1) for s in sizes])

    if get_grat:
        return grats

    filt = np.array([
        proc.get_phased_filter_coefficients(g, nang, npha, freq, scale, tot)
        for g in grats
    ])

    filt = np.array([
        proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt,
                         fdist) for I in filt
    ])

    return np.array([c * filt for c in con
                     ])  #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #2
0
def make_COS_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,nda,R,GRID = True):

    if GRID:
        grats = np.array([[[test.GRATS(c1,0,freq,fdist/2,tot + 2*fdist + 1),
                            test.GRATS(c2,da,freq,fdist/2,tot + 2*fdist + 1),
                            (
                            test.GRATS(c1,0,freq,fdist/2,tot + 2*fdist + 1)
                            + 
                            test.GRATS(c2,da,freq,fdist/2,tot + 2*fdist + 1)
                            )
                            ] for c1 in con for c2 in con] for da in [i * math.pi/(2 * (nda - 1)) for i in range(0,nda)]])

    else:
        grats = np.array([[[test.GRATS(c1,0,freq,fdist/2,tot + 2*fdist + 1),
                            test.GRATS(c1,da,freq,fdist/2,tot + 2*fdist + 1),
                            (
                            test.GRATS(c1,0,freq,fdist/2,tot + 2*fdist + 1)
                            + 
                            test.GRATS(c1,da,freq,fdist/2,tot + 2*fdist + 1)
                            )
                            ] for c1 in con] for da in [i * math.pi/(2 * (nda - 1)) for i in range(0,nda)]])

    filt = np.array([[[proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in C] for C in A] for A in grats])

    filt = np.array([[[proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in C] for C in A] for A in filt])
    
    return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #3
0
def make_WTA_filters(con,
                     nfilt,
                     nang,
                     npha,
                     freq,
                     scale,
                     tot,
                     fdist,
                     R,
                     npts=32):

    grats = np.array([[[
        test.GRATC(0, a, freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1) +
        test.GRATC(c, a + (np.pi / 2), freq, tot + 2 * fdist + 1,
                   tot + 2 * fdist + 1),
        test.GRATC(1, a, freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1) +
        test.GRATC(c, a +
                   (np.pi / 2), freq, tot + 2 * fdist + 1, tot + 2 * fdist + 1)
    ] for a in [i * math.pi / npts for i in range(npts)]] for c in con])

    filt = np.array([[[
        proc.get_phased_filter_coefficients(x, nang, npha, freq, scale, tot, R)
        for x in g
    ] for g in C] for C in grats])

    filt = np.array([[[
        proc.sample_coef(x, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt,
                         fdist) for x in I
    ] for I in C] for C in filt])

    return filt  #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #4
0
def make_TI_filters(con,
                    nfilt,
                    nang,
                    npha,
                    freq,
                    scale,
                    tot,
                    fdist,
                    R,
                    npts=20):

    grats = np.array([[
        test.GRATC(c, 0, freq, fdist / 2, tot + 2 * fdist + 1, surr=0) +
        test.s_GRATC(c, a, freq, fdist / 2, tot + 2 * fdist + 1, surr=0)
        for a in [i * math.pi / npts for i in range(npts)]
    ] for c in con])

    filt = np.array([[
        proc.get_phased_filter_coefficients(g, nang, npha, freq, scale, tot, R)
        for g in C
    ] for C in grats])

    filt = np.array([[
        proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt,
                         fdist) for I in C
    ] for C in filt])

    return filt  #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #5
0
def make_att_COS_filters(con, p2, nfilt, nang, npha, freq, scale, tot, fdist):

    if p2 == 0:
        grats = np.array([
            test.GRATC(c, 0, freq, fdist / 2, tot + 2 * fdist + 1) +
            test.GRATC(c, np.pi / 2, freq, 2 *
                       (tot + 2 * fdist + 1), tot + 2 * fdist + 1) for c in con
        ])
    elif p2 == 1:
        grats = np.array([
            test.GRATC(c, 0, freq, fdist / 2, tot + 2 * fdist + 1) for c in con
        ])
    else:
        grats = np.array([
            test.GRATC(c, np.pi / 2, freq, fdist / 2, tot + 2 * fdist + 1)
            for c in con
        ])

    filt = np.array([
        proc.get_phased_filter_coefficients(g, nang, npha, freq, scale, tot)
        for g in grats
    ])

    filt = np.array([
        proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], nfilt,
                         fdist) for I in filt
    ])

    return filt  #(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #6
0
def make_full_field_COS_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,nda,R):
    
    grats = np.array([test.GRATC(c1,0,freq,2*(tot + 2*fdist + 1),tot + 2*fdist + 1) + test.GRATC(c2,d,freq,2*(tot + 2*fdist + 1),tot + 2*fdist + 1) for k in range(nda) for c1 in con for c2 in con for d in [k*np.pi/(2*(nda - 1))]])

    filt = np.array([proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in grats])

    filt = np.array([proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in filt])
    
    return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #7
0
def make_full_field_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,R):
    
    grats = np.array([test.GRATC(c,0,freq,2*(tot + 2*fdist + 1),tot + 2*fdist + 1) for c in con])

    filt = np.array([proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in grats])

    filt = np.array([proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in filt])
    
    return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #8
0
def make_OTUNE_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,R):

    grats = np.array([[test.GRATC(c,a,freq,freq,tot + 2*fdist + 1) for a in np.linspace(0,2*np.pi,32)] for c in [.05,.1,.25,.5]])

    filt = np.array([[proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in C] for C in grats])

    filt = np.array([[proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in C] for C in filt])
    
    return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #9
0
def make_BSS_filters(con,nfilt,nang,npha,freq,scale,tot,fdist,nda):
   
    grats = np.array([[[
        test.GRATC(c,0.,freq,fdist,tot + 2*fdist + 1),
        test.GRATC(c,0.,freq,fdist,tot + 2*fdist + 1,surr = 0)
        +
        test.s_GRATC(1,da,freq,fdist,tot+2*fdist + 1,surr = 0.)
    ] for c in con] for da in [i * math.pi/(2 * ((nda - 1) if nda > 1 else 1)) for i in range(nda)]])

    filt = np.array([[[proc.get_phased_filter_coefficients(g,nang,npha,freq,scale,tot,R) for g in C] for C in A] for A in grats])

    filt = np.array([[[proc.sample_coef(I,[[(len(I) - 1)/2,(len(I[0]) - 1)/2]],nfilt,fdist) for I in C] for C in A] for A in filt])
    
    return filt#(filt-np.array([[[dif]]]))/np.array([[[fac]]])
Beispiel #10
0
def main(f_scale, con, lam, phase, size, angle, n_filter, f_dist, file_name):

    MGSM = False
    if f_dist > 0:
        MGSM = True
        if n_filter != 4:
            print(
                "MGSM is only implemented for n_filter = 4. Setting n_filter = 4."
            )

        n_filter = 4

    if file_name == "":
        file_name = "{}_{}_{}_{}_{}_{}_{}".format(f_scale, con, lam, phase,
                                                  size, angle, n_filter,
                                                  f_dist)

    print("Saving file to file name: {}".format(file_name))

    npha = 2
    f_freq = f_scale / (2 * np.pi)
    tot = int(3 * f_scale)

    if phase == 0:
        gfunc = test.GRATC
    else:
        gfunc = test.GRATS

    grat = gfunc(con, angle, lam, size, int(tot + 2 * f_dist + 1))
    I = proc.get_phased_filter_coefficients(grat, n_filter, npha, f_freq,
                                            f_scale, tot)
    filt = proc.sample_coef(I, [[(len(I) - 1) / 2, (len(I[0]) - 1) / 2]], 8,
                            f_dist)

    filt = np.reshape(filt[0], [-1, n_filter * 2])

    if MGSM:
        out = filt
    else:
        out = filt[0]

    np.savetxt(file_name + ".csv", out)

    print("Done")