##// END OF EJS Templates
Valley Densities Proc
rflores -
r1707:21f41e756eb1
parent child
Show More
@@ -756,6 +756,89 class EDensityPlot(Plot):
756 756 plt.legend(loc='upper left',fontsize=8.5)
757 757 #plt.legend(loc='lower left',fontsize=8.5)
758 758
759 class RelativeDenPlot(Plot):
760 '''
761 Written by R. Flores
762 '''
763 '''
764 Plot for electron density
765 '''
766
767 CODE = 'den'
768 #plot_name = 'Electron Density'
769 plot_type = 'scatterbuffer'
770
771 def setup(self):
772
773 self.ncols = 1
774 self.nrows = 1
775 self.nplots = 1
776 self.ylabel = 'Range [km]'
777 self.xlabel = r'$\mathrm{N_e}$ Relative Electron Density ($\mathrm{1/cm^3}$)'
778 self.titles = ['Electron Density']
779 self.width = 3.5
780 self.height = 5.5
781 self.colorbar = False
782 self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1})
783
784 def update(self, dataOut):
785 data = {}
786 meta = {}
787
788 data['den_power'] = dataOut.ph2
789 data['den_error'] = dataOut.sdp2
790
791 meta['yrange'] = dataOut.heightList
792
793 return data, meta
794
795 def plot(self):
796
797 y = self.data.yrange
798
799 ax = self.axes[0]
800
801 data = self.data[-1]
802
803 DenPow = data['den_power']
804 errDenPow = data['den_error']
805
806 if ax.firsttime:
807 self.autoxticks=False
808 ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
809
810 plt.legend(loc='upper left',fontsize=8.5)
811 #plt.legend(loc='lower left',fontsize=8.5)
812 ax.set_xscale("log", nonposx='clip')
813 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
814 self.ystep_given=100
815 ax.set_yticks(grid_y_ticks,minor=True)
816 locmaj = LogLocator(base=10,numticks=12)
817 ax.xaxis.set_major_locator(locmaj)
818 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
819 ax.xaxis.set_minor_locator(locmin)
820 ax.xaxis.set_minor_formatter(NullFormatter())
821 ax.grid(which='minor')
822
823 else:
824 dataBefore = self.data[-2]
825 DenPowBefore = dataBefore['den_power']
826 self.clear_figures()
827 ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-')
828 ax.errorbar(DenPowBefore, y, elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed")
829
830 ax.set_xscale("log", nonposx='clip')
831 grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50)
832 ax.set_yticks(grid_y_ticks,minor=True)
833 locmaj = LogLocator(base=10,numticks=12)
834 ax.xaxis.set_major_locator(locmaj)
835 locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12)
836 ax.xaxis.set_minor_locator(locmin)
837 ax.xaxis.set_minor_formatter(NullFormatter())
838 ax.grid(which='minor')
839 plt.legend(loc='upper left',fontsize=8.5)
840 #plt.legend(loc='lower left',fontsize=8.5)
841
759 842 class FaradayAnglePlot(Plot):
760 843 '''
761 844 Written by R. Flores
@@ -360,13 +360,14 class HDFWriter(Operation):
360 360 Operation.__init__(self)
361 361 return
362 362
363 def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None):
363 def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None, uniqueChannel=False):
364 364 self.path = path
365 365 self.blocksPerFile = blocksPerFile
366 366 self.metadataList = metadataList
367 367 self.dataList = [s.strip() for s in dataList]
368 368 self.setType = setType
369 369 self.description = description
370 self.uniqueChannel = uniqueChannel
370 371
371 372 if self.metadataList is None:
372 373 self.metadataList = self.dataOut.metadata_list
@@ -388,6 +389,9 class HDFWriter(Operation):
388 389 elif isinstance(dataAux, (int, float, numpy.integer, numpy.float)):
389 390 dsDict['nDim'] = 0
390 391 else:
392 if uniqueChannel: #Creates extra dimension to avoid the creation of multiple channels
393 dataAux = numpy.expand_dims(dataAux, axis=0)
394
391 395 dsDict['nDim'] = len(dataAux.shape)
392 396 dsDict['shape'] = dataAux.shape
393 397 dsDict['dsNumber'] = dataAux.shape[0]
@@ -422,18 +426,19 class HDFWriter(Operation):
422 426 return False
423 427
424 428 def run(self, dataOut, path, blocksPerFile=10, metadataList=None,
425 dataList=[], setType=None, description={}):
429 dataList=[], setType=None, description={}, uniqueChannel= False):
426 430
427 431 self.dataOut = dataOut
428 432 if not(self.isConfig):
429 433 self.setup(path=path, blocksPerFile=blocksPerFile,
430 434 metadataList=metadataList, dataList=dataList,
431 setType=setType, description=description)
435 setType=setType, description=description, uniqueChannel=uniqueChannel)
432 436
433 437 self.isConfig = True
434 438 self.setNextFile()
435 439
436 440 self.putData()
441
437 442 return
438 443
439 444 def setNextFile(self):
@@ -490,7 +495,7 class HDFWriter(Operation):
490 495 self.writeData(self.fp)
491 496
492 497 def getLabel(self, name, x=None):
493
498 #print("x: ", x)
494 499 if x is None:
495 500 if 'Data' in self.description:
496 501 data = self.description['Data']
@@ -558,7 +563,7 class HDFWriter(Operation):
558 563
559 564 dtsets = []
560 565 data = []
561
566 #print("self.dsList: ", self.dsList)
562 567 for dsInfo in self.dsList:
563 568 if dsInfo['nDim'] == 0:
564 569 ds = grp.create_dataset(
@@ -582,6 +587,11 class HDFWriter(Operation):
582 587 dtype=dsInfo['dtype'])
583 588 dtsets.append(ds)
584 589 data.append((dsInfo['variable'], i))
590
591 if self.uniqueChannel: #Deletes extra dimension created to avoid the creation of multiple channels
592 dataAux = getattr(self.dataOut, dsInfo['variable'])
593 dataAux = dataAux[0]
594
585 595 fp.flush()
586 596
587 597 log.log('Creating file: {}'.format(fp.filename), self.name)
@@ -779,6 +779,73 class removeInterference(Operation):
779 779
780 780 return self.dataOut
781 781
782 class removeInterferenceAtFreq(Operation):
783 '''
784 Written by R. Flores
785 '''
786 """Operation to remove interfernce at a known frequency(s).
787
788 Parameters:
789 -----------
790 None
791
792 Example
793 --------
794
795 op = proc_unit.addOperation(name='removeInterferenceAtFreq')
796
797 """
798
799 def __init__(self):
800
801 Operation.__init__(self)
802
803 def run(self, dataOut, freq = None, freqList = None):
804
805 VelRange = dataOut.getVelRange()
806 #print("VelRange: ", VelRange)
807
808 freq_ids = []
809
810 if freq is not None:
811 #print("freq")
812 #if freq < 0:
813 inda = numpy.where(VelRange >= freq)
814 minIndex = inda[0][0]
815 #print(numpy.shape(dataOut.dataLag_spc))
816 dataOut.data_spc[:,minIndex,:] = numpy.nan
817
818 #inda = numpy.where(VelRange >= ymin_noise)
819 #indb = numpy.where(VelRange <= ymax_noise)
820
821 #minIndex = inda[0][0]
822 #maxIndex = indb[0][-1]
823
824 elif freqList is not None:
825 #print("freqList")
826 for freq in freqList:
827 #if freq < 0:
828 inda = numpy.where(VelRange >= freq)
829 minIndex = inda[0][0]
830 #print(numpy.shape(dataOut.dataLag_spc))
831 if freq > 0:
832 #dataOut.data_spc[:,minIndex-1,:] = numpy.nan
833 freq_ids.append(minIndex-1)
834 else:
835 #dataOut.data_spc[:,minIndex,:] = numpy.nan
836 freq_ids.append(minIndex)
837 else:
838 raise ValueError("freq or freqList should be specified ...")
839
840 #freq_ids = numpy.array(freq_ids).flatten()
841
842 avg = numpy.mean(dataOut.data_spc[:,[t for t in range(dataOut.data_spc.shape[0]) if t not in freq_ids],:],axis=1)
843
844 for p in list(freq_ids):
845 dataOut.data_spc[:,p,:] = avg#numpy.nan
846
847
848 return dataOut
782 849
783 850 class IncohInt(Operation):
784 851
@@ -2877,8 +2877,8 class IntegrationFaradaySpectraNoLags(Operation):
2877 2877 self.__lastdatatime = 0
2878 2878
2879 2879 self.__buffer_spc = []
2880 #self.__buffer_cspc = []
2881 self.__buffer_cspc = None
2880 self.__buffer_cspc = []
2881 #self.__buffer_cspc = None
2882 2882 self.__buffer_dc = 0
2883 2883
2884 2884 self.__profIndex = 0
@@ -3210,9 +3210,9 class IntegrationFaradaySpectraNoLags(Operation):
3210 3210 #print(self.__buffer_spc[:,1,3,20,0])
3211 3211 #print(self.__buffer_spc[:,1,5,37,0])
3212 3212 data_spc = numpy.sum(self.__buffer_spc,axis=0)
3213 print("data_spc: ", data_spc[0,:,0])
3214 print("data_spc: ", data_spc[0,:,7])
3215 print("shape: ", numpy.shape(data_spc))
3213 #print("data_spc: ", data_spc[0,:,0])
3214 #print("data_spc: ", data_spc[0,:,7])
3215 #print("shape: ", numpy.shape(data_spc))
3216 3216 #exit(1)
3217 3217 #data_cspc = numpy.sum(self.__buffer_cspc,axis=0)
3218 3218 if self.__buffer_cspc is not None:
@@ -3228,8 +3228,8 class IntegrationFaradaySpectraNoLags(Operation):
3228 3228 n = self.__profIndex
3229 3229
3230 3230 self.__buffer_spc = []
3231 #self.__buffer_cspc = []
3232 self.__buffer_cspc = None
3231 self.__buffer_cspc = []
3232 #self.__buffer_cspc = None
3233 3233 self.__buffer_dc = 0
3234 3234 self.__profIndex = 0
3235 3235
@@ -3292,12 +3292,13 class IntegrationFaradaySpectraNoLags(Operation):
3292 3292 #print(numpy.shape(dataOut.data_spc))
3293 3293 #print(numpy.shape(dataOut.data_cspc))
3294 3294 #exit(1)
3295 dataOut.data_cspc = None
3295 #dataOut.data_cspc = None
3296 3296 if not self.isConfig:
3297 3297 self.setup(dataOut, n, timeInterval, overlapping,DPL )
3298 3298 self.isConfig = True
3299 3299
3300 3300 if not self.ByLags:
3301 #print("dataOut.data_cspc: ", dataOut.data_cspc)
3301 3302 self.nProfiles=dataOut.nProfiles
3302 3303 self.nChannels=dataOut.nChannels
3303 3304 self.nHeights=dataOut.nHeights
@@ -3320,6 +3321,7 class IntegrationFaradaySpectraNoLags(Operation):
3320 3321
3321 3322 dataOut.data_spc = numpy.squeeze(avgdata_spc)
3322 3323 dataOut.data_cspc = numpy.squeeze(avgdata_cspc)
3324 dataOut.data_cspc = numpy.expand_dims(dataOut.data_cspc, axis=0)
3323 3325 dataOut.data_dc = avgdata_dc
3324 3326 else:
3325 3327 dataOut.dataLag_spc = avgdata_spc
@@ -4290,7 +4292,7 class SpectraDataToFaraday_MST(Operation): #MST MODE
4290 4292 dataOut.pan = dataOut.tnoise[0]
4291 4293 dataOut.pbn = dataOut.tnoise[1]
4292 4294
4293 def noise(self,dataOut):
4295 def noise(self,dataOut,minIndex,maxIndex):
4294 4296
4295 4297 dataOut.noise_lag = numpy.zeros((dataOut.nChannels),'float32')
4296 4298 #print("Lags")
@@ -4312,9 +4314,9 class SpectraDataToFaraday_MST(Operation): #MST MODE
4312 4314 #dataOut.noise_lag[1] = dataOut.getNoise(ymin_index=80,ymax_index=106)[1]
4313 4315 if dataOut.flagDecodeData:
4314 4316 #dataOut.noise_lag[1] = dataOut.getNoise(ymin_index=150,ymax_index=200)[1]
4315 dataOut.noise_lag[1] = dataOut.getNoise()[1]
4317 dataOut.noise_lag[1] = dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[1]
4316 4318 else:
4317 dataOut.noise_lag[1] = dataOut.getNoise()[1]
4319 dataOut.noise_lag[1] = dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[1]
4318 4320 #else:
4319 4321 #dataOut.noise_lag[1,lag] = numpy.mean(dataOut.noise_lag[1,:6])
4320 4322 #dataOut.noise_lag[:,lag] = dataOut.getNoise(ymin_index=33,ymax_index=46)
@@ -4324,9 +4326,9 class SpectraDataToFaraday_MST(Operation): #MST MODE
4324 4326 dataOut.data_spc = dataOut.dataLag_spc[:,:,:,0]
4325 4327 if dataOut.flagDecodeData:
4326 4328 #dataOut.noise_lag[0] = dataOut.getNoise(ymin_index=150,ymax_index=200)[0]
4327 dataOut.noise_lag[0] = dataOut.getNoise()[0]
4329 dataOut.noise_lag[0] = dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[0]
4328 4330 else:
4329 dataOut.noise_lag[0] = dataOut.getNoise()[0]
4331 dataOut.noise_lag[0] = dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[0]
4330 4332
4331 4333 dataOut.tnoise = dataOut.noise_lag/float(dataOut.nProfiles*dataOut.nIncohInt)
4332 4334 #dataOut.tnoise /= float(dataOut.nProfiles*dataOut.nIncohInt)
@@ -4392,12 +4394,7 class SpectraDataToFaraday_MST(Operation): #MST MODE
4392 4394 input()
4393 4395 '''
4394 4396
4395
4396
4397
4398
4399
4400 def run(self,dataOut):
4397 def run(self,dataOut,ymin_noise = None,ymax_noise = None):
4401 4398
4402 4399 dataOut.paramInterval=0#int(dataOut.nint*dataOut.header[7][0]*2 )
4403 4400 dataOut.lat=-11.95
@@ -4421,28 +4418,52 class SpectraDataToFaraday_MST(Operation): #MST MODE
4421 4418 dataOut.data_spc /= dataOut.windowOfFilter
4422 4419 dataOut.data_cspc /= dataOut.windowOfFilter
4423 4420 '''
4424 #print(dataOut.data_spc.shape)
4425 print("*****************Sum: ", numpy.sum(dataOut.data_spc[0]))
4426 print("*******************normFactor: *******************", dataOut.normFactor)
4421 #print("dataOut.data_spc.shape: ", dataOut.data_spc.shape)
4422 #print("dataOut.data_cspc.shape: ", dataOut.data_cspc.shape)
4423 #print("*****************Sum: ", numpy.sum(dataOut.data_spc[0]))
4424 #print("*******************normFactor: *******************", dataOut.normFactor)
4427 4425 dataOut.dataLag_spc = numpy.stack((dataOut.data_spc, dataOut.data_spc), axis=-1)
4428 4426 dataOut.dataLag_cspc = numpy.stack((dataOut.data_cspc, dataOut.data_cspc), axis=-1)
4429 4427 #print(dataOut.dataLag_spc.shape)
4430 4428 dataOut.DPL = numpy.shape(dataOut.dataLag_spc)[-1]
4429
4431 4430 #exit(1)
4432 4431 self.ConvertData(dataOut)
4433 self.noise(dataOut)
4432
4433 inda = numpy.where(dataOut.heightList >= ymin_noise)
4434 indb = numpy.where(dataOut.heightList <= ymax_noise)
4435
4436 minIndex = inda[0][0]
4437 maxIndex = indb[0][-1]
4438
4439 #print("ymin_noise: ", dataOut.heightList[minIndex])
4440 #print("ymax_noise: ", dataOut.heightList[maxIndex])
4441
4442 self.noise(dataOut,minIndex,maxIndex)
4434 4443 dataOut.NAVG=16#dataOut.rnint2[0] #CHECK THIS!
4435 4444 dataOut.MAXNRANGENDT=dataOut.NDP
4436 '''
4437 if dataOut.flagDecodeData:
4438 print(dataOut.kabxys_integrated[4][:,0,0])
4445 #'''
4446 if 0:
4447 #print(dataOut.kabxys_integrated[4][:,0,0])
4448 #print("dataOut.heightList: ", dataOut.heightList)
4449 #print("dataOut.pbn: ", dataOut.pbn)
4450 print("INSIDE")
4439 4451 import matplotlib.pyplot as plt
4440 plt.plot(dataOut.kabxys_integrated[4][:,0,0],dataOut.heightList)
4441 plt.axvline(dataOut.pan)
4442 plt.xlim(1.1*1e3,0.6*1e6)
4443 plt.ylim(30,90)
4452 #print("dataOut.getPower(): ", dataOut.getPower())
4453 plt.plot(10*numpy.log10(dataOut.kabxys_integrated[4][:,0,0]),dataOut.heightList)
4454 #plt.plot(10**((dataOut.getPower()[1])/10),dataOut.heightList)
4455 #plt.plot(dataOut.getPower()[0],dataOut.heightList)
4456 #plt.plot(dataOut.dataLag_spc[:,:,:,0],dataOut.heightList)
4457 plt.axvline(10*numpy.log10(dataOut.pan))
4458 #print(dataOut.nProfiles)
4459 #plt.axvline(10*numpy.log10(1*dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[0]/dataOut.normFactor))
4460 #print("10*numpy.log10(dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[1]/dataOut.normFactor): ", 10*numpy.log10(dataOut.getNoise(ymin_index=minIndex,ymax_index=maxIndex)[1]/dataOut.normFactor))
4461 #plt.xlim(1,25000)
4462 #plt.xlim(15,20)
4463 #plt.ylim(30,90)
4464 plt.grid()
4444 4465 plt.show()
4445 '''
4466 #'''
4446 4467 dataOut.DPL = 1
4447 4468 return dataOut
4448 4469
@@ -3115,6 +3115,8 class DoublePulseACFs(Operation):
3115 3115 dataOut.p[i,j]=pa+pb-(dataOut.pan+dataOut.pbn)
3116 3116 '''
3117 3117 #print("init 2.6",pa,dataOut.pan)
3118 #dataOut.pan = 23600/2
3119 #dataOut.pbn = 23600/2
3118 3120 dataOut.p[i,j]=pa+pb-(dataOut.pan+dataOut.pbn)
3119 3121 #print(i,j,dataOut.p[i,j])
3120 3122 dataOut.sdp[i,j]=2*dataOut.rnint2[j]*((pa+pb)*(pa+pb))
@@ -3122,7 +3124,16 class DoublePulseACFs(Operation):
3122 3124
3123 3125 rhorp=dataOut.kabxys_integrated[8][i,j,0]+dataOut.kabxys_integrated[11][i,j,0]
3124 3126 rhoip=dataOut.kabxys_integrated[10][i,j,0]-dataOut.kabxys_integrated[9][i,j,0]
3125
3127 '''
3128 import matplotlib.pyplot as plt
3129 plt.plot(numpy.abs(dataOut.kabxys_integrated[4][:,j,0]+dataOut.kabxys_integrated[5][:,j,0])+numpy.abs(dataOut.kabxys_integrated[6][:,j,0]+dataOut.kabxys_integrated[7][:,j,0]),dataOut.heightList)
3130 plt.axvline((dataOut.pan+dataOut.pbn))
3131 plt.xlim(20000,30000)
3132 #plt.plot(numpy.abs(dataOut.kabxys_integrated[4][:,j,0]+dataOut.kabxys_integrated[5][:,j,0])+numpy.abs(dataOut.kabxys_integrated[6][:,j,0]+dataOut.kabxys_integrated[7][:,j,0])-(dataOut.pan+dataOut.pbn),dataOut.heightList)
3133 #plt.xlim(1,10000)
3134 plt.grid()
3135 plt.show()
3136 '''
3126 3137 if ((pa>dataOut.pan)&(pb>dataOut.pbn)):
3127 3138
3128 3139 ss4=numpy.abs((pa-dataOut.pan)*(pb-dataOut.pbn))
@@ -3206,6 +3217,18 class DoublePulseACFs(Operation):
3206 3217 #print("p: ",dataOut.p[33,:])
3207 3218 #exit(1)
3208 3219 #'''
3220 '''
3221 import matplotlib.pyplot as plt
3222 #plt.plot(numpy.abs(dataOut.kabxys_integrated[4][:,j,0]+dataOut.kabxys_integrated[5][:,j,0])+numpy.abs(dataOut.kabxys_integrated[6][:,j,0]+dataOut.kabxys_integrated[7][:,j,0]),dataOut.heightList)
3223 #plt.axvline((dataOut.pan+dataOut.pbn))
3224 print(numpy.shape(dataOut.p))
3225 plt.plot(dataOut.p[:,0]*dataOut.heightList*dataOut.heightList,dataOut.heightList)
3226
3227 #plt.xlim(1,100000000)
3228 plt.xlim(100,100000000)
3229 plt.grid()
3230 plt.show()
3231 '''
3209 3232 #print(numpy.sum(dataOut.rhor))
3210 3233 #exit(1)
3211 3234 return dataOut
@@ -3442,9 +3465,19 class FaradayAngleAndDPPower(Operation):
3442 3465 dataOut.flagTeTiCorrection = False
3443 3466 #print("ph2: ", numpy.sum(dataOut.ph2[:16]))
3444 3467 #print("ph2: ", numpy.sum(dataOut.ph2[16:32]))
3468 '''
3469 import matplotlib.pyplot as plt
3470 #plt.plot(numpy.abs(dataOut.kabxys_integrated[4][:,j,0]+dataOut.kabxys_integrated[5][:,j,0])+numpy.abs(dataOut.kabxys_integrated[6][:,j,0]+dataOut.kabxys_integrated[7][:,j,0]),dataOut.heightList)
3471 #plt.axvline((dataOut.pan+dataOut.pbn))
3472 #print(numpy.shape(dataOut.p))
3473 plt.plot(dataOut.ph2,dataOut.heightList)
3445 3474
3475 plt.xlim(1000,1000000000)
3476 #plt.ylim(50,400)
3477 plt.grid()
3478 plt.show()
3446 3479 #exit(1)
3447
3480 '''
3448 3481 return dataOut
3449 3482
3450 3483
General Comments 0
You need to be logged in to leave comments. Login now