##// END OF EJS Templates
hora y fecha en el primer bloque hdf5 >> consola
hora y fecha en el primer bloque hdf5 >> consola

File last commit:

r1399:101813202a42
r1400:005589ae0527
Show More
jroIO_base.py
1577 lines | 46.3 KiB | text/x-python | PythonLexer
Cleaning IO modules (base, voltaje and spectra)
r1251 """
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 Created on Jul 2, 2014
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 @author: roj-idl71
Cleaning IO modules (base, voltaje and spectra)
r1251 """
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 import os
import sys
import glob
import time
import numpy
import fnmatch
José Chávez
1.0
r944 import inspect
José Chávez
merge revisado
r1074 import time
import datetime
José Chávez
pruebas jrovoltage
r963 import zmq
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Juan C. Espinoza
Update plots modules
r1308 from schainpy.model.proc.jroproc_base import Operation, MPDecorator
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 from schainpy.model.data.jroheaderIO import get_dtype_index, get_numpy_dtype, get_procflag_dtype, get_dtype_width
Juan C. Espinoza
set new matplotlib version in setup, improved searchFiles for multiprocessing
r1112 from schainpy.utils import log
Raise Warning when no more files
r1150 import schainpy.admin
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 LOCALTIME = True
Cleaning IO modules (base, voltaje and spectra)
r1251 DT_DIRECTIVES = {
'%Y': 4,
'%y': 2,
'%m': 2,
'%d': 2,
'%j': 3,
'%H': 2,
'%M': 2,
'%S': 2,
'%f': 6
}
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 def isNumber(cad):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
Chequea si el conjunto de caracteres que componen un string puede ser convertidos a un numero.
add multiSchain (@jchavez)
r892 Excepciones:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Si un determinado string no puede ser convertido a numero
Input:
str, string al cual se le analiza para determinar si convertible a un numero o no
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
True : si el string es uno numerico
False : no es un string numerico
"""
try:
José Chávez
merge revisado
r1074 float(cad)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return True
except:
return False
José Chávez
merge revisado
r1074
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 def isFileInEpoch(filename, startUTSeconds, endUTSeconds):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
Esta funcion determina si un archivo de datos se encuentra o no dentro del rango de fecha especificado.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Inputs:
filename : nombre completo del archivo de datos en formato Jicamarca (.r)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 startUTSeconds : fecha inicial del rango seleccionado. La fecha esta dada en
segundos contados desde 01/01/1970.
endUTSeconds : fecha final del rango seleccionado. La fecha esta dada en
segundos contados desde 01/01/1970.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
Boolean : Retorna True si el archivo de datos contiene datos en el rango de
fecha especificado, de lo contrario retorna False.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Excepciones:
Si el archivo no existe o no puede ser abierto
Si la cabecera no puede ser leida.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
basicHeaderObj = BasicHeader(LOCALTIME)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 try:
José Chávez
merge revisado
r1074 fp = open(filename, 'rb')
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 except IOError:
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("The file %s can't be opened" % (filename))
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 sts = basicHeaderObj.read(fp)
fp.close()
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not(sts):
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("Skipping the file %s because it has not a valid header" % (filename))
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not ((startUTSeconds <= basicHeaderObj.utc) and (endUTSeconds > basicHeaderObj.utc)):
return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
José Chávez
merge revisado
r1074
Miguel Valdez
Filtering block by time
r759 def isTimeInRange(thisTime, startTime, endTime):
if endTime >= startTime:
if (thisTime < startTime) or (thisTime > endTime):
return 0
return 1
else:
if (thisTime < startTime) and (thisTime > endTime):
return 0
return 1
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074
Miguel Valdez
jroIO_base.py: Compare dates when startTime > endTime
r652 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Inputs:
filename : nombre completo del archivo de datos en formato Jicamarca (.r)
add multiSchain (@jchavez)
r892
Miguel Valdez
jroIO_base.py: Compare dates when startTime > endTime
r652 startDate : fecha inicial del rango seleccionado en formato datetime.date
add multiSchain (@jchavez)
r892
Miguel Valdez
jroIO_base.py: Compare dates when startTime > endTime
r652 endDate : fecha final del rango seleccionado en formato datetime.date
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 startTime : tiempo inicial del rango seleccionado en formato datetime.time
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 endTime : tiempo final del rango seleccionado en formato datetime.time
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
Boolean : Retorna True si el archivo de datos contiene datos en el rango de
fecha especificado, de lo contrario retorna False.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Excepciones:
Si el archivo no existe o no puede ser abierto
Si la cabecera no puede ser leida.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 try:
José Chávez
merge revisado
r1074 fp = open(filename, 'rb')
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 except IOError:
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("The file %s can't be opened" % (filename))
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 return None
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 firstBasicHeaderObj = BasicHeader(LOCALTIME)
systemHeaderObj = SystemHeader()
radarControllerHeaderObj = RadarControllerHeader()
processingHeaderObj = ProcessingHeader()
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 lastBasicHeaderObj = BasicHeader(LOCALTIME)
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 sts = firstBasicHeaderObj.read(fp)
add multiSchain (@jchavez)
r892
Miguel Valdez
jroIO_base: File size is verified
r780 if not(sts):
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] Skipping the file %s because it has not a valid header" % (filename))
Miguel Valdez
jroIO_base: File size is verified
r780 return None
add multiSchain (@jchavez)
r892
Miguel Valdez
r803 if not systemHeaderObj.read(fp):
return None
add multiSchain (@jchavez)
r892
Miguel Valdez
r803 if not radarControllerHeaderObj.read(fp):
return None
add multiSchain (@jchavez)
r892
Miguel Valdez
r803 if not processingHeaderObj.read(fp):
return None
add multiSchain (@jchavez)
r892
Miguel Valdez
jroIO_base: File size is verified
r780 filesize = os.path.getsize(filename)
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 offset = processingHeaderObj.blockSize + 24 # header size
add multiSchain (@jchavez)
r892
Miguel Valdez
jroIO_base: File size is verified
r780 if filesize <= offset:
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] %s: This file has not enough data" % filename)
Miguel Valdez
jroIO_base: File size is verified
r780 return None
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 fp.seek(-offset, 2)
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 sts = lastBasicHeaderObj.read(fp)
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 fp.close()
add multiSchain (@jchavez)
r892
Miguel Valdez
jroIO_base: File size is verified
r780 thisDatetime = lastBasicHeaderObj.datatime
thisTime_last_block = thisDatetime.time()
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 thisDatetime = firstBasicHeaderObj.datatime
thisDate = thisDatetime.date()
thisTime_first_block = thisDatetime.time()
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 # General case
Miguel Valdez
isFileinTimeRange: startTime can be greater than endTime
r648 # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o
#-----------o----------------------------o-----------
# startTime endTime
add multiSchain (@jchavez)
r892
Miguel Valdez
isFileinTimeRange: startTime can be greater than endTime
r648 if endTime >= startTime:
Miguel Valdez
Filtering block by time
r759 if (thisTime_last_block < startTime) or (thisTime_first_block > endTime):
Miguel Valdez
isFileinTimeRange: startTime can be greater than endTime
r648 return None
add multiSchain (@jchavez)
r892
Miguel Valdez
isFileinTimeRange: startTime can be greater than endTime
r648 return thisDatetime
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 # If endTime < startTime then endTime belongs to the next day
add multiSchain (@jchavez)
r892
Miguel Valdez
isFileinTimeRange: startTime can be greater than endTime
r648 #<<<<<<<<<<<o o>>>>>>>>>>>
#-----------o----------------------------o-----------
# endTime startTime
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 if (thisDate == startDate) and (thisTime_last_block < startTime):
Miguel Valdez
jroIO_base.py: Compare dates when startTime > endTime
r652 return None
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 if (thisDate == endDate) and (thisTime_first_block > endTime):
Miguel Valdez
jroIO_base.py: Compare dates when startTime > endTime
r652 return None
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 if (thisTime_last_block < startTime) and (thisTime_first_block > endTime):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return None
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return thisDatetime
José Chávez
merge revisado
r1074
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 def isFolderInDateRange(folder, startDate=None, endDate=None):
"""
Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 Inputs:
folder : nombre completo del directorio.
Su formato deberia ser "/path_root/?YYYYDDD"
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 siendo:
YYYY : Anio (ejemplo 2015)
DDD : Dia del anio (ejemplo 305)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 startDate : fecha inicial del rango seleccionado en formato datetime.date
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 endDate : fecha final del rango seleccionado en formato datetime.date
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 Return:
Boolean : Retorna True si el archivo de datos contiene datos en el rango de
fecha especificado, de lo contrario retorna False.
Excepciones:
Si el directorio no tiene el formato adecuado
"""
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 basename = os.path.basename(folder)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not isRadarFolder(basename):
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("The folder %s has not the rigth format" % folder)
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 return 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if startDate and endDate:
thisDate = getDateFromRadarFolder(basename)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if thisDate < startDate:
return 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if thisDate > endDate:
return 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 return 1
José Chávez
merge revisado
r1074
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 def isFileInDateRange(filename, startDate=None, endDate=None):
"""
Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 Inputs:
filename : nombre completo del archivo de datos en formato Jicamarca (.r)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 Su formato deberia ser "?YYYYDDDsss"
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 siendo:
YYYY : Anio (ejemplo 2015)
DDD : Dia del anio (ejemplo 305)
sss : set
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 startDate : fecha inicial del rango seleccionado en formato datetime.date
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 endDate : fecha final del rango seleccionado en formato datetime.date
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 Return:
Boolean : Retorna True si el archivo de datos contiene datos en el rango de
fecha especificado, de lo contrario retorna False.
Excepciones:
Si el archivo no tiene el formato adecuado
"""
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 basename = os.path.basename(filename)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not isRadarFile(basename):
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("The filename %s has not the rigth format" % filename)
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 return 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if startDate and endDate:
thisDate = getDateFromRadarFile(basename)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if thisDate < startDate:
return 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if thisDate > endDate:
return 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 return 1
José Chávez
merge revisado
r1074
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def getFileFromSet(path, ext, set):
validFilelist = []
fileList = os.listdir(path)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 # 0 1234 567 89A BCDE
# H YYYY DDD SSS .ext
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 for thisFile in fileList:
try:
year = int(thisFile[1:5])
José Chávez
merge revisado
r1074 doy = int(thisFile[5:8])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 except:
continue
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
continue
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 validFilelist.append(thisFile)
José Chávez
merge revisado
r1074 myfile = fnmatch.filter(
validFilelist, '*%4.4d%3.3d%3.3d*' % (year, doy, set))
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 if len(myfile) != 0:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return myfile[0]
else:
José Chávez
merge revisado
r1074 filename = '*%4.4d%3.3d%3.3d%s' % (year, doy, set, ext.lower())
George Yong
Python 2to3, Spectra (all operations) working
r1167 print('the filename %s does not exist' % filename)
print('...going to the last file: ')
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if validFilelist:
José Chávez
merge revisado
r1074 validFilelist = sorted(validFilelist, key=str.lower)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return validFilelist[-1]
return None
José Chávez
merge revisado
r1074
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def getlastFileFromPath(path, ext):
"""
Depura el fileList dejando solo los que cumplan el formato de "PYYYYDDDSSS.ext"
add multiSchain (@jchavez)
r892 al final de la depuracion devuelve el ultimo file de la lista que quedo.
Input:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 fileList : lista conteniendo todos los files (sin path) que componen una determinada carpeta
add multiSchain (@jchavez)
r892 ext : extension de los files contenidos en una carpeta
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
El ultimo file de una determinada carpeta, no se considera el path.
"""
validFilelist = []
fileList = os.listdir(path)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 # 0 1234 567 89A BCDE
# H YYYY DDD SSS .ext
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 for thisFile in fileList:
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 year = thisFile[1:5]
if not isNumber(year):
continue
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 doy = thisFile[5:8]
if not isNumber(doy):
continue
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 year = int(year)
doy = int(doy)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
continue
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 validFilelist.append(thisFile)
if validFilelist:
José Chávez
merge revisado
r1074 validFilelist = sorted(validFilelist, key=str.lower)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return validFilelist[-1]
return None
José Chávez
merge revisado
r1074
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 def isRadarFolder(folder):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 try:
year = int(folder[1:5])
doy = int(folder[5:8])
except:
return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
José Chávez
merge revisado
r1074
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 def isRadarFile(file):
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 try:
José Chávez
merge revisado
r1074 year = int(file[1:5])
doy = int(file[5:8])
set = int(file[8:11])
except:
return 0
return 1
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589
def getDateFromRadarFile(file):
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 try:
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 year = int(file[1:5])
doy = int(file[5:8])
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 set = int(file[8:11])
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 except:
return None
José Chávez
merge revisado
r1074 thisDate = datetime.date(year, 1, 1) + datetime.timedelta(doy - 1)
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 return thisDate
José Chávez
merge revisado
r1074
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 def getDateFromRadarFolder(folder):
try:
year = int(folder[1:5])
doy = int(folder[5:8])
except:
return None
José Chávez
merge revisado
r1074 thisDate = datetime.date(year, 1, 1) + datetime.timedelta(doy - 1)
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 return thisDate
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 def parse_format(s, fmt):
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 for i in range(fmt.count('%')):
x = fmt.index('%')
d = DT_DIRECTIVES[fmt[x:x+2]]
fmt = fmt.replace(fmt[x:x+2], s[x:x+d])
return fmt
José Chávez
merge revisado
r1074
Cleaning IO modules (base, voltaje and spectra)
r1251 class Reader(object):
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 c = 3E8
isConfig = False
dtype = None
pathList = []
filenameList = []
Cleaning IO modules (base, voltaje and spectra)
r1251 datetimeList = []
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 filename = None
ext = None
flagIsNewFile = 1
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 flagDiscontinuousBlock = 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 flagIsNewBlock = 0
Cleaning IO modules (base, voltaje and spectra)
r1251 flagNoMoreFiles = 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 fp = None
firstHeaderSize = 0
basicHeaderSize = 24
versionFile = 1103
fileSize = None
fileSizeByHeader = None
Cleaning IO modules (base, voltaje and spectra)
r1251 fileIndex = -1
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 profileIndex = None
Cleaning IO modules (base, voltaje and spectra)
r1251 blockIndex = 0
nTotalBlocks = 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 maxTimeStep = 30
lastUTTime = None
datablock = None
dataOut = None
Miguel Valdez
JRODATA: timeInterval is a property now...
r527 getByBlock = False
Cleaning IO modules (base, voltaje and spectra)
r1251 path = None
startDate = None
endDate = None
startTime = datetime.time(0, 0, 0)
endTime = datetime.time(23, 59, 59)
set = None
expLabel = ""
online = False
delay = 60
nTries = 3 # quantity tries
nFiles = 3 # number of files for searching
walk = True
getblock = False
nTxs = 1
realtime = False
blocksize = 0
blocktime = None
warnings = True
verbose = True
server = None
format = None
oneDDict = None
twoDDict = None
independentParam = None
filefmt = None
folderfmt = None
Fix python 2.7 compatibility
r1252 open_file = open
open_mode = 'rb'
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def run(self):
add multiSchain (@jchavez)
r892
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 raise NotImplementedError
add multiSchain (@jchavez)
r892
José Chávez
1.0
r944 def getAllowedArgs(self):
Juan C. Espinoza
Add __attrs__ attribute to Process clasess to improve CLI finder
r1097 if hasattr(self, '__attrs__'):
return self.__attrs__
else:
return inspect.getargspec(self.run).args
José Chávez
1.0
r944
Cleaning IO modules (base, voltaje and spectra)
r1251 def set_kwargs(self, **kwargs):
José Chávez
merge revisado
r1074
Cleaning IO modules (base, voltaje and spectra)
r1251 for key, value in kwargs.items():
setattr(self, key, value)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 def find_folders(self, path, startDate, endDate, folderfmt, last=False):
add multiSchain (@jchavez)
r892
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 folders = [x for f in path.split(',')
Cleaning IO modules (base, voltaje and spectra)
r1251 for x in os.listdir(f) if os.path.isdir(os.path.join(f, x))]
folders.sort()
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 if last:
folders = [folders[-1]]
add multiSchain (@jchavez)
r892
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 for folder in folders:
try:
dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date()
Cleaning IO modules (base, voltaje and spectra)
r1251 if dt >= startDate and dt <= endDate:
yield os.path.join(path, folder)
else:
log.log('Skiping folder {}'.format(folder), self.name)
except Exception as e:
log.log('Skiping folder {}'.format(folder), self.name)
continue
return
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
def find_files(self, folders, ext, filefmt, startDate=None, endDate=None,
Cleaning IO modules (base, voltaje and spectra)
r1251 expLabel='', last=False):
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
for path in folders:
Cleaning IO modules (base, voltaje and spectra)
r1251 files = glob.glob1(path, '*{}'.format(ext))
files.sort()
if last:
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 if files:
Cleaning IO modules (base, voltaje and spectra)
r1251 fo = files[-1]
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 try:
Juan C. Espinoza
Fix ParametersPlot & BLTRParamReader
r1322 dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date()
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 yield os.path.join(path, expLabel, fo)
except Exception as e:
Cleaning IO modules (base, voltaje and spectra)
r1251 pass
Fix python 2.7 compatibility
r1252 return
Cleaning IO modules (base, voltaje and spectra)
r1251 else:
Fix python 2.7 compatibility
r1252 return
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 for fo in files:
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 try:
dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date()
Cleaning IO modules (base, voltaje and spectra)
r1251 if dt >= startDate and dt <= endDate:
yield os.path.join(path, expLabel, fo)
else:
log.log('Skiping file {}'.format(fo), self.name)
except Exception as e:
log.log('Skiping file {}'.format(fo), self.name)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 continue
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 def searchFilesOffLine(self, path, startDate, endDate,
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 expLabel, ext, walk,
Cleaning IO modules (base, voltaje and spectra)
r1251 filefmt, folderfmt):
"""Search files in offline mode for the given arguments
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 Return:
Generator of files
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
Cleaning IO modules (base, voltaje and spectra)
r1251 if walk:
folders = self.find_folders(
path, startDate, endDate, folderfmt)
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 else:
Cleaning IO modules (base, voltaje and spectra)
r1251 folders = path.split(',')
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 return self.find_files(
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 folders, ext, filefmt, startDate, endDate, expLabel)
Cleaning IO modules (base, voltaje and spectra)
r1251
def searchFilesOnLine(self, path, startDate, endDate,
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 expLabel, ext, walk,
Cleaning IO modules (base, voltaje and spectra)
r1251 filefmt, folderfmt):
"""Search for the last file of the last folder
Arguments:
path : carpeta donde estan contenidos los files que contiene data
expLabel : Nombre del subexperimento (subfolder)
ext : extension de los files
Juan C. Espinoza
Change multiSchain by MPProject
r1052 walk : Si es habilitado no realiza busquedas dentro de los ubdirectorios (doypath)
Return:
Cleaning IO modules (base, voltaje and spectra)
r1251 generator with the full path of last filename
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 if walk:
folders = self.find_folders(
path, startDate, endDate, folderfmt, last=True)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 else:
Cleaning IO modules (base, voltaje and spectra)
r1251 folders = path.split(',')
completado op clean Rayleigh, modificada la escritura y lectura de hdf5 para potencia, cambio en gráficos para uso del ChannelList, añadir en otros pendiente
r1397
Cleaning IO modules (base, voltaje and spectra)
r1251 return self.find_files(
folders, ext, filefmt, startDate, endDate, expLabel, last=True)
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 def setNextFile(self):
"""Set the next file to be readed open it and parse de file header"""
add multiSchain (@jchavez)
r892
Fix searching files correctly in jroIO_base & Spectra shift
r1270 while True:
if self.fp != None:
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.fp.close()
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 if self.online:
Fix searching files correctly in jroIO_base & Spectra shift
r1270 newFile = self.setNextFileOnline()
Cleaning IO modules (base, voltaje and spectra)
r1251 else:
Fix searching files correctly in jroIO_base & Spectra shift
r1270 newFile = self.setNextFileOffline()
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Fix searching files correctly in jroIO_base & Spectra shift
r1270 if not(newFile):
if self.online:
raise schainpy.admin.SchainError('Time to wait for new files reach')
Cleaning IO modules (base, voltaje and spectra)
r1251 else:
Fix searching files correctly in jroIO_base & Spectra shift
r1270 if self.fileIndex == -1:
raise schainpy.admin.SchainWarning('No files found in the given path')
else:
raise schainpy.admin.SchainWarning('No more files to read')
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Fix searching files correctly in jroIO_base & Spectra shift
r1270 if self.verifyFile(self.filename):
break
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 log.log('Opening file: %s' % self.filename, self.name)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 self.readFirstHeader()
self.nReadBlocks = 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 def setNextFileOnline(self):
"""Check for the next file to be readed in online mode.
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Cleaning IO modules (base, voltaje and spectra)
r1251 Set:
Juan C. Espinoza
Change multiSchain by MPProject
r1052 self.filename
self.fp
Cleaning IO modules (base, voltaje and spectra)
r1251 self.filesize
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Juan C. Espinoza
Change multiSchain by MPProject
r1052 Return:
Cleaning IO modules (base, voltaje and spectra)
r1251 boolean
Juan C. Espinoza
Change multiSchain by MPProject
r1052
"""
Cleaning IO modules (base, voltaje and spectra)
r1251 nextFile = True
nextDay = False
add multiSchain (@jchavez)
r892
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 for nFiles in range(self.nFiles+1):
Cleaning IO modules (base, voltaje and spectra)
r1251 for nTries in range(self.nTries):
fullfilename, filename = self.checkForRealPath(nextFile, nextDay)
if fullfilename is not None:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 break
Errors handling and gracefully terminate main process
r1241 log.warning(
Cleaning IO modules (base, voltaje and spectra)
r1251 "Waiting %0.2f sec for the next file: \"%s\" , try %02d ..." % (self.delay, filename, nTries + 1),
Errors handling and gracefully terminate main process
r1241 self.name)
Cleaning IO modules (base, voltaje and spectra)
r1251 time.sleep(self.delay)
nextFile = False
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 continue
Juan C. Espinoza
Minor bugs
r1278 if fullfilename is not None:
Cleaning IO modules (base, voltaje and spectra)
r1251 break
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 self.nTries = 1
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 nextFile = True
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 if nFiles == (self.nFiles - 1):
log.log('Trying with next day...', self.name)
Juan C. Espinoza
Minor bugs
r1278 nextDay = True
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.nTries = 3
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 if fullfilename:
José Chávez
merge revisado
r1074 self.fileSize = os.path.getsize(fullfilename)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.filename = fullfilename
self.flagIsNewFile = 1
José Chávez
merge revisado
r1074 if self.fp != None:
self.fp.close()
Fix python 2.7 compatibility
r1252 self.fp = self.open_file(fullfilename, self.open_mode)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.flagNoMoreFiles = 0
Cleaning IO modules (base, voltaje and spectra)
r1251 self.fileIndex += 1
return 1
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 else:
Cleaning IO modules (base, voltaje and spectra)
r1251 return 0
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 def setNextFileOffline(self):
"""Open the next file to be readed in offline mode"""
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 try:
filename = next(self.filenameList)
self.fileIndex +=1
except StopIteration:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.flagNoMoreFiles = 1
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 return 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 self.filename = filename
self.fileSize = os.path.getsize(filename)
Fix python 2.7 compatibility
r1252 self.fp = self.open_file(filename, self.open_mode)
Cleaning IO modules (base, voltaje and spectra)
r1251 self.flagIsNewFile = 1
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 return 1
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Fix searching files correctly in jroIO_base & Spectra shift
r1270 @staticmethod
def isDateTimeInRange(dt, startDate, endDate, startTime, endTime):
"""Check if the given datetime is in range"""
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 startDateTime= datetime.datetime.combine(startDate,startTime)
endDateTime = datetime.datetime.combine(endDate,endTime)
añadido FaradayIntegration para limpieza de datos, restringida la operación al funcionamiento con la pdata regular
r1399 #print("dt eval: ", dt, startDateTime,endDateTime)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 if startDateTime <= dt <= endDateTime:
clean Rayleigh funcionando, tiempo de ejecución elevado usando todos los pares
r1391 return True
Fix searching files correctly in jroIO_base & Spectra shift
r1270 return False
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 def verifyFile(self, filename):
"""Check for a valid file
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 Arguments:
filename -- full path filename
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 Return:
boolean
"""
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Cleaning IO modules (base, voltaje and spectra)
r1251 return True
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Cleaning IO modules (base, voltaje and spectra)
r1251 def checkForRealPath(self, nextFile, nextDay):
"""Check if the next file to be readed exists"""
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 raise NotImplementedError
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 def readFirstHeader(self):
"""Parse the file header"""
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 pass
Juan C. Espinoza
Fix ParametersPlot & BLTRParamReader
r1322 def waitDataBlock(self, pointer_location, blocksize=None):
"""
"""
currentPointer = pointer_location
if blocksize is None:
neededSize = self.processingHeaderObj.blockSize # + self.basicHeaderSize
else:
neededSize = blocksize
for nTries in range(self.nTries):
self.fp.close()
self.fp = open(self.filename, 'rb')
self.fp.seek(currentPointer)
self.fileSize = os.path.getsize(self.filename)
currentSize = self.fileSize - currentPointer
if (currentSize >= neededSize):
return 1
log.warning(
"Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries + 1),
self.name
)
time.sleep(self.delay)
return 0
Cleaning IO modules (base, voltaje and spectra)
r1251 class JRODataReader(Reader):
utc = 0
nReadBlocks = 0
foldercounter = 0
firstHeaderSize = 0
basicHeaderSize = 24
__isFirstTimeOnline = 1
filefmt = "*%Y%j***"
folderfmt = "*%Y%j"
Juan C. Espinoza
Rewrite controller, remove MPDecorator to units (keep for plots an writers) use of queues for interproc comm instead of zmq, self operations are no longer supported
r1287 __attrs__ = ['path', 'startDate', 'endDate', 'startTime', 'endTime', 'online', 'delay', 'walk']
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 def getDtypeWidth(self):
dtype_index = get_dtype_index(self.dtype)
dtype_width = get_dtype_width(dtype_index)
return dtype_width
def checkForRealPath(self, nextFile, nextDay):
"""Check if the next file to be readed exists.
Example :
nombre correcto del file es .../.../D2009307/P2009307367.ext
Entonces la funcion prueba con las siguientes combinaciones
.../.../y2009307367.ext
.../.../Y2009307367.ext
.../.../x2009307/y2009307367.ext
.../.../x2009307/Y2009307367.ext
.../.../X2009307/y2009307367.ext
.../.../X2009307/Y2009307367.ext
siendo para este caso, la ultima combinacion de letras, identica al file buscado
Return:
str -- fullpath of the file
"""
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 if nextFile:
self.set += 1
if nextDay:
self.set = 0
self.doy += 1
foldercounter = 0
prefixDirList = [None, 'd', 'D']
if self.ext.lower() == ".r": # voltage
prefixFileList = ['d', 'D']
elif self.ext.lower() == ".pdata": # spectra
prefixFileList = ['p', 'P']
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 # barrido por las combinaciones posibles
for prefixDir in prefixDirList:
thispath = self.path
if prefixDir != None:
# formo el nombre del directorio xYYYYDDD (x=d o x=D)
if foldercounter == 0:
thispath = os.path.join(self.path, "%s%04d%03d" %
(prefixDir, self.year, self.doy))
else:
thispath = os.path.join(self.path, "%s%04d%03d_%02d" % (
prefixDir, self.year, self.doy, foldercounter))
for prefixFile in prefixFileList: # barrido por las dos combinaciones posibles de "D"
# formo el nombre del file xYYYYDDDSSS.ext
filename = "%s%04d%03d%03d%s" % (prefixFile, self.year, self.doy, self.set, self.ext)
fullfilename = os.path.join(
thispath, filename)
if os.path.exists(fullfilename):
return fullfilename, filename
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
return None, filename
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def __waitNewBlock(self):
"""
add multiSchain (@jchavez)
r892 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Si el modo de lectura es OffLine siempre retorn 0
"""
if not self.online:
return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if (self.nReadBlocks >= self.processingHeaderObj.dataBlocksPerFile):
return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 currentPointer = self.fp.tell()
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 for nTries in range(self.nTries):
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.fp.close()
José Chávez
merge revisado
r1074 self.fp = open(self.filename, 'rb')
self.fp.seek(currentPointer)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074 self.fileSize = os.path.getsize(self.filename)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 currentSize = self.fileSize - currentPointer
José Chávez
merge revisado
r1074 if (currentSize >= neededSize):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj.read(self.fp)
return 1
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.fileSize == self.fileSizeByHeader:
José Chávez
merge revisado
r1074 # self.flagEoF = True
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 0
add multiSchain (@jchavez)
r892
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries + 1))
Errors handling and gracefully terminate main process
r1241 time.sleep(self.delay)
add multiSchain (@jchavez)
r892
return 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def __setNewBlock(self):
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Cleaning IO modules (base, voltaje and spectra)
r1251 if self.fp == None:
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 return 0
if self.flagIsNewFile:
Miguel Valdez
realtime argument added to JROReader
r659 self.lastUTTime = self.basicHeaderObj.utc
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
add multiSchain (@jchavez)
r892
Miguel Valdez
realtime argument added to JROReader
r659 if self.realtime:
self.flagDiscontinuousBlock = 1
if not(self.setNextFile()):
return 0
else:
José Chávez
merge revisado
r1074 return 1
Cleaning IO modules (base, voltaje and spectra)
r1251
José Chávez
test zmq for rawdata
r975 currentSize = self.fileSize - self.fp.tell()
neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
José Chávez
test zmq for rawdata
r975 if (currentSize >= neededSize):
self.basicHeaderObj.read(self.fp)
Miguel Valdez
realtime argument added to JROReader
r659 self.lastUTTime = self.basicHeaderObj.utc
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.__waitNewBlock():
Miguel Valdez
realtime argument added to JROReader
r659 self.lastUTTime = self.basicHeaderObj.utc
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
Cleaning IO modules (base, voltaje and spectra)
r1251
José Chávez
test zmq for rawdata
r975 if not(self.setNextFile()):
return 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074 deltaTime = self.basicHeaderObj.utc - self.lastUTTime
Miguel Valdez
realtime argument added to JROReader
r659 self.lastUTTime = self.basicHeaderObj.utc
add multiSchain (@jchavez)
r892
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock = 0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
if deltaTime > self.maxTimeStep:
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.flagDiscontinuousBlock = 1
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
return 1
def readNextBlock(self):
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 while True:
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 if not(self.__setNewBlock()):
continue
José Chávez
merge revisado
r1074
Miguel Valdez
Filtering block by time
r759 if not(self.readBlock()):
return 0
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Miguel Valdez
Filtering block by time
r759 self.getBasicHeader()
Fix searching files correctly in jroIO_base & Spectra shift
r1270
if not self.isDateTimeInRange(self.dataOut.datatime, self.startDate, self.endDate, self.startTime, self.endTime):
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] Block No. %d/%d -> %s [Skipping]" % (self.nReadBlocks,
José Chávez
merge revisado
r1074 self.processingHeaderObj.dataBlocksPerFile,
George Yong
Python 2to3, Spectra (all operations) working
r1167 self.dataOut.datatime.ctime()))
Miguel Valdez
Filtering block by time
r759 continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 break
add multiSchain (@jchavez)
r892
José Chávez
finishing day, need testing
r931 if self.verbose:
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] Block No. %d/%d -> %s" % (self.nReadBlocks,
José Chávez
merge revisado
r1074 self.processingHeaderObj.dataBlocksPerFile,
George Yong
Python 2to3, Spectra (all operations) working
r1167 self.dataOut.datatime.ctime()))
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
Cleaning IO modules (base, voltaje and spectra)
r1251 def readFirstHeader(self):
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj.read(self.fp)
self.systemHeaderObj.read(self.fp)
self.radarControllerHeaderObj.read(self.fp)
self.processingHeaderObj.read(self.fp)
self.firstHeaderSize = self.basicHeaderObj.size
José Chávez
merge revisado
r1074 datatype = int(numpy.log2((self.processingHeaderObj.processFlags &
PROCFLAG.DATATYPE_MASK)) - numpy.log2(PROCFLAG.DATATYPE_CHAR))
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if datatype == 0:
José Chávez
merge revisado
r1074 datatype_str = numpy.dtype([('real', '<i1'), ('imag', '<i1')])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 elif datatype == 1:
José Chávez
merge revisado
r1074 datatype_str = numpy.dtype([('real', '<i2'), ('imag', '<i2')])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 elif datatype == 2:
José Chávez
merge revisado
r1074 datatype_str = numpy.dtype([('real', '<i4'), ('imag', '<i4')])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 elif datatype == 3:
José Chávez
merge revisado
r1074 datatype_str = numpy.dtype([('real', '<i8'), ('imag', '<i8')])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 elif datatype == 4:
José Chávez
merge revisado
r1074 datatype_str = numpy.dtype([('real', '<f4'), ('imag', '<f4')])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 elif datatype == 5:
José Chávez
merge revisado
r1074 datatype_str = numpy.dtype([('real', '<f8'), ('imag', '<f8')])
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 else:
George Yong
Python 2to3, Spectra (all operations) working
r1167 raise ValueError('Data type was not defined')
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
self.dtype = datatype_str
#self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c
José Chávez
merge revisado
r1074 self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + \
self.firstHeaderSize + self.basicHeaderSize * \
(self.processingHeaderObj.dataBlocksPerFile - 1)
José Chávez
arreglado varios dias con mp
r1079 # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels)
# self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.getBlockDimension()
add multiSchain (@jchavez)
r892
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 def verifyFile(self, filename):
add multiSchain (@jchavez)
r892
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 flag = True
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 try:
fp = open(filename, 'rb')
except IOError:
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 log.error("File {} can't be opened".format(filename), self.name)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return False
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 if self.online and self.waitDataBlock(0):
pass
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 basicHeaderObj = BasicHeader(LOCALTIME)
systemHeaderObj = SystemHeader()
radarControllerHeaderObj = RadarControllerHeader()
processingHeaderObj = ProcessingHeader()
if not(basicHeaderObj.read(fp)):
flag = False
if not(systemHeaderObj.read(fp)):
flag = False
if not(radarControllerHeaderObj.read(fp)):
flag = False
if not(processingHeaderObj.read(fp)):
flag = False
if not self.online:
dt1 = basicHeaderObj.datatime
pos = self.fileSize-processingHeaderObj.blockSize-24
if pos<0:
flag = False
log.error('Invalid size for file: {}'.format(self.filename), self.name)
else:
fp.seek(pos)
Fix searching files correctly in jroIO_base & Spectra shift
r1270 if not(basicHeaderObj.read(fp)):
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 flag = False
dt2 = basicHeaderObj.datatime
if not self.isDateTimeInRange(dt1, self.startDate, self.endDate, self.startTime, self.endTime) and not \
self.isDateTimeInRange(dt2, self.startDate, self.endDate, self.startTime, self.endTime):
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 flag = False
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
fp.close()
Juan C. Espinoza
Fix ScpecraWriter and CohInt attribute
r1310 return flag
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 def findDatafiles(self, path, startDate=None, endDate=None, expLabel='', ext='.r', walk=True, include_path=False):
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 path_empty = True
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 dateList = []
pathList = []
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 multi_path = path.split(',')
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 if not walk:
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 for single_path in multi_path:
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in Signal Chain GUI: Updating FTP configuration from old SendByFTP operation.
r607 if not os.path.isdir(single_path):
continue
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 fileList = glob.glob1(single_path, "*" + ext)
add multiSchain (@jchavez)
r892
Miguel Valdez
Data directories are sorted before reading files
r726 if not fileList:
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 path_empty = False
add multiSchain (@jchavez)
r892
Miguel Valdez
Data directories are sorted before reading files
r726 fileList.sort()
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 for thisFile in fileList:
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 if not os.path.isfile(os.path.join(single_path, thisFile)):
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 if not isRadarFile(thisFile):
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not isFileInDateRange(thisFile, startDate, endDate):
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 thisDate = getDateFromRadarFile(thisFile)
add multiSchain (@jchavez)
r892
Juan C. Espinoza
ParameterReader unit and ParameterWriter operation added
r1232 if thisDate in dateList or single_path in pathList:
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 dateList.append(thisDate)
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 pathList.append(single_path)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 else:
for single_path in multi_path:
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not os.path.isdir(single_path):
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 dirList = []
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 for thisPath in os.listdir(single_path):
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 if not os.path.isdir(os.path.join(single_path, thisPath)):
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not isRadarFolder(thisPath):
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not isFolderInDateRange(thisPath, startDate, endDate):
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 dirList.append(thisPath)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if not dirList:
continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Data directories are sorted before reading files
r726 dirList.sort()
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in findDataFiles
r601 for thisDir in dirList:
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base:...
r632 datapath = os.path.join(single_path, thisDir, expLabel)
José Chávez
merge revisado
r1074 fileList = glob.glob1(datapath, "*" + ext)
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 if not fileList:
Miguel Valdez
Bug fixed in jroIO_base:...
r632 continue
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 path_empty = False
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 thisDate = getDateFromRadarFolder(thisDir)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base:...
r632 pathList.append(datapath)
Miguel Valdez
-USRP Reader was added to Signal Chain GUI...
r589 dateList.append(thisDate)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 dateList.sort()
add multiSchain (@jchavez)
r892
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 if walk:
pattern_path = os.path.join(multi_path[0], "[dYYYYDDD]", expLabel)
else:
pattern_path = multi_path[0]
add multiSchain (@jchavez)
r892
Miguel Valdez
Filtering block by time
r759 if path_empty:
Errors handling and gracefully terminate main process
r1241 raise schainpy.admin.SchainError("[Reading] No *%s files in %s for %s to %s" % (ext, pattern_path, startDate, endDate))
Miguel Valdez
Filtering block by time
r759 else:
if not dateList:
Errors handling and gracefully terminate main process
r1241 raise schainpy.admin.SchainError("[Reading] Date range selected invalid [%s - %s]: No *%s files in %s)" % (startDate, endDate, ext, path))
Miguel Valdez
Filtering block by time
r759
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 if include_path:
return dateList, pathList
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base: date and time filters were not working when walk=0 and there were many days inside one directory.
r640 return dateList
add multiSchain (@jchavez)
r892
Cleaning IO modules (base, voltaje and spectra)
r1251 def setup(self, **kwargs):
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 self.set_kwargs(**kwargs)
if not self.ext.startswith('.'):
self.ext = '.{}'.format(self.ext)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 if self.server is not None:
if 'tcp://' in self.server:
Juan C. Espinoza
Change multiSchain by MPProject
r1052 address = server
else:
Cleaning IO modules (base, voltaje and spectra)
r1251 address = 'ipc:///tmp/%s' % self.server
Juan C. Espinoza
Change multiSchain by MPProject
r1052 self.server = address
self.context = zmq.Context()
self.receiver = self.context.socket(zmq.PULL)
self.receiver.connect(self.server)
time.sleep(0.5)
George Yong
Python 2to3, Spectra (all operations) working
r1167 print('[Starting] ReceiverData from {}'.format(self.server))
José Chávez
merge revisado
r1074 else:
Juan C. Espinoza
Change multiSchain by MPProject
r1052 self.server = None
Cleaning IO modules (base, voltaje and spectra)
r1251 if self.path == None:
George Yong
Python 2to3, Spectra (all operations) working
r1167 raise ValueError("[Reading] The path is not valid")
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 if self.online:
log.log("[Reading] Searching files in online mode...", self.name)
Juan C. Espinoza
Change multiSchain by MPProject
r1052
José Chávez
merge revisado
r1074 for nTries in range(self.nTries):
Cleaning IO modules (base, voltaje and spectra)
r1251 fullpath = self.searchFilesOnLine(self.path, self.startDate,
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.endDate, self.expLabel, self.ext, self.walk,
Cleaning IO modules (base, voltaje and spectra)
r1251 self.filefmt, self.folderfmt)
try:
fullpath = next(fullpath)
except:
fullpath = None
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Juan C. Espinoza
Change multiSchain by MPProject
r1052 if fullpath:
break
Cleaning IO modules (base, voltaje and spectra)
r1251 log.warning(
'Waiting {} sec for a valid file in {}: try {} ...'.format(
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.delay, self.path, nTries + 1),
Cleaning IO modules (base, voltaje and spectra)
r1251 self.name)
Errors handling and gracefully terminate main process
r1241 time.sleep(self.delay)
Juan C. Espinoza
Change multiSchain by MPProject
r1052
George Yong
Multiprocessing for Spectra (all operation) working
r1171 if not(fullpath):
Cleaning IO modules (base, voltaje and spectra)
r1251 raise schainpy.admin.SchainError(
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 'There isn\'t any valid file in {}'.format(self.path))
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Cleaning IO modules (base, voltaje and spectra)
r1251 pathname, filename = os.path.split(fullpath)
self.year = int(filename[1:5])
self.doy = int(filename[5:8])
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.set = int(filename[8:11]) - 1
Cleaning IO modules (base, voltaje and spectra)
r1251 else:
log.log("Searching files in {}".format(self.path), self.name)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.filenameList = self.searchFilesOffLine(self.path, self.startDate,
Cleaning IO modules (base, voltaje and spectra)
r1251 self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Cleaning IO modules (base, voltaje and spectra)
r1251 self.setNextFile()
Juan C. Espinoza
Change multiSchain by MPProject
r1052
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return
def getBasicHeader(self):
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 self.dataOut.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond / \
1000. + self.profileIndex * self.radarControllerHeaderObj.ippSeconds
add multiSchain (@jchavez)
r892
Miguel Valdez
Merge with branch schain_julia_drifts from rev. 803 to 995....
r568 self.dataOut.flagDiscontinuousBlock = self.flagDiscontinuousBlock
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut.timeZone = self.basicHeaderObj.timeZone
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut.dstFlag = self.basicHeaderObj.dstFlag
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut.errorCount = self.basicHeaderObj.errorCount
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def getFirstHeader(self):
add multiSchain (@jchavez)
r892
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def getData(self):
add multiSchain (@jchavez)
r892
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def hasNotDataInBuffer(self):
add multiSchain (@jchavez)
r892
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def readBlock(self):
add multiSchain (@jchavez)
r892
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def isEndProcess(self):
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return self.flagNoMoreFiles
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def printReadBlocks(self):
add multiSchain (@jchavez)
r892
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] Number of read blocks per file %04d" % self.nReadBlocks)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def printTotalBlocks(self):
add multiSchain (@jchavez)
r892
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Reading] Number of read blocks %04d" % self.nTotalBlocks)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 def run(self, **kwargs):
"""
Arguments:
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 path :
startDate :
Cleaning IO modules (base, voltaje and spectra)
r1251 endDate :
startTime :
endTime :
set :
expLabel :
ext :
online :
delay :
walk :
getblock :
nTxs :
realtime :
blocksize :
blocktime :
skip :
cursor :
warnings :
server :
verbose :
format :
oneDDict :
twoDDict :
independentParam :
"""
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not(self.isConfig):
Cleaning IO modules (base, voltaje and spectra)
r1251 self.setup(**kwargs)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.isConfig = True
Cleaning IO modules (base, voltaje and spectra)
r1251 if self.server is None:
José Chávez
test zmq for rawdata
r975 self.getData()
José Chávez
merge revisado
r1074 else:
José Chávez
test zmq for rawdata
r975 self.getFromServer()
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074
Cleaning IO modules (base, voltaje and spectra)
r1251 class JRODataWriter(Reader):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
add multiSchain (@jchavez)
r892 """
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Esta clase permite escribir datos a archivos procesados (.r o ,pdata). La escritura
add multiSchain (@jchavez)
r892 de los datos siempre se realiza por bloques.
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 setFile = None
profilesPerBlock = None
blocksPerFile = None
nWriteBlocks = 0
Miguel Valdez
Bug fixed in jroIO_base:...
r632 fileDate = None
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def __init__(self, dataOut=None):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def hasAllDataInBuffer(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def setBlockDimension(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def writeBlock(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def putData(self):
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
Cleaning IO modules (base, voltaje and spectra)
r1251 def getDtypeWidth(self):
dtype_index = get_dtype_index(self.dtype)
dtype_width = get_dtype_width(dtype_index)
return dtype_width
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 def getProcessFlags(self):
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 processFlags = 0
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 dtype_index = get_dtype_index(self.dtype)
procflag_dtype = get_procflag_dtype(dtype_index)
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 processFlags += procflag_dtype
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if self.dataOut.flagDecodeData:
processFlags += PROCFLAG.DECODE_DATA
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if self.dataOut.flagDeflipData:
processFlags += PROCFLAG.DEFLIP_DATA
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if self.dataOut.code is not None:
processFlags += PROCFLAG.DEFINE_PROCESS_CODE
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if self.dataOut.nCohInt > 1:
processFlags += PROCFLAG.COHERENT_INTEGRATION
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if self.dataOut.type == "Spectra":
if self.dataOut.nIncohInt > 1:
processFlags += PROCFLAG.INCOHERENT_INTEGRATION
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if self.dataOut.data_dc is not None:
processFlags += PROCFLAG.SAVE_CHANNELS_DC
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed:...
r624 if self.dataOut.flagShiftFFT:
processFlags += PROCFLAG.SHIFT_FFT_DATA
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 return processFlags
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def setBasicHeader(self):
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 self.basicHeaderObj.size = self.basicHeaderSize # bytes
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj.version = self.versionFile
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.basicHeaderObj.dataBlock = self.nTotalBlocks
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 utc = numpy.floor(self.dataOut.utctime)
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 milisecond = (self.dataOut.utctime - utc) * 1000.0
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj.utc = utc
self.basicHeaderObj.miliSecond = milisecond
self.basicHeaderObj.timeZone = self.dataOut.timeZone
self.basicHeaderObj.dstFlag = self.dataOut.dstFlag
self.basicHeaderObj.errorCount = self.dataOut.errorCount
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def setFirstHeader(self):
"""
Obtiene una copia del First Header
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Affected:
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj
self.systemHeaderObj
self.radarControllerHeaderObj
self.processingHeaderObj self.
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
None
"""
add multiSchain (@jchavez)
r892
Miguel Valdez
-Using ValueError raises instead of IOError...
r684 raise NotImplementedError
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def __writeFirstHeader(self):
"""
Escribe el primer header del file es decir el Basic header y el Long header (SystemHeader, RadarControllerHeader, ProcessingHeader)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Affected:
__dataType
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
None
"""
Juan C. Espinoza
Change multiSchain by MPProject
r1052
# CALCULAR PARAMETROS
José Chávez
merge revisado
r1074 sizeLongHeader = self.systemHeaderObj.size + \
self.radarControllerHeaderObj.size + self.processingHeaderObj.size
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj.size = self.basicHeaderSize + sizeLongHeader
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.basicHeaderObj.write(self.fp)
self.systemHeaderObj.write(self.fp)
self.radarControllerHeaderObj.write(self.fp)
self.processingHeaderObj.write(self.fp)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 def __setNewBlock(self):
"""
Si es un nuevo file escribe el First Header caso contrario escribe solo el Basic Header
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
0 : si no pudo escribir nada
1 : Si escribio el Basic el First Header
add multiSchain (@jchavez)
r892 """
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.fp == None:
self.setNextFile()
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.flagIsNewFile:
return 1
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.blockIndex < self.processingHeaderObj.dataBlocksPerFile:
self.basicHeaderObj.write(self.fp)
return 1
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 if not(self.setNextFile()):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
def writeNextBlock(self):
"""
Selecciona el bloque siguiente de datos y los escribe en un file
add multiSchain (@jchavez)
r892
Return:
0 : Si no hizo pudo escribir el bloque de datos
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 1 : Si no pudo escribir el bloque de datos
"""
José Chávez
merge revisado
r1074 if not(self.__setNewBlock()):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.writeBlock()
add multiSchain (@jchavez)
r892
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Writing] Block No. %d/%d" % (self.blockIndex,
self.processingHeaderObj.dataBlocksPerFile))
add multiSchain (@jchavez)
r892
return 1
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
def setNextFile(self):
Cleaning IO modules (base, voltaje and spectra)
r1251 """Determina el siguiente file que sera escrito
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
add multiSchain (@jchavez)
r892 Affected:
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.filename
self.subfolder
self.fp
self.setFile
self.flagIsNewFile
Return:
0 : Si el archivo no puede ser escrito
1 : Si el archivo esta listo para ser escrito
"""
ext = self.ext
path = self.path
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if self.fp != None:
self.fp.close()
add multiSchain (@jchavez)
r892
completado op clean Rayleigh, modificada la escritura y lectura de hdf5 para potencia, cambio en gráficos para uso del ChannelList, añadir en otros pendiente
r1397
Cleaning IO modules (base, voltaje and spectra)
r1251 if not os.path.exists(path):
os.mkdir(path)
José Chávez
merge revisado
r1074 timeTuple = time.localtime(self.dataOut.utctime)
subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year, timeTuple.tm_yday)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074 fullpath = os.path.join(path, subfolder)
Miguel Valdez
Bug fixed in jroIO_base:...
r632 setFile = self.setFile
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 if not(os.path.exists(fullpath)):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 os.mkdir(fullpath)
José Chávez
merge revisado
r1074 setFile = -1 # inicializo mi contador de seteo
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 else:
José Chávez
merge revisado
r1074 filesList = os.listdir(fullpath)
if len(filesList) > 0:
filesList = sorted(filesList, key=str.lower)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 filen = filesList[-1]
# el filename debera tener el siguiente formato
# 0 1234 567 89A BCDE (hex)
# x YYYY DDD SSS .ext
José Chávez
merge revisado
r1074 if isNumber(filen[8:11]):
# inicializo mi contador de seteo al seteo del ultimo file
setFile = int(filen[8:11])
add multiSchain (@jchavez)
r892 else:
Miguel Valdez
Bug fixed in jroIO_base:...
r632 setFile = -1
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 else:
José Chávez
merge revisado
r1074 setFile = -1 # inicializo mi contador de seteo
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 setFile += 1
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 # If this is a new day it resets some values
Miguel Valdez
Bug fixed in jroIO_base:...
r632 if self.dataOut.datatime.date() > self.fileDate:
setFile = 0
self.nTotalBlocks = 0
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Juan C. Espinoza
set new matplotlib version in setup, improved searchFiles for multiprocessing
r1112 filen = '{}{:04d}{:03d}{:03d}{}'.format(
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074 filename = os.path.join(path, subfolder, filen)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487
José Chávez
merge revisado
r1074 fp = open(filename, 'wb')
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.blockIndex = 0
self.filename = filename
self.subfolder = subfolder
self.fp = fp
self.setFile = setFile
self.flagIsNewFile = 1
Miguel Valdez
Bug fixed in jroIO_base:...
r632 self.fileDate = self.dataOut.datatime.date()
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.setFirstHeader()
add multiSchain (@jchavez)
r892
George Yong
Python 2to3, Spectra (all operations) working
r1167 print('[Writing] Opening file: %s' % self.filename)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.__writeFirstHeader()
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
add multiSchain (@jchavez)
r892
Juan C. Espinoza
Change multiSchain by MPProject
r1052 def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4):
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
add multiSchain (@jchavez)
r892 Setea el tipo de formato en la cual sera guardada la data y escribe el First Header
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Inputs:
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 path : directory where data will be saved
add multiSchain (@jchavez)
r892 profilesPerBlock : number of profiles per block
Miguel Valdez
IO_Writer: default datatype was changed to 3 (int32), instead of 2 (int16).
r626 set : initial file set
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 datatype : An integer number that defines data type:
0 : int8 (1 byte)
1 : int16 (2 bytes)
2 : int32 (4 bytes)
3 : int64 (8 bytes)
Miguel Valdez
IO_Writer: default datatype was changed to 3 (int32), instead of 2 (int16).
r626 4 : float32 (4 bytes)
5 : double64 (8 bytes)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 Return:
0 : Si no realizo un buen seteo
add multiSchain (@jchavez)
r892 1 : Si realizo un buen seteo
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 """
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if ext == None:
ext = self.ext
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed in jroIO_base:...
r632 self.ext = ext.lower()
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.path = path
Adicionada operación Clean Rayleigh a Spectra Proc
r1385
Miguel Valdez
Bug fixed in jroIO_base:...
r632 if set is None:
self.setFile = -1
else:
Adicionada operación Clean Rayleigh a Spectra Proc
r1385 self.setFile = set - 1
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.blocksPerFile = blocksPerFile
self.profilesPerBlock = profilesPerBlock
self.dataOut = dataOut
Miguel Valdez
Bug fixed in jroIO_base:...
r632 self.fileDate = self.dataOut.datatime.date()
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 self.dtype = self.dataOut.dtype
add multiSchain (@jchavez)
r892
Miguel Valdez
Bug fixed: error calculating size of RC Header. ...
r616 if datatype is not None:
self.dtype = get_numpy_dtype(datatype)
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not(self.setNextFile()):
George Yong
Python 2to3, Spectra (all operations) working
r1167 print("[Writing] There isn't a next file")
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 0
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.setBlockDimension()
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 return 1
add multiSchain (@jchavez)
r892
ebocanegra
23/11/2017
r1123 def run(self, dataOut, path, blocksPerFile=100, profilesPerBlock=64, set=None, ext=None, datatype=4, **kwargs):
add multiSchain (@jchavez)
r892
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 if not(self.isConfig):
add multiSchain (@jchavez)
r892
José Chávez
merge revisado
r1074 self.setup(dataOut, path, blocksPerFile, profilesPerBlock=profilesPerBlock,
set=set, ext=ext, datatype=datatype, **kwargs)
Daniel Valdez
This is the new organization by packages and scripts for Signal Chain, this version contains new features and bugs fixed until August 2014
r487 self.isConfig = True
George Yong
Multiprocessing for writing Units(Spectral, Voltage and Parameters)
r1179 self.dataOut = dataOut
self.putData()
Cleaning IO modules (base, voltaje and spectra)
r1251 return self.dataOut
Juan C. Espinoza
Rewrite controller, remove MPDecorator to units (keep for plots an writers) use of queues for interproc comm instead of zmq, self operations are no longer supported
r1287
Juan C. Espinoza
Update plots modules
r1308 @MPDecorator
Juan C. Espinoza
Rewrite controller, remove MPDecorator to units (keep for plots an writers) use of queues for interproc comm instead of zmq, self operations are no longer supported
r1287 class printInfo(Operation):
def __init__(self):
Operation.__init__(self)
self.__printInfo = True
def run(self, dataOut, headers = ['systemHeaderObj', 'radarControllerHeaderObj', 'processingHeaderObj']):
if self.__printInfo == False:
Juan C. Espinoza
Update plots modules
r1308 return
Juan C. Espinoza
Rewrite controller, remove MPDecorator to units (keep for plots an writers) use of queues for interproc comm instead of zmq, self operations are no longer supported
r1287
for header in headers:
if hasattr(dataOut, header):
obj = getattr(dataOut, header)
if hasattr(obj, 'printInfo'):
obj.printInfo()
else:
print(obj)
else:
log.warning('Header {} Not found in object'.format(header))
self.__printInfo = False