@@ -0,0 +1,87 | |||||
|
1 | import numpy | |||
|
2 | import sys | |||
|
3 | import zmq | |||
|
4 | import time | |||
|
5 | import h5py | |||
|
6 | import os | |||
|
7 | ||||
|
8 | path="/home/alex/Downloads/pedestal" | |||
|
9 | ext=".hdf5" | |||
|
10 | ||||
|
11 | port ="5556" | |||
|
12 | if len(sys.argv)>1: | |||
|
13 | port = sys.argv[1] | |||
|
14 | int(port) | |||
|
15 | ||||
|
16 | if len(sys.argv)>2: | |||
|
17 | port1 = sys.argv[2] | |||
|
18 | int(port1) | |||
|
19 | ||||
|
20 | #Socket to talk to server | |||
|
21 | context = zmq.Context() | |||
|
22 | socket = context.socket(zmq.SUB) | |||
|
23 | ||||
|
24 | print("Collecting updates from weather server...") | |||
|
25 | socket.connect("tcp://localhost:%s"%port) | |||
|
26 | ||||
|
27 | if len(sys.argv)>2: | |||
|
28 | socket.connect("tcp://localhost:%s"%port1) | |||
|
29 | ||||
|
30 | #Subscribe to zipcode, default is NYC,10001 | |||
|
31 | topicfilter = "10001" | |||
|
32 | socket.setsockopt_string(zmq.SUBSCRIBE,topicfilter) | |||
|
33 | #Process 5 updates | |||
|
34 | total_value=0 | |||
|
35 | count= -1 | |||
|
36 | azi= [] | |||
|
37 | elev=[] | |||
|
38 | time0=[] | |||
|
39 | #for update_nbr in range(250): | |||
|
40 | while(True): | |||
|
41 | string= socket.recv() | |||
|
42 | topic,ang_elev,ang_elev_dec,ang_azi,ang_azi_dec,seconds,seconds_dec= string.split() | |||
|
43 | ang_azi =float(ang_azi)+1e-3*float(ang_azi_dec) | |||
|
44 | ang_elev =float(ang_elev)+1e-3*float(ang_elev_dec) | |||
|
45 | seconds =float(seconds) +1e-6*float(seconds_dec) | |||
|
46 | azi.append(ang_azi) | |||
|
47 | elev.append(ang_elev) | |||
|
48 | time0.append(seconds) | |||
|
49 | count +=1 | |||
|
50 | if count == 100: | |||
|
51 | timetuple=time.localtime() | |||
|
52 | epoc = time.mktime(timetuple) | |||
|
53 | #print(epoc) | |||
|
54 | fullpath = path + ("/" if path[-1]!="/" else "") | |||
|
55 | ||||
|
56 | if not os.path.exists(fullpath): | |||
|
57 | os.mkdir(fullpath) | |||
|
58 | ||||
|
59 | azi_array = numpy.array(azi) | |||
|
60 | elev_array = numpy.array(elev) | |||
|
61 | time0_array= numpy.array(time0) | |||
|
62 | pedestal_array=numpy.array([azi,elev,time0]) | |||
|
63 | count=0 | |||
|
64 | azi= [] | |||
|
65 | elev=[] | |||
|
66 | time0=[] | |||
|
67 | #print(pedestal_array[0]) | |||
|
68 | #print(pedestal_array[1]) | |||
|
69 | ||||
|
70 | meta='PE' | |||
|
71 | filex="%s%4.4d%3.3d%10.4d%s"%(meta,timetuple.tm_year,timetuple.tm_yday,epoc,ext) | |||
|
72 | filename = os.path.join(fullpath,filex) | |||
|
73 | fp = h5py.File(filename,'w') | |||
|
74 | #print("Escribiendo HDF5...",epoc) | |||
|
75 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DataΒ·....Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
76 | grp = fp.create_group("Data") | |||
|
77 | dset = grp.create_dataset("azimuth" , data=pedestal_array[0]) | |||
|
78 | dset = grp.create_dataset("elevacion", data=pedestal_array[1]) | |||
|
79 | dset = grp.create_dataset("utc" , data=pedestal_array[2]) | |||
|
80 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· MetadataΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
81 | grp = fp.create_group("Metadata") | |||
|
82 | dset = grp.create_dataset("utctimeInit", data=pedestal_array[2][0]) | |||
|
83 | timeInterval = pedestal_array[2][1]-pedestal_array[2][0] | |||
|
84 | dset = grp.create_dataset("timeInterval", data=timeInterval) | |||
|
85 | fp.close() | |||
|
86 | ||||
|
87 | #print ("Average messagedata value for topic '%s' was %dF" % ( topicfilter,total_value / update_nbr)) |
@@ -0,0 +1,48 | |||||
|
1 | ########################################################################### | |||
|
2 | ############################### SERVIDOR################################### | |||
|
3 | ######################### SIMULADOR DE PEDESTAL############################ | |||
|
4 | ########################################################################### | |||
|
5 | import time | |||
|
6 | import math | |||
|
7 | import numpy | |||
|
8 | import struct | |||
|
9 | from time import sleep | |||
|
10 | import zmq | |||
|
11 | import pickle | |||
|
12 | port="5556" | |||
|
13 | context = zmq.Context() | |||
|
14 | socket = context.socket(zmq.PUB) | |||
|
15 | socket.bind("tcp://*:%s"%port) | |||
|
16 | ###### PARAMETROS DE ENTRADA################################ | |||
|
17 | print("PEDESTAL RESOLUCION 0.01") | |||
|
18 | print("MAXIMA VELOCIDAD DEL PEDESTAL") | |||
|
19 | ang_elev = 4.12 | |||
|
20 | ang_azi = 30 | |||
|
21 | velocidad= input ("Ingresa velocidad:") | |||
|
22 | velocidad= float(velocidad) | |||
|
23 | print (velocidad) | |||
|
24 | ############################################################ | |||
|
25 | sleep(3) | |||
|
26 | print("Start program") | |||
|
27 | t1 = time.time() | |||
|
28 | count=0 | |||
|
29 | while(True): | |||
|
30 | tmp_vuelta = int(360/velocidad) | |||
|
31 | t1=t1+tmp_vuelta*count | |||
|
32 | count= count+1 | |||
|
33 | muestras_seg = 100 | |||
|
34 | t2 = time.time() | |||
|
35 | for i in range(tmp_vuelta): | |||
|
36 | for j in range(muestras_seg): | |||
|
37 | tmp_variable = (i+j/100.0) | |||
|
38 | ang_azi = (tmp_variable)*float(velocidad) | |||
|
39 | seconds = t1+ tmp_variable | |||
|
40 | topic=10001 | |||
|
41 | print ("AzimΒ°: ","%.4f"%ang_azi,"Time:" ,"%.5f"%seconds) | |||
|
42 | seconds_dec=(seconds-int(seconds))*1e6 | |||
|
43 | ang_azi_dec= (ang_azi-int(ang_azi))*1e3 | |||
|
44 | ang_elev_dec=(ang_elev-int(ang_elev))*1e3 | |||
|
45 | sleep(0.0088) | |||
|
46 | socket.send_string("%d %d %d %d %d %d %d"%(topic,ang_elev,ang_elev_dec,ang_azi,ang_azi_dec,seconds,seconds_dec)) | |||
|
47 | t3 = time.time() | |||
|
48 | print ("Total time for 1 vuelta in Seconds",t3-t2) |
@@ -0,0 +1,82 | |||||
|
1 | import os, sys | |||
|
2 | import datetime | |||
|
3 | import time | |||
|
4 | from schainpy.controller import Project | |||
|
5 | ||||
|
6 | desc = "USRP_test" | |||
|
7 | filename = "USRP_processing.xml" | |||
|
8 | controllerObj = Project() | |||
|
9 | controllerObj.setup(id = '191', name='Test_USRP', description=desc) | |||
|
10 | ||||
|
11 | ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# | |||
|
12 | ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# | |||
|
13 | path = '/home/alex/Downloads/test_rawdata' | |||
|
14 | figpath = '/home/alex/Downloads/hdf5_test' | |||
|
15 | ######################## UNIDAD DE LECTURA############################# | |||
|
16 | ''' | |||
|
17 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |||
|
18 | path=path, | |||
|
19 | startDate="2020/01/01", #"2020/01/01",#today, | |||
|
20 | endDate= "2020/12/01", #"2020/12/30",#today, | |||
|
21 | startTime='00:00:00', | |||
|
22 | endTime='23:59:59', | |||
|
23 | delay=0, | |||
|
24 | #set=0, | |||
|
25 | online=0, | |||
|
26 | walk=1) | |||
|
27 | ||||
|
28 | ''' | |||
|
29 | readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader', | |||
|
30 | frequency=9.345e9, | |||
|
31 | FixRCP_IPP= 60, | |||
|
32 | Tau_0 = 30, | |||
|
33 | AcqH0_0=0, | |||
|
34 | samples=330, | |||
|
35 | AcqDH_0=0.15, | |||
|
36 | FixRCP_TXA=0.15, | |||
|
37 | FixRCP_TXB=0.15, | |||
|
38 | Fdoppler=600.0, | |||
|
39 | Hdoppler=36, | |||
|
40 | Adoppler=300,#300 | |||
|
41 | delay=0, | |||
|
42 | online=0, | |||
|
43 | walk=0, | |||
|
44 | profilesPerBlock=625, | |||
|
45 | dataBlocksPerFile=100) | |||
|
46 | #nTotalReadFiles=2) | |||
|
47 | ||||
|
48 | ||||
|
49 | #opObj11 = readUnitConfObj.addOperation(name='printInfo') | |||
|
50 | ||||
|
51 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |||
|
52 | ||||
|
53 | procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) | |||
|
54 | procUnitConfObjB.addParameter(name='nFFTPoints', value=625, format='int') | |||
|
55 | procUnitConfObjB.addParameter(name='nProfiles', value=625, format='int') | |||
|
56 | ||||
|
57 | opObj11 = procUnitConfObjB.addOperation(name='removeDC') | |||
|
58 | opObj11.addParameter(name='mode', value=2) | |||
|
59 | #opObj11 = procUnitConfObjB.addOperation(name='SpectraPlot') | |||
|
60 | #opObj11 = procUnitConfObjB.addOperation(name='PowerProfilePlot') | |||
|
61 | ||||
|
62 | procUnitConfObjC= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjB.getId()) | |||
|
63 | procUnitConfObjC.addOperation(name='SpectralMoments') | |||
|
64 | #opObj11 = procUnitConfObjC.addOperation(name='PowerPlot') | |||
|
65 | ||||
|
66 | ''' | |||
|
67 | opObj11 = procUnitConfObjC.addOperation(name='SpectralMomentsPlot') | |||
|
68 | #opObj11.addParameter(name='xmin', value=14) | |||
|
69 | #opObj11.addParameter(name='xmax', value=15) | |||
|
70 | #opObj11.addParameter(name='save', value=figpath) | |||
|
71 | opObj11.addParameter(name='showprofile', value=1) | |||
|
72 | #opObj11.addParameter(name='save_period', value=10) | |||
|
73 | ''' | |||
|
74 | ||||
|
75 | opObj10 = procUnitConfObjC.addOperation(name='ParameterWriter') | |||
|
76 | opObj10.addParameter(name='path',value=figpath) | |||
|
77 | #opObj10.addParameter(name='mode',value=0) | |||
|
78 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') | |||
|
79 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list') | |||
|
80 | opObj10.addParameter(name='dataList',value='data_POW,data_DOP,data_WIDTH,data_SNR')#,format='list' | |||
|
81 | ||||
|
82 | controllerObj.start() |
@@ -0,0 +1,162 | |||||
|
1 | import os,numpy,h5py | |||
|
2 | from shutil import copyfile | |||
|
3 | ||||
|
4 | def isNumber(str): | |||
|
5 | try: | |||
|
6 | float(str) | |||
|
7 | return True | |||
|
8 | except: | |||
|
9 | return False | |||
|
10 | ||||
|
11 | def getfirstFilefromPath(path,meta,ext): | |||
|
12 | validFilelist = [] | |||
|
13 | fileList = os.listdir(path) | |||
|
14 | if len(fileList)<1: | |||
|
15 | return None | |||
|
16 | # meta 1234 567 8-18 BCDE | |||
|
17 | # H,D,PE YYYY DDD EPOC .ext | |||
|
18 | ||||
|
19 | for thisFile in fileList: | |||
|
20 | if meta =="PE": | |||
|
21 | try: | |||
|
22 | number= int(thisFile[len(meta)+7:len(meta)+17]) | |||
|
23 | except: | |||
|
24 | print("There is a file or folder with different format") | |||
|
25 | if meta == "D": | |||
|
26 | try: | |||
|
27 | number= int(thisFile[8:11]) | |||
|
28 | except: | |||
|
29 | print("There is a file or folder with different format") | |||
|
30 | ||||
|
31 | if not isNumber(str=number): | |||
|
32 | continue | |||
|
33 | if (os.path.splitext(thisFile)[-1].lower() != ext.lower()): | |||
|
34 | continue | |||
|
35 | validFilelist.sort() | |||
|
36 | validFilelist.append(thisFile) | |||
|
37 | if len(validFilelist)>0: | |||
|
38 | validFilelist = sorted(validFilelist,key=str.lower) | |||
|
39 | return validFilelist | |||
|
40 | return None | |||
|
41 | ||||
|
42 | def gettimeutcfromDirFilename(path,file): | |||
|
43 | dir_file= path+"/"+file | |||
|
44 | fp = h5py.File(dir_file,'r') | |||
|
45 | epoc = fp['Metadata'].get('utctimeInit')[()] | |||
|
46 | fp.close() | |||
|
47 | return epoc | |||
|
48 | ||||
|
49 | def getDatavaluefromDirFilename(path,file,value): | |||
|
50 | dir_file= path+"/"+file | |||
|
51 | fp = h5py.File(dir_file,'r') | |||
|
52 | array = fp['Data'].get(value)[()] | |||
|
53 | fp.close() | |||
|
54 | return array | |||
|
55 | ||||
|
56 | ||||
|
57 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Velocidad de PedestalΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
58 | w = input ("Ingresa velocidad de Pedestal: ") | |||
|
59 | w = 4 | |||
|
60 | w = float(w) | |||
|
61 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Resolucion minimo en gradosΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
62 | alfa = input ("Ingresa resolucion minima en grados: ") | |||
|
63 | alfa = 1 | |||
|
64 | alfa = float(alfa) | |||
|
65 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· IPP del Experimento Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
66 | IPP = input ("Ingresa el IPP del experimento: ") | |||
|
67 | IPP = 0.0004 | |||
|
68 | IPP = float(IPP) | |||
|
69 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· MODE Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
70 | mode = input ("Ingresa el MODO del experimento T or F: ") | |||
|
71 | mode = "T" | |||
|
72 | mode = str(mode) | |||
|
73 | ||||
|
74 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Tiempo en generar la resolucion minΒ·Β·Β· | |||
|
75 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· MCU Β·Β· var_ang = w * (var_tiempo)Β·Β·Β· | |||
|
76 | var_tiempo = alfa/w | |||
|
77 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Tiempo Equivalente en perfilesΒ·Β·Β·Β·Β·Β·Β·Β· | |||
|
78 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· var_tiempo = IPP * ( num_perfiles )Β· | |||
|
79 | num_perfiles = int(var_tiempo/IPP) | |||
|
80 | ||||
|
81 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·DATA PEDESTALΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
82 | dir_pedestal = "/home/alex/Downloads/pedestal" | |||
|
83 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATA ADQΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
84 | if mode=="T": | |||
|
85 | dir_adq = "/home/alex/Downloads/hdf5_testPP/d2020194" # Time domain | |||
|
86 | else: | |||
|
87 | dir_adq = "/home/alex/Downloads/hdf5_test/d2020194" # Frequency domain | |||
|
88 | ||||
|
89 | print( "Velocidad angular :", w) | |||
|
90 | print( "Resolucion minima en grados :", alfa) | |||
|
91 | print( "Numero de perfiles equivalente:", num_perfiles) | |||
|
92 | print( "Mode :", mode) | |||
|
93 | ||||
|
94 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· First FileΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
95 | list_pedestal = getfirstFilefromPath(path=dir_pedestal,meta="PE",ext=".hdf5") | |||
|
96 | list_adq = getfirstFilefromPath(path=dir_adq ,meta="D",ext=".hdf5") | |||
|
97 | ||||
|
98 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· utc time Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
99 | utc_pedestal= gettimeutcfromDirFilename(path=dir_pedestal,file=list_pedestal[0]) | |||
|
100 | utc_adq = gettimeutcfromDirFilename(path=dir_adq ,file=list_adq[0]) | |||
|
101 | ||||
|
102 | print("utc_pedestal :",utc_pedestal) | |||
|
103 | print("utc_adq :",utc_adq) | |||
|
104 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Relacion: utc_adq (+/-) var_tiempo*nro_file= utc_pedestal | |||
|
105 | time_Interval_p = 0.01 | |||
|
106 | n_perfiles_p = 100 | |||
|
107 | if utc_adq>utc_pedestal: | |||
|
108 | nro_file = int((int(utc_adq) - int(utc_pedestal))/(time_Interval_p*n_perfiles_p)) | |||
|
109 | ff_pedestal = list_pedestal[nro_file] | |||
|
110 | utc_pedestal = gettimeutcfromDirFilename(path=dir_pedestal,file=ff_pedestal) | |||
|
111 | nro_key_p = int((utc_adq-utc_pedestal)/time_Interval_p) | |||
|
112 | if utc_adq >utc_pedestal: | |||
|
113 | ff_pedestal = ff_pedestal | |||
|
114 | else: | |||
|
115 | nro_file = nro_file-1 | |||
|
116 | ff_pedestal = list_pedestal[nro_file] | |||
|
117 | angulo = getDatavaluefromDirFilename(path=dir_pedestal,file=ff_pedestal,value="azimuth") | |||
|
118 | nro_key_p = int((utc_adq-utc_pedestal)/time_Interval_p) | |||
|
119 | print("nro_file :",nro_file) | |||
|
120 | print("name_file :",ff_pedestal) | |||
|
121 | print("utc_pedestal_file :",utc_pedestal) | |||
|
122 | print("nro_key_p :",nro_key_p) | |||
|
123 | print("utc_pedestal_init :",utc_pedestal+nro_key_p*time_Interval_p) | |||
|
124 | print("angulo_array :",angulo[nro_key_p]) | |||
|
125 | #4+25+25+25+21 | |||
|
126 | #while True: | |||
|
127 | list_pedestal = getfirstFilefromPath(path=dir_pedestal,meta="PE",ext=".hdf5") | |||
|
128 | list_adq = getfirstFilefromPath(path=dir_adq ,meta="D",ext=".hdf5") | |||
|
129 | ||||
|
130 | nro_file = nro_file #10 | |||
|
131 | nro_key_perfil = nro_key_p | |||
|
132 | blocksPerFile = 100 | |||
|
133 | wr_path = "/home/alex/Downloads/hdf5_wr/" | |||
|
134 | # Lectura de archivos de adquisicion para adicion de azimuth | |||
|
135 | for thisFile in range(len(list_adq)): | |||
|
136 | print("thisFileAdq",thisFile) | |||
|
137 | angulo_adq = numpy.zeros(blocksPerFile) | |||
|
138 | tmp = 0 | |||
|
139 | for j in range(blocksPerFile): | |||
|
140 | iterador = nro_key_perfil + 25*(j-tmp) | |||
|
141 | if iterador < n_perfiles_p: | |||
|
142 | nro_file = nro_file | |||
|
143 | else: | |||
|
144 | nro_file = nro_file+1 | |||
|
145 | tmp = j | |||
|
146 | iterador = nro_key_perfil | |||
|
147 | ff_pedestal = list_pedestal[nro_file] | |||
|
148 | angulo = getDatavaluefromDirFilename(path=dir_pedestal,file=ff_pedestal,value="azimuth") | |||
|
149 | angulo_adq[j]= angulo[iterador] | |||
|
150 | copyfile(dir_adq+"/"+list_adq[thisFile],wr_path+list_adq[thisFile]) | |||
|
151 | fp = h5py.File(wr_path+list_adq[thisFile],'a') | |||
|
152 | grp = fp.create_group("Pedestal") | |||
|
153 | dset = grp.create_dataset("azimuth" , data=angulo_adq) | |||
|
154 | fp.close() | |||
|
155 | print("Angulo",angulo_adq) | |||
|
156 | print("Angulo",len(angulo_adq)) | |||
|
157 | nro_key_perfil=iterador + 25 | |||
|
158 | if nro_key_perfil< n_perfiles_p: | |||
|
159 | nro_file = nro_file | |||
|
160 | else: | |||
|
161 | nro_file = nro_file+1 | |||
|
162 | nro_key_perfil= nro_key_p |
@@ -360,9 +360,11 class Voltage(JROData): | |||||
360 |
|
360 | |||
361 | # data es un numpy array de 2 dmensiones (canales, alturas) |
|
361 | # data es un numpy array de 2 dmensiones (canales, alturas) | |
362 | data = None |
|
362 | data = None | |
363 |
data |
|
363 | dataPP_POW = None | |
364 |
data |
|
364 | dataPP_DOP = None | |
365 |
data |
|
365 | dataPP_WIDTH = None | |
|
366 | dataPP_SNR = None | |||
|
367 | ||||
366 | def __init__(self): |
|
368 | def __init__(self): | |
367 | ''' |
|
369 | ''' | |
368 | Constructor |
|
370 | Constructor | |
@@ -1261,15 +1263,19 class PlotterData(object): | |||||
1261 | self.flagDataAsBlock = dataOut.flagDataAsBlock |
|
1263 | self.flagDataAsBlock = dataOut.flagDataAsBlock | |
1262 | self.nProfiles = dataOut.nProfiles |
|
1264 | self.nProfiles = dataOut.nProfiles | |
1263 | if plot == 'pp_power': |
|
1265 | if plot == 'pp_power': | |
1264 |
buffer = dataOut.data |
|
1266 | buffer = dataOut.dataPP_POWER | |
|
1267 | self.flagDataAsBlock = dataOut.flagDataAsBlock | |||
|
1268 | self.nProfiles = dataOut.nProfiles | |||
|
1269 | if plot == 'pp_signal': | |||
|
1270 | buffer = dataOut.dataPP_POW | |||
1265 | self.flagDataAsBlock = dataOut.flagDataAsBlock |
|
1271 | self.flagDataAsBlock = dataOut.flagDataAsBlock | |
1266 | self.nProfiles = dataOut.nProfiles |
|
1272 | self.nProfiles = dataOut.nProfiles | |
1267 | if plot == 'pp_velocity': |
|
1273 | if plot == 'pp_velocity': | |
1268 |
buffer = dataOut.data |
|
1274 | buffer = dataOut.dataPP_DOP | |
1269 | self.flagDataAsBlock = dataOut.flagDataAsBlock |
|
1275 | self.flagDataAsBlock = dataOut.flagDataAsBlock | |
1270 | self.nProfiles = dataOut.nProfiles |
|
1276 | self.nProfiles = dataOut.nProfiles | |
1271 | if plot == 'pp_specwidth': |
|
1277 | if plot == 'pp_specwidth': | |
1272 |
buffer = dataOut.data |
|
1278 | buffer = dataOut.dataPP_WIDTH | |
1273 | self.flagDataAsBlock = dataOut.flagDataAsBlock |
|
1279 | self.flagDataAsBlock = dataOut.flagDataAsBlock | |
1274 | self.nProfiles = dataOut.nProfiles |
|
1280 | self.nProfiles = dataOut.nProfiles | |
1275 |
|
1281 |
@@ -156,6 +156,8 class ScopePlot(Plot): | |||||
156 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) |
|
156 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) | |
157 | if self.CODE == "pp_power": |
|
157 | if self.CODE == "pp_power": | |
158 | scope = self.data['pp_power'] |
|
158 | scope = self.data['pp_power'] | |
|
159 | elif self.CODE == "pp_signal": | |||
|
160 | scope = self.data["pp_signal"] | |||
159 | elif self.CODE == "pp_velocity": |
|
161 | elif self.CODE == "pp_velocity": | |
160 | scope = self.data["pp_velocity"] |
|
162 | scope = self.data["pp_velocity"] | |
161 | elif self.CODE == "pp_specwidth": |
|
163 | elif self.CODE == "pp_specwidth": | |
@@ -191,6 +193,13 class ScopePlot(Plot): | |||||
191 | thisDatetime, |
|
193 | thisDatetime, | |
192 | wintitle |
|
194 | wintitle | |
193 | ) |
|
195 | ) | |
|
196 | if self.CODE=="pp_signal": | |||
|
197 | self.plot_weatherpower(self.data.heights, | |||
|
198 | scope[:,i,:], | |||
|
199 | channels, | |||
|
200 | thisDatetime, | |||
|
201 | wintitle | |||
|
202 | ) | |||
194 | if self.CODE=="pp_velocity": |
|
203 | if self.CODE=="pp_velocity": | |
195 | self.plot_weathervelocity(scope[:,i,:], |
|
204 | self.plot_weathervelocity(scope[:,i,:], | |
196 | self.data.heights, |
|
205 | self.data.heights, | |
@@ -230,6 +239,13 class ScopePlot(Plot): | |||||
230 | thisDatetime, |
|
239 | thisDatetime, | |
231 | wintitle |
|
240 | wintitle | |
232 | ) |
|
241 | ) | |
|
242 | if self.CODE=="pp_signal": | |||
|
243 | self.plot_weatherpower(self.data.heights, | |||
|
244 | scope, | |||
|
245 | channels, | |||
|
246 | thisDatetime, | |||
|
247 | wintitle | |||
|
248 | ) | |||
233 | if self.CODE=="pp_velocity": |
|
249 | if self.CODE=="pp_velocity": | |
234 | self.plot_weathervelocity(scope, |
|
250 | self.plot_weathervelocity(scope, | |
235 | self.data.heights, |
|
251 | self.data.heights, | |
@@ -249,7 +265,7 class ScopePlot(Plot): | |||||
249 |
|
265 | |||
250 | class PulsepairPowerPlot(ScopePlot): |
|
266 | class PulsepairPowerPlot(ScopePlot): | |
251 | ''' |
|
267 | ''' | |
252 | Plot for |
|
268 | Plot for P= S+N | |
253 | ''' |
|
269 | ''' | |
254 |
|
270 | |||
255 | CODE = 'pp_power' |
|
271 | CODE = 'pp_power' | |
@@ -259,7 +275,7 class PulsepairPowerPlot(ScopePlot): | |||||
259 |
|
275 | |||
260 | class PulsepairVelocityPlot(ScopePlot): |
|
276 | class PulsepairVelocityPlot(ScopePlot): | |
261 | ''' |
|
277 | ''' | |
262 | Plot for |
|
278 | Plot for VELOCITY | |
263 | ''' |
|
279 | ''' | |
264 | CODE = 'pp_velocity' |
|
280 | CODE = 'pp_velocity' | |
265 | plot_name = 'PulsepairVelocity' |
|
281 | plot_name = 'PulsepairVelocity' | |
@@ -268,9 +284,19 class PulsepairVelocityPlot(ScopePlot): | |||||
268 |
|
284 | |||
269 | class PulsepairSpecwidthPlot(ScopePlot): |
|
285 | class PulsepairSpecwidthPlot(ScopePlot): | |
270 | ''' |
|
286 | ''' | |
271 | Plot for |
|
287 | Plot for WIDTH | |
272 | ''' |
|
288 | ''' | |
273 | CODE = 'pp_specwidth' |
|
289 | CODE = 'pp_specwidth' | |
274 | plot_name = 'PulsepairSpecwidth' |
|
290 | plot_name = 'PulsepairSpecwidth' | |
275 | plot_type = 'scatter' |
|
291 | plot_type = 'scatter' | |
276 | buffering = False |
|
292 | buffering = False | |
|
293 | ||||
|
294 | class PulsepairSignalPlot(ScopePlot): | |||
|
295 | ''' | |||
|
296 | Plot for S | |||
|
297 | ''' | |||
|
298 | ||||
|
299 | CODE = 'pp_signal' | |||
|
300 | plot_name = 'PulsepairSignal' | |||
|
301 | plot_type = 'scatter' | |||
|
302 | buffering = False |
@@ -360,21 +360,27 class SimulatorReader(JRODataReader, ProcessingUnit): | |||||
360 | fd = Fdoppler #+(600.0/120)*self.nReadBlocks |
|
360 | fd = Fdoppler #+(600.0/120)*self.nReadBlocks | |
361 | d_signal = Adoppler*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64) |
|
361 | d_signal = Adoppler*numpy.array(numpy.exp(1.0j*2.0*math.pi*fd*time_vec),dtype=numpy.complex64) | |
362 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·SeΓ±al con ancho espectralΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
362 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·SeΓ±al con ancho espectralΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
363 | #specw_sig = numpy.linspace(-149,150,300) |
|
363 | if prof_gen%2==0: | |
364 | #w = 8 |
|
364 | min = int(prof_gen/2.0-1.0) | |
365 | #A = 20 |
|
365 | max = int(prof_gen/2.0) | |
366 | #specw_sig = specw_sig/w |
|
366 | else: | |
367 | #specw_sig = numpy.sinc(specw_sig) |
|
367 | min = int(prof_gen/2.0) | |
368 | #specw_sig = A*numpy.array(specw_sig,dtype=numpy.complex64) |
|
368 | max = int(prof_gen/2.0) | |
|
369 | specw_sig = numpy.linspace(-min,max,prof_gen) | |||
|
370 | w = 4 | |||
|
371 | A = 20 | |||
|
372 | specw_sig = specw_sig/w | |||
|
373 | specw_sig = numpy.sinc(specw_sig) | |||
|
374 | specw_sig = A*numpy.array(specw_sig,dtype=numpy.complex64) | |||
369 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLERΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
375 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLERΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
370 | HD=int(Hdoppler/self.AcqDH_0) |
|
376 | HD=int(Hdoppler/self.AcqDH_0) | |
371 | for i in range(12): |
|
377 | for i in range(12): | |
372 | self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ d_signal# RESULT |
|
378 | self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ d_signal# RESULT | |
373 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLER*Sinc(x)Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· |
|
379 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· DATABLOCK + DOPPLER*Sinc(x)Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
374 |
|
|
380 | HD=int(Hdoppler/self.AcqDH_0) | |
375 |
|
|
381 | HD=int(HD/2) | |
376 |
|
|
382 | for i in range(12): | |
377 |
|
|
383 | self.datablock[0,:,HD+i]=self.datablock[0,:,HD+i]+ specw_sig*d_signal# RESULT | |
378 |
|
384 | |||
379 | def readBlock(self): |
|
385 | def readBlock(self): | |
380 |
|
386 | |||
@@ -421,7 +427,8 class SimulatorReader(JRODataReader, ProcessingUnit): | |||||
421 | FixPP_CohInt= 1,Tau_0= 250,AcqH0_0 = 70 ,AcqDH_0=1.25, Bauds= 32, |
|
427 | FixPP_CohInt= 1,Tau_0= 250,AcqH0_0 = 70 ,AcqDH_0=1.25, Bauds= 32, | |
422 | FixRCP_TXA = 40, FixRCP_TXB = 50, fAngle = 2.0*math.pi*(1/16),DC_level= 50, |
|
428 | FixRCP_TXA = 40, FixRCP_TXB = 50, fAngle = 2.0*math.pi*(1/16),DC_level= 50, | |
423 | stdev= 8,Num_Codes = 1 , Dyn_snCode = None, samples=200, |
|
429 | stdev= 8,Num_Codes = 1 , Dyn_snCode = None, samples=200, | |
424 |
channels=2,Fdoppler=20,Hdoppler=36,Adoppler=500, |
|
430 | channels=2,Fdoppler=20,Hdoppler=36,Adoppler=500, | |
|
431 | profilesPerBlock=300,dataBlocksPerFile=120,nTotalReadFiles=10000, | |||
425 | **kwargs): |
|
432 | **kwargs): | |
426 |
|
433 | |||
427 | self.set_kwargs(**kwargs) |
|
434 | self.set_kwargs(**kwargs) | |
@@ -447,14 +454,14 class SimulatorReader(JRODataReader, ProcessingUnit): | |||||
447 | codeType=0, nCode=Num_Codes, nBaud=32, code=Dyn_snCode, |
|
454 | codeType=0, nCode=Num_Codes, nBaud=32, code=Dyn_snCode, | |
448 | flip1=0, flip2=0,Taus=Tau_0) |
|
455 | flip1=0, flip2=0,Taus=Tau_0) | |
449 |
|
456 | |||
450 |
self.set_PH(dtype=0, blockSize=0, profilesPerBlock= |
|
457 | self.set_PH(dtype=0, blockSize=0, profilesPerBlock=profilesPerBlock, | |
451 |
dataBlocksPerFile= |
|
458 | dataBlocksPerFile=dataBlocksPerFile, nWindows=1, processFlags=numpy.array([1024]), nCohInt=1, | |
452 | nIncohInt=1, totalSpectra=0, nHeights=samples, firstHeight=AcqH0_0, |
|
459 | nIncohInt=1, totalSpectra=0, nHeights=samples, firstHeight=AcqH0_0, | |
453 | deltaHeight=AcqDH_0, samplesWin=samples, spectraComb=0, nCode=0, |
|
460 | deltaHeight=AcqDH_0, samplesWin=samples, spectraComb=0, nCode=0, | |
454 | code=0, nBaud=None, shif_fft=False, flag_dc=False, |
|
461 | code=0, nBaud=None, shif_fft=False, flag_dc=False, | |
455 | flag_cspc=False, flag_decode=False, flag_deflip=False) |
|
462 | flag_cspc=False, flag_decode=False, flag_deflip=False) | |
456 |
|
463 | |||
457 |
self.set_SH(nSamples=samples, nProfiles= |
|
464 | self.set_SH(nSamples=samples, nProfiles=profilesPerBlock, nChannels=channels) | |
458 |
|
465 | |||
459 | self.readFirstHeader() |
|
466 | self.readFirstHeader() | |
460 |
|
467 |
@@ -109,6 +109,20 class ParametersProc(ProcessingUnit): | |||||
109 |
self.dataOut.flagNoData = False |
|
109 | self.dataOut.flagNoData = False | |
110 |
self.dataOut.utctimeInit = self.dataIn.utctime |
|
110 | self.dataOut.utctimeInit = self.dataIn.utctime | |
111 |
self.dataOut.paramInterval = self.dataIn.nProfiles*self.dataIn.nCohInt*self.dataIn.ippSeconds |
|
111 | self.dataOut.paramInterval = self.dataIn.nProfiles*self.dataIn.nCohInt*self.dataIn.ippSeconds | |
|
112 | if hasattr(self.dataIn, 'dataPP_POW'): | |||
|
113 | self.dataOut.dataPP_POW = self.dataIn.dataPP_POW | |||
|
114 | ||||
|
115 | if hasattr(self.dataIn, 'dataPP_POWER'): | |||
|
116 | self.dataOut.dataPP_POWER = self.dataIn.dataPP_POWER | |||
|
117 | ||||
|
118 | if hasattr(self.dataIn, 'dataPP_DOP'): | |||
|
119 | self.dataOut.dataPP_DOP = self.dataIn.dataPP_DOP | |||
|
120 | ||||
|
121 | if hasattr(self.dataIn, 'dataPP_SNR'): | |||
|
122 | self.dataOut.dataPP_SNR = self.dataIn.dataPP_SNR | |||
|
123 | ||||
|
124 | if hasattr(self.dataIn, 'dataPP_WIDTH'): | |||
|
125 | self.dataOut.dataPP_WIDTH = self.dataIn.dataPP_WIDTH | |||
112 |
return |
|
126 | return | |
113 |
|
127 | |||
114 |
#---------------------- Spectra Data --------------------------- |
|
128 | #---------------------- Spectra Data --------------------------- | |
@@ -3984,4 +3998,3 class SMOperations(): | |||||
3984 |
# error[indInvalid1] = 13 |
|
3998 | # error[indInvalid1] = 13 | |
3985 |
# |
|
3999 | # | |
3986 |
# return heights, error |
|
4000 | # return heights, error | |
3987 | No newline at end of file |
|
@@ -2,7 +2,7 import sys | |||||
2 | import numpy,math |
|
2 | import numpy,math | |
3 | from scipy import interpolate |
|
3 | from scipy import interpolate | |
4 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator |
|
4 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
5 | from schainpy.model.data.jrodata import Voltage |
|
5 | from schainpy.model.data.jrodata import Voltage,hildebrand_sekhon | |
6 | from schainpy.utils import log |
|
6 | from schainpy.utils import log | |
7 | from time import time |
|
7 | from time import time | |
8 |
|
8 | |||
@@ -1355,9 +1355,6 class PulsePairVoltage(Operation): | |||||
1355 | n, |
|
1355 | n, | |
1356 | dataOut.nHeights), |
|
1356 | dataOut.nHeights), | |
1357 | dtype='complex') |
|
1357 | dtype='complex') | |
1358 | #self.noise = numpy.zeros([self.__nch,self.__nHeis]) |
|
|||
1359 | #for i in range(self.__nch): |
|
|||
1360 | # self.noise[i]=dataOut.getNoise(channel=i) |
|
|||
1361 |
|
1358 | |||
1362 | def putData(self,data): |
|
1359 | def putData(self,data): | |
1363 | ''' |
|
1360 | ''' | |
@@ -1372,101 +1369,127 class PulsePairVoltage(Operation): | |||||
1372 | Return the PULSEPAIR and the profiles used in the operation |
|
1369 | Return the PULSEPAIR and the profiles used in the operation | |
1373 | Affected : self.__profileIndex |
|
1370 | Affected : self.__profileIndex | |
1374 | ''' |
|
1371 | ''' | |
|
1372 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Remove DCΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
1375 | if self.removeDC==True: |
|
1373 | if self.removeDC==True: | |
1376 | mean = numpy.mean(self.__buffer,1) |
|
1374 | mean = numpy.mean(self.__buffer,1) | |
1377 | tmp = mean.reshape(self.__nch,1,self.__nHeis) |
|
1375 | tmp = mean.reshape(self.__nch,1,self.__nHeis) | |
1378 | dc= numpy.tile(tmp,[1,self.__nProf,1]) |
|
1376 | dc= numpy.tile(tmp,[1,self.__nProf,1]) | |
1379 | self.__buffer = self.__buffer - dc |
|
1377 | self.__buffer = self.__buffer - dc | |
|
1378 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Calculo de Potencia Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
1379 | pair0 = self.__buffer*numpy.conj(self.__buffer) | |||
|
1380 | pair0 = pair0.real | |||
|
1381 | lag_0 = numpy.sum(pair0,1) | |||
|
1382 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Calculo de Ruido x canalΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
1383 | self.noise = numpy.zeros(self.__nch) | |||
|
1384 | for i in range(self.__nch): | |||
|
1385 | daux = numpy.sort(pair0[i,:,:],axis= None) | |||
|
1386 | self.noise[i]=hildebrand_sekhon( daux ,self.nCohInt) | |||
|
1387 | ||||
|
1388 | self.noise = self.noise.reshape(self.__nch,1) | |||
|
1389 | self.noise = numpy.tile(self.noise,[1,self.__nHeis]) | |||
|
1390 | noise_buffer = self.noise.reshape(self.__nch,1,self.__nHeis) | |||
|
1391 | noise_buffer = numpy.tile(noise_buffer,[1,self.__nProf,1]) | |||
|
1392 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Potencia recibida= P , Potencia senal = S , Ruido= NΒ·Β· | |||
|
1393 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· P= S+N ,P=lag_0/N Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
1394 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Power Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
1395 | data_power = lag_0/(self.n*self.nCohInt) | |||
|
1396 | #------------------ Senal Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
|
1397 | data_intensity = pair0 - noise_buffer | |||
|
1398 | data_intensity = numpy.sum(data_intensity,axis=1)*(self.n*self.nCohInt)#*self.nCohInt) | |||
|
1399 | #data_intensity = (lag_0-self.noise*self.n)*(self.n*self.nCohInt) | |||
|
1400 | for i in range(self.__nch): | |||
|
1401 | for j in range(self.__nHeis): | |||
|
1402 | if data_intensity[i][j] < 0: | |||
|
1403 | data_intensity[i][j] = numpy.min(numpy.absolute(data_intensity[i][j])) | |||
1380 |
|
1404 | |||
1381 | lag_0 = numpy.sum(self.__buffer*numpy.conj(self.__buffer),1) |
|
1405 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Calculo de Frecuencia y Velocidad dopplerΒ·Β·Β·Β·Β·Β·Β·Β· | |
1382 | data_intensity = lag_0/(self.n*self.nCohInt)#*self.nCohInt) |
|
|||
1383 |
|
||||
1384 | pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:]) |
|
1406 | pair1 = self.__buffer[:,:-1,:]*numpy.conjugate(self.__buffer[:,1:,:]) | |
1385 | lag_1 = numpy.sum(pair1,1) |
|
1407 | lag_1 = numpy.sum(pair1,1) | |
1386 | #angle = numpy.angle(numpy.sum(pair1,1))*180/(math.pi) |
|
1408 | data_freq = (-1/(2.0*math.pi*self.ippSec*self.nCohInt))*numpy.angle(lag_1) | |
1387 | data_velocity = (-1.0*self.lambda_/(4*math.pi*self.ippSec))*numpy.angle(lag_1)#self.ippSec*self.nCohInt |
|
1409 | data_velocity = (self.lambda_/2.0)*data_freq | |
1388 |
|
1410 | |||
1389 | self.noise = numpy.zeros([self.__nch,self.__nHeis]) |
|
1411 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Potencia promedio estimada de la SenalΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
1390 | for i in range(self.__nch): |
|
1412 | lag_0 = lag_0/self.n | |
1391 | self.noise[i]=dataOut.getNoise(channel=i) |
|
1413 | S = lag_0-self.noise | |
1392 |
|
1414 | |||
1393 | lag_0 = lag_0.real/(self.n) |
|
1415 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Frecuencia Doppler promedio Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |
1394 | lag_1 = lag_1/(self.n-1) |
|
1416 | lag_1 = lag_1/(self.n-1) | |
1395 | R1 = numpy.abs(lag_1) |
|
1417 | R1 = numpy.abs(lag_1) | |
1396 | S = (lag_0-self.noise) |
|
|||
1397 |
|
1418 | |||
|
1419 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Calculo del SNRΒ·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
1398 | data_snrPP = S/self.noise |
|
1420 | data_snrPP = S/self.noise | |
1399 | data_snrPP = numpy.where(data_snrPP<0,1,data_snrPP) |
|
1421 | for i in range(self.__nch): | |
|
1422 | for j in range(self.__nHeis): | |||
|
1423 | if data_snrPP[i][j] < 1.e-20: | |||
|
1424 | data_snrPP[i][j] = 1.e-20 | |||
1400 |
|
1425 | |||
|
1426 | #Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· Calculo del ancho espectral Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β· | |||
1401 | L = S/R1 |
|
1427 | L = S/R1 | |
1402 | L = numpy.where(L<0,1,L) |
|
1428 | L = numpy.where(L<0,1,L) | |
1403 | L = numpy.log(L) |
|
1429 | L = numpy.log(L) | |
1404 |
|
||||
1405 | tmp = numpy.sqrt(numpy.absolute(L)) |
|
1430 | tmp = numpy.sqrt(numpy.absolute(L)) | |
1406 |
|
1431 | data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec*self.nCohInt))*tmp*numpy.sign(L) | ||
1407 | data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec))*tmp*numpy.sign(L) |
|
|||
1408 | #data_specwidth = (self.lambda_/(2*math.sqrt(2)*math.pi*self.ippSec))*k |
|
|||
1409 | n = self.__profIndex |
|
1432 | n = self.__profIndex | |
1410 |
|
1433 | |||
1411 | self.__buffer = numpy.zeros((self.__nch, self.__nProf,self.__nHeis), dtype='complex') |
|
1434 | self.__buffer = numpy.zeros((self.__nch, self.__nProf,self.__nHeis), dtype='complex') | |
1412 | self.__profIndex = 0 |
|
1435 | self.__profIndex = 0 | |
1413 | return data_intensity,data_velocity,data_snrPP,data_specwidth,n |
|
1436 | return data_power,data_intensity,data_velocity,data_snrPP,data_specwidth,n | |
|
1437 | ||||
1414 |
|
1438 | |||
1415 | def pulsePairbyProfiles(self,dataOut): |
|
1439 | def pulsePairbyProfiles(self,dataOut): | |
1416 |
|
1440 | |||
1417 | self.__dataReady = False |
|
1441 | self.__dataReady = False | |
|
1442 | data_power = None | |||
1418 | data_intensity = None |
|
1443 | data_intensity = None | |
1419 | data_velocity = None |
|
1444 | data_velocity = None | |
1420 | data_specwidth = None |
|
1445 | data_specwidth = None | |
1421 | data_snrPP = None |
|
1446 | data_snrPP = None | |
1422 | self.putData(data=dataOut.data) |
|
1447 | self.putData(data=dataOut.data) | |
1423 | if self.__profIndex == self.n: |
|
1448 | if self.__profIndex == self.n: | |
1424 | #self.noise = numpy.zeros([self.__nch,self.__nHeis]) |
|
1449 | data_power,data_intensity, data_velocity,data_snrPP,data_specwidth, n = self.pushData(dataOut=dataOut) | |
1425 | #for i in range(self.__nch): |
|
|||
1426 | # self.noise[i]=data.getNoise(channel=i) |
|
|||
1427 | #print(self.noise.shape) |
|
|||
1428 | data_intensity, data_velocity,data_snrPP,data_specwidth, n = self.pushData(dataOut=dataOut) |
|
|||
1429 | self.__dataReady = True |
|
1450 | self.__dataReady = True | |
1430 |
|
1451 | |||
1431 | return data_intensity, data_velocity,data_snrPP,data_specwidth |
|
1452 | return data_power, data_intensity, data_velocity, data_snrPP, data_specwidth | |
|
1453 | ||||
1432 |
|
1454 | |||
1433 | def pulsePairOp(self, dataOut, datatime= None): |
|
1455 | def pulsePairOp(self, dataOut, datatime= None): | |
1434 |
|
1456 | |||
1435 | if self.__initime == None: |
|
1457 | if self.__initime == None: | |
1436 | self.__initime = datatime |
|
1458 | self.__initime = datatime | |
1437 | #print("hola") |
|
1459 | data_power, data_intensity, data_velocity, data_snrPP, data_specwidth = self.pulsePairbyProfiles(dataOut) | |
1438 | data_intensity, data_velocity,data_snrPP,data_specwidth = self.pulsePairbyProfiles(dataOut) |
|
|||
1439 | self.__lastdatatime = datatime |
|
1460 | self.__lastdatatime = datatime | |
1440 |
|
1461 | |||
1441 |
if data_ |
|
1462 | if data_power is None: | |
1442 | return None, None,None,None,None |
|
1463 | return None, None, None,None,None,None | |
1443 |
|
1464 | |||
1444 | avgdatatime = self.__initime |
|
1465 | avgdatatime = self.__initime | |
1445 | deltatime = datatime - self.__lastdatatime |
|
1466 | deltatime = datatime - self.__lastdatatime | |
1446 | self.__initime = datatime |
|
1467 | self.__initime = datatime | |
1447 |
|
1468 | |||
1448 | return data_intensity, data_velocity,data_snrPP,data_specwidth,avgdatatime |
|
1469 | return data_power, data_intensity, data_velocity, data_snrPP, data_specwidth, avgdatatime | |
1449 |
|
1470 | |||
1450 | def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs): |
|
1471 | def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs): | |
1451 |
|
1472 | |||
1452 | if not self.isConfig: |
|
1473 | if not self.isConfig: | |
1453 | self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs) |
|
1474 | self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs) | |
1454 | self.isConfig = True |
|
1475 | self.isConfig = True | |
1455 | data_intensity, data_velocity,data_snrPP,data_specwidth, avgdatatime = self.pulsePairOp(dataOut, dataOut.utctime) |
|
1476 | data_power, data_intensity, data_velocity,data_snrPP,data_specwidth, avgdatatime = self.pulsePairOp(dataOut, dataOut.utctime) | |
1456 | dataOut.flagNoData = True |
|
1477 | dataOut.flagNoData = True | |
1457 |
|
1478 | |||
1458 | if self.__dataReady: |
|
1479 | if self.__dataReady: | |
1459 | dataOut.nCohInt *= self.n |
|
1480 | dataOut.nCohInt *= self.n | |
1460 |
dataOut.data |
|
1481 | dataOut.dataPP_POW = data_intensity # S | |
1461 |
dataOut.data |
|
1482 | dataOut.dataPP_POWER = data_power # P | |
1462 |
dataOut.data |
|
1483 | dataOut.dataPP_DOP = data_velocity | |
1463 |
dataOut.data |
|
1484 | dataOut.dataPP_SNR = data_snrPP | |
|
1485 | dataOut.dataPP_WIDTH = data_specwidth | |||
1464 | dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo. |
|
1486 | dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo. | |
1465 | dataOut.utctime = avgdatatime |
|
1487 | dataOut.utctime = avgdatatime | |
1466 | dataOut.flagNoData = False |
|
1488 | dataOut.flagNoData = False | |
1467 | return dataOut |
|
1489 | return dataOut | |
1468 |
|
1490 | |||
1469 |
|
1491 | |||
|
1492 | ||||
1470 | # import collections |
|
1493 | # import collections | |
1471 | # from scipy.stats import mode |
|
1494 | # from scipy.stats import mode | |
1472 | # |
|
1495 | # |
@@ -25,8 +25,20 readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader', | |||||
25 | delay=0, |
|
25 | delay=0, | |
26 | online=0, |
|
26 | online=0, | |
27 | walk=0, |
|
27 | walk=0, | |
28 |
|
|
28 | profilesPerBlock=625, | |
29 |
|
29 | dataBlocksPerFile=100)#,#nTotalReadFiles=2) | ||
|
30 | ''' | |||
|
31 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |||
|
32 | path=path, | |||
|
33 | startDate="2020/01/01", #"2020/01/01",#today, | |||
|
34 | endDate= "2020/12/01", #"2020/12/30",#today, | |||
|
35 | startTime='00:00:00', | |||
|
36 | endTime='23:59:59', | |||
|
37 | delay=0, | |||
|
38 | #set=0, | |||
|
39 | online=0, | |||
|
40 | walk=1) | |||
|
41 | ''' | |||
30 | opObj11 = readUnitConfObj.addOperation(name='printInfo') |
|
42 | opObj11 = readUnitConfObj.addOperation(name='printInfo') | |
31 |
|
43 | |||
32 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
44 | procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
@@ -36,14 +48,26 procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=rea | |||||
36 | #opObj10 = procUnitConfObjA.addOperation(name='selectChannels') |
|
48 | #opObj10 = procUnitConfObjA.addOperation(name='selectChannels') | |
37 | #opObj10.addParameter(name='channelList', value=[0]) |
|
49 | #opObj10.addParameter(name='channelList', value=[0]) | |
38 | opObj11 = procUnitConfObjA.addOperation(name='PulsePairVoltage', optype='other') |
|
50 | opObj11 = procUnitConfObjA.addOperation(name='PulsePairVoltage', optype='other') | |
39 |
opObj11.addParameter(name='n', value=' |
|
51 | opObj11.addParameter(name='n', value='625', format='int')#10 | |
40 | opObj11.addParameter(name='removeDC', value=1, format='int') |
|
52 | opObj11.addParameter(name='removeDC', value=1, format='int') | |
41 |
|
53 | |||
42 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') |
|
54 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') | |
|
55 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') | |||
|
56 | ||||
43 |
|
57 | |||
44 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') |
|
58 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') | |
45 | #opObj11.addParameter(name='xmax', value=8) |
|
59 | #opObj11.addParameter(name='xmax', value=8) | |
46 |
|
60 | |||
47 | opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') |
|
61 | #opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') | |
|
62 | ||||
|
63 | procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) | |||
|
64 | ||||
|
65 | ||||
|
66 | opObj10 = procUnitConfObjB.addOperation(name='ParameterWriter') | |||
|
67 | opObj10.addParameter(name='path',value=figpath) | |||
|
68 | #opObj10.addParameter(name='mode',value=0) | |||
|
69 | opObj10.addParameter(name='blocksPerFile',value='100',format='int') | |||
|
70 | opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list') | |||
|
71 | opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH')#,format='list' | |||
48 |
|
72 | |||
49 | controllerObj.start() |
|
73 | controllerObj.start() |
General Comments 0
You need to be logged in to leave comments.
Login now