<commit_before>from config import config
from axi2s_c import axi2s_c
from axi2s_u import axi2s_u
from AD9361_c import AD9361_c
import numpy as np
import time
class scan:
	FFTSIZE = 3072
	OUTSIZE = 1000
	STEP = 10e6
	AGC_TAGET_MAX = 1024*1024/2
	AGC_TAGET_MIN = 1024*1024/512
	def __init__(self,g):
		self.g = g
		self.ram = axi2s_u(g.AXI2S_IBASE,g.AXI2S_ISIZE)
		self.config = g.todict()
		self.axi = axi2s_c()
		self.axi.status(self.config)
		self.ad = AD9361_c()
		self.gain = 0x4c
		self.ad.Set_Rx_Gain(self.gain,1)
		self.agc()
		self.iq = np.zeros(scan.FFTSIZE*16,dtype=complex)
	def init(self):
		self.gain = 0x4c
		self.ad.Set_Rx_Gain(self.gain,1)
		self.agc()
		self.iq = np.zeros(scan.FFTSIZE*16,dtype=complex)
		
	def nowData(self,k):
		self.axi.getCNT()
		pos = self.axi.cnt['AXI2S_IACNT']
		if pos<scan.FFTSIZE*4*k:
			pos = self.g.AXI2S_ISIZE
		pos -= scan.FFTSIZE*4*k
		iq = self.ram.npfrom(pos,scan.FFTSIZE*k)
		return iq

	def agcOnce(self):
		iq = self.nowData(1)
		p = (np.dot(iq,np.conj(iq))/scan.FFTSIZE).real+1.
		if p>scan.AGC_TAGET_MAX and self.gain!=0:
			d=-int(np.log10(p/scan.AGC_TAGET_MAX)*10.)
		if p<scan.AGC_TAGET_MIN and self.gain!=0x4c:
			d=-int(np.log10(p/scan.AGC_TAGET_MAX)*10.)
		self.setGain(d)
		return d

	def setGain(self,d):
		dg = self.gain+d
		if dg<0 :
			print "too large"
			dg = 0
		if dg>0x4c:
			print "too small"
			dg = 0x4c
		self.ad.Set_Rx_Gain(dg,1)
		self.ad.Check_FDD()
		self.gain = dg

	def agc(self):
		c = 10
		while c>0:
			d = self.agcOnce()<commit_msg>auto update<commit_after>from config import config
from axi2s_c import axi2s_c
from axi2s_u import axi2s_u
from AD9361_c import AD9361_c
import numpy as np
import time
class scan:
	FFTSIZE = 3072
	OUTSIZE = 1000
	STEP = 10e6
	AGC_TAGET_MAX = 1024*1024/2
	AGC_TAGET_MIN = 1024*1024/512
	def __init__(self,g):
		self.g = g
		self.ram = axi2s_u(g.AXI2S_IBASE,g.AXI2S_ISIZE)
		self.config = g.todict()
		self.axi = axi2s_c()
		self.axi.status(self.config)
		self.ad = AD9361_c()
		self.gain = 0x4c
		self.ad.Set_Rx_Gain(self.gain,1)
		self.agc()
		self.iq = np.zeros(scan.FFTSIZE*16,dtype=complex)
	def init(self):
		self.gain = 0x4c
		self.ad.Set_Rx_Gain(self.gain,1)
		self.agc()
		self.iq = np.zeros(scan.FFTSIZE*16,dtype=complex)
		
	def nowData(self,k):
		self.axi.getCNT()
		pos = self.axi.cnt['AXI2S_IACNT']
		if pos<scan.FFTSIZE*4*k:
			pos = self.g.AXI2S_ISIZE
		pos -= scan.FFTSIZE*4*k
		iq = self.ram.npfrom(pos,scan.FFTSIZE*k)
		return iq

	def agcOnce(self):
		iq = self.nowData(1)
		p = (np.dot(iq,np.conj(iq))/scan.FFTSIZE).real+1.
		if p>scan.AGC_TAGET_MAX and self.gain!=0:
			d=-int(np.log10(p/scan.AGC_TAGET_MAX)*10.)
			self.setGain(d)
		if p<scan.AGC_TAGET_MIN and self.gain!=0x4c:
			d=-int(np.log10(p/scan.AGC_TAGET_MAX)*10.)
			self.setGain(d)
		return d

	def setGain(self,d):
		dg = self.gain+d
		if dg<0 :
			print "too large"
			dg = 0
		if dg>0x4c:
			print "too small"
			dg = 0x4c
		self.ad.Set_Rx_Gain(dg,1)
		self.ad.Check_FDD()
		self.gain = dg

	def agc(self):
		c = 10
		while c>0:
			d = self.agcOnce()
{'fraction_non_alphanumeric': 0.14515072083879424, 'fraction_numerical': 0.057667103538663174, 'mean_word_length': 3.570359281437126, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1503616', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1491, 'n_words': 251}