예제 #1
0
파일: order_flat.py 프로젝트: carleen/plp
def get_order_flat1d(s, i1=None, i2=None):

    if i1 is None:
        i1 = 0
    if i2 is None:
        i2 = len(s)

    x = np.arange(len(s))

    if 0:

        from astropy.modeling import models, fitting
        p_init = models.Chebyshev1D(degree=6, window=[0, 2047])
        fit_p = fitting.LinearLSQFitter()
        p = fit_p(p_init, x[i1:i2][mmm[i1:i2]], s[i1:i2][mmm[i1:i2]])

    if 1:
        # t= np.linspace(x[i1]+10, x[i2-1]-10, 10)
        # p = LSQUnivariateSpline(x[i1:i2],
        #                         s[i1:i2],
        #                         t, bbox=[0, 2047])

        # t= np.concatenate([[x[1],x[i1-5],x[i1],x[i1+5]],
        #                    np.linspace(x[i1]+10, x[i2-1]-10, 10),
        #                    [x[i2-5], x[i2], x[i2+5],x[-2]]])

        t_list = []
        if i1 > 10:
            t_list.append([x[1],x[i1]])
        else:
            t_list.append([x[1]])
        t_list.append(np.linspace(x[i1]+10, x[i2-1]-10, 10))
        if i2 < len(s) - 10:
            t_list.append([x[i2], x[-2]])
        else:
            t_list.append([x[-2]])

        t= np.concatenate(t_list)

        # s0 = ni.median_filter(s, 40)
        from scipy.interpolate import LSQUnivariateSpline
        p = LSQUnivariateSpline(x,
                                s,
                                t, bbox=[0, len(s)-1])

    return p
예제 #2
0
def get_order_flat1d(s, i1=None, i2=None):

    if i1 is None:
        i1 = 0
    if i2 is None:
        i2 = len(s)

    x = np.arange(len(s))

    if 0:

        from astropy.modeling import models, fitting
        p_init = models.Chebyshev1D(degree=6, window=[0, 2047])
        fit_p = fitting.LinearLSQFitter()
        p = fit_p(p_init, x[i1:i2][mmm[i1:i2]], s[i1:i2][mmm[i1:i2]])

    if 1:
        # t= np.linspace(x[i1]+10, x[i2-1]-10, 10)
        # p = LSQUnivariateSpline(x[i1:i2],
        #                         s[i1:i2],
        #                         t, bbox=[0, 2047])

        # t= np.concatenate([[x[1],x[i1-5],x[i1],x[i1+5]],
        #                    np.linspace(x[i1]+10, x[i2-1]-10, 10),
        #                    [x[i2-5], x[i2], x[i2+5],x[-2]]])

        t_list = []
        if i1 > 10:
            t_list.append([x[1], x[i1]])
        else:
            t_list.append([x[1]])
        t_list.append(np.linspace(x[i1] + 10, x[i2 - 1] - 10, 10))
        if i2 < len(s) - 10:
            t_list.append([x[i2], x[-2]])
        else:
            t_list.append([x[-2]])

        t = np.concatenate(t_list)

        # s0 = ni.median_filter(s, 40)
        from scipy.interpolate import LSQUnivariateSpline
        p = LSQUnivariateSpline(x, s, t, bbox=[0, len(s) - 1])

    return p
예제 #3
0
파일: order_flat.py 프로젝트: carleen/plp
def check_order_trace1(ax, x, s, i1i2):
    x = np.arange(len(s))
    ax.plot(x, s)
    i1, i2 = i1i2
    ax.plot(np.array(x)[[i1, i2]], np.array(s)[[i1,i2]], "o")
예제 #4
0
def check_order_trace1(ax, x, s, i1i2):
    x = np.arange(len(s))
    ax.plot(x, s)
    i1, i2 = i1i2
    ax.plot(np.array(x)[[i1, i2]], np.array(s)[[i1, i2]], "o")