Linear depolarizarion ratio (LDR) for the current setup.

    Args:
        scatterer: a Scatterer instance.
        h_pol: If True (default), return LDR_h.
        If False, return LDR_v.

    Returns:
       The LDR.
350500
def ldr(scatterer, h_pol=True):
    
    Z = scatterer.get_Z()
    if h_pol:
        return (Z[0,0] - Z[0,1] + Z[1,0] - Z[1,1]) / \
               (Z[0,0] - Z[0,1] - Z[1,0] + Z[1,1])
    else:
        return (Z[0,0] + Z[0,1] - Z[1,0] - Z[1,1]) / \
               (Z[0,0] + Z[0,1] + Z[1,0] + Z[1,1])
1071546
def ratiometric
      ptr = ::FFI::MemoryPointer.new(:int)
      Klass.getRatiometric(@handle, ptr)
      (ptr.get_int(0) == 0) ? false : true
    end
386950
def avhrr(scans_nb, scan_points,
          scan_angle=55.37, frequency=1 / 6.0, apply_offset=True):
    
    # build the avhrr instrument (scan angles)
    avhrr_inst = np.vstack(((scan_points / 1023.5 - 1)
                            * np.deg2rad(-scan_angle),
                            np.zeros((len(scan_points),))))

    avhrr_inst = np.tile(
        avhrr_inst[:, np.newaxis, :], [1, np.int(scans_nb), 1])

    # building the corresponding times array
    # times = (np.tile(scan_points * 0.000025 + 0.0025415, [scans_nb, 1])
    #         + np.expand_dims(offset, 1))

    times = np.tile(scan_points * 0.000025, [np.int(scans_nb), 1])
    if apply_offset:
        offset = np.arange(np.int(scans_nb)) * frequency
        times += np.expand_dims(offset, 1)

    return ScanGeometry(avhrr_inst, times)
12058
def corruptSparseVector(sdr, noiseLevel):
  

  numNoiseBits = int(noiseLevel * np.sum(sdr))
  if numNoiseBits <= 0:
    return sdr
  activeBits = np.where(sdr > 0)[0]
  inActiveBits = np.where(sdr == 0)[0]

  turnOffBits = np.random.permutation(activeBits)
  turnOnBits = np.random.permutation(inActiveBits)
  turnOffBits = turnOffBits[:numNoiseBits]
  turnOnBits = turnOnBits[:numNoiseBits]

  sdr[turnOffBits] = 0
  sdr[turnOnBits] = 1
181992
def _ratio_enum(anchor, ratios):
        
        w, h, x_ctr, y_ctr = AnchorGenerator._whctrs(anchor)
        size = w * h
        size_ratios = size / ratios
        ws = np.round(np.sqrt(size_ratios))
        hs = np.round(ws * ratios)
        anchors = AnchorGenerator._mkanchors(ws, hs, x_ctr, y_ctr)
        return anchors
522719
def _set_scatter_signature(self):
        
        self._scatter_signature = (self.thet0, self.thet, self.phi0, self.phi,
            self.alpha, self.beta, self.orient)
82093
def dipole_moment(r_array, charge_array):
    '''
    '''
    return np.sum(r_array * charge_array[:, np.newaxis], axis=0)
211949
def get_polarization_change(self, convert_to_muC_per_cm2=True, all_in_polar=True):
        
        tot = self.get_same_branch_polarization_data(
            convert_to_muC_per_cm2=convert_to_muC_per_cm2, all_in_polar=all_in_polar)
        # reshape to preserve backwards compatibility due to changes
        # when switching from np.matrix to np.array
        return (tot[-1] - tot[0]).reshape((1,  3))
631888
def lnprior(self, X):
        
        if np.any(X < self._lower_left) or np.any(X > self._upper_right):
            return -np.inf
        else:
            return 0.0
684536
def Morlet (sampr, freq, width=7.0):
  
  dt = 1. / sampr
  sf = freq / width # sf in Hz
  st = 1. / (2. * np.pi * sf) # st in s
  t = np.arange(-3.5*st, 3.5*st, dt)
  A = 1. / (st * np.sqrt(2.*np.pi)) # A in 1 / s
  # units: 1/s * (exp (s**2 / s**2)) * exp( 1/ s * s)
  return A * np.exp(-t**2. / (2. * st**2.)) * np.exp(1.j * 2. * np.pi * freq * t)
393658
def c_mvar(self):
        
        if self.b == -4:
            return 1.0
        elif self.b == -3:
            return 0.0
        elif self.b == -2:
            return -1.0
        elif self.b == -1:
            return -2.0
        elif self.b == 0:
            return -3.0
944544
def lnlike(x, star):
    """"""
    ll = lnprior(x)
    if np.isinf(ll):
        return ll, (np.nan, np.nan)
    per, t0, b = x
    model = TransitModel('b', per=per, t0=t0, b=b, rhos=10.)(star.time)
    like, d, vard = star.lnlike(model, full_output=True)
    ll += like
    return ll, (d,)
824560
def get_ht_op(_, data):
    
    protection = ('no', 'nonmember', 20, 'non-HT mixed')
    sta_chan_width = (20, 'any')
    answers = {
        'primary channel': data[0],
        'secondary channel offset': ht_secondary_offset[data[1] & 0x3],
        'STA channel width': sta_chan_width[(data[1] & 0x4) >> 2],
        'RIFS': (data[1] & 0x8) >> 3,
        'HT protection': protection[data[2] & 0x3],
        'non-GF present': (data[2] & 0x4) >> 2,
        'OBSS non-GF present': (data[2] & 0x10) >> 4,
        'dual beacon': (data[4] & 0x40) >> 6,
        'dual CTS protection': (data[4] & 0x80) >> 7,
        'STBC beacon': data[5] & 0x1,
        'L-SIG TXOP Prot': (data[5] & 0x2) >> 1,
        'PCO active': (data[5] & 0x4) >> 2,
        'PCO phase': (data[5] & 0x8) >> 3,
    }
    return answers
298315
def rsdl(self):
        """"""

        return np.linalg.norm((self.X - self.Yprv).ravel())
909816
def rsr(self):
        """"""
        arr = np.array([self.wave.value, self.throughput]).swapaxes(0, 1)

        return arr
121512
def rho_hv(scatterer):
    
    Z = scatterer.get_Z()
    a = (Z[2,2] + Z[3,3])**2 + (Z[3,2] - Z[2,3])**2
    b = (Z[0,0] - Z[0,1] - Z[1,0] + Z[1,1])
    c = (Z[0,0] + Z[0,1] + Z[1,0] + Z[1,1])
    return np.sqrt(a / (b*c))
444702
def get_vec_lr(self):
        """"""

        return self.width * self.cos_a(), -self.width * self.sin_a()