blimpy/calib_utils/stokescal.py
def phase_offsets(Idat,Qdat,Udat,Vdat,tsamp,chan_per_coarse,feedtype='l',**kwargs):
    '''
    Calculates phase difference between X and Y feeds given U and V (U and Q for circular basis)
    data from a noise diode measurement on the target
    '''
    #Fold noise diode data and calculate ON OFF diferences for U and V
    if feedtype=='l':
        U_OFF,U_ON = foldcal(Udat,tsamp,**kwargs)
        V_OFF,V_ON = foldcal(Vdat,tsamp,**kwargs)
        Udiff = U_ON-U_OFF
        Vdiff = V_ON-V_OFF
        poffset = np.arctan2(-1*Vdiff,Udiff)

    if feedtype=='c':
        U_OFF,U_ON = foldcal(Udat,tsamp,**kwargs)
        Q_OFF,Q_ON = foldcal(Qdat,tsamp,**kwargs)
        Udiff = U_ON-U_OFF
        Qdiff = Q_ON-Q_OFF
        poffset = np.arctan2(Udiff,Qdiff)

    coarse_p =  convert_to_coarse(poffset,chan_per_coarse)

    #Correct for problems created by discontinuity in arctan
    #Find whether phase offsets have increasing or decreasing slope
    y = coarse_p[:6]
    x = np.arange(y.size)
    m = np.polyfit(x,y,1)[0]

    for i in range(coarse_p.size-3):
        if (m>0 and coarse_p[i+1]<coarse_p[i]) or (m<0 and coarse_p[i+1]>coarse_p[i]):
            coarse_p[i+1] = 2*coarse_p[i+2]-coarse_p[i+3]    #Move problem point near the next

    return coarse_p
def phase_offsets(Idat,Qdat,Udat,Vdat,tsamp,chan_per_coarse,feedtype='l',**kwargs):
    '''
    Calculates phase difference between X and Y feeds given U and V (U and Q for circular basis)
    data from a noise diode measurement on the target
    '''
    #Fold noise diode data and calculate ON OFF diferences for U and V
    if feedtype=='l':
        U_OFF,U_ON = foldcal(Udat,tsamp,**kwargs)
        V_OFF,V_ON = foldcal(Vdat,tsamp,**kwargs)
        Udiff = U_ON-U_OFF
        Vdiff = V_ON-V_OFF
        poffset = np.arctan2(-1*Vdiff,Udiff)

    if feedtype=='c':
        U_OFF,U_ON = foldcal(Udat,tsamp,**kwargs)
        Q_OFF,Q_ON = foldcal(Qdat,tsamp,**kwargs)
        Udiff = U_ON-U_OFF
        Qdiff = Q_ON-Q_OFF
        poffset = np.arctan2(Udiff,Qdiff)

    coarse_p =  convert_to_coarse(poffset,chan_per_coarse)

    #Correct for problems created by discontinuity in arctan
    #Find whether phase offsets have increasing or decreasing slope
    y = coarse_p[:6]
    x = np.arange(y.size)
    m = np.polyfit(x,y,1)[0]

    for i in range(coarse_p.size-3):
        if (m>0 and coarse_p[i+1]<coarse_p[i]) or (m<0 and coarse_p[i+1]>coarse_p[i]):
            coarse_p[i+1] = 2*coarse_p[i+2]-coarse_p[i+3]    #Move problem point near the next

    return coarse_p
def phase_offsets ( Idat , Qdat , Udat , Vdat , tsamp , chan_per_coarse , feedtype = 'l' , * * kwargs ) : #Fold noise diode data and calculate ON OFF diferences for U and V if feedtype == 'l' : U_OFF , U_ON = foldcal ( Udat , tsamp , * * kwargs ) V_OFF , V_ON = foldcal ( Vdat , tsamp , * * kwargs ) Udiff = U_ON - U_OFF Vdiff = V_ON - V_OFF poffset = np . arctan2 ( - 1 * Vdiff , Udiff ) if feedtype == 'c' : U_OFF , U_ON = foldcal ( Udat , tsamp , * * kwargs ) Q_OFF , Q_ON = foldcal ( Qdat , tsamp , * * kwargs ) Udiff = U_ON - U_OFF Qdiff = Q_ON - Q_OFF poffset = np . arctan2 ( Udiff , Qdiff ) coarse_p = convert_to_coarse ( poffset , chan_per_coarse ) #Correct for problems created by discontinuity in arctan #Find whether phase offsets have increasing or decreasing slope y = coarse_p [ : 6 ] x = np . arange ( y . size ) m = np . polyfit ( x , y , 1 ) [ 0 ] for i in range ( coarse_p . size - 3 ) : if ( m > 0 and coarse_p [ i + 1 ] < coarse_p [ i ] ) or ( m < 0 and coarse_p [ i + 1 ] > coarse_p [ i ] ) : coarse_p [ i + 1 ] = 2 * coarse_p [ i + 2 ] - coarse_p [ i + 3 ] #Move problem point near the next return coarse_p
Calculates phase difference between X and Y feeds given U and V (U and Q for circular basis)
    data from a noise diode measurement on the target
Calculates phase difference between X and Y feeds given U and V ( U and Q for circular basis ) data from a noise diode measurement on the target