import os import sys import glob import fnmatch import datetime import time import re import h5py import numpy from scipy.optimize import curve_fit from scipy import asarray as ar, exp from scipy import stats from numpy.ma.core import getdata SPEED_OF_LIGHT = 299792458 SPEED_OF_LIGHT = 3e8 try: from gevent import sleep except: from time import sleep from schainpy.model.data.jrodata import Spectra #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation #from schainpy.model.io.jroIO_bltr import BLTRReader from numpy import imag, shape, NaN, empty class Header(object): def __init__(self): raise NotImplementedError def read(self): raise NotImplementedError def write(self): raise NotImplementedError def printInfo(self): message = "#" * 50 + "\n" message += self.__class__.__name__.upper() + "\n" message += "#" * 50 + "\n" keyList = list(self.__dict__.keys()) keyList.sort() for key in keyList: message += "%s = %s" % (key, self.__dict__[key]) + "\n" if "size" not in keyList: attr = getattr(self, "size") if attr: message += "%s = %s" % ("size", attr) + "\n" # print message FILE_HEADER = numpy.dtype([ # HEADER 1024bytes ('Hname', 'a32'), # Original file name # Date and time when the file was created ('Htime', numpy.str_, 32), # Name of operator who created the file ('Hoper', numpy.str_, 64), # Place where the measurements was carried out ('Hplace', numpy.str_, 128), # Description of measurements ('Hdescr', numpy.str_, 256), ('Hdummy', numpy.str_, 512), # Reserved space # Main chunk 8bytes # Main chunk signature FZKF or NUIG ('Msign', numpy.str_, 4), ('MsizeData', '=5 ('SPARrawGate1', ' 1180: self.fp.seek(self.PointerReader, os.SEEK_SET) self.FirstPoint = self.PointerReader else: self.FirstPoint = 1180 self.srviHeader = SRVIHeader() self.srviHeader.SRVIread(self.fp) # Se obtiene la cabecera del SRVI self.blocksize = self.srviHeader.SizeOfDataBlock1 # Se obtiene el tamao del bloque if self.blocksize == 148: print('blocksize == 148 bug') jump = numpy.fromfile(self.fp, [('jump', numpy.str_, 140)], 1) # Se obtiene la cabecera del SRVI self.srviHeader.SRVIread(self.fp) if not self.srviHeader.SizeOfSRVI1: self.fileSelector += 1 self.nextfileflag == True self.FileHeaderFlag == True self.recordheader = RecordHeader() self.recordheader.RHread(self.fp) self.RadarConst = self.recordheader.RadarConst dwell = self.recordheader.time_t npw1 = self.recordheader.npw1 npw2 = self.recordheader.npw2 self.dataOut.channelList = list(range(1)) self.dataOut.nIncohInt = self.Num_inCoh self.dataOut.nProfiles = self.Num_Bins self.dataOut.nCohInt = 1 self.dataOut.windowOfFilter = 1 self.dataOut.utctime = dwell self.dataOut.timeZone = 0 self.dataOut.outputInterval = self.dataOut.getTimeInterval() self.dataOut.heightList = self.SPARrawGate1 * self.__deltaHeigth + \ numpy.array(list(range(self.Num_Hei))) * self.__deltaHeigth self.HSDVsign = numpy.fromfile(self.fp, [('HSDV', numpy.str_, 4)], 1) self.SizeHSDV = numpy.fromfile(self.fp, [('SizeHSDV', ' 0., self.data_spc, 0) self.dataOut.COFA = numpy.array([self.COFA_Co, self.COFA_Cx]) print(' ') print('SPC', numpy.shape(self.dataOut.data_spc)) # print 'SPC',self.dataOut.data_spc noinor1 = 713031680 noinor2 = 30 npw1 = 1 # 0**(npw1/10) * noinor1 * noinor2 npw2 = 1 # 0**(npw2/10) * noinor1 * noinor2 self.dataOut.NPW = numpy.array([npw1, npw2]) print(' ') self.data_spc = numpy.transpose(self.data_spc, (2, 1, 0)) self.data_spc = numpy.fft.fftshift(self.data_spc, axes=1) self.data_spc = numpy.fliplr(self.data_spc) self.data_spc = numpy.where(self.data_spc > 0., self.data_spc, 0) self.dataOut_spc = numpy.ones([1, self.Num_Bins, self.Num_Hei]) self.dataOut_spc[0, :, :] = self.data_spc[0, :, :] # print 'SHAPE', self.dataOut_spc.shape # For nyquist correction: # fix = 20 # ~3m/s #shift = self.Num_Bins/2 + fix #self.data_spc = numpy.array([ self.data_spc[: , self.Num_Bins-shift+1: , :] , self.data_spc[: , 0:self.Num_Bins-shift , :]]) '''Block Reading, the Block Data is received and Reshape is used to give it shape. ''' self.PointerReader = self.fp.tell()