Method for returning the readnoise of a detector (in DN).

        :units: DN

        This should work on a chip, since different chips to be consistant with other
        detector classes where different chips have different gains.
765080
def getReadNoise(self):
        
        if self.proc_unit == 'native':
            return self._rdnoise / self._gain()
        return self._rdnoise
147876
def _addNoise(self, pattern, noiseLevel, inputSize):
    
    if pattern is None:
      return None

    # Bits that could be noise. These can't be from the original set.
    candidateBits = list(set(range(inputSize)) - set(pattern))
    random.shuffle(candidateBits)

    newBits = set()
    for bit in pattern:
      if random.random() < noiseLevel:
        newBits.add(candidateBits.pop())
      else:
        newBits.add(bit)

    return newBits
222237
def read_byte(self, addr):
        
        if addr < 0 or addr > 127:
            raise ValueError("invalid byte address")
        log.debug("read byte at address {0} ({0:02X}h)".format(addr))
        cmd = "\x01" + chr(addr) + "\x00" + self.uid
        return self.transceive(cmd)[-1]
692360
def get_mtype_and_number_from_code(si, sensor_code):
    
    mtype_and_ory, x, y, z = sensor_code.split("-")
    if mtype_and_ory[-1] in "XYZ" and "ACCX" not in si:  # Need to support old sensor_file.json files.
        mtype = mtype_and_ory[:-1]
    else:
        mtype = mtype_and_ory
    for m_number in si[mtype]:
        cc = get_sensor_code_by_number(si, mtype, m_number)
        if cc == sensor_code:
            return mtype, m_number
    return None, None
816741
def get_symbol(units) -> str:
    
    if kind(units) == "energy":
        d = {}
        d["nm"] = r"\lambda"
        d["wn"] = r"\bar\nu"
        d["eV"] = r"\hslash\omega"
        d["Hz"] = r"f"
        d["THz"] = r"f"
        d["GHz"] = r"f"
        return d.get(units, "E")
    elif kind(units) == "delay":
        return r"\tau"
    elif kind(units) == "fluence":
        return r"\mathcal{F}"
    elif kind(units) == "pulse_width":
        return r"\sigma"
    elif kind(units) == "temperature":
        return r"T"
    else:
        return kind(units)
115045
def ndstype(self):
        
        if self.type is not None:
            return io_nds2.Nds2ChannelType.find(self.type).value
728265
def get_sn(unit):
    
    sn = 0
    match_re = re.findall(str(sentence_delimiters), unit)
    if match_re:
        string = ''.join(match_re)
        sn = len(string)
    return int(sn)
775719
def _ReadEncodedData(self, read_size):
    
    encoded_data = self._file_object.read(read_size)

    read_count = len(encoded_data)

    self._encoded_data = b''.join([self._encoded_data, encoded_data])

    self._decoded_data, self._encoded_data = (
        self._decoder.Decode(self._encoded_data))

    self._decoded_data_size = len(self._decoded_data)

    return read_count
543074
def detect(self, x, conf, adc_zero):
        
        self.c = conf
        self.annotations = []
        self.sample_valid = False

        if len(x) < 1:
            return []

        self.x = x
        self.adc_zero = adc_zero

        self.qfv = np.zeros((self.c._BUFLN), dtype="int64")
        self.smv = np.zeros((self.c._BUFLN), dtype="int64")
        self.v1 = 0

        t0 = 0
        self.tf = len(x) - 1
        self.t = 0 - self.c.dt4

        self.annot = GQRS.Annotation(0, "NOTE", 0, 0)

        # Cicular buffer of Peaks
        first_peak = GQRS.Peak(0, 0, 0)
        tmp = first_peak
        for _ in range(1, self.c._NPEAKS):
            tmp.next_peak = GQRS.Peak(0, 0, 0)
            tmp.next_peak.prev_peak = tmp
            tmp = tmp.next_peak
        tmp.next_peak = first_peak
        first_peak.prev_peak = tmp
        self.current_peak = first_peak

        if self.c.spm > self.c._BUFLN:
            if self.tf - t0 > self.c._BUFLN:
                tf_learn = t0 + self.c._BUFLN - self.c.dt4
            else:
                tf_learn = self.tf - self.c.dt4
        else:
            if self.tf - t0 > self.c.spm:
                tf_learn = t0 + self.c.spm - self.c.dt4
            else:
                tf_learn = self.tf - self.c.dt4

        self.countdown = -1
        self.state = "LEARNING"
        self.gqrs(t0, tf_learn)

        self.rewind_gqrs()

        self.state = "RUNNING"
        self.t = t0 - self.c.dt4
        self.gqrs(t0, self.tf)

        return self.annotations
555323
def read(self, size:int=None):
        
        if size:
            result = self._buffer[0:size]
            self._buffer = self._buffer[size:]
            return result
        else:
            result = self._buffer
            self._buffer = ''
            return result
1180187
def read(device):
        
        response = None
        bytes_avail = bytes_available(device)

        if isinstance(device, alarmdecoder.devices.SerialDevice):
            response = device._device.read(bytes_avail)
        elif isinstance(device, alarmdecoder.devices.SocketDevice):
            response = device._device.recv(bytes_avail)

        return response
1157183
def read_adc(self, adc_number):
        
        assert 0 <= adc_number <= 7, 'ADC number must be a value of 0-7!'
        # Build a single channel read command.
        # For example channel zero = 0b11000000
        command = 0b11 << 6                  # Start bit, single channel read
        command |= (adc_number & 0x07) << 3  # Channel number (in 3 bits)
        # Note the bottom 3 bits of command are 0, this is to account for the
        # extra clock to do the conversion, and the low null bit returned at
        # the start of the response.
        resp = self._spi.transfer([command, 0x0, 0x0])
        # Parse out the 10 bits of response data and return it.
        result = (resp[0] & 0x01) << 9
        result |= (resp[1] & 0xFF) << 1
        result |= (resp[2] & 0x80) >> 7
        return result & 0x3FF
1078240
def _readsie(self, pos):
        
        codenum, pos = self._readuie(pos)
        if not codenum:
            return 0, pos
        try:
            if self[pos]:
                return -codenum, pos + 1
            else:
                return codenum, pos + 1
        except IndexError:
            raise ReadError("Read off end of bitstring trying to read code.")
1007268
def _parse_Sigma(self,Sigma_amp,Sigma,dSigmadR,d2SigmadR2):
        
        if isinstance(Sigma,dict):
            Sigma= [Sigma]
        try:
            nsigma= len(Sigma)
        except TypeError:
            Sigma_amp= [Sigma_amp]
            Sigma= [Sigma]
            dSigmadR= [dSigmadR]
            d2SigmadR2= [d2SigmadR2]
            nsigma= 1
        self._nsigma= nsigma
        self._Sigma_amp= Sigma_amp
        self._Sigma= Sigma
        self._dSigmadR= dSigmadR
        self._d2SigmadR2= d2SigmadR2
        if isinstance(Sigma[0],dict):
            self._Sigma_dict= copy.copy(Sigma)
            self._parse_Sigma_dict()
        else:
            self._Sigma_dict= None
        return None
476955
def read(self, size=1024):
        
        b = super(PtyProcessUnicode, self).read(size)
        return self.decoder.decode(b, final=False)
852013
def _read_message(self):
        
        # first 4 bytes is Big-Endian payload length
        payload_info = self._read_bytes_from_socket(4)
        read_len = unpack(">I", payload_info)[0]

        # now read the payload
        payload = self._read_bytes_from_socket(read_len)

        # pylint: disable=no-member
        message = cast_channel_pb2.CastMessage()
        message.ParseFromString(payload)

        return message
497186
def getReadNoise(self, exten):
        
        rn = self._image[exten]._rdnoise
        if self.proc_unit == 'native':
            rn = self._rdnoise / self.getGain(exten)
        return rn