@@ -1,7 +1,7 | |||
|
1 | 1 | ''' |
|
2 |
Created on |
|
|
2 | Created on Jul 3, 2018 | |
|
3 | 3 | |
|
4 | 4 | @author $Author$ |
|
5 | 5 | @version $Id$ |
|
6 | 6 | ''' |
|
7 |
__version__ = ' |
|
|
7 | __version__ = '3.0' |
@@ -11,8 +11,8 import sys | |||
|
11 | 11 | import time |
|
12 | 12 | import traceback |
|
13 | 13 | import smtplib |
|
14 |
import |
|
|
15 |
import |
|
|
14 | import configparser | |
|
15 | import io | |
|
16 | 16 | from threading import Thread |
|
17 | 17 | from multiprocessing import Process |
|
18 | 18 | from email.mime.text import MIMEText |
@@ -65,7 +65,7 class Alarm(Process): | |||
|
65 | 65 | @staticmethod |
|
66 | 66 | def send_email(**kwargs): |
|
67 | 67 | notifier = SchainNotify() |
|
68 |
print |
|
|
68 | print(kwargs) | |
|
69 | 69 | notifier.notify(**kwargs) |
|
70 | 70 | |
|
71 | 71 | @staticmethod |
@@ -144,10 +144,10 class SchainConfigure(): | |||
|
144 | 144 | return |
|
145 | 145 | |
|
146 | 146 | # create Parser using standard module ConfigParser |
|
147 |
self.__parser = |
|
|
147 | self.__parser = configparser.ConfigParser() | |
|
148 | 148 | |
|
149 | 149 | # read conf file into a StringIO with "[madrigal]\n" section heading prepended |
|
150 |
strConfFile = |
|
|
150 | strConfFile = io.StringIO("[schain]\n" + self.__confFile.read()) | |
|
151 | 151 | |
|
152 | 152 | # parse StringIO configuration file |
|
153 | 153 | self.__parser.readfp(strConfFile) |
@@ -355,7 +355,7 class SchainNotify: | |||
|
355 | 355 | if not self.__emailToAddress: |
|
356 | 356 | return 0 |
|
357 | 357 | |
|
358 |
print |
|
|
358 | print("***** Sending alert to %s *****" %self.__emailToAddress) | |
|
359 | 359 | # set up message |
|
360 | 360 | |
|
361 | 361 | sent=self.sendEmail(email_from=self.__emailFromAddress, |
@@ -500,4 +500,4 if __name__ == '__main__': | |||
|
500 | 500 | |
|
501 | 501 | test.sendAlert('This is a message from the python module SchainNotify', 'Test from SchainNotify') |
|
502 | 502 | |
|
503 |
print |
|
|
503 | print('Hopefully message sent - check.') No newline at end of file |
@@ -67,7 +67,7 def MPProject(project, n=cpu_count()): | |||
|
67 | 67 | for process in processes: |
|
68 | 68 | process.terminate() |
|
69 | 69 | process.join() |
|
70 |
print |
|
|
70 | print(traceback.print_tb(trace)) | |
|
71 | 71 | |
|
72 | 72 | sys.excepthook = beforeExit |
|
73 | 73 | |
@@ -114,7 +114,7 class ParameterConf(): | |||
|
114 | 114 | return self.__formated_value |
|
115 | 115 | |
|
116 | 116 | if value == '': |
|
117 |
raise ValueError |
|
|
117 | raise ValueError('%s: This parameter value is empty' % self.name) | |
|
118 | 118 | |
|
119 | 119 | if format == 'list': |
|
120 | 120 | strList = value.split(',') |
@@ -180,16 +180,16 class ParameterConf(): | |||
|
180 | 180 | new_value = ast.literal_eval(value) |
|
181 | 181 | |
|
182 | 182 | if type(new_value) not in (tuple, list): |
|
183 |
raise ValueError |
|
|
183 | raise ValueError('%s has to be a tuple or list of pairs' % value) | |
|
184 | 184 | |
|
185 | 185 | if type(new_value[0]) not in (tuple, list): |
|
186 | 186 | if len(new_value) != 2: |
|
187 |
raise ValueError |
|
|
187 | raise ValueError('%s has to be a tuple or list of pairs' % value) | |
|
188 | 188 | new_value = [new_value] |
|
189 | 189 | |
|
190 | 190 | for thisPair in new_value: |
|
191 | 191 | if len(thisPair) != 2: |
|
192 |
raise ValueError |
|
|
192 | raise ValueError('%s has to be a tuple or list of pairs' % value) | |
|
193 | 193 | |
|
194 | 194 | self.__formated_value = new_value |
|
195 | 195 | |
@@ -265,7 +265,7 class ParameterConf(): | |||
|
265 | 265 | |
|
266 | 266 | def printattr(self): |
|
267 | 267 | |
|
268 |
print |
|
|
268 | print('Parameter[%s]: name = %s, value = %s, format = %s' % (self.id, self.name, self.value, self.format)) | |
|
269 | 269 | |
|
270 | 270 | |
|
271 | 271 | class OperationConf(): |
@@ -434,11 +434,11 class OperationConf(): | |||
|
434 | 434 | |
|
435 | 435 | def printattr(self): |
|
436 | 436 | |
|
437 |
print |
|
|
437 | print('%s[%s]: name = %s, type = %s, priority = %s' % (self.ELEMENTNAME, | |
|
438 | 438 | self.id, |
|
439 | 439 | self.name, |
|
440 | 440 | self.type, |
|
441 | self.priority) | |
|
441 | self.priority)) | |
|
442 | 442 | |
|
443 | 443 | for parmConfObj in self.parmConfObjList: |
|
444 | 444 | parmConfObj.printattr() |
@@ -446,11 +446,11 class OperationConf(): | |||
|
446 | 446 | def createObject(self, plotter_queue=None): |
|
447 | 447 | |
|
448 | 448 | if self.type == 'self': |
|
449 |
raise ValueError |
|
|
449 | raise ValueError('This operation type cannot be created') | |
|
450 | 450 | |
|
451 | 451 | if self.type == 'plotter': |
|
452 | 452 | if not plotter_queue: |
|
453 |
raise ValueError |
|
|
453 | raise ValueError('plotter_queue is not defined. Use:\nmyProject = Project()\nmyProject.setPlotterQueue(plotter_queue)') | |
|
454 | 454 | |
|
455 | 455 | opObj = Plotter(self.name, plotter_queue) |
|
456 | 456 | |
@@ -563,7 +563,7 class ProcUnitConf(): | |||
|
563 | 563 | |
|
564 | 564 | # Compatible with old signal chain version |
|
565 | 565 | if datatype == None and name == None: |
|
566 |
raise ValueError |
|
|
566 | raise ValueError('datatype or name should be defined') | |
|
567 | 567 | |
|
568 | 568 | if name == None: |
|
569 | 569 | if 'Proc' in datatype: |
@@ -652,11 +652,11 class ProcUnitConf(): | |||
|
652 | 652 | |
|
653 | 653 | def printattr(self): |
|
654 | 654 | |
|
655 |
print |
|
|
655 | print('%s[%s]: name = %s, datatype = %s, inputId = %s' % (self.ELEMENTNAME, | |
|
656 | 656 | self.id, |
|
657 | 657 | self.name, |
|
658 | 658 | self.datatype, |
|
659 | self.inputId) | |
|
659 | self.inputId)) | |
|
660 | 660 | |
|
661 | 661 | for opConfObj in self.opConfObjList: |
|
662 | 662 | opConfObj.printattr() |
@@ -759,7 +759,7 class ReadUnitConf(ProcUnitConf): | |||
|
759 | 759 | |
|
760 | 760 | # Compatible with old signal chain version |
|
761 | 761 | if datatype == None and name == None: |
|
762 |
raise ValueError |
|
|
762 | raise ValueError('datatype or name should be defined') | |
|
763 | 763 | if name == None: |
|
764 | 764 | if 'Reader' in datatype: |
|
765 | 765 | name = datatype |
@@ -831,7 +831,7 class ReadUnitConf(ProcUnitConf): | |||
|
831 | 831 | opObj.addParameter( |
|
832 | 832 | name='endTime', value=self.endTime, format='time') |
|
833 | 833 | |
|
834 | for key, value in kwargs.items(): | |
|
834 | for key, value in list(kwargs.items()): | |
|
835 | 835 | opObj.addParameter(name=key, value=value, |
|
836 | 836 | format=type(value).__name__) |
|
837 | 837 | else: |
@@ -853,7 +853,7 class ReadUnitConf(ProcUnitConf): | |||
|
853 | 853 | name='startTime', value=self.startTime, format='time') |
|
854 | 854 | opObj.addParameter(name='endTime', value=self.endTime, format='time') |
|
855 | 855 | |
|
856 | for key, value in kwargs.items(): | |
|
856 | for key, value in list(kwargs.items()): | |
|
857 | 857 | opObj.addParameter(name=key, value=value, |
|
858 | 858 | format=type(value).__name__) |
|
859 | 859 | |
@@ -914,7 +914,7 class Project(Process): | |||
|
914 | 914 | |
|
915 | 915 | def __getNewId(self): |
|
916 | 916 | |
|
917 | idList = self.procUnitConfObjDict.keys() | |
|
917 | idList = list(self.procUnitConfObjDict.keys()) | |
|
918 | 918 | |
|
919 | 919 | id = int(self.id) * 10 |
|
920 | 920 | |
@@ -940,7 +940,7 class Project(Process): | |||
|
940 | 940 | |
|
941 | 941 | self.id = str(new_id) |
|
942 | 942 | |
|
943 | keyList = self.procUnitConfObjDict.keys() | |
|
943 | keyList = list(self.procUnitConfObjDict.keys()) | |
|
944 | 944 | keyList.sort() |
|
945 | 945 | |
|
946 | 946 | n = 1 |
@@ -958,11 +958,11 class Project(Process): | |||
|
958 | 958 | |
|
959 | 959 | def setup(self, id, name='', description='', email=None, alarm=[]): |
|
960 | 960 | |
|
961 | ||
|
962 |
print |
|
|
963 |
print |
|
|
964 |
print |
|
|
965 | ||
|
961 | print() | |
|
962 | print('*' * 60) | |
|
963 | print(' Starting SIGNAL CHAIN PROCESSING v%s ' % schainpy.__version__) | |
|
964 | print('*' * 60) | |
|
965 | print() | |
|
966 | 966 | self.id = str(id) |
|
967 | 967 | self.description = description |
|
968 | 968 | self.email = email |
@@ -970,7 +970,7 class Project(Process): | |||
|
970 | 970 | |
|
971 | 971 | def update(self, **kwargs): |
|
972 | 972 | |
|
973 | for key, value in kwargs.items(): | |
|
973 | for key, value in list(kwargs.items()): | |
|
974 | 974 | setattr(self, key, value) |
|
975 | 975 | |
|
976 | 976 | def clone(self): |
@@ -1008,7 +1008,7 class Project(Process): | |||
|
1008 | 1008 | |
|
1009 | 1009 | def removeProcUnit(self, id): |
|
1010 | 1010 | |
|
1011 | if id in self.procUnitConfObjDict.keys(): | |
|
1011 | if id in list(self.procUnitConfObjDict.keys()): | |
|
1012 | 1012 | self.procUnitConfObjDict.pop(id) |
|
1013 | 1013 | |
|
1014 | 1014 | def getReadUnitId(self): |
@@ -1019,7 +1019,7 class Project(Process): | |||
|
1019 | 1019 | |
|
1020 | 1020 | def getReadUnitObj(self): |
|
1021 | 1021 | |
|
1022 | for obj in self.procUnitConfObjDict.values(): | |
|
1022 | for obj in list(self.procUnitConfObjDict.values()): | |
|
1023 | 1023 | if obj.getElementName() == 'ReadUnit': |
|
1024 | 1024 | return obj |
|
1025 | 1025 | |
@@ -1037,7 +1037,7 class Project(Process): | |||
|
1037 | 1037 | |
|
1038 | 1038 | def getProcUnitObjByName(self, name): |
|
1039 | 1039 | |
|
1040 | for obj in self.procUnitConfObjDict.values(): | |
|
1040 | for obj in list(self.procUnitConfObjDict.values()): | |
|
1041 | 1041 | if obj.name == name: |
|
1042 | 1042 | return obj |
|
1043 | 1043 | |
@@ -1045,7 +1045,7 class Project(Process): | |||
|
1045 | 1045 | |
|
1046 | 1046 | def procUnitItems(self): |
|
1047 | 1047 | |
|
1048 | return self.procUnitConfObjDict.items() | |
|
1048 | return list(self.procUnitConfObjDict.items()) | |
|
1049 | 1049 | |
|
1050 | 1050 | def makeXml(self): |
|
1051 | 1051 | |
@@ -1054,7 +1054,7 class Project(Process): | |||
|
1054 | 1054 | projectElement.set('name', self.name) |
|
1055 | 1055 | projectElement.set('description', self.description) |
|
1056 | 1056 | |
|
1057 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
|
1057 | for procUnitConfObj in list(self.procUnitConfObjDict.values()): | |
|
1058 | 1058 | procUnitConfObj.makeXml(projectElement) |
|
1059 | 1059 | |
|
1060 | 1060 | self.projectElement = projectElement |
@@ -1068,17 +1068,17 class Project(Process): | |||
|
1068 | 1068 | filename = 'schain.xml' |
|
1069 | 1069 | |
|
1070 | 1070 | if not filename: |
|
1071 |
print |
|
|
1071 | print('filename has not been defined. Use setFilename(filename) for do it.') | |
|
1072 | 1072 | return 0 |
|
1073 | 1073 | |
|
1074 | 1074 | abs_file = os.path.abspath(filename) |
|
1075 | 1075 | |
|
1076 | 1076 | if not os.access(os.path.dirname(abs_file), os.W_OK): |
|
1077 |
print |
|
|
1077 | print('No write permission on %s' % os.path.dirname(abs_file)) | |
|
1078 | 1078 | return 0 |
|
1079 | 1079 | |
|
1080 | 1080 | if os.path.isfile(abs_file) and not(os.access(abs_file, os.W_OK)): |
|
1081 |
print |
|
|
1081 | print('File %s already exists and it could not be overwriten' % abs_file) | |
|
1082 | 1082 | return 0 |
|
1083 | 1083 | |
|
1084 | 1084 | self.makeXml() |
@@ -1092,13 +1092,13 class Project(Process): | |||
|
1092 | 1092 | def readXml(self, filename=None): |
|
1093 | 1093 | |
|
1094 | 1094 | if not filename: |
|
1095 |
print |
|
|
1095 | print('filename is not defined') | |
|
1096 | 1096 | return 0 |
|
1097 | 1097 | |
|
1098 | 1098 | abs_file = os.path.abspath(filename) |
|
1099 | 1099 | |
|
1100 | 1100 | if not os.path.isfile(abs_file): |
|
1101 |
print |
|
|
1101 | print('%s file does not exist' % abs_file) | |
|
1102 | 1102 | return 0 |
|
1103 | 1103 | |
|
1104 | 1104 | self.projectElement = None |
@@ -1107,7 +1107,7 class Project(Process): | |||
|
1107 | 1107 | try: |
|
1108 | 1108 | self.projectElement = ElementTree().parse(abs_file) |
|
1109 | 1109 | except: |
|
1110 |
print |
|
|
1110 | print('Error reading %s, verify file format' % filename) | |
|
1111 | 1111 | return 0 |
|
1112 | 1112 | |
|
1113 | 1113 | self.project = self.projectElement.tag |
@@ -1146,16 +1146,16 class Project(Process): | |||
|
1146 | 1146 | |
|
1147 | 1147 | def printattr(self): |
|
1148 | 1148 | |
|
1149 |
print |
|
|
1149 | print('Project[%s]: name = %s, description = %s' % (self.id, | |
|
1150 | 1150 | self.name, |
|
1151 | self.description) | |
|
1151 | self.description)) | |
|
1152 | 1152 | |
|
1153 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
|
1153 | for procUnitConfObj in list(self.procUnitConfObjDict.values()): | |
|
1154 | 1154 | procUnitConfObj.printattr() |
|
1155 | 1155 | |
|
1156 | 1156 | def createObjects(self): |
|
1157 | 1157 | |
|
1158 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
|
1158 | for procUnitConfObj in list(self.procUnitConfObjDict.values()): | |
|
1159 | 1159 | procUnitConfObj.createObjects(self.plotterQueue) |
|
1160 | 1160 | |
|
1161 | 1161 | def __connect(self, objIN, thisObj): |
@@ -1164,7 +1164,7 class Project(Process): | |||
|
1164 | 1164 | |
|
1165 | 1165 | def connectObjects(self): |
|
1166 | 1166 | |
|
1167 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
|
1167 | for thisPUConfObj in list(self.procUnitConfObjDict.values()): | |
|
1168 | 1168 | |
|
1169 | 1169 | inputId = thisPUConfObj.getInputId() |
|
1170 | 1170 | |
@@ -1245,7 +1245,7 class Project(Process): | |||
|
1245 | 1245 | ''' |
|
1246 | 1246 | |
|
1247 | 1247 | if self.isPaused(): |
|
1248 |
print |
|
|
1248 | print('Process suspended') | |
|
1249 | 1249 | |
|
1250 | 1250 | while True: |
|
1251 | 1251 | time.sleep(0.1) |
@@ -1256,10 +1256,10 class Project(Process): | |||
|
1256 | 1256 | if self.isStopped(): |
|
1257 | 1257 | break |
|
1258 | 1258 | |
|
1259 |
print |
|
|
1259 | print('Process reinitialized') | |
|
1260 | 1260 | |
|
1261 | 1261 | if self.isStopped(): |
|
1262 |
print |
|
|
1262 | print('Process stopped') | |
|
1263 | 1263 | return 0 |
|
1264 | 1264 | |
|
1265 | 1265 | return 1 |
@@ -1270,15 +1270,15 class Project(Process): | |||
|
1270 | 1270 | |
|
1271 | 1271 | def setPlotterQueue(self, plotter_queue): |
|
1272 | 1272 | |
|
1273 |
raise NotImplementedError |
|
|
1273 | raise NotImplementedError('Use schainpy.controller_api.ControllerThread instead Project class') | |
|
1274 | 1274 | |
|
1275 | 1275 | def getPlotterQueue(self): |
|
1276 | 1276 | |
|
1277 |
raise NotImplementedError |
|
|
1277 | raise NotImplementedError('Use schainpy.controller_api.ControllerThread instead Project class') | |
|
1278 | 1278 | |
|
1279 | 1279 | def useExternalPlotter(self): |
|
1280 | 1280 | |
|
1281 |
raise NotImplementedError |
|
|
1281 | raise NotImplementedError('Use schainpy.controller_api.ControllerThread instead Project class') | |
|
1282 | 1282 | |
|
1283 | 1283 | def run(self): |
|
1284 | 1284 | |
@@ -1287,7 +1287,7 class Project(Process): | |||
|
1287 | 1287 | self.createObjects() |
|
1288 | 1288 | self.connectObjects() |
|
1289 | 1289 | |
|
1290 | keyList = self.procUnitConfObjDict.keys() | |
|
1290 | keyList = list(self.procUnitConfObjDict.keys()) | |
|
1291 | 1291 | keyList.sort() |
|
1292 | 1292 | |
|
1293 | 1293 | err = None |
@@ -1310,7 +1310,7 class Project(Process): | |||
|
1310 | 1310 | except KeyboardInterrupt: |
|
1311 | 1311 | is_ok = False |
|
1312 | 1312 | break |
|
1313 |
except ValueError |
|
|
1313 | except ValueError as e: | |
|
1314 | 1314 | time.sleep(0.5) |
|
1315 | 1315 | err = self.__handleError(procUnitConfObj) |
|
1316 | 1316 | is_ok = False |
@@ -1339,4 +1339,4 class Project(Process): | |||
|
1339 | 1339 | |
|
1340 | 1340 | log.success('{} finished (time: {}s)'.format( |
|
1341 | 1341 | self.name, |
|
1342 |
time.time()-self.start_time)) |
|
|
1342 | time.time()-self.start_time)) No newline at end of file |
@@ -1,5 +1,5 | |||
|
1 | 1 | import threading |
|
2 |
from |
|
|
2 | from queue import Queue | |
|
3 | 3 | |
|
4 | 4 | from schainpy.controller import Project |
|
5 | 5 | from schainpy.model.graphics.jroplotter import PlotManager |
@@ -77,7 +77,7 class ControllerThread(threading.Thread, Project): | |||
|
77 | 77 | |
|
78 | 78 | plotterList = PlotManager.plotterList |
|
79 | 79 | |
|
80 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
|
80 | for thisPUConfObj in list(self.procUnitConfObjDict.values()): | |
|
81 | 81 | |
|
82 | 82 | inputId = thisPUConfObj.getInputId() |
|
83 | 83 | |
@@ -176,4 +176,4 class ControllerThread(threading.Thread, Project): | |||
|
176 | 176 | # self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1) |
|
177 | 177 | # Project.run(self) |
|
178 | 178 | # self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1) |
|
179 |
# |
|
|
179 | # No newline at end of file |
@@ -5,8 +5,8 | |||
|
5 | 5 | # from schainpy.model.utils.jroutils import * |
|
6 | 6 | # from schainpy.serializer import * |
|
7 | 7 | |
|
8 | from graphics import * | |
|
9 | from data import * | |
|
10 | from io import * | |
|
11 | from proc import * | |
|
12 | from utils import * | |
|
8 | from .graphics import * | |
|
9 | from .data import * | |
|
10 | from .io import * | |
|
11 | from .proc import * | |
|
12 | from .utils import * |
@@ -7,7 +7,7 import sys | |||
|
7 | 7 | import numpy |
|
8 | 8 | import copy |
|
9 | 9 | import datetime |
|
10 | from __builtin__ import None | |
|
10 | ||
|
11 | 11 | |
|
12 | 12 | SPEED_OF_LIGHT = 299792458 |
|
13 | 13 | SPEED_OF_LIGHT = 3e8 |
@@ -78,7 +78,7 class Header(object): | |||
|
78 | 78 | message += self.__class__.__name__.upper() + "\n" |
|
79 | 79 | message += "#"*50 + "\n" |
|
80 | 80 | |
|
81 | keyList = self.__dict__.keys() | |
|
81 | keyList = list(self.__dict__.keys()) | |
|
82 | 82 | keyList.sort() |
|
83 | 83 | |
|
84 | 84 | for key in keyList: |
@@ -90,7 +90,7 class Header(object): | |||
|
90 | 90 | if attr: |
|
91 | 91 | message += "%s = %s" %("size", attr) + "\n" |
|
92 | 92 | |
|
93 |
print |
|
|
93 | print(message) | |
|
94 | 94 | |
|
95 | 95 | class FileHeader(Header): |
|
96 | 96 | |
@@ -134,9 +134,9 class FileHeader(Header): | |||
|
134 | 134 | |
|
135 | 135 | ''' |
|
136 | 136 | |
|
137 |
except Exception |
|
|
138 |
print |
|
|
139 |
print |
|
|
137 | except Exception as e: | |
|
138 | print("FileHeader: ") | |
|
139 | print(eBasicHeader) | |
|
140 | 140 | return 0 |
|
141 | 141 | |
|
142 | 142 | self.FileMgcNumber= byte(header['FileMgcNumber'][0]) |
@@ -279,8 +279,8 class RecordHeader(Header): | |||
|
279 | 279 | |
|
280 | 280 | try: |
|
281 | 281 | header = numpy.fromfile(fp,RECORD_STRUCTURE,1) |
|
282 |
except Exception |
|
|
283 |
print |
|
|
282 | except Exception as e: | |
|
283 | print("System Header: " + e) | |
|
284 | 284 | return 0 |
|
285 | 285 | |
|
286 | 286 | self.RecMgcNumber = header['RecMgcNumber'][0] #0x23030001 |
@@ -1,3 +1,3 | |||
|
1 | from jrodata import * | |
|
2 | from jroheaderIO import * | |
|
3 | from jroamisr import * No newline at end of file | |
|
1 | from .jrodata import * | |
|
2 | from .jroheaderIO import * | |
|
3 | from .jroamisr import * No newline at end of file |
@@ -68,7 +68,7 class AMISR: | |||
|
68 | 68 | if inputObj is None: |
|
69 | 69 | return copy.deepcopy(self) |
|
70 | 70 | |
|
71 | for key in inputObj.__dict__.keys(): | |
|
71 | for key in list(inputObj.__dict__.keys()): | |
|
72 | 72 | self.__dict__[key] = inputObj.__dict__[key] |
|
73 | 73 | |
|
74 | 74 | def getNHeights(self): |
@@ -8,8 +8,8 import copy | |||
|
8 | 8 | import numpy |
|
9 | 9 | import datetime |
|
10 | 10 | |
|
11 | from jroheaderIO import SystemHeader, RadarControllerHeader | |
|
12 | from schainpy import cSchain | |
|
11 | from .jroheaderIO import SystemHeader, RadarControllerHeader | |
|
12 | # from schainpy import cSchain | |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | def getNumpyDtype(dataTypeCode): |
@@ -27,7 +27,7 def getNumpyDtype(dataTypeCode): | |||
|
27 | 27 | elif dataTypeCode == 5: |
|
28 | 28 | numpyDtype = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) |
|
29 | 29 | else: |
|
30 |
raise ValueError |
|
|
30 | raise ValueError('dataTypeCode was not defined') | |
|
31 | 31 | |
|
32 | 32 | return numpyDtype |
|
33 | 33 | |
@@ -68,41 +68,41 def hildebrand_sekhon(data, navg): | |||
|
68 | 68 | """ |
|
69 | 69 | |
|
70 | 70 | sortdata = numpy.sort(data, axis=None) |
|
71 |
|
|
|
72 |
|
|
|
73 | # | |
|
74 |
|
|
|
75 |
|
|
|
76 | # | |
|
77 |
|
|
|
78 | # | |
|
79 |
|
|
|
80 | # | |
|
81 |
|
|
|
82 | # | |
|
83 |
|
|
|
84 | # | |
|
85 |
|
|
|
86 | # | |
|
87 |
|
|
|
88 | # | |
|
89 |
|
|
|
90 | # | |
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 | # | |
|
99 |
|
|
|
100 | # | |
|
101 |
|
|
|
102 | # | |
|
103 |
|
|
|
71 | lenOfData = len(sortdata) | |
|
72 | nums_min = lenOfData*0.2 | |
|
73 | ||
|
74 | if nums_min <= 5: | |
|
75 | nums_min = 5 | |
|
76 | ||
|
77 | sump = 0. | |
|
78 | ||
|
79 | sumq = 0. | |
|
80 | ||
|
81 | j = 0 | |
|
82 | ||
|
83 | cont = 1 | |
|
84 | ||
|
85 | while((cont==1)and(j<lenOfData)): | |
|
86 | ||
|
87 | sump += sortdata[j] | |
|
88 | ||
|
89 | sumq += sortdata[j]**2 | |
|
90 | ||
|
91 | if j > nums_min: | |
|
92 | rtest = float(j)/(j-1) + 1.0/navg | |
|
93 | if ((sumq*j) > (rtest*sump**2)): | |
|
94 | j = j - 1 | |
|
95 | sump = sump - sortdata[j] | |
|
96 | sumq = sumq - sortdata[j]**2 | |
|
97 | cont = 0 | |
|
98 | ||
|
99 | j += 1 | |
|
100 | ||
|
101 | lnoise = sump /j | |
|
102 | ||
|
103 | return lnoise | |
|
104 | 104 | |
|
105 | return cSchain.hildebrand_sekhon(sortdata, navg) | |
|
105 | # return cSchain.hildebrand_sekhon(sortdata, navg) | |
|
106 | 106 | |
|
107 | 107 | |
|
108 | 108 | class Beam: |
@@ -122,7 +122,7 class GenericData(object): | |||
|
122 | 122 | if inputObj == None: |
|
123 | 123 | return copy.deepcopy(self) |
|
124 | 124 | |
|
125 | for key in inputObj.__dict__.keys(): | |
|
125 | for key in list(inputObj.__dict__.keys()): | |
|
126 | 126 | |
|
127 | 127 | attribute = inputObj.__dict__[key] |
|
128 | 128 | |
@@ -241,7 +241,7 class JROData(GenericData): | |||
|
241 | 241 | |
|
242 | 242 | def getChannelIndexList(self): |
|
243 | 243 | |
|
244 | return range(self.nChannels) | |
|
244 | return list(range(self.nChannels)) | |
|
245 | 245 | |
|
246 | 246 | def getNHeights(self): |
|
247 | 247 | |
@@ -662,7 +662,7 class Spectra(JROData): | |||
|
662 | 662 | |
|
663 | 663 | def getPairsIndexList(self): |
|
664 | 664 | |
|
665 | return range(self.nPairs) | |
|
665 | return list(range(self.nPairs)) | |
|
666 | 666 | |
|
667 | 667 | def getNormFactor(self): |
|
668 | 668 | |
@@ -714,8 +714,8 class Spectra(JROData): | |||
|
714 | 714 | pairsIndexList = [] |
|
715 | 715 | for pair in pairsList: |
|
716 | 716 | if pair not in self.pairsList: |
|
717 |
raise ValueError |
|
|
718 | pair) | |
|
717 | raise ValueError("Pair %s is not in dataOut.pairsList" % ( | |
|
718 | pair)) | |
|
719 | 719 | pairsIndexList.append(self.pairsList.index(pair)) |
|
720 | 720 | for i in range(len(pairsIndexList)): |
|
721 | 721 | pair = self.pairsList[pairsIndexList[i]] |
@@ -736,7 +736,7 class Spectra(JROData): | |||
|
736 | 736 | |
|
737 | 737 | def setValue(self, value): |
|
738 | 738 | |
|
739 |
print |
|
|
739 | print("This property should not be initialized") | |
|
740 | 740 | |
|
741 | 741 | return |
|
742 | 742 | |
@@ -941,7 +941,7 class Fits(JROData): | |||
|
941 | 941 | |
|
942 | 942 | def getChannelIndexList(self): |
|
943 | 943 | |
|
944 | return range(self.nChannels) | |
|
944 | return list(range(self.nChannels)) | |
|
945 | 945 | |
|
946 | 946 | def getNoise(self, type=1): |
|
947 | 947 | |
@@ -1068,7 +1068,7 class Correlation(JROData): | |||
|
1068 | 1068 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
1069 | 1069 | |
|
1070 | 1070 | if ind_vel[0] < 0: |
|
1071 | ind_vel[range(0, 1)] = ind_vel[range(0, 1)] + self.num_prof | |
|
1071 | ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof | |
|
1072 | 1072 | |
|
1073 | 1073 | if mode == 1: |
|
1074 | 1074 | jspectra[:, freq_dc, :] = ( |
@@ -1080,7 +1080,7 class Correlation(JROData): | |||
|
1080 | 1080 | xx = numpy.zeros([4, 4]) |
|
1081 | 1081 | |
|
1082 | 1082 | for fil in range(4): |
|
1083 | xx[fil, :] = vel[fil]**numpy.asarray(range(4)) | |
|
1083 | xx[fil, :] = vel[fil]**numpy.asarray(list(range(4))) | |
|
1084 | 1084 | |
|
1085 | 1085 | xx_inv = numpy.linalg.inv(xx) |
|
1086 | 1086 | xx_aux = xx_inv[0, :] |
@@ -1239,7 +1239,7 class Parameters(Spectra): | |||
|
1239 | 1239 | |
|
1240 | 1240 | def setValue(self, value): |
|
1241 | 1241 | |
|
1242 |
print |
|
|
1242 | print("This property should not be initialized") | |
|
1243 | 1243 | |
|
1244 | 1244 | return |
|
1245 | 1245 | |
@@ -1248,4 +1248,4 class Parameters(Spectra): | |||
|
1248 | 1248 | return self.spc_noise |
|
1249 | 1249 | |
|
1250 | 1250 | timeInterval = property(getTimeInterval) |
|
1251 |
noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
|
|
1251 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") No newline at end of file |
@@ -8,6 +8,7 import numpy | |||
|
8 | 8 | import copy |
|
9 | 9 | import datetime |
|
10 | 10 | import inspect |
|
11 | from schainpy.utils import log | |
|
11 | 12 | |
|
12 | 13 | SPEED_OF_LIGHT = 299792458 |
|
13 | 14 | SPEED_OF_LIGHT = 3e8 |
@@ -110,7 +111,7 class Header(object): | |||
|
110 | 111 | message += self.__class__.__name__.upper() + "\n" |
|
111 | 112 | message += "#" * 50 + "\n" |
|
112 | 113 | |
|
113 | keyList = self.__dict__.keys() | |
|
114 | keyList = list(self.__dict__.keys()) | |
|
114 | 115 | keyList.sort() |
|
115 | 116 | |
|
116 | 117 | for key in keyList: |
@@ -122,7 +123,7 class Header(object): | |||
|
122 | 123 | if attr: |
|
123 | 124 | message += "%s = %s" % ("size", attr) + "\n" |
|
124 | 125 | |
|
125 |
print |
|
|
126 | print(message) | |
|
126 | 127 | |
|
127 | 128 | |
|
128 | 129 | class BasicHeader(Header): |
@@ -161,9 +162,9 class BasicHeader(Header): | |||
|
161 | 162 | header = numpy.fromfile(fp, BASIC_STRUCTURE, 1) |
|
162 | 163 | else: |
|
163 | 164 | header = numpy.fromstring(fp, BASIC_STRUCTURE, 1) |
|
164 |
except Exception |
|
|
165 |
print |
|
|
166 |
print |
|
|
165 | except Exception as e: | |
|
166 | print("BasicHeader: ") | |
|
167 | print(e) | |
|
167 | 168 | return 0 |
|
168 | 169 | |
|
169 | 170 | self.size = int(header['nSize'][0]) |
@@ -229,7 +230,7 class SystemHeader(Header): | |||
|
229 | 230 | self.length = 0 |
|
230 | 231 | try: |
|
231 | 232 | startFp = fp.tell() |
|
232 |
except Exception |
|
|
233 | except Exception as e: | |
|
233 | 234 | startFp = None |
|
234 | 235 | pass |
|
235 | 236 | |
@@ -238,8 +239,8 class SystemHeader(Header): | |||
|
238 | 239 | header = numpy.fromfile(fp, SYSTEM_STRUCTURE, 1) |
|
239 | 240 | else: |
|
240 | 241 | header = numpy.fromstring(fp, SYSTEM_STRUCTURE, 1) |
|
241 |
except Exception |
|
|
242 |
print |
|
|
242 | except Exception as e: | |
|
243 | print("System Header: " + str(e)) | |
|
243 | 244 | return 0 |
|
244 | 245 | |
|
245 | 246 | self.size = header['nSize'][0] |
@@ -344,7 +345,7 class RadarControllerHeader(Header): | |||
|
344 | 345 | self.length = 0 |
|
345 | 346 | try: |
|
346 | 347 | startFp = fp.tell() |
|
347 |
except Exception |
|
|
348 | except Exception as e: | |
|
348 | 349 | startFp = None |
|
349 | 350 | pass |
|
350 | 351 | |
@@ -354,8 +355,8 class RadarControllerHeader(Header): | |||
|
354 | 355 | else: |
|
355 | 356 | header = numpy.fromstring(fp, RADAR_STRUCTURE, 1) |
|
356 | 357 | self.length += header.nbytes |
|
357 |
except Exception |
|
|
358 |
print |
|
|
358 | except Exception as e: | |
|
359 | print("RadarControllerHeader: " + str(e)) | |
|
359 | 360 | return 0 |
|
360 | 361 | |
|
361 | 362 | size = int(header['nSize'][0]) |
@@ -384,8 +385,8 class RadarControllerHeader(Header): | |||
|
384 | 385 | samplingWindow = numpy.fromstring( |
|
385 | 386 | fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) |
|
386 | 387 | self.length += samplingWindow.nbytes |
|
387 |
except Exception |
|
|
388 |
print |
|
|
388 | except Exception as e: | |
|
389 | print("RadarControllerHeader: " + str(e)) | |
|
389 | 390 | return 0 |
|
390 | 391 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) |
|
391 | 392 | self.firstHeight = samplingWindow['h0'] |
@@ -399,8 +400,8 class RadarControllerHeader(Header): | |||
|
399 | 400 | self.Taus = numpy.fromstring( |
|
400 | 401 | fp[self.length:], '<f4', self.numTaus) |
|
401 | 402 | self.length += self.Taus.nbytes |
|
402 |
except Exception |
|
|
403 |
print |
|
|
403 | except Exception as e: | |
|
404 | print("RadarControllerHeader: " + str(e)) | |
|
404 | 405 | return 0 |
|
405 | 406 | |
|
406 | 407 | self.code_size = 0 |
@@ -419,8 +420,8 class RadarControllerHeader(Header): | |||
|
419 | 420 | self.nBaud = numpy.fromstring( |
|
420 | 421 | fp[self.length:], '<u4', 1)[0] |
|
421 | 422 | self.length += self.nBaud.nbytes |
|
422 |
except Exception |
|
|
423 |
print |
|
|
423 | except Exception as e: | |
|
424 | print("RadarControllerHeader: " + str(e)) | |
|
424 | 425 | return 0 |
|
425 | 426 | code = numpy.empty([self.nCode, self.nBaud], dtype='i1') |
|
426 | 427 | |
@@ -433,13 +434,14 class RadarControllerHeader(Header): | |||
|
433 | 434 | temp = numpy.fromstring( |
|
434 | 435 | fp, 'u4', int(numpy.ceil(self.nBaud / 32.))) |
|
435 | 436 | self.length += temp.nbytes |
|
436 |
except Exception |
|
|
437 |
print |
|
|
437 | except Exception as e: | |
|
438 | print("RadarControllerHeader: " + str(e)) | |
|
438 | 439 | return 0 |
|
439 | 440 | |
|
440 | 441 | for ib in range(self.nBaud - 1, -1, -1): |
|
441 |
|
|
|
442 |
|
|
|
442 | log.error(ib / 32) | |
|
443 | code[ic, ib] = temp[int(ib / 32)] % 2 | |
|
444 | temp[int(ib / 32)] = temp[int(ib / 32)] / 2 | |
|
443 | 445 | |
|
444 | 446 | self.code = 2.0 * code - 1.0 |
|
445 | 447 | self.code_size = int(numpy.ceil(self.nBaud / 32.)) * self.nCode * 4 |
@@ -454,7 +456,7 class RadarControllerHeader(Header): | |||
|
454 | 456 | |
|
455 | 457 | if fp.tell() != endFp: |
|
456 | 458 | # fp.seek(endFp) |
|
457 |
print |
|
|
459 | print("%s: Radar Controller Header size is not consistent: from data [%d] != from header field [%d]" % (fp.name, fp.tell() - startFp, size)) | |
|
458 | 460 | # return 0 |
|
459 | 461 | |
|
460 | 462 | if fp.tell() > endFp: |
@@ -557,7 +559,7 class RadarControllerHeader(Header): | |||
|
557 | 559 | |
|
558 | 560 | def set_size(self, value): |
|
559 | 561 | |
|
560 |
raise IOError |
|
|
562 | raise IOError("size is a property and it cannot be set, just read") | |
|
561 | 563 | |
|
562 | 564 | return |
|
563 | 565 | |
@@ -617,7 +619,7 class ProcessingHeader(Header): | |||
|
617 | 619 | self.length = 0 |
|
618 | 620 | try: |
|
619 | 621 | startFp = fp.tell() |
|
620 |
except Exception |
|
|
622 | except Exception as e: | |
|
621 | 623 | startFp = None |
|
622 | 624 | pass |
|
623 | 625 | |
@@ -627,8 +629,8 class ProcessingHeader(Header): | |||
|
627 | 629 | else: |
|
628 | 630 | header = numpy.fromstring(fp, PROCESSING_STRUCTURE, 1) |
|
629 | 631 | self.length += header.nbytes |
|
630 |
except Exception |
|
|
631 |
print |
|
|
632 | except Exception as e: | |
|
633 | print("ProcessingHeader: " + str(e)) | |
|
632 | 634 | return 0 |
|
633 | 635 | |
|
634 | 636 | size = int(header['nSize'][0]) |
@@ -650,8 +652,8 class ProcessingHeader(Header): | |||
|
650 | 652 | samplingWindow = numpy.fromstring( |
|
651 | 653 | fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) |
|
652 | 654 | self.length += samplingWindow.nbytes |
|
653 |
except Exception |
|
|
654 |
print |
|
|
655 | except Exception as e: | |
|
656 | print("ProcessingHeader: " + str(e)) | |
|
655 | 657 | return 0 |
|
656 | 658 | |
|
657 | 659 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) |
@@ -667,8 +669,8 class ProcessingHeader(Header): | |||
|
667 | 669 | self.spectraComb = numpy.fromstring( |
|
668 | 670 | fp[self.length:], 'u1', 2 * self.totalSpectra) |
|
669 | 671 | self.length += self.spectraComb.nbytes |
|
670 |
except Exception |
|
|
671 |
print |
|
|
672 | except Exception as e: | |
|
673 | print("ProcessingHeader: " + str(e)) | |
|
672 | 674 | return 0 |
|
673 | 675 | |
|
674 | 676 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): |
@@ -783,7 +785,7 class ProcessingHeader(Header): | |||
|
783 | 785 | |
|
784 | 786 | def set_size(self, value): |
|
785 | 787 | |
|
786 |
raise IOError |
|
|
788 | raise IOError("size is a property and it cannot be set, just read") | |
|
787 | 789 | |
|
788 | 790 | return |
|
789 | 791 | |
@@ -902,4 +904,4 def get_procflag_dtype(index): | |||
|
902 | 904 | |
|
903 | 905 | def get_dtype_width(index): |
|
904 | 906 | |
|
905 |
return DTYPE_WIDTH[index] |
|
|
907 | return DTYPE_WIDTH[index] No newline at end of file |
@@ -1,7 +1,7 | |||
|
1 | from jroplot_voltage import * | |
|
2 | from jroplot_spectra import * | |
|
3 | from jroplot_heispectra import * | |
|
4 | from jroplot_correlation import * | |
|
5 | from jroplot_parameters import * | |
|
6 | from jroplot_data import * | |
|
7 | from jroplotter import * | |
|
1 | from .jroplot_voltage import * | |
|
2 | from .jroplot_spectra import * | |
|
3 | from .jroplot_heispectra import * | |
|
4 | from .jroplot_correlation import * | |
|
5 | from .jroplot_parameters import * | |
|
6 | from .jroplot_data import * | |
|
7 | from .jroplotter import * |
@@ -1,7 +1,7 | |||
|
1 | 1 | import os |
|
2 | 2 | import numpy |
|
3 | 3 | import time, datetime |
|
4 | import mpldriver | |
|
4 | from schainpy.model.graphics import mpldriver | |
|
5 | 5 | |
|
6 | 6 | from schainpy.model.proc.jroproc_base import Operation |
|
7 | 7 | |
@@ -130,7 +130,7 class Figure(Operation): | |||
|
130 | 130 | |
|
131 | 131 | def init(self, id, nplots, wintitle): |
|
132 | 132 | |
|
133 |
raise NotImplementedError |
|
|
133 | raise NotImplementedError("This method has been replaced by createFigure") | |
|
134 | 134 | |
|
135 | 135 | def createFigure(self, id, wintitle, widthplot=None, heightplot=None, show=True): |
|
136 | 136 | |
@@ -188,11 +188,11 class Figure(Operation): | |||
|
188 | 188 | |
|
189 | 189 | def setTextFromAxes(self, text): |
|
190 | 190 | |
|
191 |
raise NotImplementedError |
|
|
191 | raise NotImplementedError("This method has been replaced with Axes.setText") | |
|
192 | 192 | |
|
193 | 193 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
194 | 194 | |
|
195 |
raise NotImplementedError |
|
|
195 | raise NotImplementedError("This method has been replaced with Axes.addAxes") | |
|
196 | 196 | |
|
197 | 197 | def addAxes(self, *args): |
|
198 | 198 | """ |
@@ -234,7 +234,7 class Figure(Operation): | |||
|
234 | 234 | if not figfile: |
|
235 | 235 | |
|
236 | 236 | if not thisDatetime: |
|
237 |
raise ValueError |
|
|
237 | raise ValueError("Saving figure: figfile or thisDatetime should be defined") | |
|
238 | 238 | return |
|
239 | 239 | |
|
240 | 240 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
@@ -654,4 +654,4 class Axes: | |||
|
654 | 654 | z_buffer[index[0],::] = self.__missing |
|
655 | 655 | z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing) |
|
656 | 656 | |
|
657 |
return x_buffer, y_buffer, z_buffer |
|
|
657 | return x_buffer, y_buffer, z_buffer No newline at end of file |
@@ -3,7 +3,7 import datetime | |||
|
3 | 3 | import numpy |
|
4 | 4 | import copy |
|
5 | 5 | from schainpy.model import * |
|
6 | from figure import Figure, isRealtime | |
|
6 | from .figure import Figure, isRealtime | |
|
7 | 7 | |
|
8 | 8 | class CorrelationPlot(Figure): |
|
9 | 9 | isConfig = None |
@@ -99,7 +99,7 class CorrelationPlot(Figure): | |||
|
99 | 99 | |
|
100 | 100 | if realtime: |
|
101 | 101 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
102 |
print |
|
|
102 | print('Skipping this plot function') | |
|
103 | 103 | return |
|
104 | 104 | |
|
105 | 105 | if channelList == None: |
@@ -108,7 +108,7 class CorrelationPlot(Figure): | |||
|
108 | 108 | channelIndexList = [] |
|
109 | 109 | for channel in channelList: |
|
110 | 110 | if channel not in dataOut.channelList: |
|
111 |
raise ValueError |
|
|
111 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
112 | 112 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
113 | 113 | |
|
114 | 114 | factor = dataOut.normFactor |
@@ -184,4 +184,4 class CorrelationPlot(Figure): | |||
|
184 | 184 | save=save, |
|
185 | 185 | ftp=ftp, |
|
186 | 186 | wr_period=wr_period, |
|
187 |
thisDatetime=thisDatetime) |
|
|
187 | thisDatetime=thisDatetime) No newline at end of file |
@@ -339,7 +339,7 class PlotData(Operation, Process): | |||
|
339 | 339 | self.titles: list of axes title |
|
340 | 340 | |
|
341 | 341 | ''' |
|
342 | raise(NotImplementedError, 'Implement this method in child class') | |
|
342 | raise NotImplementedError | |
|
343 | 343 | |
|
344 | 344 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
345 | 345 | ''' |
@@ -490,7 +490,7 class PlotData(Operation, Process): | |||
|
490 | 490 | if self.save_labels: |
|
491 | 491 | labels = self.save_labels |
|
492 | 492 | else: |
|
493 | labels = range(self.nrows) | |
|
493 | labels = list(range(self.nrows)) | |
|
494 | 494 | |
|
495 | 495 | if self.oneFigure: |
|
496 | 496 | label = '' |
@@ -514,7 +514,7 class PlotData(Operation, Process): | |||
|
514 | 514 | def plot(self): |
|
515 | 515 | ''' |
|
516 | 516 | ''' |
|
517 | raise(NotImplementedError, 'Implement this method in child class') | |
|
517 | raise NotImplementedError | |
|
518 | 518 | |
|
519 | 519 | def run(self): |
|
520 | 520 | |
@@ -961,7 +961,7 class PlotParamData(PlotRTIData): | |||
|
961 | 961 | self.ylabel = 'Height [km]' |
|
962 | 962 | if not self.titles: |
|
963 | 963 | self.titles = self.data.parameters \ |
|
964 |
if self.data.parameters else ['Param {}'.format(x) for x in |
|
|
964 | if self.data.parameters else ['Param {}'.format(x) for x in range(self.nrows)] | |
|
965 | 965 | if self.showSNR: |
|
966 | 966 | self.titles.append('SNR') |
|
967 | 967 | |
@@ -1041,7 +1041,7 class PlotPolarMapData(PlotData): | |||
|
1041 | 1041 | else: |
|
1042 | 1042 | self.nplots = self.data.shape(self.CODE)[0] |
|
1043 | 1043 | self.nrows = self.nplots |
|
1044 | self.channels = range(self.nplots) | |
|
1044 | self.channels = list(range(self.nplots)) | |
|
1045 | 1045 | if self.mode == 'E': |
|
1046 | 1046 | self.xlabel = 'Longitude' |
|
1047 | 1047 | self.ylabel = 'Latitude' |
@@ -1145,4 +1145,4 class PlotPolarMapData(PlotData): | |||
|
1145 | 1145 | self.titles = ['{} {}'.format(self.data.parameters[x], title) for x in self.channels] |
|
1146 | 1146 | self.saveTime = self.max_time |
|
1147 | 1147 | |
|
1148 |
|
|
|
1148 | No newline at end of file |
@@ -7,8 +7,8 import os | |||
|
7 | 7 | import datetime |
|
8 | 8 | import numpy |
|
9 | 9 | |
|
10 | from figure import Figure, isRealtime | |
|
11 | from plotting_codes import * | |
|
10 | from .figure import Figure, isRealtime | |
|
11 | from .plotting_codes import * | |
|
12 | 12 | |
|
13 | 13 | class SpectraHeisScope(Figure): |
|
14 | 14 | |
@@ -98,7 +98,7 class SpectraHeisScope(Figure): | |||
|
98 | 98 | |
|
99 | 99 | if dataOut.realtime: |
|
100 | 100 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
101 |
print |
|
|
101 | print('Skipping this plot function') | |
|
102 | 102 | return |
|
103 | 103 | |
|
104 | 104 | if channelList == None: |
@@ -107,7 +107,7 class SpectraHeisScope(Figure): | |||
|
107 | 107 | channelIndexList = [] |
|
108 | 108 | for channel in channelList: |
|
109 | 109 | if channel not in dataOut.channelList: |
|
110 |
raise ValueError |
|
|
110 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
111 | 111 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
112 | 112 | |
|
113 | 113 | # x = dataOut.heightList |
@@ -238,7 +238,7 class RTIfromSpectraHeis(Figure): | |||
|
238 | 238 | channelIndexList = [] |
|
239 | 239 | for channel in channelList: |
|
240 | 240 | if channel not in dataOut.channelList: |
|
241 |
raise ValueError |
|
|
241 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
242 | 242 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
243 | 243 | |
|
244 | 244 | if timerange != None: |
@@ -326,4 +326,4 class RTIfromSpectraHeis(Figure): | |||
|
326 | 326 | ftp=ftp, |
|
327 | 327 | wr_period=wr_period, |
|
328 | 328 | thisDatetime=thisDatetime, |
|
329 |
update_figfile=update_figfile) |
|
|
329 | update_figfile=update_figfile) No newline at end of file |
@@ -2,8 +2,8 import os | |||
|
2 | 2 | import datetime |
|
3 | 3 | import numpy |
|
4 | 4 | import inspect |
|
5 | from figure import Figure, isRealtime, isTimeInHourRange | |
|
6 | from plotting_codes import * | |
|
5 | from .figure import Figure, isRealtime, isTimeInHourRange | |
|
6 | from .plotting_codes import * | |
|
7 | 7 | |
|
8 | 8 | |
|
9 | 9 | class FitGauPlot(Figure): |
@@ -101,7 +101,7 class FitGauPlot(Figure): | |||
|
101 | 101 | """ |
|
102 | 102 | if realtime: |
|
103 | 103 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
104 |
print |
|
|
104 | print('Skipping this plot function') | |
|
105 | 105 | return |
|
106 | 106 | |
|
107 | 107 | if channelList == None: |
@@ -110,7 +110,7 class FitGauPlot(Figure): | |||
|
110 | 110 | channelIndexList = [] |
|
111 | 111 | for channel in channelList: |
|
112 | 112 | if channel not in dataOut.channelList: |
|
113 |
raise ValueError |
|
|
113 | raise ValueError("Channel %d is not in dataOut.channelList" %channel) | |
|
114 | 114 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
115 | 115 | |
|
116 | 116 | # if normFactor is None: |
@@ -134,7 +134,7 class FitGauPlot(Figure): | |||
|
134 | 134 | y = dataOut.getHeiRange() |
|
135 | 135 | |
|
136 | 136 | z = dataOut.GauSPC[:,GauSelector,:,:] #GauSelector] #dataOut.data_spc/factor |
|
137 |
print |
|
|
137 | print('GausSPC', z[0,32,10:40]) | |
|
138 | 138 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
139 | 139 | zdB = 10*numpy.log10(z) |
|
140 | 140 | |
@@ -311,7 +311,7 class MomentsPlot(Figure): | |||
|
311 | 311 | |
|
312 | 312 | if realtime: |
|
313 | 313 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
314 |
print |
|
|
314 | print('Skipping this plot function') | |
|
315 | 315 | return |
|
316 | 316 | |
|
317 | 317 | if channelList == None: |
@@ -320,7 +320,7 class MomentsPlot(Figure): | |||
|
320 | 320 | channelIndexList = [] |
|
321 | 321 | for channel in channelList: |
|
322 | 322 | if channel not in dataOut.channelList: |
|
323 |
raise ValueError |
|
|
323 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
324 | 324 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
325 | 325 | |
|
326 | 326 | factor = dataOut.normFactor |
@@ -701,7 +701,7 class WindProfilerPlot(Figure): | |||
|
701 | 701 | if ymin == None: ymin = numpy.nanmin(y) |
|
702 | 702 | if ymax == None: ymax = numpy.nanmax(y) |
|
703 | 703 | |
|
704 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) | |
|
704 | if zmax == None: zmax = numpy.nanmax(abs(z[list(range(2)),:])) | |
|
705 | 705 | #if numpy.isnan(zmax): zmax = 50 |
|
706 | 706 | if zmin == None: zmin = -zmax |
|
707 | 707 | |
@@ -875,12 +875,12 class ParametersPlot(Figure): | |||
|
875 | 875 | return |
|
876 | 876 | |
|
877 | 877 | if channelList == None: |
|
878 | channelIndexList = range(dataOut.data_param.shape[0]) | |
|
878 | channelIndexList = list(range(dataOut.data_param.shape[0])) | |
|
879 | 879 | else: |
|
880 | 880 | channelIndexList = [] |
|
881 | 881 | for channel in channelList: |
|
882 | 882 | if channel not in dataOut.channelList: |
|
883 |
raise ValueError |
|
|
883 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
884 | 884 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
885 | 885 | |
|
886 | 886 | x = dataOut.getTimeRange1(dataOut.paramInterval) |
@@ -2148,4 +2148,4 class NSMeteorDetection2Plot(Figure): | |||
|
2148 | 2148 | save=save, |
|
2149 | 2149 | ftp=ftp, |
|
2150 | 2150 | wr_period=wr_period, |
|
2151 |
thisDatetime=thisDatetime) |
|
|
2151 | thisDatetime=thisDatetime) No newline at end of file |
@@ -7,8 +7,8 import os | |||
|
7 | 7 | import datetime |
|
8 | 8 | import numpy |
|
9 | 9 | |
|
10 | from figure import Figure, isRealtime, isTimeInHourRange | |
|
11 | from plotting_codes import * | |
|
10 | from .figure import Figure, isRealtime, isTimeInHourRange | |
|
11 | from .plotting_codes import * | |
|
12 | 12 | |
|
13 | 13 | |
|
14 | 14 | class SpectraPlot(Figure): |
@@ -106,7 +106,7 class SpectraPlot(Figure): | |||
|
106 | 106 | """ |
|
107 | 107 | if realtime: |
|
108 | 108 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
109 |
print |
|
|
109 | print('Skipping this plot function') | |
|
110 | 110 | return |
|
111 | 111 | |
|
112 | 112 | if channelList == None: |
@@ -115,7 +115,7 class SpectraPlot(Figure): | |||
|
115 | 115 | channelIndexList = [] |
|
116 | 116 | for channel in channelList: |
|
117 | 117 | if channel not in dataOut.channelList: |
|
118 |
raise ValueError |
|
|
118 | raise ValueError("Channel %d is not in dataOut.channelList" %channel) | |
|
119 | 119 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
120 | 120 | |
|
121 | 121 | if normFactor is None: |
@@ -307,7 +307,7 class CrossSpectraPlot(Figure): | |||
|
307 | 307 | pairsIndexList = [] |
|
308 | 308 | for pair in pairsList: |
|
309 | 309 | if pair not in dataOut.pairsList: |
|
310 |
raise ValueError |
|
|
310 | raise ValueError("Pair %s is not in dataOut.pairsList" %str(pair)) | |
|
311 | 311 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
312 | 312 | |
|
313 | 313 | if not pairsIndexList: |
@@ -554,7 +554,7 class RTIPlot(Figure): | |||
|
554 | 554 | channelIndexList = [] |
|
555 | 555 | for channel in channelList: |
|
556 | 556 | if channel not in dataOut.channelList: |
|
557 |
raise ValueError |
|
|
557 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
558 | 558 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
559 | 559 | |
|
560 | 560 | if normFactor is None: |
@@ -581,7 +581,7 class RTIPlot(Figure): | |||
|
581 | 581 | |
|
582 | 582 | update_figfile = False |
|
583 | 583 | |
|
584 | if dataOut.ltctime >= self.xmax: | |
|
584 | if self.xmax is not None and dataOut.ltctime >= self.xmax: #yong | |
|
585 | 585 | self.counter_imagwr = wr_period |
|
586 | 586 | self.isConfig = False |
|
587 | 587 | update_figfile = True |
@@ -732,7 +732,7 class CoherenceMap(Figure): | |||
|
732 | 732 | pairsIndexList = [] |
|
733 | 733 | for pair in pairsList: |
|
734 | 734 | if pair not in dataOut.pairsList: |
|
735 |
raise ValueError |
|
|
735 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) | |
|
736 | 736 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
737 | 737 | |
|
738 | 738 | if pairsIndexList == []: |
@@ -915,7 +915,7 class PowerProfilePlot(Figure): | |||
|
915 | 915 | channelIndexList = [] |
|
916 | 916 | for channel in channelList: |
|
917 | 917 | if channel not in dataOut.channelList: |
|
918 |
raise ValueError |
|
|
918 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
919 | 919 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
920 | 920 | |
|
921 | 921 | factor = dataOut.normFactor |
@@ -1040,7 +1040,7 class SpectraCutPlot(Figure): | |||
|
1040 | 1040 | channelIndexList = [] |
|
1041 | 1041 | for channel in channelList: |
|
1042 | 1042 | if channel not in dataOut.channelList: |
|
1043 |
raise ValueError |
|
|
1043 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
1044 | 1044 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1045 | 1045 | |
|
1046 | 1046 | factor = dataOut.normFactor |
@@ -1219,7 +1219,7 class Noise(Figure): | |||
|
1219 | 1219 | channelIndexList = [] |
|
1220 | 1220 | for channel in channelList: |
|
1221 | 1221 | if channel not in dataOut.channelList: |
|
1222 |
raise ValueError |
|
|
1222 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
1223 | 1223 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1224 | 1224 | |
|
1225 | 1225 | x = dataOut.getTimeRange() |
@@ -1408,7 +1408,7 class BeaconPhase(Figure): | |||
|
1408 | 1408 | pairsIndexList = [] |
|
1409 | 1409 | for pair in pairsList: |
|
1410 | 1410 | if pair not in dataOut.pairsList: |
|
1411 |
raise ValueError |
|
|
1411 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) | |
|
1412 | 1412 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1413 | 1413 | |
|
1414 | 1414 | if pairsIndexList == []: |
@@ -1539,4 +1539,4 class BeaconPhase(Figure): | |||
|
1539 | 1539 | ftp=ftp, |
|
1540 | 1540 | wr_period=wr_period, |
|
1541 | 1541 | thisDatetime=thisDatetime, |
|
1542 |
update_figfile=update_figfile) |
|
|
1542 | update_figfile=update_figfile) No newline at end of file |
@@ -7,7 +7,7 import os | |||
|
7 | 7 | import datetime |
|
8 | 8 | import numpy |
|
9 | 9 | |
|
10 | from figure import Figure | |
|
10 | from .figure import Figure | |
|
11 | 11 | |
|
12 | 12 | class Scope(Figure): |
|
13 | 13 | |
@@ -134,7 +134,7 class Scope(Figure): | |||
|
134 | 134 | channelIndexList = [] |
|
135 | 135 | for channel in channelList: |
|
136 | 136 | if channel not in dataOut.channelList: |
|
137 |
raise ValueError |
|
|
137 | raise ValueError("Channel %d is not in dataOut.channelList") | |
|
138 | 138 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
139 | 139 | |
|
140 | 140 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
@@ -222,4 +222,4 class Scope(Figure): | |||
|
222 | 222 | save=save, |
|
223 | 223 | ftp=ftp, |
|
224 | 224 | wr_period=wr_period, |
|
225 |
thisDatetime=thisDatetime) |
|
|
225 | thisDatetime=thisDatetime) No newline at end of file |
@@ -17,11 +17,11 import schainpy.admin | |||
|
17 | 17 | |
|
18 | 18 | from schainpy.model.proc.jroproc_base import Operation |
|
19 | 19 | from schainpy.model.serializer.data import obj2Dict, dict2Obj |
|
20 | from jroplot_correlation import * | |
|
21 | from jroplot_heispectra import * | |
|
22 | from jroplot_parameters import * | |
|
23 | from jroplot_spectra import * | |
|
24 | from jroplot_voltage import * | |
|
20 | from .jroplot_correlation import * | |
|
21 | from .jroplot_heispectra import * | |
|
22 | from .jroplot_parameters import * | |
|
23 | from .jroplot_spectra import * | |
|
24 | from .jroplot_voltage import * | |
|
25 | 25 | |
|
26 | 26 | |
|
27 | 27 | class Plotter(Operation): |
@@ -46,7 +46,7 class Plotter(Operation): | |||
|
46 | 46 | |
|
47 | 47 | def setup(self, **kwargs): |
|
48 | 48 | |
|
49 |
print |
|
|
49 | print("Initializing ...") | |
|
50 | 50 | |
|
51 | 51 | |
|
52 | 52 | def run(self, dataOut, id=None, **kwargs): |
@@ -106,8 +106,8 class PlotManager(): | |||
|
106 | 106 | sys.exc_info()[1], |
|
107 | 107 | sys.exc_info()[2]) |
|
108 | 108 | |
|
109 |
print |
|
|
110 |
print |
|
|
109 | print("***** Error occurred in PlotManager *****") | |
|
110 | print("***** [%s]: %s" %(name, err[-1])) | |
|
111 | 111 | |
|
112 | 112 | message = "\nError ocurred in %s:\n" %name |
|
113 | 113 | message += "".join(err) |
@@ -168,7 +168,7 class PlotManager(): | |||
|
168 | 168 | |
|
169 | 169 | dataPlot = serial_data['data'] |
|
170 | 170 | |
|
171 | if plot_id not in self.plotInstanceDict.keys(): | |
|
171 | if plot_id not in list(self.plotInstanceDict.keys()): | |
|
172 | 172 | className = eval(plot_name) |
|
173 | 173 | self.plotInstanceDict[plot_id] = className(**kwargs) |
|
174 | 174 | |
@@ -198,7 +198,7 class PlotManager(): | |||
|
198 | 198 | |
|
199 | 199 | self.__lock.acquire() |
|
200 | 200 | |
|
201 | for plot_id in self.plotInstanceDict.keys(): | |
|
201 | for plot_id in list(self.plotInstanceDict.keys()): | |
|
202 | 202 | plotter = self.plotInstanceDict[plot_id] |
|
203 | 203 | plotter.close() |
|
204 | 204 | |
@@ -211,7 +211,7 class PlotManager(): | |||
|
211 | 211 | def start(self): |
|
212 | 212 | |
|
213 | 213 | if not self.controllerThreadObj.isRunning(): |
|
214 |
raise RuntimeError |
|
|
214 | raise RuntimeError("controllerThreadObj has not been initialized. Use controllerThreadObj.start() before call this method") | |
|
215 | 215 | |
|
216 | 216 | self.join() |
|
217 | 217 | |
@@ -237,4 +237,4 class PlotManager(): | |||
|
237 | 237 | |
|
238 | 238 | self.__lock.release() |
|
239 | 239 | |
|
240 |
return err |
|
|
240 | return err No newline at end of file |
@@ -171,11 +171,11 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='' | |||
|
171 | 171 | |
|
172 | 172 | ###################################################### |
|
173 | 173 | if '0.' in matplotlib.__version__[0:2]: |
|
174 |
print |
|
|
174 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
175 | 175 | return iplot |
|
176 | 176 | |
|
177 | 177 | if '1.0.' in matplotlib.__version__[0:4]: |
|
178 |
print |
|
|
178 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
179 | 179 | return iplot |
|
180 | 180 | |
|
181 | 181 | if grid != None: |
@@ -246,11 +246,11 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, | |||
|
246 | 246 | ax_cb.yaxis.tick_right() |
|
247 | 247 | |
|
248 | 248 | if '0.' in matplotlib.__version__[0:2]: |
|
249 |
print |
|
|
249 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
250 | 250 | return imesh |
|
251 | 251 | |
|
252 | 252 | if '1.0.' in matplotlib.__version__[0:4]: |
|
253 |
print |
|
|
253 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
254 | 254 | return imesh |
|
255 | 255 | |
|
256 | 256 | matplotlib.pyplot.tight_layout() |
@@ -334,11 +334,11 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', tit | |||
|
334 | 334 | iplot = ax.lines[-1] |
|
335 | 335 | |
|
336 | 336 | if '0.' in matplotlib.__version__[0:2]: |
|
337 |
print |
|
|
337 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
338 | 338 | return iplot |
|
339 | 339 | |
|
340 | 340 | if '1.0.' in matplotlib.__version__[0:4]: |
|
341 |
print |
|
|
341 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
342 | 342 | return iplot |
|
343 | 343 | |
|
344 | 344 | if grid != None: |
@@ -407,11 +407,11 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='' | |||
|
407 | 407 | iplot = ax.lines[-1] |
|
408 | 408 | |
|
409 | 409 | if '0.' in matplotlib.__version__[0:2]: |
|
410 |
print |
|
|
410 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
411 | 411 | return iplot |
|
412 | 412 | |
|
413 | 413 | if '1.0.' in matplotlib.__version__[0:4]: |
|
414 |
print |
|
|
414 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
415 | 415 | return iplot |
|
416 | 416 | |
|
417 | 417 | if grid != None: |
@@ -461,11 +461,11 def createPolar(ax, x, y, | |||
|
461 | 461 | iplot = ax.lines[-1] |
|
462 | 462 | |
|
463 | 463 | if '0.' in matplotlib.__version__[0:2]: |
|
464 |
print |
|
|
464 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
465 | 465 | return iplot |
|
466 | 466 | |
|
467 | 467 | if '1.0.' in matplotlib.__version__[0:4]: |
|
468 |
print |
|
|
468 | print("The matplotlib version has to be updated to 1.1 or newer") | |
|
469 | 469 | return iplot |
|
470 | 470 | |
|
471 | 471 | # if grid != None: |
@@ -491,11 +491,11 def polar(iplot, x, y, xlabel='', ylabel='', title=''): | |||
|
491 | 491 | def draw(fig): |
|
492 | 492 | |
|
493 | 493 | if type(fig) == 'int': |
|
494 |
raise ValueError |
|
|
494 | raise ValueError("Error drawing: Fig parameter should be a matplotlib figure object figure") | |
|
495 | 495 | |
|
496 | 496 | fig.canvas.draw() |
|
497 | 497 | |
|
498 | 498 | |
|
499 | 499 | def pause(interval=0.000001): |
|
500 | 500 | |
|
501 |
matplotlib.pyplot.pause(interval) |
|
|
501 | matplotlib.pyplot.pause(interval) No newline at end of file |
@@ -291,8 +291,8 RadarConst5 = RadarConst | |||
|
291 | 291 | # print 'OffsetStartHeader ',self.OffsetStartHeader,'RecCounter ', self.RecCounter, 'Off2StartNxtRec ' , self.Off2StartNxtRec |
|
292 | 292 | #OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec |
|
293 | 293 | #startFp.seek(OffRHeader, os.SEEK_SET) |
|
294 |
print |
|
|
295 |
print |
|
|
294 | print('debe ser 48, RecCounter*811248', self.OffsetStartHeader, self.RecCounter, self.Off2StartNxtRec) | |
|
295 | print('Posicion del bloque: ', OffRHeader) | |
|
296 | 296 | |
|
297 | 297 | header = numpy.fromfile(startFp, SRVI_STRUCTURE, 1) |
|
298 | 298 | |
@@ -326,6 +326,6 self.Datasize = self.nProfiles * self.nChannels * self.nHeights * 2 * 4 | |||
|
326 | 326 | # print 'Datasize',self.Datasize |
|
327 | 327 | endFp = self.OffsetStartHeader + self.RecCounter * self.Off2StartNxtRec |
|
328 | 328 | |
|
329 |
print |
|
|
329 | print('==============================================') | |
|
330 | 330 | |
|
331 |
print |
|
|
331 | print('==============================================') No newline at end of file |
@@ -4,20 +4,20 $Author: murco $ | |||
|
4 | 4 | $Id: JRODataIO.py 169 2012-11-19 21:57:03Z murco $ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | from jroIO_voltage import * | |
|
8 | from jroIO_spectra import * | |
|
9 | from jroIO_heispectra import * | |
|
10 | from jroIO_usrp import * | |
|
11 | from jroIO_digitalRF import * | |
|
12 | from jroIO_kamisr import * | |
|
13 | from jroIO_param import * | |
|
14 | from jroIO_hf import * | |
|
7 | from .jroIO_voltage import * | |
|
8 | from .jroIO_spectra import * | |
|
9 | from .jroIO_heispectra import * | |
|
10 | from .jroIO_usrp import * | |
|
11 | from .jroIO_digitalRF import * | |
|
12 | from .jroIO_kamisr import * | |
|
13 | from .jroIO_param import * | |
|
14 | from .jroIO_hf import * | |
|
15 | 15 | |
|
16 | from jroIO_madrigal import * | |
|
16 | from .jroIO_madrigal import * | |
|
17 | 17 | |
|
18 | from bltrIO_param import * | |
|
19 | from jroIO_bltr import * | |
|
20 | from jroIO_mira35c import * | |
|
21 | from julIO_param import * | |
|
18 | from .bltrIO_param import * | |
|
19 | from .jroIO_bltr import * | |
|
20 | from .jroIO_mira35c import * | |
|
21 | from .julIO_param import * | |
|
22 | 22 | |
|
23 | from pxIO_param import * No newline at end of file | |
|
23 | from .pxIO_param import * No newline at end of file |
@@ -121,7 +121,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
121 | 121 | self.datatime = datetime.datetime(1900,1,1) |
|
122 | 122 | |
|
123 | 123 | if self.path is None: |
|
124 |
raise ValueError |
|
|
124 | raise ValueError("The path is not valid") | |
|
125 | 125 | |
|
126 | 126 | if ext is None: |
|
127 | 127 | ext = self.ext |
@@ -131,8 +131,8 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
131 | 131 | self.fileIndex = 0 |
|
132 | 132 | |
|
133 | 133 | if not self.fileList: |
|
134 |
raise Warning |
|
|
135 | path) | |
|
134 | raise Warning("There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' " % ( | |
|
135 | path)) | |
|
136 | 136 | |
|
137 | 137 | self.setNextFile() |
|
138 | 138 | |
@@ -340,7 +340,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
340 | 340 | self.dataOut.sizeOfFile = self.sizeOfFile |
|
341 | 341 | self.dataOut.lat = self.lat |
|
342 | 342 | self.dataOut.lon = self.lon |
|
343 | self.dataOut.channelList = range(self.nchannels) | |
|
343 | self.dataOut.channelList = list(range(self.nchannels)) | |
|
344 | 344 | self.dataOut.kchan = self.kchan |
|
345 | 345 | self.dataOut.delta = self.delta |
|
346 | 346 | self.dataOut.correction = self.correction |
@@ -366,4 +366,4 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
366 | 366 | |
|
367 | 367 | self.set_output() |
|
368 | 368 | |
|
369 |
return 1 |
|
|
369 | return 1 No newline at end of file |
@@ -144,7 +144,7 class AMISRReader(ProcessingUnit): | |||
|
144 | 144 | self.status = 1 |
|
145 | 145 | else: |
|
146 | 146 | self.status = 0 |
|
147 |
print |
|
|
147 | print('Path:%s does not exists'%self.path) | |
|
148 | 148 | |
|
149 | 149 | return |
|
150 | 150 | |
@@ -169,11 +169,11 class AMISRReader(ProcessingUnit): | |||
|
169 | 169 | |
|
170 | 170 | pat = '\d+.\d+' |
|
171 | 171 | dirnameList = [re.search(pat,x) for x in os.listdir(self.path)] |
|
172 |
dirnameList = |
|
|
172 | dirnameList = [x for x in dirnameList if x!=None] | |
|
173 | 173 | dirnameList = [x.string for x in dirnameList] |
|
174 | 174 | if not(online): |
|
175 | 175 | dirnameList = [self.__selDates(x) for x in dirnameList] |
|
176 |
dirnameList = |
|
|
176 | dirnameList = [x for x in dirnameList if x!=None] | |
|
177 | 177 | if len(dirnameList)>0: |
|
178 | 178 | self.status = 1 |
|
179 | 179 | self.dirnameList = dirnameList |
@@ -186,8 +186,8 class AMISRReader(ProcessingUnit): | |||
|
186 | 186 | startDateTime_Reader = datetime.datetime.combine(self.startDate,self.startTime) |
|
187 | 187 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) |
|
188 | 188 | |
|
189 |
print |
|
|
190 |
print |
|
|
189 | print('Filtering Files from %s to %s'%(startDateTime_Reader, endDateTime_Reader)) | |
|
190 | print('........................................') | |
|
191 | 191 | filter_filenameList = [] |
|
192 | 192 | self.filenameList.sort() |
|
193 | 193 | for i in range(len(self.filenameList)-1): |
@@ -226,7 +226,7 class AMISRReader(ProcessingUnit): | |||
|
226 | 226 | |
|
227 | 227 | def __getFilenameList(self, fileListInKeys, dirList): |
|
228 | 228 | for value in fileListInKeys: |
|
229 | dirName = value.keys()[0] | |
|
229 | dirName = list(value.keys())[0] | |
|
230 | 230 | for file in value[dirName]: |
|
231 | 231 | filename = os.path.join(dirName, file) |
|
232 | 232 | self.filenameList.append(filename) |
@@ -304,7 +304,7 class AMISRReader(ProcessingUnit): | |||
|
304 | 304 | self.__selectDataForTimes() |
|
305 | 305 | |
|
306 | 306 | for i in range(len(self.filenameList)): |
|
307 |
print |
|
|
307 | print("%s" %(self.filenameList[i])) | |
|
308 | 308 | |
|
309 | 309 | return |
|
310 | 310 | |
@@ -315,7 +315,7 class AMISRReader(ProcessingUnit): | |||
|
315 | 315 | idFile += 1 |
|
316 | 316 | if not(idFile < len(self.filenameList)): |
|
317 | 317 | self.flagNoMoreFiles = 1 |
|
318 |
print |
|
|
318 | print("No more Files") | |
|
319 | 319 | return 0 |
|
320 | 320 | |
|
321 | 321 | filename = self.filenameList[idFile] |
@@ -330,7 +330,7 class AMISRReader(ProcessingUnit): | |||
|
330 | 330 | |
|
331 | 331 | self.amisrFilePointer = amisrFilePointer |
|
332 | 332 | |
|
333 |
print |
|
|
333 | print("Setting the file: %s"%self.filename) | |
|
334 | 334 | |
|
335 | 335 | return 1 |
|
336 | 336 | |
@@ -341,7 +341,7 class AMISRReader(ProcessingUnit): | |||
|
341 | 341 | self.__selectDataForTimes(online=True) |
|
342 | 342 | filename = self.filenameList[0] |
|
343 | 343 | while self.__filename_online == filename: |
|
344 |
print |
|
|
344 | print('waiting %d seconds to get a new file...'%(self.__waitForNewFile)) | |
|
345 | 345 | sleep(self.__waitForNewFile) |
|
346 | 346 | self.__selectDataForTimes(online=True) |
|
347 | 347 | filename = self.filenameList[0] |
@@ -351,7 +351,7 class AMISRReader(ProcessingUnit): | |||
|
351 | 351 | self.amisrFilePointer = h5py.File(filename,'r') |
|
352 | 352 | self.flagIsNewFile = 1 |
|
353 | 353 | self.filename = filename |
|
354 |
print |
|
|
354 | print("Setting the file: %s"%self.filename) | |
|
355 | 355 | return 1 |
|
356 | 356 | |
|
357 | 357 | |
@@ -368,12 +368,12 class AMISRReader(ProcessingUnit): | |||
|
368 | 368 | #looking index list for data |
|
369 | 369 | start_index = self.radacHeaderObj.pulseCount[0,:][0] |
|
370 | 370 | end_index = self.radacHeaderObj.npulses |
|
371 | range4data = range(start_index, end_index) | |
|
371 | range4data = list(range(start_index, end_index)) | |
|
372 | 372 | self.index4_schain_datablock = numpy.array(range4data) |
|
373 | 373 | |
|
374 | 374 | buffer_start_index = 0 |
|
375 | 375 | buffer_end_index = self.radacHeaderObj.pulseCount[0,:][0] |
|
376 | range4buffer = range(buffer_start_index, buffer_end_index) | |
|
376 | range4buffer = list(range(buffer_start_index, buffer_end_index)) | |
|
377 | 377 | self.index4_buffer = numpy.array(range4buffer) |
|
378 | 378 | |
|
379 | 379 | self.linear_pulseCount = numpy.array(range4data + range4buffer) |
@@ -403,8 +403,8 class AMISRReader(ProcessingUnit): | |||
|
403 | 403 | |
|
404 | 404 | just4record0 = self.radacHeaderObj.beamCodeByPulse[0,:] |
|
405 | 405 | |
|
406 | for i in range(len(self.beamCodeDict.values())): | |
|
407 | xx = numpy.where(just4record0==self.beamCodeDict.values()[i][0]) | |
|
406 | for i in range(len(list(self.beamCodeDict.values()))): | |
|
407 | xx = numpy.where(just4record0==list(self.beamCodeDict.values())[i][0]) | |
|
408 | 408 | indexPulseByBeam = self.linear_pulseCount[xx[0]] |
|
409 | 409 | self.beamRangeDict[i] = indexPulseByBeam |
|
410 | 410 | |
@@ -499,7 +499,7 class AMISRReader(ProcessingUnit): | |||
|
499 | 499 | self.searchFilesOnLine(path, walk) |
|
500 | 500 | |
|
501 | 501 | if not(self.filenameList): |
|
502 |
print |
|
|
502 | print("There is no files into the folder: %s"%(path)) | |
|
503 | 503 | |
|
504 | 504 | sys.exit(-1) |
|
505 | 505 | |
@@ -632,8 +632,8 class AMISRReader(ProcessingUnit): | |||
|
632 | 632 | return 0 |
|
633 | 633 | |
|
634 | 634 | def printUTC(self): |
|
635 |
print |
|
|
636 |
print |
|
|
635 | print(self.dataOut.utctime) | |
|
636 | print('') | |
|
637 | 637 | |
|
638 | 638 | def setObjProperties(self): |
|
639 | 639 | |
@@ -661,7 +661,7 class AMISRReader(ProcessingUnit): | |||
|
661 | 661 | |
|
662 | 662 | if self.flagNoMoreFiles: |
|
663 | 663 | self.dataOut.flagNoData = True |
|
664 |
print |
|
|
664 | print('Process finished') | |
|
665 | 665 | return 0 |
|
666 | 666 | |
|
667 | 667 | if self.__hasNotDataInBuffer(): |
@@ -689,4 +689,4 class AMISRReader(ProcessingUnit): | |||
|
689 | 689 | self.setObjProperties() |
|
690 | 690 | self.isConfig = True |
|
691 | 691 | |
|
692 |
self.getData() |
|
|
692 | self.getData() No newline at end of file |
@@ -75,14 +75,14 def isFileInEpoch(filename, startUTSeconds, endUTSeconds): | |||
|
75 | 75 | try: |
|
76 | 76 | fp = open(filename, 'rb') |
|
77 | 77 | except IOError: |
|
78 |
print |
|
|
78 | print("The file %s can't be opened" % (filename)) | |
|
79 | 79 | return 0 |
|
80 | 80 | |
|
81 | 81 | sts = basicHeaderObj.read(fp) |
|
82 | 82 | fp.close() |
|
83 | 83 | |
|
84 | 84 | if not(sts): |
|
85 |
print |
|
|
85 | print("Skipping the file %s because it has not a valid header" % (filename)) | |
|
86 | 86 | return 0 |
|
87 | 87 | |
|
88 | 88 | if not ((startUTSeconds <= basicHeaderObj.utc) and (endUTSeconds > basicHeaderObj.utc)): |
@@ -130,7 +130,7 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime): | |||
|
130 | 130 | try: |
|
131 | 131 | fp = open(filename, 'rb') |
|
132 | 132 | except IOError: |
|
133 |
print |
|
|
133 | print("The file %s can't be opened" % (filename)) | |
|
134 | 134 | return None |
|
135 | 135 | |
|
136 | 136 | firstBasicHeaderObj = BasicHeader(LOCALTIME) |
@@ -143,7 +143,7 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime): | |||
|
143 | 143 | sts = firstBasicHeaderObj.read(fp) |
|
144 | 144 | |
|
145 | 145 | if not(sts): |
|
146 |
print |
|
|
146 | print("[Reading] Skipping the file %s because it has not a valid header" % (filename)) | |
|
147 | 147 | return None |
|
148 | 148 | |
|
149 | 149 | if not systemHeaderObj.read(fp): |
@@ -160,7 +160,7 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime): | |||
|
160 | 160 | offset = processingHeaderObj.blockSize + 24 # header size |
|
161 | 161 | |
|
162 | 162 | if filesize <= offset: |
|
163 |
print |
|
|
163 | print("[Reading] %s: This file has not enough data" % filename) | |
|
164 | 164 | return None |
|
165 | 165 | |
|
166 | 166 | fp.seek(-offset, 2) |
@@ -231,7 +231,7 def isFolderInDateRange(folder, startDate=None, endDate=None): | |||
|
231 | 231 | basename = os.path.basename(folder) |
|
232 | 232 | |
|
233 | 233 | if not isRadarFolder(basename): |
|
234 |
print |
|
|
234 | print("The folder %s has not the rigth format" % folder) | |
|
235 | 235 | return 0 |
|
236 | 236 | |
|
237 | 237 | if startDate and endDate: |
@@ -274,7 +274,7 def isFileInDateRange(filename, startDate=None, endDate=None): | |||
|
274 | 274 | basename = os.path.basename(filename) |
|
275 | 275 | |
|
276 | 276 | if not isRadarFile(basename): |
|
277 |
print |
|
|
277 | print("The filename %s has not the rigth format" % filename) | |
|
278 | 278 | return 0 |
|
279 | 279 | |
|
280 | 280 | if startDate and endDate: |
@@ -315,8 +315,8 def getFileFromSet(path, ext, set): | |||
|
315 | 315 | return myfile[0] |
|
316 | 316 | else: |
|
317 | 317 | filename = '*%4.4d%3.3d%3.3d%s' % (year, doy, set, ext.lower()) |
|
318 |
print |
|
|
319 |
print |
|
|
318 | print('the filename %s does not exist' % filename) | |
|
319 | print('...going to the last file: ') | |
|
320 | 320 | |
|
321 | 321 | if validFilelist: |
|
322 | 322 | validFilelist = sorted(validFilelist, key=str.lower) |
@@ -646,9 +646,9 class JRODataReader(JRODataIO): | |||
|
646 | 646 | return [], [] |
|
647 | 647 | |
|
648 | 648 | if len(dateList) > 1: |
|
649 |
print |
|
|
649 | print("[Reading] Data found for date range [%s - %s]: total days = %d" % (startDate, endDate, len(dateList))) | |
|
650 | 650 | else: |
|
651 |
print |
|
|
651 | print("[Reading] Data found for date range [%s - %s]: date = %s" % (startDate, endDate, dateList[0])) | |
|
652 | 652 | |
|
653 | 653 | filenameList = [] |
|
654 | 654 | datetimeList = [] |
@@ -679,10 +679,10 class JRODataReader(JRODataIO): | |||
|
679 | 679 | datetimeList = datetimeList[cursor * skip:cursor * skip + skip] |
|
680 | 680 | |
|
681 | 681 | if not(filenameList): |
|
682 |
print |
|
|
682 | print("[Reading] Time range selected invalid [%s - %s]: No *%s files in %s)" % (startTime, endTime, ext, path)) | |
|
683 | 683 | return [], [] |
|
684 | 684 | |
|
685 |
print |
|
|
685 | print("[Reading] %d file(s) was(were) found in time range: %s - %s" % (len(filenameList), startTime, endTime)) | |
|
686 | 686 | |
|
687 | 687 | # for i in range(len(filenameList)): |
|
688 | 688 | # print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime()) |
@@ -743,7 +743,7 class JRODataReader(JRODataIO): | |||
|
743 | 743 | doypath.split('_')) > 1 else 0 |
|
744 | 744 | fullpath = os.path.join(path, doypath, expLabel) |
|
745 | 745 | |
|
746 |
print |
|
|
746 | print("[Reading] %s folder was found: " % (fullpath)) | |
|
747 | 747 | |
|
748 | 748 | if set == None: |
|
749 | 749 | filename = getlastFileFromPath(fullpath, ext) |
@@ -753,7 +753,7 class JRODataReader(JRODataIO): | |||
|
753 | 753 | if not(filename): |
|
754 | 754 | return None, None, None, None, None, None |
|
755 | 755 | |
|
756 |
print |
|
|
756 | print("[Reading] %s file was found" % (filename)) | |
|
757 | 757 | |
|
758 | 758 | if not(self.__verifyFile(os.path.join(fullpath, filename))): |
|
759 | 759 | return None, None, None, None, None, None |
@@ -844,10 +844,10 class JRODataReader(JRODataIO): | |||
|
844 | 844 | |
|
845 | 845 | for nTries in range(tries): |
|
846 | 846 | if firstTime_flag: |
|
847 |
print |
|
|
847 | print("\t[Reading] Waiting %0.2f sec for the next file: \"%s\" , try %03d ..." % (self.delay, filename, nTries + 1)) | |
|
848 | 848 | sleep(self.delay) |
|
849 | 849 | else: |
|
850 |
print |
|
|
850 | print("\t[Reading] Searching the next \"%s%04d%03d%03d%s\" file ..." % (self.optchar, self.year, self.doy, self.set, self.ext)) | |
|
851 | 851 | |
|
852 | 852 | fullfilename, filename = checkForRealPath( |
|
853 | 853 | self.path, self.foldercounter, self.year, self.doy, self.set, self.ext) |
@@ -902,7 +902,7 class JRODataReader(JRODataIO): | |||
|
902 | 902 | return 0 |
|
903 | 903 | |
|
904 | 904 | if self.verbose: |
|
905 |
print |
|
|
905 | print('[Reading] Setting the file: %s' % self.filename) | |
|
906 | 906 | |
|
907 | 907 | self.__readFirstHeader() |
|
908 | 908 | self.nReadBlocks = 0 |
@@ -941,7 +941,7 class JRODataReader(JRODataIO): | |||
|
941 | 941 | # self.flagEoF = True |
|
942 | 942 | return 0 |
|
943 | 943 | |
|
944 |
print |
|
|
944 | print("[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries + 1)) | |
|
945 | 945 | sleep(self.delay) |
|
946 | 946 | |
|
947 | 947 | return 0 |
@@ -963,7 +963,7 class JRODataReader(JRODataIO): | |||
|
963 | 963 | if (currentSize >= neededSize): |
|
964 | 964 | return 1 |
|
965 | 965 | |
|
966 |
print |
|
|
966 | print("[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries + 1)) | |
|
967 | 967 | sleep(self.delay) |
|
968 | 968 | |
|
969 | 969 | return 0 |
@@ -1052,7 +1052,7 class JRODataReader(JRODataIO): | |||
|
1052 | 1052 | # Skip block out of startTime and endTime |
|
1053 | 1053 | while True: |
|
1054 | 1054 | if not(self.__setNewBlock()): |
|
1055 | raise(schainpy.admin.SchainWarning('No more files')) | |
|
1055 | raise schainpy | |
|
1056 | 1056 | return 0 |
|
1057 | 1057 | |
|
1058 | 1058 | if not(self.readBlock()): |
@@ -1060,17 +1060,17 class JRODataReader(JRODataIO): | |||
|
1060 | 1060 | |
|
1061 | 1061 | self.getBasicHeader() |
|
1062 | 1062 | if (self.dataOut.datatime < datetime.datetime.combine(self.startDate, self.startTime)) or (self.dataOut.datatime > datetime.datetime.combine(self.endDate, self.endTime)): |
|
1063 |
print |
|
|
1063 | print("[Reading] Block No. %d/%d -> %s [Skipping]" % (self.nReadBlocks, | |
|
1064 | 1064 | self.processingHeaderObj.dataBlocksPerFile, |
|
1065 | self.dataOut.datatime.ctime()) | |
|
1065 | self.dataOut.datatime.ctime())) | |
|
1066 | 1066 | continue |
|
1067 | 1067 | |
|
1068 | 1068 | break |
|
1069 | 1069 | |
|
1070 | 1070 | if self.verbose: |
|
1071 |
print |
|
|
1071 | print("[Reading] Block No. %d/%d -> %s" % (self.nReadBlocks, | |
|
1072 | 1072 | self.processingHeaderObj.dataBlocksPerFile, |
|
1073 | self.dataOut.datatime.ctime()) | |
|
1073 | self.dataOut.datatime.ctime())) | |
|
1074 | 1074 | return 1 |
|
1075 | 1075 | |
|
1076 | 1076 | def __readFirstHeader(self): |
@@ -1097,7 +1097,7 class JRODataReader(JRODataIO): | |||
|
1097 | 1097 | elif datatype == 5: |
|
1098 | 1098 | datatype_str = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) |
|
1099 | 1099 | else: |
|
1100 |
raise ValueError |
|
|
1100 | raise ValueError('Data type was not defined') | |
|
1101 | 1101 | |
|
1102 | 1102 | self.dtype = datatype_str |
|
1103 | 1103 | #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c |
@@ -1117,7 +1117,7 class JRODataReader(JRODataIO): | |||
|
1117 | 1117 | except IOError: |
|
1118 | 1118 | |
|
1119 | 1119 | if msgFlag: |
|
1120 |
print |
|
|
1120 | print("[Reading] File %s can't be opened" % (filename)) | |
|
1121 | 1121 | |
|
1122 | 1122 | return False |
|
1123 | 1123 | |
@@ -1157,7 +1157,7 class JRODataReader(JRODataIO): | |||
|
1157 | 1157 | |
|
1158 | 1158 | if currentSize < neededSize: |
|
1159 | 1159 | if msgFlag and (msg != None): |
|
1160 |
print |
|
|
1160 | print(msg) | |
|
1161 | 1161 | return False |
|
1162 | 1162 | |
|
1163 | 1163 | return True |
@@ -1255,10 +1255,10 class JRODataReader(JRODataIO): | |||
|
1255 | 1255 | pattern_path = multi_path[0] |
|
1256 | 1256 | |
|
1257 | 1257 | if path_empty: |
|
1258 |
print |
|
|
1258 | print("[Reading] No *%s files in %s for %s to %s" % (ext, pattern_path, startDate, endDate)) | |
|
1259 | 1259 | else: |
|
1260 | 1260 | if not dateList: |
|
1261 |
print |
|
|
1261 | print("[Reading] Date range selected invalid [%s - %s]: No *%s files in %s)" % (startDate, endDate, ext, path)) | |
|
1262 | 1262 | |
|
1263 | 1263 | if include_path: |
|
1264 | 1264 | return dateList, pathList |
@@ -1301,17 +1301,17 class JRODataReader(JRODataIO): | |||
|
1301 | 1301 | self.receiver = self.context.socket(zmq.PULL) |
|
1302 | 1302 | self.receiver.connect(self.server) |
|
1303 | 1303 | time.sleep(0.5) |
|
1304 |
print |
|
|
1304 | print('[Starting] ReceiverData from {}'.format(self.server)) | |
|
1305 | 1305 | else: |
|
1306 | 1306 | self.server = None |
|
1307 | 1307 | if path == None: |
|
1308 |
raise ValueError |
|
|
1308 | raise ValueError("[Reading] The path is not valid") | |
|
1309 | 1309 | |
|
1310 | 1310 | if ext == None: |
|
1311 | 1311 | ext = self.ext |
|
1312 | 1312 | |
|
1313 | 1313 | if online: |
|
1314 |
print |
|
|
1314 | print("[Reading] Searching files in online mode...") | |
|
1315 | 1315 | |
|
1316 | 1316 | for nTries in range(self.nTries): |
|
1317 | 1317 | fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine( |
@@ -1320,7 +1320,7 class JRODataReader(JRODataIO): | |||
|
1320 | 1320 | if fullpath: |
|
1321 | 1321 | break |
|
1322 | 1322 | |
|
1323 |
print |
|
|
1323 | print('[Reading] Waiting %0.2f sec for an valid file in %s: try %02d ...' % (delay, path, nTries + 1)) | |
|
1324 | 1324 | sleep(delay) |
|
1325 | 1325 | |
|
1326 | 1326 | if not(fullpath): |
@@ -1334,7 +1334,7 class JRODataReader(JRODataIO): | |||
|
1334 | 1334 | self.foldercounter = foldercounter |
|
1335 | 1335 | last_set = None |
|
1336 | 1336 | else: |
|
1337 |
print |
|
|
1337 | print("[Reading] Searching files in offline mode ...") | |
|
1338 | 1338 | pathList, filenameList = self.searchFilesOffLine(path, startDate=startDate, endDate=endDate, |
|
1339 | 1339 | startTime=startTime, endTime=endTime, |
|
1340 | 1340 | set=set, expLabel=expLabel, ext=ext, |
@@ -1375,11 +1375,11 class JRODataReader(JRODataIO): | |||
|
1375 | 1375 | |
|
1376 | 1376 | if not(self.setNextFile()): |
|
1377 | 1377 | if (startDate != None) and (endDate != None): |
|
1378 |
print |
|
|
1378 | print("[Reading] No files in range: %s - %s" % (datetime.datetime.combine(startDate, startTime).ctime(), datetime.datetime.combine(endDate, endTime).ctime())) | |
|
1379 | 1379 | elif startDate != None: |
|
1380 |
print |
|
|
1380 | print("[Reading] No files in range: %s" % (datetime.datetime.combine(startDate, startTime).ctime())) | |
|
1381 | 1381 | else: |
|
1382 |
print |
|
|
1382 | print("[Reading] No files") | |
|
1383 | 1383 | |
|
1384 | 1384 | self.fileIndex = -1 |
|
1385 | 1385 | self.pathList = [] |
@@ -1434,11 +1434,11 class JRODataReader(JRODataIO): | |||
|
1434 | 1434 | |
|
1435 | 1435 | def printReadBlocks(self): |
|
1436 | 1436 | |
|
1437 |
print |
|
|
1437 | print("[Reading] Number of read blocks per file %04d" % self.nReadBlocks) | |
|
1438 | 1438 | |
|
1439 | 1439 | def printTotalBlocks(self): |
|
1440 | 1440 | |
|
1441 |
print |
|
|
1441 | print("[Reading] Number of read blocks %04d" % self.nTotalBlocks) | |
|
1442 | 1442 | |
|
1443 | 1443 | def printNumberOfBlock(self): |
|
1444 | 1444 | 'SPAM!' |
@@ -1679,8 +1679,8 class JRODataWriter(JRODataIO): | |||
|
1679 | 1679 | |
|
1680 | 1680 | self.writeBlock() |
|
1681 | 1681 | |
|
1682 |
print |
|
|
1683 | self.processingHeaderObj.dataBlocksPerFile) | |
|
1682 | print("[Writing] Block No. %d/%d" % (self.blockIndex, | |
|
1683 | self.processingHeaderObj.dataBlocksPerFile)) | |
|
1684 | 1684 | |
|
1685 | 1685 | return 1 |
|
1686 | 1686 | |
@@ -1756,7 +1756,7 class JRODataWriter(JRODataIO): | |||
|
1756 | 1756 | |
|
1757 | 1757 | self.setFirstHeader() |
|
1758 | 1758 | |
|
1759 |
print |
|
|
1759 | print('[Writing] Opening file: %s' % self.filename) | |
|
1760 | 1760 | |
|
1761 | 1761 | self.__writeFirstHeader() |
|
1762 | 1762 | |
@@ -1808,7 +1808,7 class JRODataWriter(JRODataIO): | |||
|
1808 | 1808 | self.dtype = get_numpy_dtype(datatype) |
|
1809 | 1809 | |
|
1810 | 1810 | if not(self.setNextFile()): |
|
1811 |
print |
|
|
1811 | print("[Writing] There isn't a next file") | |
|
1812 | 1812 | return 0 |
|
1813 | 1813 | |
|
1814 | 1814 | self.setBlockDimension() |
@@ -1823,4 +1823,4 class JRODataWriter(JRODataIO): | |||
|
1823 | 1823 | set=set, ext=ext, datatype=datatype, **kwargs) |
|
1824 | 1824 | self.isConfig = True |
|
1825 | 1825 | |
|
1826 |
self.putData() |
|
|
1826 | self.putData() No newline at end of file |
@@ -29,7 +29,7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |||
|
29 | 29 | #from schainpy.model.io.jroIO_bltr import BLTRReader |
|
30 | 30 | from numpy import imag, shape, NaN |
|
31 | 31 | |
|
32 | from jroIO_base import JRODataReader | |
|
32 | from .jroIO_base import JRODataReader | |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | class Header(object): |
@@ -51,7 +51,7 class Header(object): | |||
|
51 | 51 | message += self.__class__.__name__.upper() + "\n" |
|
52 | 52 | message += "#" * 50 + "\n" |
|
53 | 53 | |
|
54 | keyList = self.__dict__.keys() | |
|
54 | keyList = list(self.__dict__.keys()) | |
|
55 | 55 | keyList.sort() |
|
56 | 56 | |
|
57 | 57 | for key in keyList: |
@@ -94,9 +94,9 class FileHeaderBLTR(Header): | |||
|
94 | 94 | |
|
95 | 95 | header = numpy.fromfile(startFp, FILE_STRUCTURE, 1) |
|
96 | 96 | |
|
97 |
print |
|
|
98 |
print |
|
|
99 |
print |
|
|
97 | print(' ') | |
|
98 | print('puntero file header', startFp.tell()) | |
|
99 | print(' ') | |
|
100 | 100 | |
|
101 | 101 | ''' numpy.fromfile(file, dtype, count, sep='') |
|
102 | 102 | file : file or str |
@@ -323,28 +323,28 class RecordHeaderBLTR(Header): | |||
|
323 | 323 | # RecCounter=0 |
|
324 | 324 | # Off2StartNxtRec=811248 |
|
325 | 325 | OffRHeader = self.OffsetStartHeader + self.RecCounter * self.Off2StartNxtRec |
|
326 |
print |
|
|
327 |
print |
|
|
328 |
print |
|
|
326 | print(' ') | |
|
327 | print('puntero Record Header', startFp.tell()) | |
|
328 | print(' ') | |
|
329 | 329 | |
|
330 | 330 | startFp.seek(OffRHeader, os.SEEK_SET) |
|
331 | 331 | |
|
332 |
print |
|
|
333 |
print |
|
|
334 |
print |
|
|
332 | print(' ') | |
|
333 | print('puntero Record Header con seek', startFp.tell()) | |
|
334 | print(' ') | |
|
335 | 335 | |
|
336 | 336 | # print 'Posicion del bloque: ',OffRHeader |
|
337 | 337 | |
|
338 | 338 | header = numpy.fromfile(startFp, RECORD_STRUCTURE, 1) |
|
339 | 339 | |
|
340 |
print |
|
|
341 |
print |
|
|
342 |
print |
|
|
340 | print(' ') | |
|
341 | print('puntero Record Header con seek', startFp.tell()) | |
|
342 | print(' ') | |
|
343 | 343 | |
|
344 |
print |
|
|
344 | print(' ') | |
|
345 | 345 | # |
|
346 | 346 | # print 'puntero Record Header despues de seek', header.tell() |
|
347 |
print |
|
|
347 | print(' ') | |
|
348 | 348 | |
|
349 | 349 | self.RecMgcNumber = hex(header['RecMgcNumber'][0]) # 0x23030001 |
|
350 | 350 | self.RecCounter = int(header['RecCounter'][0]) |
@@ -400,21 +400,21 class RecordHeaderBLTR(Header): | |||
|
400 | 400 | # print 'Datasize',self.Datasize |
|
401 | 401 | endFp = self.OffsetStartHeader + self.RecCounter * self.Off2StartNxtRec |
|
402 | 402 | |
|
403 |
print |
|
|
404 |
print |
|
|
405 |
print |
|
|
406 |
print |
|
|
407 |
print |
|
|
408 |
print |
|
|
409 |
print |
|
|
410 |
print |
|
|
411 |
print |
|
|
412 |
print |
|
|
413 |
print |
|
|
414 |
print |
|
|
415 |
print |
|
|
416 |
print |
|
|
417 |
print |
|
|
403 | print('==============================================') | |
|
404 | print('RecMgcNumber ', self.RecMgcNumber) | |
|
405 | print('RecCounter ', self.RecCounter) | |
|
406 | print('Off2StartNxtRec ', self.Off2StartNxtRec) | |
|
407 | print('Off2StartData ', self.Off2StartData) | |
|
408 | print('Range Resolution ', self.SampResolution) | |
|
409 | print('First Height ', self.StartRangeSamp) | |
|
410 | print('PRF (Hz) ', self.PRFhz) | |
|
411 | print('Heights (K) ', self.nHeights) | |
|
412 | print('Channels (N) ', self.nChannels) | |
|
413 | print('Profiles (J) ', self.nProfiles) | |
|
414 | print('iCoh ', self.nCohInt) | |
|
415 | print('iInCoh ', self.nIncohInt) | |
|
416 | print('BeamAngleAzim ', self.BeamAngleAzim) | |
|
417 | print('BeamAngleZen ', self.BeamAngleZen) | |
|
418 | 418 | |
|
419 | 419 | # print 'ModoEnUso ',self.DualModeIndex |
|
420 | 420 | # print 'UtcTime ',self.nUtime |
@@ -423,25 +423,25 class RecordHeaderBLTR(Header): | |||
|
423 | 423 | # print 'Exp Comment ',self.ExpComment |
|
424 | 424 | # print 'FFT Window Index ',self.FFTwindowingInd |
|
425 | 425 | # print 'N Dig. Channels ',self.nDigChannels |
|
426 |
print |
|
|
427 |
print |
|
|
428 |
print |
|
|
426 | print('Size de bloque ', self.RHsize) | |
|
427 | print('DataSize ', self.Datasize) | |
|
428 | print('BeamAngleAzim ', self.BeamAngleAzim) | |
|
429 | 429 | # print 'AntennaCoord0 ',self.AntennaCoord0 |
|
430 | 430 | # print 'AntennaAngl0 ',self.AntennaAngl0 |
|
431 | 431 | # print 'AntennaCoord1 ',self.AntennaCoord1 |
|
432 | 432 | # print 'AntennaAngl1 ',self.AntennaAngl1 |
|
433 | 433 | # print 'AntennaCoord2 ',self.AntennaCoord2 |
|
434 | 434 | # print 'AntennaAngl2 ',self.AntennaAngl2 |
|
435 |
print |
|
|
436 |
print |
|
|
437 |
print |
|
|
438 |
print |
|
|
439 |
print |
|
|
440 |
print |
|
|
441 |
print |
|
|
442 |
print |
|
|
443 |
print |
|
|
444 |
print |
|
|
435 | print('RecPhaseCalibr0 ', self.RecPhaseCalibr0) | |
|
436 | print('RecPhaseCalibr1 ', self.RecPhaseCalibr1) | |
|
437 | print('RecPhaseCalibr2 ', self.RecPhaseCalibr2) | |
|
438 | print('RecAmpCalibr0 ', self.RecAmpCalibr0) | |
|
439 | print('RecAmpCalibr1 ', self.RecAmpCalibr1) | |
|
440 | print('RecAmpCalibr2 ', self.RecAmpCalibr2) | |
|
441 | print('ReceiverGaindB0 ', self.ReceiverGaindB0) | |
|
442 | print('ReceiverGaindB1 ', self.ReceiverGaindB1) | |
|
443 | print('ReceiverGaindB2 ', self.ReceiverGaindB2) | |
|
444 | print('==============================================') | |
|
445 | 445 | |
|
446 | 446 | if OffRHeader > endFp: |
|
447 | 447 | sys.stderr.write( |
@@ -590,7 +590,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
590 | 590 | |
|
591 | 591 | if self.flagNoMoreFiles: |
|
592 | 592 | self.dataOut.flagNoData = True |
|
593 |
print |
|
|
593 | print('NoData se vuelve true') | |
|
594 | 594 | return 0 |
|
595 | 595 | |
|
596 | 596 | self.fp = self.path |
@@ -600,7 +600,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
600 | 600 | self.dataOut.data_cspc = self.data_cspc |
|
601 | 601 | self.dataOut.data_output = self.data_output |
|
602 | 602 | |
|
603 |
print |
|
|
603 | print('self.dataOut.data_output', shape(self.dataOut.data_output)) | |
|
604 | 604 | |
|
605 | 605 | # self.removeDC() |
|
606 | 606 | return self.dataOut.data_spc |
@@ -617,7 +617,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
617 | 617 | ''' |
|
618 | 618 | |
|
619 | 619 | # The address of the folder is generated the name of the .fdt file that will be read |
|
620 |
print |
|
|
620 | print("File: ", self.fileSelector + 1) | |
|
621 | 621 | |
|
622 | 622 | if self.fileSelector < len(self.filenameList): |
|
623 | 623 | |
@@ -630,7 +630,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
630 | 630 | |
|
631 | 631 | self.readBlock() # Block reading |
|
632 | 632 | else: |
|
633 |
print |
|
|
633 | print('readFile FlagNoData becomes true') | |
|
634 | 634 | self.flagNoMoreFiles = True |
|
635 | 635 | self.dataOut.flagNoData = True |
|
636 | 636 | return 0 |
@@ -660,7 +660,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
660 | 660 | ''' |
|
661 | 661 | |
|
662 | 662 | if self.BlockCounter < self.nFDTdataRecors - 2: |
|
663 |
print |
|
|
663 | print(self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') | |
|
664 | 664 | if self.ReadMode == 1: |
|
665 | 665 | rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter + 1) |
|
666 | 666 | elif self.ReadMode == 0: |
@@ -687,8 +687,8 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
687 | 687 | self.__firstHeigth = rheader.StartRangeSamp |
|
688 | 688 | self.__deltaHeigth = rheader.SampResolution |
|
689 | 689 | self.dataOut.heightList = self.__firstHeigth + \ |
|
690 | numpy.array(range(self.nHeights)) * self.__deltaHeigth | |
|
691 | self.dataOut.channelList = range(self.nChannels) | |
|
690 | numpy.array(list(range(self.nHeights))) * self.__deltaHeigth | |
|
691 | self.dataOut.channelList = list(range(self.nChannels)) | |
|
692 | 692 | self.dataOut.nProfiles = rheader.nProfiles |
|
693 | 693 | self.dataOut.nIncohInt = rheader.nIncohInt |
|
694 | 694 | self.dataOut.nCohInt = rheader.nCohInt |
@@ -703,7 +703,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
703 | 703 | self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles |
|
704 | 704 | |
|
705 | 705 | self.data_output = numpy.ones([3, rheader.nHeights]) * numpy.NaN |
|
706 |
print |
|
|
706 | print('self.data_output', shape(self.data_output)) | |
|
707 | 707 | self.dataOut.velocityX = [] |
|
708 | 708 | self.dataOut.velocityY = [] |
|
709 | 709 | self.dataOut.velocityV = [] |
@@ -757,11 +757,11 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
757 | 757 | z = self.data_spc.copy() # /factor |
|
758 | 758 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
759 | 759 | #zdB = 10*numpy.log10(z) |
|
760 |
print |
|
|
761 |
print |
|
|
762 |
print |
|
|
763 |
print |
|
|
764 |
print |
|
|
760 | print(' ') | |
|
761 | print('Z: ') | |
|
762 | print(shape(z)) | |
|
763 | print(' ') | |
|
764 | print(' ') | |
|
765 | 765 | |
|
766 | 766 | self.dataOut.data_spc = self.data_spc |
|
767 | 767 | |
@@ -1177,4 +1177,4 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa | |||
|
1177 | 1177 | else: |
|
1178 | 1178 | self.fileSelector += 1 |
|
1179 | 1179 | self.BlockCounter = 0 |
|
1180 |
print |
|
|
1180 | print("Next File") No newline at end of file |
@@ -27,11 +27,11 from schainpy.model.data.jrodata import Voltage | |||
|
27 | 27 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
28 | 28 | from time import time |
|
29 | 29 | |
|
30 |
import |
|
|
30 | import pickle | |
|
31 | 31 | try: |
|
32 | 32 | import digital_rf |
|
33 | 33 | except: |
|
34 |
print |
|
|
34 | print('You should install "digital_rf" module if you want to read Digital RF data') | |
|
35 | 35 | |
|
36 | 36 | |
|
37 | 37 | class DigitalRFReader(ProcessingUnit): |
@@ -59,7 +59,7 class DigitalRFReader(ProcessingUnit): | |||
|
59 | 59 | self.oldAverage = None |
|
60 | 60 | |
|
61 | 61 | def close(self): |
|
62 |
print |
|
|
62 | print('Average of writing to digital rf format is ', self.oldAverage * 1000) | |
|
63 | 63 | return |
|
64 | 64 | |
|
65 | 65 | def __getCurrentSecond(self): |
@@ -115,7 +115,7 class DigitalRFReader(ProcessingUnit): | |||
|
115 | 115 | numpy.arange(self.__nSamples, dtype=numpy.float) * \ |
|
116 | 116 | self.__deltaHeigth |
|
117 | 117 | |
|
118 | self.dataOut.channelList = range(self.__num_subchannels) | |
|
118 | self.dataOut.channelList = list(range(self.__num_subchannels)) | |
|
119 | 119 | |
|
120 | 120 | self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights() |
|
121 | 121 | |
@@ -256,7 +256,7 class DigitalRFReader(ProcessingUnit): | |||
|
256 | 256 | self.flagDecodeData = flagDecodeData |
|
257 | 257 | self.i = 0 |
|
258 | 258 | if not os.path.isdir(path): |
|
259 |
raise ValueError |
|
|
259 | raise ValueError("[Reading] Directory %s does not exist" % path) | |
|
260 | 260 | |
|
261 | 261 | try: |
|
262 | 262 | self.digitalReadObj = digital_rf.DigitalRFReader( |
@@ -267,10 +267,10 class DigitalRFReader(ProcessingUnit): | |||
|
267 | 267 | channelNameList = self.digitalReadObj.get_channels() |
|
268 | 268 | |
|
269 | 269 | if not channelNameList: |
|
270 |
raise ValueError |
|
|
270 | raise ValueError("[Reading] Directory %s does not have any files" % path) | |
|
271 | 271 | |
|
272 | 272 | if not channelList: |
|
273 | channelList = range(len(channelNameList)) | |
|
273 | channelList = list(range(len(channelNameList))) | |
|
274 | 274 | |
|
275 | 275 | ########## Reading metadata ###################### |
|
276 | 276 | |
@@ -294,7 +294,7 class DigitalRFReader(ProcessingUnit): | |||
|
294 | 294 | self.__processingHeader = self.fixed_metadata_dict['processingHeader'] |
|
295 | 295 | self.__radarControllerHeader = self.fixed_metadata_dict['radarControllerHeader'] |
|
296 | 296 | self.__systemHeader = self.fixed_metadata_dict['systemHeader'] |
|
297 |
self.dtype = |
|
|
297 | self.dtype = pickle.loads(self.fixed_metadata_dict['dtype']) | |
|
298 | 298 | except: |
|
299 | 299 | pass |
|
300 | 300 | |
@@ -361,7 +361,7 class DigitalRFReader(ProcessingUnit): | |||
|
361 | 361 | endUTCSecond = end_index / self.__sample_rate |
|
362 | 362 | if not nSamples: |
|
363 | 363 | if not ippKm: |
|
364 |
raise ValueError |
|
|
364 | raise ValueError("[Reading] nSamples or ippKm should be defined") | |
|
365 | 365 | nSamples = int(ippKm / (1e6 * 0.15 / self.__sample_rate)) |
|
366 | 366 | channelBoundList = [] |
|
367 | 367 | channelNameListFiltered = [] |
@@ -388,7 +388,7 class DigitalRFReader(ProcessingUnit): | |||
|
388 | 388 | self.__channelNameList = channelNameListFiltered |
|
389 | 389 | self.__channelBoundList = channelBoundList |
|
390 | 390 | self.__nSamples = nSamples |
|
391 |
self.__samples_to_read = |
|
|
391 | self.__samples_to_read = int(nSamples) # FIJO: AHORA 40 | |
|
392 | 392 | self.__nChannels = len(self.__channelList) |
|
393 | 393 | |
|
394 | 394 | self.__startUTCSecond = startUTCSecond |
@@ -402,7 +402,7 class DigitalRFReader(ProcessingUnit): | |||
|
402 | 402 | startUTCSecond = numpy.floor(endUTCSecond) |
|
403 | 403 | |
|
404 | 404 | # por que en el otro metodo lo primero q se hace es sumar samplestoread |
|
405 |
self.__thisUnixSample = |
|
|
405 | self.__thisUnixSample = int( | |
|
406 | 406 | startUTCSecond * self.__sample_rate) - self.__samples_to_read |
|
407 | 407 | |
|
408 | 408 | self.__data_buffer = numpy.zeros( |
@@ -411,17 +411,17 class DigitalRFReader(ProcessingUnit): | |||
|
411 | 411 | self.__setFileHeader() |
|
412 | 412 | self.isConfig = True |
|
413 | 413 | |
|
414 |
print |
|
|
414 | print("[Reading] Digital RF Data was found from %s to %s " % ( | |
|
415 | 415 | datetime.datetime.utcfromtimestamp( |
|
416 | 416 | self.__startUTCSecond - self.__timezone), |
|
417 | 417 | datetime.datetime.utcfromtimestamp( |
|
418 | 418 | self.__endUTCSecond - self.__timezone) |
|
419 | ) | |
|
419 | )) | |
|
420 | 420 | |
|
421 |
print |
|
|
421 | print("[Reading] Starting process from %s to %s" % (datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), | |
|
422 | 422 | datetime.datetime.utcfromtimestamp( |
|
423 | 423 | endUTCSecond - self.__timezone) |
|
424 | ) | |
|
424 | )) | |
|
425 | 425 | self.oldAverage = None |
|
426 | 426 | self.count = 0 |
|
427 | 427 | self.executionTime = 0 |
@@ -433,7 +433,7 class DigitalRFReader(ProcessingUnit): | |||
|
433 | 433 | # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
434 | 434 | # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
435 | 435 | # ) |
|
436 |
print |
|
|
436 | print("[Reading] reloading metadata ...") | |
|
437 | 437 | |
|
438 | 438 | try: |
|
439 | 439 | self.digitalReadObj.reload(complete_update=True) |
@@ -448,13 +448,13 class DigitalRFReader(ProcessingUnit): | |||
|
448 | 448 | |
|
449 | 449 | if end_index > self.__endUTCSecond * self.__sample_rate: |
|
450 | 450 | self.__endUTCSecond = 1.0 * end_index / self.__sample_rate |
|
451 | ||
|
452 |
print |
|
|
451 | print() | |
|
452 | print("[Reading] New timerange found [%s, %s] " % ( | |
|
453 | 453 | datetime.datetime.utcfromtimestamp( |
|
454 | 454 | self.__startUTCSecond - self.__timezone), |
|
455 | 455 | datetime.datetime.utcfromtimestamp( |
|
456 | 456 | self.__endUTCSecond - self.__timezone) |
|
457 | ) | |
|
457 | )) | |
|
458 | 458 | |
|
459 | 459 | return True |
|
460 | 460 | |
@@ -480,7 +480,7 class DigitalRFReader(ProcessingUnit): | |||
|
480 | 480 | self.__thisUnixSample += self.__samples_to_read |
|
481 | 481 | |
|
482 | 482 | if self.__thisUnixSample + 2 * self.__samples_to_read > self.__endUTCSecond * self.__sample_rate: |
|
483 |
print |
|
|
483 | print("[Reading] There are no more data into selected time-range") | |
|
484 | 484 | if self.__online: |
|
485 | 485 | self.__reload() |
|
486 | 486 | else: |
@@ -507,17 +507,17 class DigitalRFReader(ProcessingUnit): | |||
|
507 | 507 | self.executionTime + self.count * self.oldAverage) / (self.count + 1.0) |
|
508 | 508 | self.count = self.count + 1.0 |
|
509 | 509 | |
|
510 |
except IOError |
|
|
510 | except IOError as e: | |
|
511 | 511 | # read next profile |
|
512 | 512 | self.__flagDiscontinuousBlock = True |
|
513 |
print |
|
|
513 | print("[Reading] %s" % datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e) | |
|
514 | 514 | break |
|
515 | 515 | |
|
516 | 516 | if result.shape[0] != self.__samples_to_read: |
|
517 | 517 | self.__flagDiscontinuousBlock = True |
|
518 |
print |
|
|
518 | print("[Reading] %s: Too few samples were found, just %d/%d samples" % (datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
|
519 | 519 | result.shape[0], |
|
520 | self.__samples_to_read) | |
|
520 | self.__samples_to_read)) | |
|
521 | 521 | break |
|
522 | 522 | |
|
523 | 523 | self.__data_buffer[indexSubchannel, :] = result * volt_scale |
@@ -531,9 +531,9 class DigitalRFReader(ProcessingUnit): | |||
|
531 | 531 | if not dataOk: |
|
532 | 532 | return False |
|
533 | 533 | |
|
534 |
print |
|
|
534 | print("[Reading] %s: %d samples <> %f sec" % (datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
|
535 | 535 | self.__samples_to_read, |
|
536 | self.__timeInterval) | |
|
536 | self.__timeInterval)) | |
|
537 | 537 | |
|
538 | 538 | self.__bufferIndex = 0 |
|
539 | 539 | |
@@ -572,7 +572,7 class DigitalRFReader(ProcessingUnit): | |||
|
572 | 572 | return False |
|
573 | 573 | |
|
574 | 574 | if self.__flagDiscontinuousBlock: |
|
575 |
print |
|
|
575 | print('[Reading] discontinuous block found ... continue with the next block') | |
|
576 | 576 | continue |
|
577 | 577 | |
|
578 | 578 | if not self.__online: |
@@ -582,7 +582,7 class DigitalRFReader(ProcessingUnit): | |||
|
582 | 582 | if err_counter > nTries: |
|
583 | 583 | return False |
|
584 | 584 | |
|
585 |
print |
|
|
585 | print('[Reading] waiting %d seconds to read a new block' % seconds) | |
|
586 | 586 | sleep(seconds) |
|
587 | 587 | |
|
588 | 588 | self.dataOut.data = self.__data_buffer[:, |
@@ -650,7 +650,7 class DigitalRFWriter(Operation): | |||
|
650 | 650 | |
|
651 | 651 | self.metadata_dict['frequency'] = self.dataOut.frequency |
|
652 | 652 | self.metadata_dict['timezone'] = self.dataOut.timeZone |
|
653 |
self.metadata_dict['dtype'] = |
|
|
653 | self.metadata_dict['dtype'] = pickle.dumps(self.dataOut.dtype) | |
|
654 | 654 | self.metadata_dict['nProfiles'] = self.dataOut.nProfiles |
|
655 | 655 | self.metadata_dict['heightList'] = self.dataOut.heightList |
|
656 | 656 | self.metadata_dict['channelList'] = self.dataOut.channelList |
@@ -690,8 +690,8 class DigitalRFWriter(Operation): | |||
|
690 | 690 | file_cadence_millisecs = 1000 |
|
691 | 691 | |
|
692 | 692 | sample_rate_fraction = Fraction(self.__sample_rate).limit_denominator() |
|
693 |
sample_rate_numerator = |
|
|
694 |
sample_rate_denominator = |
|
|
693 | sample_rate_numerator = int(sample_rate_fraction.numerator) | |
|
694 | sample_rate_denominator = int(sample_rate_fraction.denominator) | |
|
695 | 695 | start_global_index = dataOut.utctime * self.__sample_rate |
|
696 | 696 | |
|
697 | 697 | uuid = 'prueba' |
@@ -781,8 +781,8 class DigitalRFWriter(Operation): | |||
|
781 | 781 | ## if self.currentSample == self.__nProfiles: self.currentSample = 0 |
|
782 | 782 | |
|
783 | 783 | def close(self): |
|
784 |
print |
|
|
785 |
print |
|
|
784 | print('[Writing] - Closing files ') | |
|
785 | print('Average of writing to digital rf format is ', self.oldAverage * 1000) | |
|
786 | 786 | try: |
|
787 | 787 | self.digitalWriteObj.close() |
|
788 | 788 | except: |
@@ -797,4 +797,4 if __name__ == '__main__': | |||
|
797 | 797 | while True: |
|
798 | 798 | readObj.run(path='/home/jchavez/jicamarca/mocked_data/') |
|
799 | 799 | # readObj.printInfo() |
|
800 |
# readObj.printNumberOfBlock() |
|
|
800 | # readObj.printNumberOfBlock() No newline at end of file |
@@ -13,12 +13,12 from time import sleep | |||
|
13 | 13 | |
|
14 | 14 | try: |
|
15 | 15 | import pyfits |
|
16 |
except ImportError |
|
|
17 |
print |
|
|
16 | except ImportError as e: | |
|
17 | print("Fits data cannot be used. Install pyfits module") | |
|
18 | 18 | |
|
19 | 19 | from xml.etree.ElementTree import ElementTree |
|
20 | 20 | |
|
21 | from jroIO_base import isRadarFolder, isNumber | |
|
21 | from .jroIO_base import isRadarFolder, isNumber | |
|
22 | 22 | from schainpy.model.data.jrodata import Fits |
|
23 | 23 | from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit |
|
24 | 24 | |
@@ -240,7 +240,7 class FitsWriter(Operation): | |||
|
240 | 240 | self.setFile = setFile |
|
241 | 241 | self.flagIsNewFile = 1 |
|
242 | 242 | |
|
243 |
print |
|
|
243 | print('Writing the file: %s'%self.filename) | |
|
244 | 244 | |
|
245 | 245 | self.setFitsHeader(self.dataOut, self.metadatafile) |
|
246 | 246 | |
@@ -327,7 +327,7 class FitsReader(ProcessingUnit): | |||
|
327 | 327 | try: |
|
328 | 328 | fitsObj = pyfits.open(filename,'readonly') |
|
329 | 329 | except: |
|
330 |
print |
|
|
330 | print("File %s can't be opened" %(filename)) | |
|
331 | 331 | return None |
|
332 | 332 | |
|
333 | 333 | header = fitsObj[0].header |
@@ -355,7 +355,7 class FitsReader(ProcessingUnit): | |||
|
355 | 355 | idFile += 1 |
|
356 | 356 | if not(idFile < len(self.filenameList)): |
|
357 | 357 | self.flagNoMoreFiles = 1 |
|
358 |
print |
|
|
358 | print("No more Files") | |
|
359 | 359 | return 0 |
|
360 | 360 | |
|
361 | 361 | filename = self.filenameList[idFile] |
@@ -373,7 +373,7 class FitsReader(ProcessingUnit): | |||
|
373 | 373 | self.fileSize = fileSize |
|
374 | 374 | self.fitsObj = fitsObj |
|
375 | 375 | self.blockIndex = 0 |
|
376 |
print |
|
|
376 | print("Setting the file: %s"%self.filename) | |
|
377 | 377 | |
|
378 | 378 | return 1 |
|
379 | 379 | |
@@ -398,10 +398,10 class FitsReader(ProcessingUnit): | |||
|
398 | 398 | headerObj = self.fitsObj[0] |
|
399 | 399 | |
|
400 | 400 | self.header_dict = headerObj.header |
|
401 | if 'EXPNAME' in headerObj.header.keys(): | |
|
401 | if 'EXPNAME' in list(headerObj.header.keys()): | |
|
402 | 402 | self.expName = headerObj.header['EXPNAME'] |
|
403 | 403 | |
|
404 | if 'DATATYPE' in headerObj.header.keys(): | |
|
404 | if 'DATATYPE' in list(headerObj.header.keys()): | |
|
405 | 405 | self.dataType = headerObj.header['DATATYPE'] |
|
406 | 406 | |
|
407 | 407 | self.datetimestr = headerObj.header['DATETIME'] |
@@ -421,7 +421,7 class FitsReader(ProcessingUnit): | |||
|
421 | 421 | |
|
422 | 422 | # self.timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
423 | 423 | |
|
424 | if 'COMMENT' in headerObj.header.keys(): | |
|
424 | if 'COMMENT' in list(headerObj.header.keys()): | |
|
425 | 425 | self.comments = headerObj.header['COMMENT'] |
|
426 | 426 | |
|
427 | 427 | self.readHeightList() |
@@ -498,10 +498,10 class FitsReader(ProcessingUnit): | |||
|
498 | 498 | thisDate += datetime.timedelta(1) |
|
499 | 499 | |
|
500 | 500 | if pathList == []: |
|
501 |
print |
|
|
501 | print("Any folder was found for the date range: %s-%s" %(startDate, endDate)) | |
|
502 | 502 | return None, None |
|
503 | 503 | |
|
504 |
print |
|
|
504 | print("%d folder(s) was(were) found for the date range: %s - %s" %(len(pathList), startDate, endDate)) | |
|
505 | 505 | |
|
506 | 506 | filenameList = [] |
|
507 | 507 | datetimeList = [] |
@@ -525,14 +525,14 class FitsReader(ProcessingUnit): | |||
|
525 | 525 | datetimeList.append(thisDatetime) |
|
526 | 526 | |
|
527 | 527 | if not(filenameList): |
|
528 |
print |
|
|
528 | print("Any file was found for the time range %s - %s" %(startTime, endTime)) | |
|
529 | 529 | return None, None |
|
530 | 530 | |
|
531 |
print |
|
|
532 | ||
|
531 | print("%d file(s) was(were) found for the time range: %s - %s" %(len(filenameList), startTime, endTime)) | |
|
532 | print() | |
|
533 | 533 | |
|
534 | 534 | for i in range(len(filenameList)): |
|
535 |
print |
|
|
535 | print("%s -> [%s]" %(filenameList[i], datetimeList[i].ctime())) | |
|
536 | 536 | |
|
537 | 537 | self.filenameList = filenameList |
|
538 | 538 | self.datetimeList = datetimeList |
@@ -552,22 +552,22 class FitsReader(ProcessingUnit): | |||
|
552 | 552 | walk = True): |
|
553 | 553 | |
|
554 | 554 | if path == None: |
|
555 |
raise ValueError |
|
|
555 | raise ValueError("The path is not valid") | |
|
556 | 556 | |
|
557 | 557 | if ext == None: |
|
558 | 558 | ext = self.ext |
|
559 | 559 | |
|
560 | 560 | if not(online): |
|
561 |
print |
|
|
561 | print("Searching files in offline mode ...") | |
|
562 | 562 | pathList, filenameList = self.searchFilesOffLine(path, startDate=startDate, endDate=endDate, |
|
563 | 563 | startTime=startTime, endTime=endTime, |
|
564 | 564 | set=set, expLabel=expLabel, ext=ext, |
|
565 | 565 | walk=walk) |
|
566 | 566 | |
|
567 | 567 | if not(pathList): |
|
568 |
print |
|
|
568 | print("No *%s files into the folder %s \nfor the range: %s - %s"%(ext, path, | |
|
569 | 569 | datetime.datetime.combine(startDate,startTime).ctime(), |
|
570 | datetime.datetime.combine(endDate,endTime).ctime()) | |
|
570 | datetime.datetime.combine(endDate,endTime).ctime())) | |
|
571 | 571 | |
|
572 | 572 | sys.exit(-1) |
|
573 | 573 | |
@@ -582,11 +582,11 class FitsReader(ProcessingUnit): | |||
|
582 | 582 | |
|
583 | 583 | if not(self.setNextFile()): |
|
584 | 584 | if (startDate!=None) and (endDate!=None): |
|
585 |
print |
|
|
585 | print("No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())) | |
|
586 | 586 | elif startDate != None: |
|
587 |
print |
|
|
587 | print("No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())) | |
|
588 | 588 | else: |
|
589 |
print |
|
|
589 | print("No files") | |
|
590 | 590 | |
|
591 | 591 | sys.exit(-1) |
|
592 | 592 | |
@@ -638,7 +638,7 class FitsReader(ProcessingUnit): | |||
|
638 | 638 | self.__rdBasicHeader() |
|
639 | 639 | return 1 |
|
640 | 640 | |
|
641 |
print |
|
|
641 | print("\tWaiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)) | |
|
642 | 642 | sleep( self.delay ) |
|
643 | 643 | |
|
644 | 644 | |
@@ -691,7 +691,7 class FitsReader(ProcessingUnit): | |||
|
691 | 691 | |
|
692 | 692 | if self.flagNoMoreFiles: |
|
693 | 693 | self.dataOut.flagNoData = True |
|
694 |
print |
|
|
694 | print('Process finished') | |
|
695 | 695 | return 0 |
|
696 | 696 | |
|
697 | 697 | self.flagDiscontinuousBlock = 0 |
@@ -845,4 +845,4 class SpectraHeisWriter(Operation): | |||
|
845 | 845 | self.setup(dataOut, **kwargs) |
|
846 | 846 | self.isConfig = True |
|
847 | 847 | |
|
848 |
self.putData() |
|
|
848 | self.putData() No newline at end of file |
@@ -68,10 +68,10 def getFileFromSet(path, ext, set=None): | |||
|
68 | 68 | if set == None: |
|
69 | 69 | return validFilelist[-1] |
|
70 | 70 | |
|
71 |
print |
|
|
71 | print("set =" ,set) | |
|
72 | 72 | for thisFile in validFilelist: |
|
73 | 73 | if set <= int(thisFile[6:16]): |
|
74 |
print |
|
|
74 | print(thisFile,int(thisFile[6:16])) | |
|
75 | 75 | return thisFile |
|
76 | 76 | |
|
77 | 77 | return validFilelist[-1] |
@@ -83,8 +83,8 def getFileFromSet(path, ext, set=None): | |||
|
83 | 83 | return myfile[0] |
|
84 | 84 | else: |
|
85 | 85 | filename = '*%10.10d%s'%(set,ext.lower()) |
|
86 |
print |
|
|
87 |
print |
|
|
86 | print('the filename %s does not exist'%filename) | |
|
87 | print('...going to the last file: ') | |
|
88 | 88 | |
|
89 | 89 | if validFilelist: |
|
90 | 90 | validFilelist = sorted( validFilelist, key=str.lower ) |
@@ -115,7 +115,7 Depura el fileList dejando solo los que cumplan el formato de "res-xxxxxx.ext" | |||
|
115 | 115 | try: |
|
116 | 116 | number= int(thisFile[6:16]) |
|
117 | 117 | except: |
|
118 |
print |
|
|
118 | print("There is a file or folder with different format") | |
|
119 | 119 | if not isNumber(number): |
|
120 | 120 | continue |
|
121 | 121 | |
@@ -256,7 +256,7 class HFReader(ProcessingUnit): | |||
|
256 | 256 | self.status=1 |
|
257 | 257 | else: |
|
258 | 258 | self.status=0 |
|
259 |
print |
|
|
259 | print('Path %s does not exits'%self.path) | |
|
260 | 260 | return |
|
261 | 261 | return |
|
262 | 262 | |
@@ -282,12 +282,12 class HFReader(ProcessingUnit): | |||
|
282 | 282 | |
|
283 | 283 | pat = '\d+.\d+' |
|
284 | 284 | dirnameList = [re.search(pat,x) for x in os.listdir(self.path)] |
|
285 |
dirnameList = |
|
|
285 | dirnameList = [x for x in dirnameList if x!=None] | |
|
286 | 286 | dirnameList = [x.string for x in dirnameList] |
|
287 | 287 | if not(online): |
|
288 | 288 | |
|
289 | 289 | dirnameList = [self.__selDates(x) for x in dirnameList] |
|
290 |
dirnameList = |
|
|
290 | dirnameList = [x for x in dirnameList if x!=None] | |
|
291 | 291 | |
|
292 | 292 | if len(dirnameList)>0: |
|
293 | 293 | self.status = 1 |
@@ -301,8 +301,8 class HFReader(ProcessingUnit): | |||
|
301 | 301 | def __getTimeFromData(self): |
|
302 | 302 | startDateTime_Reader = datetime.datetime.combine(self.startDate,self.startTime) |
|
303 | 303 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) |
|
304 |
print |
|
|
305 |
print |
|
|
304 | print('Filtering Files from %s to %s'%(startDateTime_Reader, endDateTime_Reader)) | |
|
305 | print('........................................') | |
|
306 | 306 | filter_filenameList=[] |
|
307 | 307 | self.filenameList.sort() |
|
308 | 308 | for i in range(len(self.filenameList)-1): |
@@ -363,24 +363,24 class HFReader(ProcessingUnit): | |||
|
363 | 363 | |
|
364 | 364 | self.flag_nextfile=False |
|
365 | 365 | else: |
|
366 |
print |
|
|
367 |
print |
|
|
366 | print(filename) | |
|
367 | print("PRIMERA CONDICION") | |
|
368 | 368 | #if self.filename_next_set== int(filename[6:16]): |
|
369 |
print |
|
|
369 | print("TODO BIEN") | |
|
370 | 370 | |
|
371 | 371 | if filename == None: |
|
372 |
raise ValueError |
|
|
372 | raise ValueError("corregir") | |
|
373 | 373 | |
|
374 | 374 | self.dirnameList=[filename] |
|
375 | 375 | fullfilename=self.path+"/"+filename |
|
376 | 376 | self.filenameList=[fullfilename] |
|
377 | 377 | self.filename_next_set=int(filename[6:16])+10 |
|
378 |
print |
|
|
378 | print("Setting next file",self.filename_next_set) | |
|
379 | 379 | self.set=int(filename[6:16]) |
|
380 | 380 | if True: |
|
381 | 381 | pass |
|
382 | 382 | else: |
|
383 |
print |
|
|
383 | print("ESTOY AQUI PORQUE NO EXISTE EL SIGUIENTE ARCHIVO") | |
|
384 | 384 | |
|
385 | 385 | else: |
|
386 | 386 | filename =getlastFileFromPath(self.path,self.ext) |
@@ -394,24 +394,24 class HFReader(ProcessingUnit): | |||
|
394 | 394 | self.flag_nextfile=False |
|
395 | 395 | else: |
|
396 | 396 | filename=getFileFromSet(self.path,self.ext,self.set) |
|
397 |
print |
|
|
398 |
print |
|
|
397 | print(filename) | |
|
398 | print("PRIMERA CONDICION") | |
|
399 | 399 | #if self.filename_next_set== int(filename[6:16]): |
|
400 |
print |
|
|
400 | print("TODO BIEN") | |
|
401 | 401 | |
|
402 | 402 | if filename == None: |
|
403 |
raise ValueError |
|
|
403 | raise ValueError("corregir") | |
|
404 | 404 | |
|
405 | 405 | self.dirnameList=[filename] |
|
406 | 406 | fullfilename=self.path+"/"+filename |
|
407 | 407 | self.filenameList=[fullfilename] |
|
408 | 408 | self.filename_next_set=int(filename[6:16])+10 |
|
409 |
print |
|
|
409 | print("Setting next file",self.filename_next_set) | |
|
410 | 410 | self.set=int(filename[6:16]) |
|
411 | 411 | if True: |
|
412 | 412 | pass |
|
413 | 413 | else: |
|
414 |
print |
|
|
414 | print("ESTOY AQUI PORQUE NO EXISTE EL SIGUIENTE ARCHIVO") | |
|
415 | 415 | |
|
416 | 416 | |
|
417 | 417 | |
@@ -434,7 +434,7 class HFReader(ProcessingUnit): | |||
|
434 | 434 | self.__selectDataForTimes() |
|
435 | 435 | |
|
436 | 436 | for i in range(len(self.filenameList)): |
|
437 |
print |
|
|
437 | print("%s"% (self.filenameList[i])) | |
|
438 | 438 | |
|
439 | 439 | return |
|
440 | 440 | |
@@ -456,7 +456,7 class HFReader(ProcessingUnit): | |||
|
456 | 456 | self.__checkPath() |
|
457 | 457 | |
|
458 | 458 | fullpath=path |
|
459 |
print |
|
|
459 | print("%s folder was found: " %(fullpath )) | |
|
460 | 460 | |
|
461 | 461 | if set == None: |
|
462 | 462 | self.set=None |
@@ -518,7 +518,7 class HFReader(ProcessingUnit): | |||
|
518 | 518 | idFile += 1 |
|
519 | 519 | if not (idFile < len(self.filenameList)): |
|
520 | 520 | self.flagNoMoreFiles = 1 |
|
521 |
print |
|
|
521 | print("No more Files") | |
|
522 | 522 | return 0 |
|
523 | 523 | filename = self.filenameList[idFile] |
|
524 | 524 | hfFilePointer =h5py.File(filename,'r') |
@@ -534,14 +534,14 class HFReader(ProcessingUnit): | |||
|
534 | 534 | self.hfFilePointer = hfFilePointer |
|
535 | 535 | hfFilePointer.close() |
|
536 | 536 | self.__t0=epoc |
|
537 |
print |
|
|
537 | print("Setting the file: %s"%self.filename) | |
|
538 | 538 | |
|
539 | 539 | return 1 |
|
540 | 540 | |
|
541 | 541 | def __setNextFileOnline(self): |
|
542 | 542 | """ |
|
543 | 543 | """ |
|
544 |
print |
|
|
544 | print("SOY NONE",self.set) | |
|
545 | 545 | if self.set==None: |
|
546 | 546 | pass |
|
547 | 547 | else: |
@@ -552,7 +552,7 class HFReader(ProcessingUnit): | |||
|
552 | 552 | self.__selectDataForTimes(online=True) |
|
553 | 553 | filename = self.filenameList[0] |
|
554 | 554 | while self.filename_online == filename: |
|
555 |
print |
|
|
555 | print('waiting %d seconds to get a new file...'%(self.__waitForNewFile)) | |
|
556 | 556 | time.sleep(self.__waitForNewFile) |
|
557 | 557 | #self.__findDataForDates(online=True) |
|
558 | 558 | self.set=self.filename_next_set |
@@ -563,27 +563,27 class HFReader(ProcessingUnit): | |||
|
563 | 563 | #print filename |
|
564 | 564 | sizeoffile=os.path.getsize(filename) |
|
565 | 565 | if sizeoffile<1670240: |
|
566 |
print |
|
|
566 | print("%s is not the rigth size"%filename) | |
|
567 | 567 | delay=50 |
|
568 |
print |
|
|
568 | print('waiting %d seconds for delay...'%(delay)) | |
|
569 | 569 | time.sleep(delay) |
|
570 | 570 | sizeoffile=os.path.getsize(filename) |
|
571 | 571 | if sizeoffile<1670240: |
|
572 | 572 | delay=50 |
|
573 |
print |
|
|
573 | print('waiting %d more seconds for delay...'%(delay)) | |
|
574 | 574 | time.sleep(delay) |
|
575 | 575 | |
|
576 | 576 | sizeoffile=os.path.getsize(filename) |
|
577 | 577 | if sizeoffile<1670240: |
|
578 | 578 | delay=50 |
|
579 |
print |
|
|
579 | print('waiting %d more seconds for delay...'%(delay)) | |
|
580 | 580 | time.sleep(delay) |
|
581 | 581 | |
|
582 | 582 | try: |
|
583 | 583 | hfFilePointer=h5py.File(filename,'r') |
|
584 | 584 | |
|
585 | 585 | except: |
|
586 |
print |
|
|
586 | print("Error reading file %s"%filename) | |
|
587 | 587 | |
|
588 | 588 | self.filename_online=filename |
|
589 | 589 | epoc=hfFilePointer['t'].value |
@@ -596,7 +596,7 class HFReader(ProcessingUnit): | |||
|
596 | 596 | self.flagIsNewFile = 1 |
|
597 | 597 | self.filename = filename |
|
598 | 598 | |
|
599 |
print |
|
|
599 | print("Setting the file: %s"%self.filename) | |
|
600 | 600 | return 1 |
|
601 | 601 | |
|
602 | 602 | def __getExpParameters(self): |
@@ -622,7 +622,7 class HFReader(ProcessingUnit): | |||
|
622 | 622 | |
|
623 | 623 | ''' |
|
624 | 624 | if path==None: |
|
625 |
raise ValueError |
|
|
625 | raise ValueError("The path is not valid") | |
|
626 | 626 | |
|
627 | 627 | if ext==None: |
|
628 | 628 | ext = self.ext |
@@ -634,11 +634,11 class HFReader(ProcessingUnit): | |||
|
634 | 634 | |
|
635 | 635 | #print set |
|
636 | 636 | if not(online): |
|
637 |
print |
|
|
637 | print("Searching files in offline mode...") | |
|
638 | 638 | |
|
639 | 639 | self.searchFilesOffLine(path, startDate, endDate, ext, startTime, endTime, walk) |
|
640 | 640 | else: |
|
641 |
print |
|
|
641 | print("Searching files in online mode...") | |
|
642 | 642 | self.searchFilesOnLine(path, walk,ext,set=set) |
|
643 | 643 | if set==None: |
|
644 | 644 | pass |
@@ -659,7 +659,7 class HFReader(ProcessingUnit): | |||
|
659 | 659 | |
|
660 | 660 | |
|
661 | 661 | if not(self.filenameList): |
|
662 |
print |
|
|
662 | print("There is no files into the folder: %s"%(path)) | |
|
663 | 663 | sys.exit(-1) |
|
664 | 664 | |
|
665 | 665 | self.__getExpParameters() |
@@ -745,7 +745,7 class HFReader(ProcessingUnit): | |||
|
745 | 745 | |
|
746 | 746 | self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth |
|
747 | 747 | |
|
748 | self.dataOut.channelList = range(self.nChannels) | |
|
748 | self.dataOut.channelList = list(range(self.nChannels)) | |
|
749 | 749 | |
|
750 | 750 | #self.dataOut.channelIndexList = None |
|
751 | 751 | |
@@ -833,7 +833,7 class HFReader(ProcessingUnit): | |||
|
833 | 833 | def getData(self): |
|
834 | 834 | if self.flagNoMoreFiles: |
|
835 | 835 | self.dataOut.flagNoData = True |
|
836 |
print |
|
|
836 | print('Process finished') | |
|
837 | 837 | return 0 |
|
838 | 838 | |
|
839 | 839 | if self.__hasNotDataInBuffer(): |
@@ -860,4 +860,4 class HFReader(ProcessingUnit): | |||
|
860 | 860 | if not self.isConfig: |
|
861 | 861 | self.setup(**kwargs) |
|
862 | 862 | self.isConfig = True |
|
863 |
self.getData() |
|
|
863 | self.getData() No newline at end of file |
@@ -111,7 +111,7 class AMISRReader(ProcessingUnit): | |||
|
111 | 111 | self.searchFilesOnLine(path, startDate, endDate, startTime,endTime,walk) |
|
112 | 112 | |
|
113 | 113 | if not(self.filenameList): |
|
114 |
print |
|
|
114 | print("There is no files into the folder: %s"%(path)) | |
|
115 | 115 | |
|
116 | 116 | sys.exit(-1) |
|
117 | 117 | |
@@ -177,7 +177,7 class AMISRReader(ProcessingUnit): | |||
|
177 | 177 | #filling system header parameters |
|
178 | 178 | self.__nSamples = self.nsa |
|
179 | 179 | self.newProfiles = self.nprofiles/self.nchannels |
|
180 | self.__channelList = range(self.nchannels) | |
|
180 | self.__channelList = list(range(self.nchannels)) | |
|
181 | 181 | |
|
182 | 182 | self.__frequency = self.frequency[0][0] |
|
183 | 183 | |
@@ -200,7 +200,7 class AMISRReader(ProcessingUnit): | |||
|
200 | 200 | self.status = 1 |
|
201 | 201 | else: |
|
202 | 202 | self.status = 0 |
|
203 |
print |
|
|
203 | print('Path:%s does not exists'%self.path) | |
|
204 | 204 | |
|
205 | 205 | return |
|
206 | 206 | |
@@ -225,11 +225,11 class AMISRReader(ProcessingUnit): | |||
|
225 | 225 | |
|
226 | 226 | pat = '\d+.\d+' |
|
227 | 227 | dirnameList = [re.search(pat,x) for x in os.listdir(self.path)] |
|
228 |
dirnameList = |
|
|
228 | dirnameList = [x for x in dirnameList if x!=None] | |
|
229 | 229 | dirnameList = [x.string for x in dirnameList] |
|
230 | 230 | if not(online): |
|
231 | 231 | dirnameList = [self.__selDates(x) for x in dirnameList] |
|
232 |
dirnameList = |
|
|
232 | dirnameList = [x for x in dirnameList if x!=None] | |
|
233 | 233 | if len(dirnameList)>0: |
|
234 | 234 | self.status = 1 |
|
235 | 235 | self.dirnameList = dirnameList |
@@ -242,8 +242,8 class AMISRReader(ProcessingUnit): | |||
|
242 | 242 | startDateTime_Reader = datetime.datetime.combine(self.startDate,self.startTime) |
|
243 | 243 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) |
|
244 | 244 | |
|
245 |
print |
|
|
246 |
print |
|
|
245 | print('Filtering Files from %s to %s'%(startDateTime_Reader, endDateTime_Reader)) | |
|
246 | print('........................................') | |
|
247 | 247 | filter_filenameList = [] |
|
248 | 248 | self.filenameList.sort() |
|
249 | 249 | #for i in range(len(self.filenameList)-1): |
@@ -288,7 +288,7 class AMISRReader(ProcessingUnit): | |||
|
288 | 288 | |
|
289 | 289 | def __getFilenameList(self, fileListInKeys, dirList): |
|
290 | 290 | for value in fileListInKeys: |
|
291 | dirName = value.keys()[0] | |
|
291 | dirName = list(value.keys())[0] | |
|
292 | 292 | for file in value[dirName]: |
|
293 | 293 | filename = os.path.join(dirName, file) |
|
294 | 294 | self.filenameList.append(filename) |
@@ -366,7 +366,7 class AMISRReader(ProcessingUnit): | |||
|
366 | 366 | self.__selectDataForTimes() |
|
367 | 367 | |
|
368 | 368 | for i in range(len(self.filenameList)): |
|
369 |
print |
|
|
369 | print("%s" %(self.filenameList[i])) | |
|
370 | 370 | |
|
371 | 371 | return |
|
372 | 372 | |
@@ -377,7 +377,7 class AMISRReader(ProcessingUnit): | |||
|
377 | 377 | idFile += 1 |
|
378 | 378 | if not(idFile < len(self.filenameList)): |
|
379 | 379 | self.flagNoMoreFiles = 1 |
|
380 |
print |
|
|
380 | print("No more Files") | |
|
381 | 381 | return 0 |
|
382 | 382 | |
|
383 | 383 | filename = self.filenameList[idFile] |
@@ -392,7 +392,7 class AMISRReader(ProcessingUnit): | |||
|
392 | 392 | |
|
393 | 393 | self.amisrFilePointer = amisrFilePointer |
|
394 | 394 | |
|
395 |
print |
|
|
395 | print("Setting the file: %s"%self.filename) | |
|
396 | 396 | |
|
397 | 397 | return 1 |
|
398 | 398 | |
@@ -404,7 +404,7 class AMISRReader(ProcessingUnit): | |||
|
404 | 404 | filename = self.filenameList[0] |
|
405 | 405 | wait = 0 |
|
406 | 406 | while self.__filename_online == filename: |
|
407 |
print |
|
|
407 | print('waiting %d seconds to get a new file...'%(self.__waitForNewFile)) | |
|
408 | 408 | if wait == 5: |
|
409 | 409 | return 0 |
|
410 | 410 | sleep(self.__waitForNewFile) |
@@ -417,7 +417,7 class AMISRReader(ProcessingUnit): | |||
|
417 | 417 | self.amisrFilePointer = h5py.File(filename,'r') |
|
418 | 418 | self.flagIsNewFile = 1 |
|
419 | 419 | self.filename = filename |
|
420 |
print |
|
|
420 | print("Setting the file: %s"%self.filename) | |
|
421 | 421 | return 1 |
|
422 | 422 | |
|
423 | 423 | |
@@ -585,7 +585,7 class AMISRReader(ProcessingUnit): | |||
|
585 | 585 | |
|
586 | 586 | if self.flagNoMoreFiles: |
|
587 | 587 | self.dataOut.flagNoData = True |
|
588 |
print |
|
|
588 | print('Process finished') | |
|
589 | 589 | return 0 |
|
590 | 590 | |
|
591 | 591 | if self.__hasNotDataInBuffer(): |
@@ -63,10 +63,10 def load_json(obj): | |||
|
63 | 63 | iterable = obj |
|
64 | 64 | |
|
65 | 65 | if isinstance(iterable, dict): |
|
66 |
return {str(k): load_json(v) if isinstance(v, dict) else str(v) if isinstance(v, |
|
|
67 | for k, v in iterable.items()} | |
|
66 | return {str(k): load_json(v) if isinstance(v, dict) else str(v) if isinstance(v, str) else v | |
|
67 | for k, v in list(iterable.items())} | |
|
68 | 68 | elif isinstance(iterable, (list, tuple)): |
|
69 |
return [str(v) if isinstance(v, |
|
|
69 | return [str(v) if isinstance(v, str) else v for v in iterable] | |
|
70 | 70 | |
|
71 | 71 | return iterable |
|
72 | 72 | |
@@ -107,10 +107,10 class MADReader(JRODataReader, ProcessingUnit): | |||
|
107 | 107 | self.ind2DList = load_json(kwargs.get('ind2DList', |
|
108 | 108 | "[\"GDALT\"]")) |
|
109 | 109 | if self.path is None: |
|
110 |
raise ValueError |
|
|
110 | raise ValueError('The path is not valid') | |
|
111 | 111 | |
|
112 | 112 | if format is None: |
|
113 |
raise ValueError |
|
|
113 | raise ValueError('The format is not valid choose simple or hdf5') | |
|
114 | 114 | elif format.lower() in ('simple', 'txt'): |
|
115 | 115 | self.ext = '.txt' |
|
116 | 116 | elif format.lower() in ('cedar',): |
@@ -122,7 +122,7 class MADReader(JRODataReader, ProcessingUnit): | |||
|
122 | 122 | self.fileId = 0 |
|
123 | 123 | |
|
124 | 124 | if not self.fileList: |
|
125 |
raise Warning |
|
|
125 | raise Warning('There is no files matching these date in the folder: {}. \n Check startDate and endDate'.format(path)) | |
|
126 | 126 | |
|
127 | 127 | self.setNextFile() |
|
128 | 128 | |
@@ -198,7 +198,7 class MADReader(JRODataReader, ProcessingUnit): | |||
|
198 | 198 | log.success('Spatial parameters: {}'.format(','.join(s_parameters)), |
|
199 | 199 | 'MADReader') |
|
200 | 200 | |
|
201 | for param in self.oneDDict.keys(): | |
|
201 | for param in list(self.oneDDict.keys()): | |
|
202 | 202 | if param.lower() not in self.parameters: |
|
203 | 203 | log.warning( |
|
204 | 204 | 'Parameter {} not found will be ignored'.format( |
@@ -206,7 +206,7 class MADReader(JRODataReader, ProcessingUnit): | |||
|
206 | 206 | 'MADReader') |
|
207 | 207 | self.oneDDict.pop(param, None) |
|
208 | 208 | |
|
209 | for param, value in self.twoDDict.items(): | |
|
209 | for param, value in list(self.twoDDict.items()): | |
|
210 | 210 | if param.lower() not in self.parameters: |
|
211 | 211 | log.warning( |
|
212 | 212 | 'Parameter {} not found, it will be ignored'.format( |
@@ -352,11 +352,11 class MADReader(JRODataReader, ProcessingUnit): | |||
|
352 | 352 | |
|
353 | 353 | parameters = [None for __ in self.parameters] |
|
354 | 354 | |
|
355 | for param, attr in self.oneDDict.items(): | |
|
355 | for param, attr in list(self.oneDDict.items()): | |
|
356 | 356 | x = self.parameters.index(param.lower()) |
|
357 | 357 | setattr(self.dataOut, attr, self.buffer[0][x]) |
|
358 | 358 | |
|
359 | for param, value in self.twoDDict.items(): | |
|
359 | for param, value in list(self.twoDDict.items()): | |
|
360 | 360 | x = self.parameters.index(param.lower()) |
|
361 | 361 | if self.ext == '.txt': |
|
362 | 362 | y = self.parameters.index(self.ind2DList[0].lower()) |
@@ -376,7 +376,7 class MADReader(JRODataReader, ProcessingUnit): | |||
|
376 | 376 | self.output[value[0]][value[1]] = dummy |
|
377 | 377 | parameters[value[1]] = param |
|
378 | 378 | |
|
379 | for key, value in self.output.items(): | |
|
379 | for key, value in list(self.output.items()): | |
|
380 | 380 | setattr(self.dataOut, key, numpy.array(value)) |
|
381 | 381 | |
|
382 | 382 | self.dataOut.parameters = [s for s in parameters if s] |
@@ -508,7 +508,7 class MADWriter(Operation): | |||
|
508 | 508 | 'Creating file: {}'.format(self.fullname), |
|
509 | 509 | 'MADWriter') |
|
510 | 510 | self.fp = madrigal.cedar.MadrigalCedarFile(self.fullname, True) |
|
511 |
except ValueError |
|
|
511 | except ValueError as e: | |
|
512 | 512 | log.error( |
|
513 | 513 | 'Impossible to create a cedar object with "madrigal.cedar.MadrigalCedarFile"', |
|
514 | 514 | 'MADWriter') |
@@ -528,7 +528,7 class MADWriter(Operation): | |||
|
528 | 528 | heights = self.dataOut.heightList |
|
529 | 529 | |
|
530 | 530 | if self.ext == '.dat': |
|
531 | for key, value in self.twoDDict.items(): | |
|
531 | for key, value in list(self.twoDDict.items()): | |
|
532 | 532 | if isinstance(value, str): |
|
533 | 533 | data = getattr(self.dataOut, value) |
|
534 | 534 | invalid = numpy.isnan(data) |
@@ -540,7 +540,7 class MADWriter(Operation): | |||
|
540 | 540 | data[invalid] = self.missing |
|
541 | 541 | |
|
542 | 542 | out = {} |
|
543 | for key, value in self.twoDDict.items(): | |
|
543 | for key, value in list(self.twoDDict.items()): | |
|
544 | 544 | key = key.lower() |
|
545 | 545 | if isinstance(value, str): |
|
546 | 546 | if 'db' in value.lower(): |
@@ -576,8 +576,8 class MADWriter(Operation): | |||
|
576 | 576 | endTime.minute, |
|
577 | 577 | endTime.second, |
|
578 | 578 | endTime.microsecond/10000, |
|
579 | self.oneDDict.keys(), | |
|
580 | self.twoDDict.keys(), | |
|
579 | list(self.oneDDict.keys()), | |
|
580 | list(self.twoDDict.keys()), | |
|
581 | 581 | len(index), |
|
582 | 582 | **self.extra_args |
|
583 | 583 | ) |
@@ -639,4 +639,4 class MADWriter(Operation): | |||
|
639 | 639 | def close(self): |
|
640 | 640 | |
|
641 | 641 | if self.counter > 0: |
|
642 |
self.setHeader() |
|
|
642 | self.setHeader() No newline at end of file |
@@ -29,7 +29,7 class matoffReader(ProcessingUnit): | |||
|
29 | 29 | def __setHeader(self, datastuff): |
|
30 | 30 | |
|
31 | 31 | self.dataOut.pairsList=[(0,1)] |
|
32 | self.dataOut.channelList = range(np.array(datastuff.get('power')).shape[1]) | |
|
32 | self.dataOut.channelList = list(range(np.array(datastuff.get('power')).shape[1])) | |
|
33 | 33 | self.dataOut.nProfiles = len(np.array(datastuff.get('vel')).flatten()) #this! |
|
34 | 34 | self.dataOut.nIncohInt = 20 |
|
35 | 35 | self.dataOut.nCohInt = 1 #this! |
@@ -39,7 +39,7 class matoffReader(ProcessingUnit): | |||
|
39 | 39 | self.dataOut.heightList = np.array(datastuff.get('hts')).flatten() |
|
40 | 40 | |
|
41 | 41 | def __readFile(self, currentfile): |
|
42 |
print |
|
|
42 | print("Reading from this file:" + currentfile) | |
|
43 | 43 | |
|
44 | 44 | #filesplit=currentfile.split("\\") |
|
45 | 45 | filesplit=currentfile.split("/") |
@@ -64,7 +64,7 class matoffReader(ProcessingUnit): | |||
|
64 | 64 | # self.utcmatcounter=0 |
|
65 | 65 | |
|
66 | 66 | # print self.utcmatcounter |
|
67 |
print |
|
|
67 | print(self.utcfirst) | |
|
68 | 68 | try: |
|
69 | 69 | datastuff=sio.loadmat(currentfile) |
|
70 | 70 | except: |
@@ -115,7 +115,7 class matoffReader(ProcessingUnit): | |||
|
115 | 115 | utclist=[] |
|
116 | 116 | |
|
117 | 117 | if not dirList: |
|
118 |
print |
|
|
118 | print("No directories found") | |
|
119 | 119 | return [] |
|
120 | 120 | |
|
121 | 121 | #if self.online: |
@@ -146,7 +146,7 class matoffReader(ProcessingUnit): | |||
|
146 | 146 | utclist.append(utctime) |
|
147 | 147 | |
|
148 | 148 | if not dirListFiltered: |
|
149 |
print |
|
|
149 | print("filtro") | |
|
150 | 150 | return [] |
|
151 | 151 | |
|
152 | 152 | for thisDir in dirListFiltered: |
@@ -188,7 +188,7 class matoffReader(ProcessingUnit): | |||
|
188 | 188 | if nTries > 3: |
|
189 | 189 | break |
|
190 | 190 | |
|
191 |
print |
|
|
191 | print("Waiting %d seconds ..." %seconds) | |
|
192 | 192 | time.sleep(40) |
|
193 | 193 | |
|
194 | 194 | if not (len(filelist) > ncurrentfiles): |
@@ -227,7 +227,7 class matoffReader(ProcessingUnit): | |||
|
227 | 227 | |
|
228 | 228 | self.fileList = fileList |
|
229 | 229 | |
|
230 |
print |
|
|
230 | print("fin setup") | |
|
231 | 231 | |
|
232 | 232 | def run(self,path=None,startDate=None, endDate=None, |
|
233 | 233 | startTime=datetime.time(0,0,0), |
@@ -251,7 +251,7 class matoffReader(ProcessingUnit): | |||
|
251 | 251 | |
|
252 | 252 | if not self.fileList: |
|
253 | 253 | self.dataOut.flagNoData = True |
|
254 |
print |
|
|
254 | print("lista vacia") | |
|
255 | 255 | return |
|
256 | 256 | |
|
257 | 257 | currentfile = self.__getNextFile() |
@@ -48,7 +48,7 class Header(object): | |||
|
48 | 48 | message += self.__class__.__name__.upper() + "\n" |
|
49 | 49 | message += "#" * 50 + "\n" |
|
50 | 50 | |
|
51 | keyList = self.__dict__.keys() | |
|
51 | keyList = list(self.__dict__.keys()) | |
|
52 | 52 | keyList.sort() |
|
53 | 53 | |
|
54 | 54 | for key in keyList: |
@@ -333,7 +333,7 class SRVIHeader(Header): | |||
|
333 | 333 | self.DataBlockTitleSRVI1 = str(header['DataBlockTitleSRVI1'][0]) |
|
334 | 334 | self.SizeOfSRVI1 = header['SizeOfSRVI1'][0] |
|
335 | 335 | # 16 |
|
336 |
print |
|
|
336 | print('Pointer fp SRVIheader', fp.tell()) | |
|
337 | 337 | |
|
338 | 338 | |
|
339 | 339 | SRVI_STRUCTURE = numpy.dtype([ |
@@ -435,9 +435,9 class RecordHeader(Header): | |||
|
435 | 435 | # print 'Datasize',self.Datasize |
|
436 | 436 | #endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec |
|
437 | 437 | |
|
438 |
print |
|
|
438 | print('==============================================') | |
|
439 | 439 | |
|
440 |
print |
|
|
440 | print('==============================================') | |
|
441 | 441 | |
|
442 | 442 | return 1 |
|
443 | 443 | |
@@ -572,7 +572,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
572 | 572 | |
|
573 | 573 | if self.flagNoMoreFiles: |
|
574 | 574 | self.dataOut.flagNoData = True |
|
575 |
print |
|
|
575 | print('NoData se vuelve true') | |
|
576 | 576 | return 0 |
|
577 | 577 | |
|
578 | 578 | self.fp = self.path |
@@ -602,7 +602,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
602 | 602 | ''' |
|
603 | 603 | |
|
604 | 604 | # The address of the folder is generated the name of the .fdt file that will be read |
|
605 |
print |
|
|
605 | print("File: ", self.fileSelector + 1) | |
|
606 | 606 | |
|
607 | 607 | if self.fileSelector < len(self.filenameList): |
|
608 | 608 | |
@@ -642,7 +642,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
642 | 642 | self.readBlock() # Block reading |
|
643 | 643 | |
|
644 | 644 | else: |
|
645 |
print |
|
|
645 | print('readFile FlagNoData becomes true') | |
|
646 | 646 | self.flagNoMoreFiles = True |
|
647 | 647 | self.dataOut.flagNoData = True |
|
648 | 648 | self.FileHeaderFlag == True |
@@ -673,7 +673,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
673 | 673 | self.blocksize = self.srviHeader.SizeOfDataBlock1 # Se obtiene el tamao del bloque |
|
674 | 674 | |
|
675 | 675 | if self.blocksize == 148: |
|
676 |
print |
|
|
676 | print('blocksize == 148 bug') | |
|
677 | 677 | jump = numpy.fromfile(self.fp, [('jump', numpy.str_, 140)], 1) |
|
678 | 678 | |
|
679 | 679 | # Se obtiene la cabecera del SRVI |
@@ -691,7 +691,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
691 | 691 | npw1 = self.recordheader.npw1 |
|
692 | 692 | npw2 = self.recordheader.npw2 |
|
693 | 693 | |
|
694 | self.dataOut.channelList = range(1) | |
|
694 | self.dataOut.channelList = list(range(1)) | |
|
695 | 695 | self.dataOut.nIncohInt = self.Num_inCoh |
|
696 | 696 | self.dataOut.nProfiles = self.Num_Bins |
|
697 | 697 | self.dataOut.nCohInt = 1 |
@@ -701,7 +701,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
701 | 701 | |
|
702 | 702 | self.dataOut.outputInterval = self.dataOut.getTimeInterval() |
|
703 | 703 | self.dataOut.heightList = self.SPARrawGate1 * self.__deltaHeigth + \ |
|
704 | numpy.array(range(self.Num_Hei)) * self.__deltaHeigth | |
|
704 | numpy.array(list(range(self.Num_Hei))) * self.__deltaHeigth | |
|
705 | 705 | |
|
706 | 706 | self.HSDVsign = numpy.fromfile(self.fp, [('HSDV', numpy.str_, 4)], 1) |
|
707 | 707 | self.SizeHSDV = numpy.fromfile(self.fp, [('SizeHSDV', '<i4')], 1) |
@@ -766,8 +766,8 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
766 | 766 | |
|
767 | 767 | self.dataOut.COFA = numpy.array([self.COFA_Co, self.COFA_Cx]) |
|
768 | 768 | |
|
769 |
print |
|
|
770 |
print |
|
|
769 | print(' ') | |
|
770 | print('SPC', numpy.shape(self.dataOut.data_spc)) | |
|
771 | 771 | # print 'SPC',self.dataOut.data_spc |
|
772 | 772 | |
|
773 | 773 | noinor1 = 713031680 |
@@ -777,7 +777,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
777 | 777 | npw2 = 1 # 0**(npw2/10) * noinor1 * noinor2 |
|
778 | 778 | self.dataOut.NPW = numpy.array([npw1, npw2]) |
|
779 | 779 | |
|
780 |
print |
|
|
780 | print(' ') | |
|
781 | 781 | |
|
782 | 782 | self.data_spc = numpy.transpose(self.data_spc, (2, 1, 0)) |
|
783 | 783 | self.data_spc = numpy.fft.fftshift(self.data_spc, axes=1) |
@@ -797,4 +797,4 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader | |||
|
797 | 797 | shape. |
|
798 | 798 | ''' |
|
799 | 799 | |
|
800 |
self.PointerReader = self.fp.tell() |
|
|
800 | self.PointerReader = self.fp.tell() No newline at end of file |
@@ -7,7 +7,7 import datetime | |||
|
7 | 7 | |
|
8 | 8 | from schainpy.model.data.jrodata import * |
|
9 | 9 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
10 | # from jroIO_base import * | |
|
10 | # from .jroIO_base import * | |
|
11 | 11 | from schainpy.model.io.jroIO_base import * |
|
12 | 12 | import schainpy |
|
13 | 13 | |
@@ -87,22 +87,22 class ParamReader(ProcessingUnit): | |||
|
87 | 87 | startTime = kwargs['startTime'] |
|
88 | 88 | endTime = kwargs['endTime'] |
|
89 | 89 | walk = kwargs['walk'] |
|
90 |
if |
|
|
90 | if 'ext' in kwargs: | |
|
91 | 91 | ext = kwargs['ext'] |
|
92 | 92 | else: |
|
93 | 93 | ext = '.hdf5' |
|
94 |
if |
|
|
94 | if 'timezone' in kwargs: | |
|
95 | 95 | self.timezone = kwargs['timezone'] |
|
96 | 96 | else: |
|
97 | 97 | self.timezone = 'lt' |
|
98 | 98 | |
|
99 |
print |
|
|
99 | print("[Reading] Searching files in offline mode ...") | |
|
100 | 100 | pathList, filenameList = self.searchFilesOffLine(path, startDate=startDate, endDate=endDate, |
|
101 | 101 | startTime=startTime, endTime=endTime, |
|
102 | 102 | ext=ext, walk=walk) |
|
103 | 103 | |
|
104 | 104 | if not(filenameList): |
|
105 |
print |
|
|
105 | print("There is no files into the folder: %s"%(path)) | |
|
106 | 106 | sys.exit(-1) |
|
107 | 107 | |
|
108 | 108 | self.fileIndex = -1 |
@@ -134,16 +134,16 class ParamReader(ProcessingUnit): | |||
|
134 | 134 | dateList, pathList = JRODataObj.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True) |
|
135 | 135 | |
|
136 | 136 | if dateList == []: |
|
137 |
print |
|
|
137 | print("[Reading] No *%s files in %s from %s to %s)"%(ext, path, | |
|
138 | 138 | datetime.datetime.combine(startDate,startTime).ctime(), |
|
139 | datetime.datetime.combine(endDate,endTime).ctime()) | |
|
139 | datetime.datetime.combine(endDate,endTime).ctime())) | |
|
140 | 140 | |
|
141 | 141 | return None, None |
|
142 | 142 | |
|
143 | 143 | if len(dateList) > 1: |
|
144 |
print |
|
|
144 | print("[Reading] %d days were found in date range: %s - %s" %(len(dateList), startDate, endDate)) | |
|
145 | 145 | else: |
|
146 |
print |
|
|
146 | print("[Reading] data was found for the date %s" %(dateList[0])) | |
|
147 | 147 | |
|
148 | 148 | filenameList = [] |
|
149 | 149 | datetimeList = [] |
@@ -172,11 +172,11 class ParamReader(ProcessingUnit): | |||
|
172 | 172 | datetimeList.append(thisDatetime) |
|
173 | 173 | |
|
174 | 174 | if not(filenameList): |
|
175 |
print |
|
|
175 | print("[Reading] Any file was found int time range %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())) | |
|
176 | 176 | return None, None |
|
177 | 177 | |
|
178 |
print |
|
|
179 | ||
|
178 | print("[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime)) | |
|
179 | print() | |
|
180 | 180 | |
|
181 | 181 | # for i in range(len(filenameList)): |
|
182 | 182 | # print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime()) |
@@ -218,7 +218,7 class ParamReader(ProcessingUnit): | |||
|
218 | 218 | |
|
219 | 219 | except IOError: |
|
220 | 220 | traceback.print_exc() |
|
221 |
raise IOError |
|
|
221 | raise IOError("The file %s can't be opened" %(filename)) | |
|
222 | 222 | #chino rata |
|
223 | 223 | #In case has utctime attribute |
|
224 | 224 | grp2 = grp1['utctime'] |
@@ -271,7 +271,7 class ParamReader(ProcessingUnit): | |||
|
271 | 271 | idFile = self.fileIndex |
|
272 | 272 | |
|
273 | 273 | if not(idFile < len(self.filenameList)): |
|
274 |
print |
|
|
274 | print("No more Files") | |
|
275 | 275 | return 0 |
|
276 | 276 | |
|
277 | 277 | filename = self.filenameList[idFile] |
@@ -282,7 +282,7 class ParamReader(ProcessingUnit): | |||
|
282 | 282 | |
|
283 | 283 | self.fp = filePointer |
|
284 | 284 | |
|
285 |
print |
|
|
285 | print("Setting the file: %s"%self.filename) | |
|
286 | 286 | |
|
287 | 287 | # self.__readMetadata() |
|
288 | 288 | self.__setBlockList() |
@@ -361,7 +361,7 class ParamReader(ProcessingUnit): | |||
|
361 | 361 | |
|
362 | 362 | listMetaname = [] |
|
363 | 363 | listMetadata = [] |
|
364 | for item in gp.items(): | |
|
364 | for item in list(gp.items()): | |
|
365 | 365 | name = item[0] |
|
366 | 366 | |
|
367 | 367 | if name=='array dimensions': |
@@ -389,7 +389,7 class ParamReader(ProcessingUnit): | |||
|
389 | 389 | listdataname = [] |
|
390 | 390 | listdata = [] |
|
391 | 391 | |
|
392 | for item in grp.items(): | |
|
392 | for item in list(grp.items()): | |
|
393 | 393 | name = item[0] |
|
394 | 394 | listdataname.append(name) |
|
395 | 395 | |
@@ -921,7 +921,7 class ParamWriter(Operation): | |||
|
921 | 921 | # self.nDims = nDims |
|
922 | 922 | # self.nDimsForDs = nDimsForDs |
|
923 | 923 | #Saving variables |
|
924 |
print |
|
|
924 | print('Writing the file: %s'%filename) | |
|
925 | 925 | self.filename = filename |
|
926 | 926 | # self.fp = fp |
|
927 | 927 | # self.grp = grp |
@@ -1092,4 +1092,4 class ParamWriter(Operation): | |||
|
1092 | 1092 | self.setNextFile() |
|
1093 | 1093 | |
|
1094 | 1094 | self.putData() |
|
1095 |
return |
|
|
1095 | return No newline at end of file |
@@ -5,7 +5,7 Created on Jul 2, 2014 | |||
|
5 | 5 | ''' |
|
6 | 6 | import numpy |
|
7 | 7 | |
|
8 | from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
|
8 | from schainpy.model.io.jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
|
9 | 9 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
10 | 10 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
11 | 11 | from schainpy.model.data.jrodata import Spectra |
@@ -325,7 +325,7 class SpectraReader(JRODataReader, ProcessingUnit): | |||
|
325 | 325 | |
|
326 | 326 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) |
|
327 | 327 | |
|
328 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) | |
|
328 | self.dataOut.channelList = list(range(self.systemHeaderObj.nChannels)) | |
|
329 | 329 | |
|
330 | 330 | self.dataOut.flagShiftFFT = True #Data is always shifted |
|
331 | 331 | |
@@ -354,7 +354,7 class SpectraReader(JRODataReader, ProcessingUnit): | |||
|
354 | 354 | |
|
355 | 355 | if self.flagNoMoreFiles: |
|
356 | 356 | self.dataOut.flagNoData = True |
|
357 |
print |
|
|
357 | print('Process finished') | |
|
358 | 358 | return 0 |
|
359 | 359 | |
|
360 | 360 | self.flagDiscontinuousBlock = 0 |
@@ -676,4 +676,4 class SpectraWriter(JRODataWriter, Operation): | |||
|
676 | 676 | |
|
677 | 677 | self.processingHeaderObj.processFlags = self.getProcessFlags() |
|
678 | 678 | |
|
679 |
self.setBasicHeader() |
|
|
679 | self.setBasicHeader() No newline at end of file |
@@ -19,7 +19,7 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |||
|
19 | 19 | try: |
|
20 | 20 | import digital_rf_hdf5 |
|
21 | 21 | except: |
|
22 |
print |
|
|
22 | print('You should install "digital_rf_hdf5" module if you want to read USRP data') | |
|
23 | 23 | |
|
24 | 24 | class USRPReader(ProcessingUnit): |
|
25 | 25 | ''' |
@@ -209,7 +209,7 class USRPReader(ProcessingUnit): | |||
|
209 | 209 | ''' |
|
210 | 210 | |
|
211 | 211 | if not os.path.isdir(path): |
|
212 |
raise ValueError |
|
|
212 | raise ValueError("[Reading] Directory %s does not exist" %path) | |
|
213 | 213 | |
|
214 | 214 | try: |
|
215 | 215 | self.digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True) |
@@ -219,10 +219,10 class USRPReader(ProcessingUnit): | |||
|
219 | 219 | channelNameList = self.digitalReadObj.get_channels() |
|
220 | 220 | |
|
221 | 221 | if not channelNameList: |
|
222 |
raise ValueError |
|
|
222 | raise ValueError("[Reading] Directory %s does not have any files" %path) | |
|
223 | 223 | |
|
224 | 224 | if not channelList: |
|
225 | channelList = range(len(channelNameList)) | |
|
225 | channelList = list(range(len(channelNameList))) | |
|
226 | 226 | |
|
227 | 227 | ########## Reading metadata ###################### |
|
228 | 228 | |
@@ -241,7 +241,7 class USRPReader(ProcessingUnit): | |||
|
241 | 241 | self.__frequency = this_metadata_file['fc'].value |
|
242 | 242 | |
|
243 | 243 | if not self.__frequency: |
|
244 |
raise ValueError |
|
|
244 | raise ValueError("Center Frequency is not defined in metadata file") | |
|
245 | 245 | |
|
246 | 246 | try: |
|
247 | 247 | self.__timezone = this_metadata_file['timezone'].value |
@@ -299,7 +299,7 class USRPReader(ProcessingUnit): | |||
|
299 | 299 | |
|
300 | 300 | if not nSamples: |
|
301 | 301 | if not ippKm: |
|
302 |
raise ValueError |
|
|
302 | raise ValueError("[Reading] nSamples or ippKm should be defined") | |
|
303 | 303 | |
|
304 | 304 | nSamples = int(ippKm / (1e6*0.15/self.__sample_rate)) |
|
305 | 305 | |
@@ -346,14 +346,14 class USRPReader(ProcessingUnit): | |||
|
346 | 346 | self.__setFileHeader() |
|
347 | 347 | self.isConfig = True |
|
348 | 348 | |
|
349 |
print |
|
|
349 | print("[Reading] USRP Data was found from %s to %s " %( | |
|
350 | 350 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
351 | 351 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
352 | ) | |
|
352 | )) | |
|
353 | 353 | |
|
354 |
print |
|
|
354 | print("[Reading] Starting process from %s to %s" %(datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), | |
|
355 | 355 | datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone) |
|
356 | ) | |
|
356 | )) | |
|
357 | 357 | |
|
358 | 358 | def __reload(self): |
|
359 | 359 | |
@@ -366,7 +366,7 class USRPReader(ProcessingUnit): | |||
|
366 | 366 | # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
367 | 367 | # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
368 | 368 | # ) |
|
369 |
print |
|
|
369 | print("[Reading] reloading metadata ...") | |
|
370 | 370 | |
|
371 | 371 | try: |
|
372 | 372 | self.digitalReadObj.reload(complete_update=True) |
@@ -380,11 +380,11 class USRPReader(ProcessingUnit): | |||
|
380 | 380 | |
|
381 | 381 | if end_index > self.__endUTCSecond*self.__sample_rate: |
|
382 | 382 | self.__endUTCSecond = 1.0*end_index/self.__sample_rate |
|
383 | ||
|
384 |
print |
|
|
383 | print() | |
|
384 | print("[Reading] New timerange found [%s, %s] " %( | |
|
385 | 385 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
386 | 386 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
387 | ) | |
|
387 | )) | |
|
388 | 388 | |
|
389 | 389 | return True |
|
390 | 390 | |
@@ -399,7 +399,7 class USRPReader(ProcessingUnit): | |||
|
399 | 399 | self.__thisUnixSample += self.__samples_to_read |
|
400 | 400 | |
|
401 | 401 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
402 |
print |
|
|
402 | print("[Reading] There are no more data into selected time-range") | |
|
403 | 403 | |
|
404 | 404 | self.__reload() |
|
405 | 405 | |
@@ -418,17 +418,17 class USRPReader(ProcessingUnit): | |||
|
418 | 418 | self.__samples_to_read, |
|
419 | 419 | thisChannelName) |
|
420 | 420 | |
|
421 |
except IOError |
|
|
421 | except IOError as e: | |
|
422 | 422 | #read next profile |
|
423 | 423 | self.__flagDiscontinuousBlock = True |
|
424 |
print |
|
|
424 | print("[Reading] %s" %datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e) | |
|
425 | 425 | break |
|
426 | 426 | |
|
427 | 427 | if result.shape[0] != self.__samples_to_read: |
|
428 | 428 | self.__flagDiscontinuousBlock = True |
|
429 |
print |
|
|
429 | print("[Reading] %s: Too few samples were found, just %d/%d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
|
430 | 430 | result.shape[0], |
|
431 | self.__samples_to_read) | |
|
431 | self.__samples_to_read)) | |
|
432 | 432 | break |
|
433 | 433 | |
|
434 | 434 | self.__data_buffer[indexChannel,:] = result*volt_scale |
@@ -442,9 +442,9 class USRPReader(ProcessingUnit): | |||
|
442 | 442 | if not dataOk: |
|
443 | 443 | return False |
|
444 | 444 | |
|
445 |
print |
|
|
445 | print("[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
|
446 | 446 | self.__samples_to_read, |
|
447 | self.__timeInterval) | |
|
447 | self.__timeInterval)) | |
|
448 | 448 | |
|
449 | 449 | self.__bufferIndex = 0 |
|
450 | 450 | |
@@ -490,7 +490,7 class USRPReader(ProcessingUnit): | |||
|
490 | 490 | return False |
|
491 | 491 | |
|
492 | 492 | if self.__flagDiscontinuousBlock: |
|
493 |
print |
|
|
493 | print('[Reading] discontinuous block found ... continue with the next block') | |
|
494 | 494 | continue |
|
495 | 495 | |
|
496 | 496 | if not self.__online: |
@@ -500,7 +500,7 class USRPReader(ProcessingUnit): | |||
|
500 | 500 | if err_counter > nTries: |
|
501 | 501 | return False |
|
502 | 502 | |
|
503 |
print |
|
|
503 | print('[Reading] waiting %d seconds to read a new block' %seconds) | |
|
504 | 504 | sleep(seconds) |
|
505 | 505 | |
|
506 | 506 | self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples] |
@@ -532,7 +532,7 class USRPReader(ProcessingUnit): | |||
|
532 | 532 | ''' |
|
533 | 533 | ''' |
|
534 | 534 | |
|
535 |
print |
|
|
535 | print(self.profileIndex) | |
|
536 | 536 | |
|
537 | 537 | def run(self, **kwargs): |
|
538 | 538 | ''' |
@@ -597,4 +597,4 if __name__ == '__main__': | |||
|
597 | 597 | while True: |
|
598 | 598 | readObj.run(path='/Volumes/DATA/haystack/passive_radar/') |
|
599 | 599 | # readObj.printInfo() |
|
600 |
readObj.printNumberOfBlock() |
|
|
600 | readObj.printNumberOfBlock() No newline at end of file |
@@ -5,7 +5,7 Created on Jul 15, 2014 | |||
|
5 | 5 | ''' |
|
6 | 6 | import time |
|
7 | 7 | import threading |
|
8 |
import |
|
|
8 | import pickle | |
|
9 | 9 | |
|
10 | 10 | # try: |
|
11 | 11 | # from gevent import sleep |
@@ -109,9 +109,9 class USRPReaderAPI(USRPReader, threading.Thread): | |||
|
109 | 109 | ''' |
|
110 | 110 | |
|
111 | 111 | if not self.isConfig: |
|
112 |
raise RuntimeError |
|
|
112 | raise RuntimeError('setup() method has to be called before start()') | |
|
113 | 113 | |
|
114 |
print |
|
|
114 | print("Running ...") | |
|
115 | 115 | |
|
116 | 116 | while True: |
|
117 | 117 | |
@@ -122,7 +122,7 class USRPReaderAPI(USRPReader, threading.Thread): | |||
|
122 | 122 | if not self.getData(): |
|
123 | 123 | break |
|
124 | 124 | |
|
125 |
print |
|
|
125 | print(".", end=' ') | |
|
126 | 126 | |
|
127 | 127 | self.__mySerial = obj2Serial(self.dataOut, |
|
128 | 128 | keyList = self.__DATAKEYLIST, |
@@ -134,6 +134,6 class USRPReaderAPI(USRPReader, threading.Thread): | |||
|
134 | 134 | |
|
135 | 135 | # sleep(0.1) |
|
136 | 136 | |
|
137 |
print |
|
|
137 | print("Closing thread") | |
|
138 | 138 | |
|
139 | 139 | return No newline at end of file |
@@ -6,13 +6,13 Created on Jul 2, 2014 | |||
|
6 | 6 | |
|
7 | 7 | import numpy |
|
8 | 8 | |
|
9 | from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
|
9 | from .jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
|
10 | 10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
11 | 11 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
12 | 12 | from schainpy.model.data.jrodata import Voltage |
|
13 | 13 | import zmq |
|
14 | 14 | import tempfile |
|
15 |
from |
|
|
15 | from io import StringIO | |
|
16 | 16 | # from _sha import blocksize |
|
17 | 17 | |
|
18 | 18 | |
@@ -286,7 +286,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
286 | 286 | self.dataOut.heightList = numpy.arange( |
|
287 | 287 | self.processingHeaderObj.nHeights) * self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight |
|
288 | 288 | |
|
289 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) | |
|
289 | self.dataOut.channelList = list(range(self.systemHeaderObj.nChannels)) | |
|
290 | 290 | |
|
291 | 291 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt |
|
292 | 292 | |
@@ -307,12 +307,12 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
307 | 307 | return |
|
308 | 308 | |
|
309 | 309 | if self.nTxs < 1 and self.processingHeaderObj.profilesPerBlock % (1. / self.nTxs) != 0: |
|
310 |
raise ValueError |
|
|
311 | 1. / self.nTxs, self.processingHeaderObj.profilesPerBlock) | |
|
310 | raise ValueError("1./nTxs (=%f), should be a multiple of nProfiles (=%d)" % ( | |
|
311 | 1. / self.nTxs, self.processingHeaderObj.profilesPerBlock)) | |
|
312 | 312 | |
|
313 | 313 | if self.nTxs > 1 and self.processingHeaderObj.nHeights % self.nTxs != 0: |
|
314 |
raise ValueError |
|
|
315 | self.nTxs, self.processingHeaderObj.nHeights) | |
|
314 | raise ValueError("nTxs (=%d), should be a multiple of nHeights (=%d)" % ( | |
|
315 | self.nTxs, self.processingHeaderObj.nHeights)) | |
|
316 | 316 | |
|
317 | 317 | self.datablock = self.datablock.reshape( |
|
318 | 318 | (self.systemHeaderObj.nChannels, self.processingHeaderObj.profilesPerBlock * self.nTxs, self.processingHeaderObj.nHeights / self.nTxs)) |
@@ -345,7 +345,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
345 | 345 | elif datatype == 5: |
|
346 | 346 | datatype_str = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) |
|
347 | 347 | else: |
|
348 |
raise ValueError |
|
|
348 | raise ValueError('Data type was not defined') | |
|
349 | 349 | |
|
350 | 350 | self.dtype = datatype_str |
|
351 | 351 | #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c |
@@ -378,7 +378,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
378 | 378 | self.readFirstHeaderFromServer() |
|
379 | 379 | |
|
380 | 380 | timestamp = self.basicHeaderObj.get_datatime() |
|
381 |
print |
|
|
381 | print('[Reading] - Block {} - {}'.format(self.nTotalBlocks, timestamp)) | |
|
382 | 382 | current_pointer_location = self.blockPointer |
|
383 | 383 | junk = numpy.fromstring( |
|
384 | 384 | block[self.blockPointer:], self.dtype, self.blocksize) |
@@ -463,7 +463,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
463 | 463 | """ |
|
464 | 464 | if self.flagNoMoreFiles: |
|
465 | 465 | self.dataOut.flagNoData = True |
|
466 |
print |
|
|
466 | print('Process finished') | |
|
467 | 467 | return 0 |
|
468 | 468 | self.flagDiscontinuousBlock = 0 |
|
469 | 469 | self.flagIsNewBlock = 0 |
@@ -761,4 +761,4 class VoltageWriter(JRODataWriter, Operation): | |||
|
761 | 761 | |
|
762 | 762 | self.processingHeaderObj.processFlags = self.getProcessFlags() |
|
763 | 763 | |
|
764 |
self.setBasicHeader() |
|
|
764 | self.setBasicHeader() No newline at end of file |
@@ -98,7 +98,7 class JULIAParamReader(JRODataReader, ProcessingUnit): | |||
|
98 | 98 | self.format = format |
|
99 | 99 | |
|
100 | 100 | if self.path is None: |
|
101 |
raise ValueError |
|
|
101 | raise ValueError("The path is not valid") | |
|
102 | 102 | |
|
103 | 103 | if ext is None: |
|
104 | 104 | ext = self.ext |
@@ -340,4 +340,4 class JULIAParamReader(JRODataReader, ProcessingUnit): | |||
|
340 | 340 | |
|
341 | 341 | self.set_output() |
|
342 | 342 | |
|
343 |
return 1 |
|
|
343 | return 1 No newline at end of file |
@@ -13,7 +13,7 import tarfile | |||
|
13 | 13 | |
|
14 | 14 | import numpy |
|
15 | 15 | |
|
16 | from utils import folder_in_range | |
|
16 | from .utils import folder_in_range | |
|
17 | 17 | |
|
18 | 18 | from schainpy.model.io.jroIO_base import JRODataReader |
|
19 | 19 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
@@ -69,14 +69,14 class PXReader(JRODataReader, ProcessingUnit): | |||
|
69 | 69 | self.ele = kwargs.get('ext', '') |
|
70 | 70 | |
|
71 | 71 | if self.path is None: |
|
72 |
raise ValueError |
|
|
72 | raise ValueError('The path is not valid') | |
|
73 | 73 | |
|
74 | 74 | self.search_files(path, startDate, endDate, startTime, endTime, walk) |
|
75 | 75 | self.cursor = 0 |
|
76 | 76 | self.counter_records = 0 |
|
77 | 77 | |
|
78 | 78 | if not self.files: |
|
79 |
raise Warning |
|
|
79 | raise Warning('There is no files matching these date in the folder: {}. \n Check startDate and endDate'.format(path)) | |
|
80 | 80 | |
|
81 | 81 | def search_files(self, path, startDate, endDate, startTime, endTime, walk): |
|
82 | 82 | ''' |
@@ -136,7 +136,7 class PXReader(JRODataReader, ProcessingUnit): | |||
|
136 | 136 | self.files[dt] = [] |
|
137 | 137 | self.files[dt].append(fullname) |
|
138 | 138 | |
|
139 | self.dates = self.files.keys() | |
|
139 | self.dates = list(self.files.keys()) | |
|
140 | 140 | self.dates.sort() |
|
141 | 141 | |
|
142 | 142 | return |
@@ -203,7 +203,7 class PXReader(JRODataReader, ProcessingUnit): | |||
|
203 | 203 | if not self.files: |
|
204 | 204 | return 0 |
|
205 | 205 | |
|
206 | self.dates = self.files.keys() | |
|
206 | self.dates = list(self.files.keys()) | |
|
207 | 207 | self.dates.sort() |
|
208 | 208 | self.cursor = 0 |
|
209 | 209 | |
@@ -348,4 +348,3 class PXReader(JRODataReader, ProcessingUnit): | |||
|
348 | 348 | self.set_output() |
|
349 | 349 | |
|
350 | 350 | return 1 |
|
351 |
@@ -4,13 +4,13 $Author: murco $ | |||
|
4 | 4 | $Id: Processor.py 1 2012-11-12 18:56:07Z murco $ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | from jroproc_voltage import * | |
|
8 | from jroproc_spectra import * | |
|
9 | from jroproc_heispectra import * | |
|
10 | from jroproc_amisr import * | |
|
11 | from jroproc_correlation import * | |
|
12 | from jroproc_parameters import * | |
|
13 | from jroproc_spectra_lags import * | |
|
14 | from jroproc_spectra_acf import * | |
|
15 | from bltrproc_parameters import * | |
|
16 | from pxproc_parameters import * | |
|
7 | from .jroproc_voltage import * | |
|
8 | from .jroproc_spectra import * | |
|
9 | from .jroproc_heispectra import * | |
|
10 | from .jroproc_amisr import * | |
|
11 | from .jroproc_correlation import * | |
|
12 | from .jroproc_parameters import * | |
|
13 | from .jroproc_spectra_lags import * | |
|
14 | from .jroproc_spectra_acf import * | |
|
15 | from .bltrproc_parameters import * | |
|
16 | from .pxproc_parameters import * |
@@ -12,7 +12,7 from time import gmtime | |||
|
12 | 12 | |
|
13 | 13 | from numpy import transpose |
|
14 | 14 | |
|
15 | from jroproc_base import ProcessingUnit, Operation | |
|
15 | from .jroproc_base import ProcessingUnit, Operation | |
|
16 | 16 | from schainpy.model.data.jrodata import Parameters |
|
17 | 17 | |
|
18 | 18 | |
@@ -95,7 +95,7 class OutliersFilter(Operation): | |||
|
95 | 95 | npoints - number of points for mask filter |
|
96 | 96 | ''' |
|
97 | 97 | |
|
98 |
print |
|
|
98 | print(' Outliers Filter {} {} / threshold = {}'.format(svalue, svalue, factor)) | |
|
99 | 99 | |
|
100 | 100 | |
|
101 | 101 | yaxis = self.dataOut.heightList |
@@ -400,4 +400,3 class OutliersFilter(Operation): | |||
|
400 | 400 | return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List |
|
401 | 401 | |
|
402 | 402 | |
|
403 | No newline at end of file |
@@ -2,7 +2,7 | |||
|
2 | 2 | @author: Daniel Suarez |
|
3 | 3 | ''' |
|
4 | 4 | import numpy |
|
5 | from jroproc_base import ProcessingUnit, Operation | |
|
5 | from .jroproc_base import ProcessingUnit, Operation | |
|
6 | 6 | from schainpy.model.data.jroamisr import AMISR |
|
7 | 7 | |
|
8 | 8 | class AMISRProc(ProcessingUnit): |
@@ -24,16 +24,16 class PrintInfo(Operation): | |||
|
24 | 24 | def run(self, dataOut): |
|
25 | 25 | |
|
26 | 26 | if not self.__isPrinted: |
|
27 |
print |
|
|
28 |
print |
|
|
29 |
print |
|
|
30 |
print |
|
|
31 |
print |
|
|
32 |
print |
|
|
33 |
print |
|
|
34 | beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in dataOut.beamCodeDict.items()] | |
|
27 | print('Number of Records by File: %d'%dataOut.nRecords) | |
|
28 | print('Number of Pulses: %d'%dataOut.nProfiles) | |
|
29 | print('Number of Pulses by Frame: %d'%dataOut.npulseByFrame) | |
|
30 | print('Number of Samples by Pulse: %d'%len(dataOut.heightList)) | |
|
31 | print('Ipp Seconds: %f'%dataOut.ippSeconds) | |
|
32 | print('Number of Beams: %d'%dataOut.nBeams) | |
|
33 | print('BeamCodes:') | |
|
34 | beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in list(dataOut.beamCodeDict.items())] | |
|
35 | 35 | for b in beamStrList: |
|
36 |
print |
|
|
36 | print(b) | |
|
37 | 37 | self.__isPrinted = True |
|
38 | 38 | |
|
39 | 39 | return |
@@ -93,7 +93,7 class BeamSelector(Operation): | |||
|
93 | 93 | return 1 |
|
94 | 94 | |
|
95 | 95 | else: |
|
96 |
raise ValueError |
|
|
96 | raise ValueError("BeamSelector needs beam value") | |
|
97 | 97 | |
|
98 | 98 | return 0 |
|
99 | 99 | |
@@ -117,7 +117,7 class ProfileToChannels(Operation): | |||
|
117 | 117 | dataOut.flagNoData = True |
|
118 | 118 | |
|
119 | 119 | if not(self.__isConfig): |
|
120 | nchannels = len(dataOut.beamRangeDict.keys()) | |
|
120 | nchannels = len(list(dataOut.beamRangeDict.keys())) | |
|
121 | 121 | nsamples = dataOut.nHeights |
|
122 | 122 | self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128') |
|
123 | 123 | dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)] |
@@ -136,7 +136,7 class ProfileToChannels(Operation): | |||
|
136 | 136 | if self.__counter_chan >= self.buffer.shape[0]: |
|
137 | 137 | self.__counter_chan = 0 |
|
138 | 138 | dataOut.data = self.buffer.copy() |
|
139 | dataOut.channelList = range(self.buffer.shape[0]) | |
|
139 | dataOut.channelList = list(range(self.buffer.shape[0])) | |
|
140 | 140 | self.__isConfig = False |
|
141 | 141 | dataOut.flagNoData = False |
|
142 | 142 | pass |
@@ -104,7 +104,7 class ProcessingUnit(object): | |||
|
104 | 104 | |
|
105 | 105 | def getOperationObj(self, objId): |
|
106 | 106 | |
|
107 | if objId not in self.operations2RunDict.keys(): | |
|
107 | if objId not in list(self.operations2RunDict.keys()): | |
|
108 | 108 | return None |
|
109 | 109 | |
|
110 | 110 | return self.operations2RunDict[objId] |
@@ -248,22 +248,22 class ProcessingUnit(object): | |||
|
248 | 248 | if opType == 'self': |
|
249 | 249 | |
|
250 | 250 | if not opName: |
|
251 |
raise ValueError |
|
|
251 | raise ValueError("opName parameter should be defined") | |
|
252 | 252 | |
|
253 | 253 | sts = self.callMethod(opName, opId) |
|
254 | 254 | |
|
255 | 255 | elif opType == 'other' or opType == 'external' or opType == 'plotter': |
|
256 | 256 | |
|
257 | 257 | if not opId: |
|
258 |
raise ValueError |
|
|
258 | raise ValueError("opId parameter should be defined") | |
|
259 | 259 | |
|
260 | if opId not in self.operations2RunDict.keys(): | |
|
261 |
raise ValueError |
|
|
260 | if opId not in list(self.operations2RunDict.keys()): | |
|
261 | raise ValueError("Any operation with id=%s has been added" %str(opId)) | |
|
262 | 262 | |
|
263 | 263 | sts = self.callObject(opId) |
|
264 | 264 | |
|
265 | 265 | else: |
|
266 |
raise ValueError |
|
|
266 | raise ValueError("opType should be 'self', 'external' or 'plotter'; and not '%s'" %opType) | |
|
267 | 267 | |
|
268 | 268 | return sts |
|
269 | 269 | |
@@ -357,4 +357,4 class Operation(object): | |||
|
357 | 357 | |
|
358 | 358 | def close(self): |
|
359 | 359 | |
|
360 |
pass |
|
|
360 | pass No newline at end of file |
@@ -1,6 +1,6 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | from jroproc_base import ProcessingUnit, Operation | |
|
3 | from .jroproc_base import ProcessingUnit, Operation | |
|
4 | 4 | from schainpy.model.data.jrodata import Correlation, hildebrand_sekhon |
|
5 | 5 | |
|
6 | 6 | class CorrelationProc(ProcessingUnit): |
@@ -1,6 +1,6 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | from jroproc_base import ProcessingUnit, Operation | |
|
3 | from .jroproc_base import ProcessingUnit, Operation | |
|
4 | 4 | from schainpy.model.data.jrodata import SpectraHeis |
|
5 | 5 | |
|
6 | 6 | class SpectraHeisProc(ProcessingUnit): |
@@ -99,7 +99,7 class SpectraHeisProc(ProcessingUnit): | |||
|
99 | 99 | |
|
100 | 100 | return |
|
101 | 101 | |
|
102 |
raise ValueError |
|
|
102 | raise ValueError("The type object %s is not valid"%(self.dataIn.type)) | |
|
103 | 103 | |
|
104 | 104 | |
|
105 | 105 | def selectChannels(self, channelList): |
@@ -133,8 +133,8 class SpectraHeisProc(ProcessingUnit): | |||
|
133 | 133 | |
|
134 | 134 | for channelIndex in channelIndexList: |
|
135 | 135 | if channelIndex not in self.dataOut.channelIndexList: |
|
136 |
print |
|
|
137 |
raise ValueError |
|
|
136 | print(channelIndexList) | |
|
137 | raise ValueError("The value %d in channelIndexList is not valid" %channelIndex) | |
|
138 | 138 | |
|
139 | 139 | # nChannels = len(channelIndexList) |
|
140 | 140 | |
@@ -187,7 +187,7 class IncohInt4SpectraHeis(Operation): | |||
|
187 | 187 | |
|
188 | 188 | |
|
189 | 189 | if n == None and timeInterval == None: |
|
190 |
raise ValueError |
|
|
190 | raise ValueError("n or timeInterval should be specified ...") | |
|
191 | 191 | |
|
192 | 192 | if n != None: |
|
193 | 193 | self.n = n |
@@ -341,4 +341,4 class IncohInt4SpectraHeis(Operation): | |||
|
341 | 341 | dataOut.utctime = avgdatatime |
|
342 | 342 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt |
|
343 | 343 | # dataOut.timeInterval = self.__timeInterval*self.n |
|
344 |
dataOut.flagNoData = False |
|
|
344 | dataOut.flagNoData = False No newline at end of file |
@@ -10,8 +10,6 import importlib | |||
|
10 | 10 | import itertools |
|
11 | 11 | from multiprocessing import Pool, TimeoutError |
|
12 | 12 | from multiprocessing.pool import ThreadPool |
|
13 | import copy_reg | |
|
14 | import cPickle | |
|
15 | 13 | import types |
|
16 | 14 | from functools import partial |
|
17 | 15 | import time |
@@ -19,7 +17,7 import time | |||
|
19 | 17 | |
|
20 | 18 | |
|
21 | 19 | from scipy.optimize import fmin_l_bfgs_b #optimize with bounds on state papameters |
|
22 | from jroproc_base import ProcessingUnit, Operation | |
|
20 | from .jroproc_base import ProcessingUnit, Operation | |
|
23 | 21 | from schainpy.model.data.jrodata import Parameters, hildebrand_sekhon |
|
24 | 22 | from scipy import asarray as ar,exp |
|
25 | 23 | from scipy.optimize import curve_fit |
@@ -36,9 +34,9 SPEED_OF_LIGHT = 299792458 | |||
|
36 | 34 | '''solving pickling issue''' |
|
37 | 35 | |
|
38 | 36 | def _pickle_method(method): |
|
39 |
func_name = method. |
|
|
40 |
obj = method. |
|
|
41 |
cls = method. |
|
|
37 | func_name = method.__func__.__name__ | |
|
38 | obj = method.__self__ | |
|
39 | cls = method.__self__.__class__ | |
|
42 | 40 | return _unpickle_method, (func_name, obj, cls) |
|
43 | 41 | |
|
44 | 42 | def _unpickle_method(func_name, obj, cls): |
@@ -213,7 +211,7 class GaussianFit(Operation): | |||
|
213 | 211 | self.spc = dataOut.data_pre[0].copy() |
|
214 | 212 | |
|
215 | 213 | |
|
216 |
print |
|
|
214 | print('SelfSpectra Shape', numpy.asarray(self.spc).shape) | |
|
217 | 215 | |
|
218 | 216 | |
|
219 | 217 | #plt.figure(50) |
@@ -251,7 +249,7 class GaussianFit(Operation): | |||
|
251 | 249 | pool = Pool(processes=self.Num_Chn) |
|
252 | 250 | args = [(Vrange, Ch, pnoise, noise_, num_intg, SNRlimit) for Ch in range(self.Num_Chn)] |
|
253 | 251 | objs = [self for __ in range(self.Num_Chn)] |
|
254 | attrs = zip(objs, args) | |
|
252 | attrs = list(zip(objs, args)) | |
|
255 | 253 | gauSPC = pool.map(target, attrs) |
|
256 | 254 | dataOut.GauSPC = numpy.asarray(gauSPC) |
|
257 | 255 | # ret = [] |
@@ -506,8 +504,8 class GaussianFit(Operation): | |||
|
506 | 504 | # print 'noise', noise |
|
507 | 505 | # print 's_noise', wnoise |
|
508 | 506 | |
|
509 |
print |
|
|
510 |
print |
|
|
507 | print('========================================================') | |
|
508 | print('total_time: ', time.time()-start_time) | |
|
511 | 509 | |
|
512 | 510 | # re-normalizing spc and noise |
|
513 | 511 | # This part differs from gg1 |
@@ -959,12 +957,12 class PrecipitationProc(Operation): | |||
|
959 | 957 | dataOut.data_output = Ze |
|
960 | 958 | dataOut.data_param = numpy.ones([2,self.Num_Hei]) |
|
961 | 959 | dataOut.channelList = [0,1] |
|
962 |
print |
|
|
960 | print('channelList', dataOut.channelList) | |
|
963 | 961 | dataOut.data_param[0]=dBZe |
|
964 | 962 | dataOut.data_param[1]=dBRR |
|
965 |
print |
|
|
966 |
print |
|
|
967 |
print |
|
|
963 | print('RR SHAPE', dBRR.shape) | |
|
964 | print('Ze SHAPE', dBZe.shape) | |
|
965 | print('dataOut.data_param SHAPE', dataOut.data_param.shape) | |
|
968 | 966 | |
|
969 | 967 | |
|
970 | 968 | def dBZeMODE2(self, dataOut): # Processing for MIRA35C |
@@ -980,7 +978,7 class PrecipitationProc(Operation): | |||
|
980 | 978 | data_output = numpy.ones([self.Num_Chn , self.Num_Hei])*numpy.NaN |
|
981 | 979 | |
|
982 | 980 | ETA = numpy.sum(SNR,1) |
|
983 |
print |
|
|
981 | print('ETA' , ETA) | |
|
984 | 982 | ETA = numpy.where(ETA is not 0. , ETA, numpy.NaN) |
|
985 | 983 | |
|
986 | 984 | Ze = numpy.ones([self.Num_Chn, self.Num_Hei] ) |
@@ -1068,7 +1066,7 class FullSpectralAnalysis(Operation): | |||
|
1068 | 1066 | |
|
1069 | 1067 | data = dataOut.data_pre |
|
1070 | 1068 | noise = dataOut.noise |
|
1071 |
print |
|
|
1069 | print('noise',noise) | |
|
1072 | 1070 | #SNRdB = 10*numpy.log10(dataOut.data_SNR) |
|
1073 | 1071 | |
|
1074 | 1072 | FirstMoment = numpy.average(dataOut.data_param[:,1,:],0) |
@@ -1095,14 +1093,14 class FullSpectralAnalysis(Operation): | |||
|
1095 | 1093 | velocityX=numpy.append(velocityX, Vzon)#Vmag |
|
1096 | 1094 | |
|
1097 | 1095 | else: |
|
1098 |
print |
|
|
1096 | print('Vzon',Vzon) | |
|
1099 | 1097 | velocityX=numpy.append(velocityX, numpy.NaN) |
|
1100 | 1098 | |
|
1101 | 1099 | if abs(Vmer)<100. and abs(Vmer) > 0.: |
|
1102 | 1100 | velocityY=numpy.append(velocityY, Vmer)#Vang |
|
1103 | 1101 | |
|
1104 | 1102 | else: |
|
1105 |
print |
|
|
1103 | print('Vmer',Vmer) | |
|
1106 | 1104 | velocityY=numpy.append(velocityY, numpy.NaN) |
|
1107 | 1105 | |
|
1108 | 1106 | if dbSNR[Height] > SNRlimit: |
@@ -1120,18 +1118,18 class FullSpectralAnalysis(Operation): | |||
|
1120 | 1118 | data_output[1]=numpy.array(velocityY) |
|
1121 | 1119 | data_output[2]=-velocityV#FirstMoment |
|
1122 | 1120 | |
|
1123 |
print |
|
|
1121 | print(' ') | |
|
1124 | 1122 | #print 'FirstMoment' |
|
1125 | 1123 | #print FirstMoment |
|
1126 |
print |
|
|
1127 |
print |
|
|
1128 |
print |
|
|
1124 | print('velocityX',data_output[0]) | |
|
1125 | print(' ') | |
|
1126 | print('velocityY',data_output[1]) | |
|
1129 | 1127 | #print numpy.array(velocityY) |
|
1130 |
print |
|
|
1128 | print(' ') | |
|
1131 | 1129 | #print 'SNR' |
|
1132 | 1130 | #print 10*numpy.log10(dataOut.data_SNR) |
|
1133 | 1131 | #print numpy.shape(10*numpy.log10(dataOut.data_SNR)) |
|
1134 |
print |
|
|
1132 | print(' ') | |
|
1135 | 1133 | |
|
1136 | 1134 | |
|
1137 | 1135 | dataOut.data_output=data_output |
@@ -1184,20 +1182,20 class FullSpectralAnalysis(Operation): | |||
|
1184 | 1182 | |
|
1185 | 1183 | SmoothSPC=self.moving_average(FactNorm,N=3) |
|
1186 | 1184 | |
|
1187 | xSamples = ar(range(len(SmoothSPC))) | |
|
1185 | xSamples = ar(list(range(len(SmoothSPC)))) | |
|
1188 | 1186 | ySamples[i] = SmoothSPC |
|
1189 | 1187 | |
|
1190 | 1188 | #dbSNR=10*numpy.log10(dataSNR) |
|
1191 |
print |
|
|
1192 |
print |
|
|
1193 |
print |
|
|
1189 | print(' ') | |
|
1190 | print(' ') | |
|
1191 | print(' ') | |
|
1194 | 1192 | |
|
1195 | 1193 | #print 'dataSNR', dbSNR.shape, dbSNR[0,40:120] |
|
1196 |
print |
|
|
1197 |
print |
|
|
1198 |
print |
|
|
1199 |
print |
|
|
1200 |
print |
|
|
1194 | print('SmoothSPC', SmoothSPC.shape, SmoothSPC[0:20]) | |
|
1195 | print('noise',noise) | |
|
1196 | print('zline',zline.shape, zline[0:20]) | |
|
1197 | print('FactNorm',FactNorm.shape, FactNorm[0:20]) | |
|
1198 | print('FactNorm suma', numpy.sum(FactNorm)) | |
|
1201 | 1199 | |
|
1202 | 1200 | for i in range(spc.shape[0]): |
|
1203 | 1201 | |
@@ -1218,12 +1216,12 class FullSpectralAnalysis(Operation): | |||
|
1218 | 1216 | |
|
1219 | 1217 | phase[i] = self.moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi |
|
1220 | 1218 | |
|
1221 |
print |
|
|
1222 |
print |
|
|
1223 |
print |
|
|
1224 |
print |
|
|
1225 |
print |
|
|
1226 |
print |
|
|
1219 | print('cspcLine', cspcLine.shape, cspcLine[0:20]) | |
|
1220 | print('CSPCFactor', CSPCFactor)#, CSPCFactor[0:20] | |
|
1221 | print(numpy.sum(ySamples[chan_index0]), numpy.sum(ySamples[chan_index1]), -noise[i]) | |
|
1222 | print('CSPCNorm', CSPCNorm.shape, CSPCNorm[0:20]) | |
|
1223 | print('CSPCNorm suma', numpy.sum(CSPCNorm)) | |
|
1224 | print('CSPCSamples', CSPCSamples.shape, CSPCSamples[0,0:20]) | |
|
1227 | 1225 | |
|
1228 | 1226 | '''****** Getting fij width ******''' |
|
1229 | 1227 | |
@@ -1237,14 +1235,14 class FullSpectralAnalysis(Operation): | |||
|
1237 | 1235 | meanGauss=sum(xSamples*yMean) / len(xSamples) |
|
1238 | 1236 | sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples) |
|
1239 | 1237 | |
|
1240 |
print |
|
|
1241 |
print |
|
|
1242 |
print |
|
|
1243 |
print |
|
|
1244 |
print |
|
|
1238 | print('****************************') | |
|
1239 | print('len(xSamples): ',len(xSamples)) | |
|
1240 | print('yMean: ', yMean.shape, yMean[0:20]) | |
|
1241 | print('ySamples', ySamples.shape, ySamples[0,0:20]) | |
|
1242 | print('xSamples: ',xSamples.shape, xSamples[0:20]) | |
|
1245 | 1243 | |
|
1246 |
print |
|
|
1247 |
print |
|
|
1244 | print('meanGauss',meanGauss) | |
|
1245 | print('sigma',sigma) | |
|
1248 | 1246 | |
|
1249 | 1247 | #if (abs(meanGauss/sigma**2) > 0.0001) : #0.000000001): |
|
1250 | 1248 | if dbSNR > SNRlimit : |
@@ -1256,7 +1254,7 class FullSpectralAnalysis(Operation): | |||
|
1256 | 1254 | |
|
1257 | 1255 | else: |
|
1258 | 1256 | FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean) |
|
1259 |
print |
|
|
1257 | print('Verificador: Dentro', Height) | |
|
1260 | 1258 | except :#RuntimeError: |
|
1261 | 1259 | FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean) |
|
1262 | 1260 | |
@@ -1293,10 +1291,10 class FullSpectralAnalysis(Operation): | |||
|
1293 | 1291 | else: |
|
1294 | 1292 | Range = numpy.array([0,0]) |
|
1295 | 1293 | |
|
1296 |
print |
|
|
1297 |
print |
|
|
1298 |
print |
|
|
1299 |
print |
|
|
1294 | print(' ') | |
|
1295 | print('GCpos',GCpos, ( len(xFrec)- len(xFrec)*0.1)) | |
|
1296 | print('Rangpos',Rangpos) | |
|
1297 | print('RANGE: ', Range) | |
|
1300 | 1298 | FrecRange=xFrec[Range[0]:Range[1]] |
|
1301 | 1299 | |
|
1302 | 1300 | '''****** Getting SCPC Slope ******''' |
@@ -1306,9 +1304,9 class FullSpectralAnalysis(Operation): | |||
|
1306 | 1304 | if len(FrecRange)>5 and len(FrecRange)<spc.shape[1]*0.5: |
|
1307 | 1305 | PhaseRange=self.moving_average(phase[i,Range[0]:Range[1]],N=3) |
|
1308 | 1306 | |
|
1309 |
print |
|
|
1310 |
print |
|
|
1311 |
print |
|
|
1307 | print('FrecRange', len(FrecRange) , FrecRange) | |
|
1308 | print('PhaseRange', len(PhaseRange), PhaseRange) | |
|
1309 | print(' ') | |
|
1312 | 1310 | if len(FrecRange) == len(PhaseRange): |
|
1313 | 1311 | slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange) |
|
1314 | 1312 | PhaseSlope[i]=slope |
@@ -1354,7 +1352,7 class FullSpectralAnalysis(Operation): | |||
|
1354 | 1352 | Vmag=numpy.sqrt(Vzon**2+Vmer**2) |
|
1355 | 1353 | Vang=numpy.arctan2(Vmer,Vzon) |
|
1356 | 1354 | Vver=xFrec[Vpos] |
|
1357 |
print |
|
|
1355 | print('vzon y vmer', Vzon, Vmer) | |
|
1358 | 1356 | return Vzon, Vmer, Vver, GaussCenter |
|
1359 | 1357 | |
|
1360 | 1358 | class SpectralMoments(Operation): |
@@ -1441,11 +1439,11 class SpectralMoments(Operation): | |||
|
1441 | 1439 | else: spec2 = scipy.ndimage.filters.uniform_filter1d(spec,size=smooth) |
|
1442 | 1440 | |
|
1443 | 1441 | # Calculo de Momentos |
|
1444 | bb = spec2[range(m,spec2.size)] | |
|
1442 | bb = spec2[list(range(m,spec2.size))] | |
|
1445 | 1443 | bb = (bb<n0).nonzero() |
|
1446 | 1444 | bb = bb[0] |
|
1447 | 1445 | |
|
1448 | ss = spec2[range(0,m + 1)] | |
|
1446 | ss = spec2[list(range(0,m + 1))] | |
|
1449 | 1447 | ss = (ss<n0).nonzero() |
|
1450 | 1448 | ss = ss[0] |
|
1451 | 1449 | |
@@ -1461,7 +1459,7 class SpectralMoments(Operation): | |||
|
1461 | 1459 | |
|
1462 | 1460 | if (ss1 > m): ss1 = m |
|
1463 | 1461 | |
|
1464 | valid = numpy.asarray(range(int(m + bb0 - ss1 + 1))) + ss1 | |
|
1462 | valid = numpy.asarray(list(range(int(m + bb0 - ss1 + 1)))) + ss1 | |
|
1465 | 1463 | power = ((spec2[valid] - n0)*fwindow[valid]).sum() |
|
1466 | 1464 | fd = ((spec2[valid]- n0)*freq[valid]*fwindow[valid]).sum()/power |
|
1467 | 1465 | w = math.sqrt(((spec2[valid] - n0)*fwindow[valid]*(freq[valid]- fd)**2).sum()/power) |
@@ -1809,7 +1807,7 class WindProfiler(Operation): | |||
|
1809 | 1807 | maxid = listPhi.index(max(listPhi)) |
|
1810 | 1808 | minid = listPhi.index(min(listPhi)) |
|
1811 | 1809 | |
|
1812 | rango = range(len(phi)) | |
|
1810 | rango = list(range(len(phi))) | |
|
1813 | 1811 | # rango = numpy.delete(rango,maxid) |
|
1814 | 1812 | |
|
1815 | 1813 | heiRang1 = heiRang*math.cos(phi[maxid]) |
@@ -1867,7 +1865,7 class WindProfiler(Operation): | |||
|
1867 | 1865 | heiRang = kwargs['heightList'] |
|
1868 | 1866 | SNR0 = kwargs['SNR'] |
|
1869 | 1867 | |
|
1870 |
if |
|
|
1868 | if 'dirCosx' in kwargs and 'dirCosy' in kwargs: | |
|
1871 | 1869 | theta_x = numpy.array(kwargs['dirCosx']) |
|
1872 | 1870 | theta_y = numpy.array(kwargs['dirCosy']) |
|
1873 | 1871 | else: |
@@ -1875,13 +1873,13 class WindProfiler(Operation): | |||
|
1875 | 1873 | azim = numpy.array(kwargs['azimuth']) |
|
1876 | 1874 | theta_x, theta_y = self.__calculateCosDir(elev, azim) |
|
1877 | 1875 | azimuth = kwargs['correctAzimuth'] |
|
1878 |
if |
|
|
1876 | if 'horizontalOnly' in kwargs: | |
|
1879 | 1877 | horizontalOnly = kwargs['horizontalOnly'] |
|
1880 | 1878 | else: horizontalOnly = False |
|
1881 |
if |
|
|
1879 | if 'correctFactor' in kwargs: | |
|
1882 | 1880 | correctFactor = kwargs['correctFactor'] |
|
1883 | 1881 | else: correctFactor = 1 |
|
1884 |
if |
|
|
1882 | if 'channelList' in kwargs: | |
|
1885 | 1883 | channelList = kwargs['channelList'] |
|
1886 | 1884 | if len(channelList) == 2: |
|
1887 | 1885 | horizontalOnly = True |
@@ -2002,7 +2000,7 class WindProfiler(Operation): | |||
|
2002 | 2000 | position_y = kwargs['positionY'] |
|
2003 | 2001 | azimuth = kwargs['azimuth'] |
|
2004 | 2002 | |
|
2005 |
if |
|
|
2003 | if 'correctFactor' in kwargs: | |
|
2006 | 2004 | correctFactor = kwargs['correctFactor'] |
|
2007 | 2005 | else: |
|
2008 | 2006 | correctFactor = 1 |
@@ -2355,20 +2353,20 class WindProfiler(Operation): | |||
|
2355 | 2353 | dataOut.flagNoData = True |
|
2356 | 2354 | self.__dataReady = False |
|
2357 | 2355 | |
|
2358 |
if |
|
|
2356 | if 'nHours' in kwargs: | |
|
2359 | 2357 | nHours = kwargs['nHours'] |
|
2360 | 2358 | else: |
|
2361 | 2359 | nHours = 1 |
|
2362 | 2360 | |
|
2363 |
if |
|
|
2361 | if 'meteorsPerBin' in kwargs: | |
|
2364 | 2362 | meteorThresh = kwargs['meteorsPerBin'] |
|
2365 | 2363 | else: |
|
2366 | 2364 | meteorThresh = 6 |
|
2367 | 2365 | |
|
2368 |
if |
|
|
2366 | if 'hmin' in kwargs: | |
|
2369 | 2367 | hmin = kwargs['hmin'] |
|
2370 | 2368 | else: hmin = 70 |
|
2371 |
if |
|
|
2369 | if 'hmax' in kwargs: | |
|
2372 | 2370 | hmax = kwargs['hmax'] |
|
2373 | 2371 | else: hmax = 110 |
|
2374 | 2372 | |
@@ -2404,22 +2402,22 class WindProfiler(Operation): | |||
|
2404 | 2402 | dataOut.flagNoData = True |
|
2405 | 2403 | self.__dataReady = False |
|
2406 | 2404 | |
|
2407 |
if |
|
|
2405 | if 'nMins' in kwargs: | |
|
2408 | 2406 | nMins = kwargs['nMins'] |
|
2409 | 2407 | else: nMins = 20 |
|
2410 |
if |
|
|
2408 | if 'rx_location' in kwargs: | |
|
2411 | 2409 | rx_location = kwargs['rx_location'] |
|
2412 | 2410 | else: rx_location = [(0,1),(1,1),(1,0)] |
|
2413 |
if |
|
|
2411 | if 'azimuth' in kwargs: | |
|
2414 | 2412 | azimuth = kwargs['azimuth'] |
|
2415 | 2413 | else: azimuth = 51.06 |
|
2416 |
if |
|
|
2414 | if 'dfactor' in kwargs: | |
|
2417 | 2415 | dfactor = kwargs['dfactor'] |
|
2418 |
if |
|
|
2416 | if 'mode' in kwargs: | |
|
2419 | 2417 | mode = kwargs['mode'] |
|
2420 |
if |
|
|
2418 | if 'theta_x' in kwargs: | |
|
2421 | 2419 | theta_x = kwargs['theta_x'] |
|
2422 |
if |
|
|
2420 | if 'theta_y' in kwargs: | |
|
2423 | 2421 | theta_y = kwargs['theta_y'] |
|
2424 | 2422 | else: mode = 'SA' |
|
2425 | 2423 | |
@@ -2480,7 +2478,7 class EWDriftsEstimation(Operation): | |||
|
2480 | 2478 | maxid = listPhi.index(max(listPhi)) |
|
2481 | 2479 | minid = listPhi.index(min(listPhi)) |
|
2482 | 2480 | |
|
2483 | rango = range(len(phi)) | |
|
2481 | rango = list(range(len(phi))) | |
|
2484 | 2482 | # rango = numpy.delete(rango,maxid) |
|
2485 | 2483 | |
|
2486 | 2484 | heiRang1 = heiRang*math.cos(phi[maxid]) |
@@ -3857,7 +3855,7 class SMOperations(): | |||
|
3857 | 3855 | |
|
3858 | 3856 | def getPhasePairs(self, channelPositions): |
|
3859 | 3857 | chanPos = numpy.array(channelPositions) |
|
3860 | listOper = list(itertools.combinations(range(5),2)) | |
|
3858 | listOper = list(itertools.combinations(list(range(5)),2)) | |
|
3861 | 3859 | |
|
3862 | 3860 | distances = numpy.zeros(4) |
|
3863 | 3861 | axisX = [] |
@@ -2,10 +2,10 import itertools | |||
|
2 | 2 | |
|
3 | 3 | import numpy |
|
4 | 4 | |
|
5 | from jroproc_base import ProcessingUnit, Operation | |
|
5 | from .jroproc_base import ProcessingUnit, Operation | |
|
6 | 6 | from schainpy.model.data.jrodata import Spectra |
|
7 | 7 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
8 | ||
|
8 | from schainpy.utils import log #yong | |
|
9 | 9 | |
|
10 | 10 | class SpectraProc(ProcessingUnit): |
|
11 | 11 | |
@@ -99,11 +99,11 class SpectraProc(ProcessingUnit): | |||
|
99 | 99 | (self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
100 | 100 | for pair in self.dataOut.pairsList: |
|
101 | 101 | if pair[0] not in self.dataOut.channelList: |
|
102 |
raise ValueError |
|
|
103 | str(pair), str(self.dataOut.channelList)) | |
|
102 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % ( | |
|
103 | str(pair), str(self.dataOut.channelList))) | |
|
104 | 104 | if pair[1] not in self.dataOut.channelList: |
|
105 |
raise ValueError |
|
|
106 | str(pair), str(self.dataOut.channelList)) | |
|
105 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" % ( | |
|
106 | str(pair), str(self.dataOut.channelList))) | |
|
107 | 107 | |
|
108 | 108 | cspc[pairIndex, :, :] = fft_volt[pair[0], :, :] * \ |
|
109 | 109 | numpy.conjugate(fft_volt[pair[1], :, :]) |
@@ -140,7 +140,7 class SpectraProc(ProcessingUnit): | |||
|
140 | 140 | if self.dataIn.type == "Voltage": |
|
141 | 141 | |
|
142 | 142 | if nFFTPoints == None: |
|
143 |
raise ValueError |
|
|
143 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") | |
|
144 | 144 | |
|
145 | 145 | if nProfiles == None: |
|
146 | 146 | nProfiles = nFFTPoints |
@@ -180,8 +180,8 class SpectraProc(ProcessingUnit): | |||
|
180 | 180 | self.id_min += nVoltProfiles |
|
181 | 181 | self.id_max += nVoltProfiles |
|
182 | 182 | else: |
|
183 |
raise ValueError |
|
|
184 | self.dataIn.type, self.dataIn.data.shape[1], nProfiles) | |
|
183 | raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % ( | |
|
184 | self.dataIn.type, self.dataIn.data.shape[1], nProfiles)) | |
|
185 | 185 | self.dataOut.flagNoData = True |
|
186 | 186 | return 0 |
|
187 | 187 | else: |
@@ -201,8 +201,8 class SpectraProc(ProcessingUnit): | |||
|
201 | 201 | |
|
202 | 202 | return True |
|
203 | 203 | |
|
204 |
raise ValueError |
|
|
205 | self.dataIn.type) | |
|
204 | raise ValueError("The type of input object '%s' is not valid" % ( | |
|
205 | self.dataIn.type)) | |
|
206 | 206 | |
|
207 | 207 | def __selectPairs(self, pairsList): |
|
208 | 208 | |
@@ -256,8 +256,8 class SpectraProc(ProcessingUnit): | |||
|
256 | 256 | |
|
257 | 257 | for channel in channelList: |
|
258 | 258 | if channel not in self.dataOut.channelList: |
|
259 |
raise ValueError |
|
|
260 | channel, str(self.dataOut.channelList)) | |
|
259 | raise ValueError("Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" % ( | |
|
260 | channel, str(self.dataOut.channelList))) | |
|
261 | 261 | |
|
262 | 262 | index = self.dataOut.channelList.index(channel) |
|
263 | 263 | channelIndexList.append(index) |
@@ -282,8 +282,8 class SpectraProc(ProcessingUnit): | |||
|
282 | 282 | |
|
283 | 283 | for channelIndex in channelIndexList: |
|
284 | 284 | if channelIndex not in self.dataOut.channelIndexList: |
|
285 |
raise ValueError |
|
|
286 | channelIndex, self.dataOut.channelIndexList) | |
|
285 | raise ValueError("Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " % ( | |
|
286 | channelIndex, self.dataOut.channelIndexList)) | |
|
287 | 287 | |
|
288 | 288 | # nChannels = len(channelIndexList) |
|
289 | 289 | |
@@ -318,8 +318,8 class SpectraProc(ProcessingUnit): | |||
|
318 | 318 | """ |
|
319 | 319 | |
|
320 | 320 | if (minHei > maxHei): |
|
321 |
raise ValueError |
|
|
322 | minHei, maxHei) | |
|
321 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % ( | |
|
322 | minHei, maxHei)) | |
|
323 | 323 | |
|
324 | 324 | if (minHei < self.dataOut.heightList[0]): |
|
325 | 325 | minHei = self.dataOut.heightList[0] |
@@ -410,8 +410,8 class SpectraProc(ProcessingUnit): | |||
|
410 | 410 | """ |
|
411 | 411 | |
|
412 | 412 | if (minIndex < 0) or (minIndex > maxIndex): |
|
413 |
raise ValueError |
|
|
414 | minIndex, maxIndex) | |
|
413 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % ( | |
|
414 | minIndex, maxIndex)) | |
|
415 | 415 | |
|
416 | 416 | if (maxIndex >= self.dataOut.nHeights): |
|
417 | 417 | maxIndex = self.dataOut.nHeights - 1 |
@@ -448,11 +448,12 class SpectraProc(ProcessingUnit): | |||
|
448 | 448 | else: |
|
449 | 449 | jcspectraExist = False |
|
450 | 450 | |
|
451 | freq_dc = jspectra.shape[1] / 2 | |
|
451 | freq_dc = int(jspectra.shape[1] / 2) | |
|
452 | 452 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
453 | ind_vel = ind_vel.astype(int) | |
|
453 | 454 | |
|
454 | 455 | if ind_vel[0] < 0: |
|
455 | ind_vel[range(0, 1)] = ind_vel[range(0, 1)] + self.num_prof | |
|
456 | ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof | |
|
456 | 457 | |
|
457 | 458 | if mode == 1: |
|
458 | 459 | jspectra[:, freq_dc, :] = ( |
@@ -468,12 +469,12 class SpectraProc(ProcessingUnit): | |||
|
468 | 469 | xx = numpy.zeros([4, 4]) |
|
469 | 470 | |
|
470 | 471 | for fil in range(4): |
|
471 | xx[fil, :] = vel[fil]**numpy.asarray(range(4)) | |
|
472 | xx[fil, :] = vel[fil]**numpy.asarray(list(range(4))) | |
|
472 | 473 | |
|
473 | 474 | xx_inv = numpy.linalg.inv(xx) |
|
474 | 475 | xx_aux = xx_inv[0, :] |
|
475 | 476 | |
|
476 | for ich in range(num_chan): | |
|
477 | for ich in range(num_chan): | |
|
477 | 478 | yy = jspectra[ich, ind_vel, :] |
|
478 | 479 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
479 | 480 | |
@@ -508,7 +509,7 class SpectraProc(ProcessingUnit): | |||
|
508 | 509 | # hei_interf |
|
509 | 510 | if hei_interf is None: |
|
510 | 511 | count_hei = num_hei / 2 # Como es entero no importa |
|
511 | hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei | |
|
512 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei | |
|
512 | 513 | hei_interf = numpy.asarray(hei_interf)[0] |
|
513 | 514 | # nhei_interf |
|
514 | 515 | if (nhei_interf == None): |
@@ -520,10 +521,10 class SpectraProc(ProcessingUnit): | |||
|
520 | 521 | if (offhei_interf == None): |
|
521 | 522 | offhei_interf = 0 |
|
522 | 523 | |
|
523 | ind_hei = range(num_hei) | |
|
524 | ind_hei = list(range(num_hei)) | |
|
524 | 525 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 |
|
525 | 526 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 |
|
526 | mask_prof = numpy.asarray(range(num_prof)) | |
|
527 | mask_prof = numpy.asarray(list(range(num_prof))) | |
|
527 | 528 | num_mask_prof = mask_prof.size |
|
528 | 529 | comp_mask_prof = [0, num_prof / 2] |
|
529 | 530 | |
@@ -541,8 +542,8 class SpectraProc(ProcessingUnit): | |||
|
541 | 542 | psort = power.ravel().argsort() |
|
542 | 543 | |
|
543 | 544 | # Se estima la interferencia promedio en los Espectros de Potencia empleando |
|
544 | junkspc_interf = jspectra[ich, :, hei_interf[psort[range( | |
|
545 | offhei_interf, nhei_interf + offhei_interf)]]] | |
|
545 | junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range( | |
|
546 | offhei_interf, nhei_interf + offhei_interf))]]] | |
|
546 | 547 | |
|
547 | 548 | if noise_exist: |
|
548 | 549 | # tmp_noise = jnoise[ich] / num_prof |
@@ -603,7 +604,7 class SpectraProc(ProcessingUnit): | |||
|
603 | 604 | xx = numpy.zeros([4, 4]) |
|
604 | 605 | |
|
605 | 606 | for id1 in range(4): |
|
606 | xx[:, id1] = ind[id1]**numpy.asarray(range(4)) | |
|
607 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) | |
|
607 | 608 | |
|
608 | 609 | xx_inv = numpy.linalg.inv(xx) |
|
609 | 610 | xx = xx_inv[:, 0] |
@@ -632,17 +633,17 class SpectraProc(ProcessingUnit): | |||
|
632 | 633 | cspower = cspower.sum(axis=0) |
|
633 | 634 | |
|
634 | 635 | cspsort = cspower.ravel().argsort() |
|
635 | junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[range( | |
|
636 | offhei_interf, nhei_interf + offhei_interf)]]] | |
|
636 | junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[list(range( | |
|
637 | offhei_interf, nhei_interf + offhei_interf))]]] | |
|
637 | 638 | junkcspc_interf = junkcspc_interf.transpose() |
|
638 | 639 | jcspc_interf = junkcspc_interf.sum(axis=1) / nhei_interf |
|
639 | 640 | |
|
640 | 641 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() |
|
641 | 642 | |
|
642 | 643 | median_real = numpy.median(numpy.real( |
|
643 | junkcspc_interf[mask_prof[ind[range(3 * num_prof / 4)]], :])) | |
|
644 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof / 4))]], :])) | |
|
644 | 645 | median_imag = numpy.median(numpy.imag( |
|
645 | junkcspc_interf[mask_prof[ind[range(3 * num_prof / 4)]], :])) | |
|
646 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof / 4))]], :])) | |
|
646 | 647 | junkcspc_interf[comp_mask_prof, :] = numpy.complex( |
|
647 | 648 | median_real, median_imag) |
|
648 | 649 | |
@@ -662,7 +663,7 class SpectraProc(ProcessingUnit): | |||
|
662 | 663 | xx = numpy.zeros([4, 4]) |
|
663 | 664 | |
|
664 | 665 | for id1 in range(4): |
|
665 | xx[:, id1] = ind[id1]**numpy.asarray(range(4)) | |
|
666 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) | |
|
666 | 667 | |
|
667 | 668 | xx_inv = numpy.linalg.inv(xx) |
|
668 | 669 | xx = xx_inv[:, 0] |
@@ -693,13 +694,13 class SpectraProc(ProcessingUnit): | |||
|
693 | 694 | maxHei = self.dataOut.heightList[-1] |
|
694 | 695 | |
|
695 | 696 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
696 |
print |
|
|
697 |
print |
|
|
697 | print('minHei: %.2f is out of the heights range' % (minHei)) | |
|
698 | print('minHei is setting to %.2f' % (self.dataOut.heightList[0])) | |
|
698 | 699 | minHei = self.dataOut.heightList[0] |
|
699 | 700 | |
|
700 | 701 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): |
|
701 |
print |
|
|
702 |
print |
|
|
702 | print('maxHei: %.2f is out of the heights range' % (maxHei)) | |
|
703 | print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1])) | |
|
703 | 704 | maxHei = self.dataOut.heightList[-1] |
|
704 | 705 | |
|
705 | 706 | # validacion de velocidades |
@@ -712,13 +713,13 class SpectraProc(ProcessingUnit): | |||
|
712 | 713 | maxVel = velrange[-1] |
|
713 | 714 | |
|
714 | 715 | if (minVel < velrange[0]) or (minVel > maxVel): |
|
715 |
print |
|
|
716 |
print |
|
|
716 | print('minVel: %.2f is out of the velocity range' % (minVel)) | |
|
717 | print('minVel is setting to %.2f' % (velrange[0])) | |
|
717 | 718 | minVel = velrange[0] |
|
718 | 719 | |
|
719 | 720 | if (maxVel > velrange[-1]) or (maxVel < minVel): |
|
720 |
print |
|
|
721 |
print |
|
|
721 | print('maxVel: %.2f is out of the velocity range' % (maxVel)) | |
|
722 | print('maxVel is setting to %.2f' % (velrange[-1])) | |
|
722 | 723 | maxVel = velrange[-1] |
|
723 | 724 | |
|
724 | 725 | # seleccion de indices para rango |
@@ -740,8 +741,8 class SpectraProc(ProcessingUnit): | |||
|
740 | 741 | maxIndex = len(heights) |
|
741 | 742 | |
|
742 | 743 | if (minIndex < 0) or (minIndex > maxIndex): |
|
743 |
raise ValueError |
|
|
744 | minIndex, maxIndex) | |
|
744 | raise ValueError("some value in (%d,%d) is not valid" % ( | |
|
745 | minIndex, maxIndex)) | |
|
745 | 746 | |
|
746 | 747 | if (maxIndex >= self.dataOut.nHeights): |
|
747 | 748 | maxIndex = self.dataOut.nHeights - 1 |
@@ -823,7 +824,7 class IncohInt(Operation): | |||
|
823 | 824 | self.__byTime = False |
|
824 | 825 | |
|
825 | 826 | if n is None and timeInterval is None: |
|
826 |
raise ValueError |
|
|
827 | raise ValueError("n or timeInterval should be specified ...") | |
|
827 | 828 | |
|
828 | 829 | if n is not None: |
|
829 | 830 | self.n = int(n) |
@@ -949,4 +950,4 class IncohInt(Operation): | |||
|
949 | 950 | |
|
950 | 951 | dataOut.nIncohInt *= self.n |
|
951 | 952 | dataOut.utctime = avgdatatime |
|
952 |
dataOut.flagNoData = False |
|
|
953 | dataOut.flagNoData = False No newline at end of file |
@@ -1,6 +1,6 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | from jroproc_base import ProcessingUnit, Operation | |
|
3 | from .jroproc_base import ProcessingUnit, Operation | |
|
4 | 4 | from schainpy.model.data.jrodata import Spectra |
|
5 | 5 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
6 | 6 | |
@@ -119,9 +119,9 class SpectraAFCProc(ProcessingUnit): | |||
|
119 | 119 | cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
120 | 120 | for pair in self.dataOut.pairsList: |
|
121 | 121 | if pair[0] not in self.dataOut.channelList: |
|
122 |
raise ValueError |
|
|
122 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))) | |
|
123 | 123 | if pair[1] not in self.dataOut.channelList: |
|
124 |
raise ValueError |
|
|
124 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))) | |
|
125 | 125 | |
|
126 | 126 | chan_index0 = self.dataOut.channelList.index(pair[0]) |
|
127 | 127 | chan_index1 = self.dataOut.channelList.index(pair[1]) |
@@ -148,7 +148,7 class SpectraAFCProc(ProcessingUnit): | |||
|
148 | 148 | if self.dataIn.type == "Voltage": |
|
149 | 149 | |
|
150 | 150 | if nFFTPoints == None: |
|
151 |
raise ValueError |
|
|
151 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") | |
|
152 | 152 | |
|
153 | 153 | if nProfiles == None: |
|
154 | 154 | nProfiles = nFFTPoints |
@@ -172,7 +172,7 class SpectraAFCProc(ProcessingUnit): | |||
|
172 | 172 | # self.profIndex += 1 |
|
173 | 173 | |
|
174 | 174 | else: |
|
175 |
raise ValueError |
|
|
175 | raise ValueError("") | |
|
176 | 176 | |
|
177 | 177 | self.firstdatatime = self.dataIn.utctime |
|
178 | 178 | |
@@ -186,7 +186,7 class SpectraAFCProc(ProcessingUnit): | |||
|
186 | 186 | |
|
187 | 187 | return True |
|
188 | 188 | |
|
189 |
raise ValueError |
|
|
189 | raise ValueError("The type of input object '%s' is not valid"%(self.dataIn.type)) | |
|
190 | 190 | |
|
191 | 191 | def __selectPairs(self, pairsList): |
|
192 | 192 | |
@@ -246,7 +246,7 class SpectraAFCProc(ProcessingUnit): | |||
|
246 | 246 | |
|
247 | 247 | for channel in channelList: |
|
248 | 248 | if channel not in self.dataOut.channelList: |
|
249 |
raise ValueError |
|
|
249 | raise ValueError("Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList))) | |
|
250 | 250 | |
|
251 | 251 | index = self.dataOut.channelList.index(channel) |
|
252 | 252 | channelIndexList.append(index) |
@@ -271,7 +271,7 class SpectraAFCProc(ProcessingUnit): | |||
|
271 | 271 | |
|
272 | 272 | for channelIndex in channelIndexList: |
|
273 | 273 | if channelIndex not in self.dataOut.channelIndexList: |
|
274 |
raise ValueError |
|
|
274 | raise ValueError("Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList)) | |
|
275 | 275 | |
|
276 | 276 | # nChannels = len(channelIndexList) |
|
277 | 277 | |
@@ -305,7 +305,7 class SpectraAFCProc(ProcessingUnit): | |||
|
305 | 305 | """ |
|
306 | 306 | |
|
307 | 307 | if (minHei > maxHei): |
|
308 |
raise ValueError |
|
|
308 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei)) | |
|
309 | 309 | |
|
310 | 310 | if (minHei < self.dataOut.heightList[0]): |
|
311 | 311 | minHei = self.dataOut.heightList[0] |
@@ -394,7 +394,7 class SpectraAFCProc(ProcessingUnit): | |||
|
394 | 394 | """ |
|
395 | 395 | |
|
396 | 396 | if (minIndex < 0) or (minIndex > maxIndex): |
|
397 |
raise ValueError |
|
|
397 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |
|
398 | 398 | |
|
399 | 399 | if (maxIndex >= self.dataOut.nHeights): |
|
400 | 400 | maxIndex = self.dataOut.nHeights-1 |
@@ -435,7 +435,7 class SpectraAFCProc(ProcessingUnit): | |||
|
435 | 435 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
436 | 436 | |
|
437 | 437 | if ind_vel[0]<0: |
|
438 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
|
438 | ind_vel[list(range(0,1))] = ind_vel[list(range(0,1))] + self.num_prof | |
|
439 | 439 | |
|
440 | 440 | if mode == 1: |
|
441 | 441 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
@@ -449,7 +449,7 class SpectraAFCProc(ProcessingUnit): | |||
|
449 | 449 | xx = numpy.zeros([4,4]) |
|
450 | 450 | |
|
451 | 451 | for fil in range(4): |
|
452 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
|
452 | xx[fil,:] = vel[fil]**numpy.asarray(list(range(4))) | |
|
453 | 453 | |
|
454 | 454 | xx_inv = numpy.linalg.inv(xx) |
|
455 | 455 | xx_aux = xx_inv[0,:] |
@@ -489,7 +489,7 class SpectraAFCProc(ProcessingUnit): | |||
|
489 | 489 | #hei_interf |
|
490 | 490 | if hei_interf is None: |
|
491 | 491 | count_hei = num_hei/2 #Como es entero no importa |
|
492 | hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei | |
|
492 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei | |
|
493 | 493 | hei_interf = numpy.asarray(hei_interf)[0] |
|
494 | 494 | #nhei_interf |
|
495 | 495 | if (nhei_interf == None): |
@@ -501,10 +501,10 class SpectraAFCProc(ProcessingUnit): | |||
|
501 | 501 | if (offhei_interf == None): |
|
502 | 502 | offhei_interf = 0 |
|
503 | 503 | |
|
504 | ind_hei = range(num_hei) | |
|
504 | ind_hei = list(range(num_hei)) | |
|
505 | 505 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 |
|
506 | 506 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 |
|
507 | mask_prof = numpy.asarray(range(num_prof)) | |
|
507 | mask_prof = numpy.asarray(list(range(num_prof))) | |
|
508 | 508 | num_mask_prof = mask_prof.size |
|
509 | 509 | comp_mask_prof = [0, num_prof/2] |
|
510 | 510 | |
@@ -523,7 +523,7 class SpectraAFCProc(ProcessingUnit): | |||
|
523 | 523 | psort = power.ravel().argsort() |
|
524 | 524 | |
|
525 | 525 | #Se estima la interferencia promedio en los Espectros de Potencia empleando |
|
526 | junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]] | |
|
526 | junkspc_interf = jspectra[ich,:,hei_interf[psort[list(range(offhei_interf, nhei_interf + offhei_interf))]]] | |
|
527 | 527 | |
|
528 | 528 | if noise_exist: |
|
529 | 529 | # tmp_noise = jnoise[ich] / num_prof |
@@ -576,7 +576,7 class SpectraAFCProc(ProcessingUnit): | |||
|
576 | 576 | xx = numpy.zeros([4,4]) |
|
577 | 577 | |
|
578 | 578 | for id1 in range(4): |
|
579 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) | |
|
579 | xx[:,id1] = ind[id1]**numpy.asarray(list(range(4))) | |
|
580 | 580 | |
|
581 | 581 | xx_inv = numpy.linalg.inv(xx) |
|
582 | 582 | xx = xx_inv[:,0] |
@@ -602,14 +602,14 class SpectraAFCProc(ProcessingUnit): | |||
|
602 | 602 | cspower = cspower.sum(axis = 0) |
|
603 | 603 | |
|
604 | 604 | cspsort = cspower.ravel().argsort() |
|
605 | junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]] | |
|
605 | junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[list(range(offhei_interf, nhei_interf + offhei_interf))]]] | |
|
606 | 606 | junkcspc_interf = junkcspc_interf.transpose() |
|
607 | 607 | jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf |
|
608 | 608 | |
|
609 | 609 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() |
|
610 | 610 | |
|
611 | median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) | |
|
612 | median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) | |
|
611 | median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[list(range(3*num_prof/4))]],:])) | |
|
612 | median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[list(range(3*num_prof/4))]],:])) | |
|
613 | 613 | junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag) |
|
614 | 614 | |
|
615 | 615 | for iprof in range(num_prof): |
@@ -626,7 +626,7 class SpectraAFCProc(ProcessingUnit): | |||
|
626 | 626 | xx = numpy.zeros([4,4]) |
|
627 | 627 | |
|
628 | 628 | for id1 in range(4): |
|
629 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) | |
|
629 | xx[:,id1] = ind[id1]**numpy.asarray(list(range(4))) | |
|
630 | 630 | |
|
631 | 631 | xx_inv = numpy.linalg.inv(xx) |
|
632 | 632 | xx = xx_inv[:,0] |
@@ -657,13 +657,13 class SpectraAFCProc(ProcessingUnit): | |||
|
657 | 657 | maxHei = self.dataOut.heightList[-1] |
|
658 | 658 | |
|
659 | 659 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
660 |
print |
|
|
661 |
print |
|
|
660 | print('minHei: %.2f is out of the heights range'%(minHei)) | |
|
661 | print('minHei is setting to %.2f'%(self.dataOut.heightList[0])) | |
|
662 | 662 | minHei = self.dataOut.heightList[0] |
|
663 | 663 | |
|
664 | 664 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): |
|
665 |
print |
|
|
666 |
print |
|
|
665 | print('maxHei: %.2f is out of the heights range'%(maxHei)) | |
|
666 | print('maxHei is setting to %.2f'%(self.dataOut.heightList[-1])) | |
|
667 | 667 | maxHei = self.dataOut.heightList[-1] |
|
668 | 668 | |
|
669 | 669 | # validacion de velocidades |
@@ -676,13 +676,13 class SpectraAFCProc(ProcessingUnit): | |||
|
676 | 676 | maxVel = velrange[-1] |
|
677 | 677 | |
|
678 | 678 | if (minVel < velrange[0]) or (minVel > maxVel): |
|
679 |
print |
|
|
680 |
print |
|
|
679 | print('minVel: %.2f is out of the velocity range'%(minVel)) | |
|
680 | print('minVel is setting to %.2f'%(velrange[0])) | |
|
681 | 681 | minVel = velrange[0] |
|
682 | 682 | |
|
683 | 683 | if (maxVel > velrange[-1]) or (maxVel < minVel): |
|
684 |
print |
|
|
685 |
print |
|
|
684 | print('maxVel: %.2f is out of the velocity range'%(maxVel)) | |
|
685 | print('maxVel is setting to %.2f'%(velrange[-1])) | |
|
686 | 686 | maxVel = velrange[-1] |
|
687 | 687 | |
|
688 | 688 | # seleccion de indices para rango |
@@ -704,7 +704,7 class SpectraAFCProc(ProcessingUnit): | |||
|
704 | 704 | maxIndex = len(heights) |
|
705 | 705 | |
|
706 | 706 | if (minIndex < 0) or (minIndex > maxIndex): |
|
707 |
raise ValueError |
|
|
707 | raise ValueError("some value in (%d,%d) is not valid" % (minIndex, maxIndex)) | |
|
708 | 708 | |
|
709 | 709 | if (maxIndex >= self.dataOut.nHeights): |
|
710 | 710 | maxIndex = self.dataOut.nHeights-1 |
@@ -733,4 +733,4 class SpectraAFCProc(ProcessingUnit): | |||
|
733 | 733 | |
|
734 | 734 | self.dataOut.noise_estimation = noise.copy() |
|
735 | 735 | |
|
736 |
return 1 |
|
|
736 | return 1 No newline at end of file |
@@ -1,6 +1,6 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | from jroproc_base import ProcessingUnit, Operation | |
|
3 | from .jroproc_base import ProcessingUnit, Operation | |
|
4 | 4 | from schainpy.model.data.jrodata import Spectra |
|
5 | 5 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
6 | 6 | |
@@ -125,9 +125,9 class SpectraLagsProc(ProcessingUnit): | |||
|
125 | 125 | cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
126 | 126 | for pair in self.dataOut.pairsList: |
|
127 | 127 | if pair[0] not in self.dataOut.channelList: |
|
128 |
raise ValueError |
|
|
128 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))) | |
|
129 | 129 | if pair[1] not in self.dataOut.channelList: |
|
130 |
raise ValueError |
|
|
130 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))) | |
|
131 | 131 | |
|
132 | 132 | chan_index0 = self.dataOut.channelList.index(pair[0]) |
|
133 | 133 | chan_index1 = self.dataOut.channelList.index(pair[1]) |
@@ -158,7 +158,7 class SpectraLagsProc(ProcessingUnit): | |||
|
158 | 158 | if self.dataIn.type == "Voltage": |
|
159 | 159 | |
|
160 | 160 | if nFFTPoints == None: |
|
161 |
raise ValueError |
|
|
161 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") | |
|
162 | 162 | |
|
163 | 163 | if nProfiles == None: |
|
164 | 164 | nProfiles = nFFTPoints |
@@ -189,7 +189,7 class SpectraLagsProc(ProcessingUnit): | |||
|
189 | 189 | |
|
190 | 190 | return True |
|
191 | 191 | |
|
192 |
raise ValueError |
|
|
192 | raise ValueError("The type of input object '%s' is not valid"%(self.dataIn.type)) | |
|
193 | 193 | |
|
194 | 194 | def __selectPairs(self, pairsList): |
|
195 | 195 | |
@@ -249,7 +249,7 class SpectraLagsProc(ProcessingUnit): | |||
|
249 | 249 | |
|
250 | 250 | for channel in channelList: |
|
251 | 251 | if channel not in self.dataOut.channelList: |
|
252 |
raise ValueError |
|
|
252 | raise ValueError("Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList))) | |
|
253 | 253 | |
|
254 | 254 | index = self.dataOut.channelList.index(channel) |
|
255 | 255 | channelIndexList.append(index) |
@@ -274,7 +274,7 class SpectraLagsProc(ProcessingUnit): | |||
|
274 | 274 | |
|
275 | 275 | for channelIndex in channelIndexList: |
|
276 | 276 | if channelIndex not in self.dataOut.channelIndexList: |
|
277 |
raise ValueError |
|
|
277 | raise ValueError("Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList)) | |
|
278 | 278 | |
|
279 | 279 | # nChannels = len(channelIndexList) |
|
280 | 280 | |
@@ -308,7 +308,7 class SpectraLagsProc(ProcessingUnit): | |||
|
308 | 308 | """ |
|
309 | 309 | |
|
310 | 310 | if (minHei > maxHei): |
|
311 |
raise ValueError |
|
|
311 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei)) | |
|
312 | 312 | |
|
313 | 313 | if (minHei < self.dataOut.heightList[0]): |
|
314 | 314 | minHei = self.dataOut.heightList[0] |
@@ -397,7 +397,7 class SpectraLagsProc(ProcessingUnit): | |||
|
397 | 397 | """ |
|
398 | 398 | |
|
399 | 399 | if (minIndex < 0) or (minIndex > maxIndex): |
|
400 |
raise ValueError |
|
|
400 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |
|
401 | 401 | |
|
402 | 402 | if (maxIndex >= self.dataOut.nHeights): |
|
403 | 403 | maxIndex = self.dataOut.nHeights-1 |
@@ -438,7 +438,7 class SpectraLagsProc(ProcessingUnit): | |||
|
438 | 438 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
439 | 439 | |
|
440 | 440 | if ind_vel[0]<0: |
|
441 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
|
441 | ind_vel[list(range(0,1))] = ind_vel[list(range(0,1))] + self.num_prof | |
|
442 | 442 | |
|
443 | 443 | if mode == 1: |
|
444 | 444 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
@@ -452,7 +452,7 class SpectraLagsProc(ProcessingUnit): | |||
|
452 | 452 | xx = numpy.zeros([4,4]) |
|
453 | 453 | |
|
454 | 454 | for fil in range(4): |
|
455 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
|
455 | xx[fil,:] = vel[fil]**numpy.asarray(list(range(4))) | |
|
456 | 456 | |
|
457 | 457 | xx_inv = numpy.linalg.inv(xx) |
|
458 | 458 | xx_aux = xx_inv[0,:] |
@@ -492,7 +492,7 class SpectraLagsProc(ProcessingUnit): | |||
|
492 | 492 | #hei_interf |
|
493 | 493 | if hei_interf is None: |
|
494 | 494 | count_hei = num_hei/2 #Como es entero no importa |
|
495 | hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei | |
|
495 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei | |
|
496 | 496 | hei_interf = numpy.asarray(hei_interf)[0] |
|
497 | 497 | #nhei_interf |
|
498 | 498 | if (nhei_interf == None): |
@@ -504,10 +504,10 class SpectraLagsProc(ProcessingUnit): | |||
|
504 | 504 | if (offhei_interf == None): |
|
505 | 505 | offhei_interf = 0 |
|
506 | 506 | |
|
507 | ind_hei = range(num_hei) | |
|
507 | ind_hei = list(range(num_hei)) | |
|
508 | 508 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 |
|
509 | 509 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 |
|
510 | mask_prof = numpy.asarray(range(num_prof)) | |
|
510 | mask_prof = numpy.asarray(list(range(num_prof))) | |
|
511 | 511 | num_mask_prof = mask_prof.size |
|
512 | 512 | comp_mask_prof = [0, num_prof/2] |
|
513 | 513 | |
@@ -526,7 +526,7 class SpectraLagsProc(ProcessingUnit): | |||
|
526 | 526 | psort = power.ravel().argsort() |
|
527 | 527 | |
|
528 | 528 | #Se estima la interferencia promedio en los Espectros de Potencia empleando |
|
529 | junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]] | |
|
529 | junkspc_interf = jspectra[ich,:,hei_interf[psort[list(range(offhei_interf, nhei_interf + offhei_interf))]]] | |
|
530 | 530 | |
|
531 | 531 | if noise_exist: |
|
532 | 532 | # tmp_noise = jnoise[ich] / num_prof |
@@ -579,7 +579,7 class SpectraLagsProc(ProcessingUnit): | |||
|
579 | 579 | xx = numpy.zeros([4,4]) |
|
580 | 580 | |
|
581 | 581 | for id1 in range(4): |
|
582 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) | |
|
582 | xx[:,id1] = ind[id1]**numpy.asarray(list(range(4))) | |
|
583 | 583 | |
|
584 | 584 | xx_inv = numpy.linalg.inv(xx) |
|
585 | 585 | xx = xx_inv[:,0] |
@@ -605,14 +605,14 class SpectraLagsProc(ProcessingUnit): | |||
|
605 | 605 | cspower = cspower.sum(axis = 0) |
|
606 | 606 | |
|
607 | 607 | cspsort = cspower.ravel().argsort() |
|
608 | junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]] | |
|
608 | junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[list(range(offhei_interf, nhei_interf + offhei_interf))]]] | |
|
609 | 609 | junkcspc_interf = junkcspc_interf.transpose() |
|
610 | 610 | jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf |
|
611 | 611 | |
|
612 | 612 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() |
|
613 | 613 | |
|
614 | median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) | |
|
615 | median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) | |
|
614 | median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[list(range(3*num_prof/4))]],:])) | |
|
615 | median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[list(range(3*num_prof/4))]],:])) | |
|
616 | 616 | junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag) |
|
617 | 617 | |
|
618 | 618 | for iprof in range(num_prof): |
@@ -629,7 +629,7 class SpectraLagsProc(ProcessingUnit): | |||
|
629 | 629 | xx = numpy.zeros([4,4]) |
|
630 | 630 | |
|
631 | 631 | for id1 in range(4): |
|
632 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) | |
|
632 | xx[:,id1] = ind[id1]**numpy.asarray(list(range(4))) | |
|
633 | 633 | |
|
634 | 634 | xx_inv = numpy.linalg.inv(xx) |
|
635 | 635 | xx = xx_inv[:,0] |
@@ -660,13 +660,13 class SpectraLagsProc(ProcessingUnit): | |||
|
660 | 660 | maxHei = self.dataOut.heightList[-1] |
|
661 | 661 | |
|
662 | 662 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
663 |
print |
|
|
664 |
print |
|
|
663 | print('minHei: %.2f is out of the heights range'%(minHei)) | |
|
664 | print('minHei is setting to %.2f'%(self.dataOut.heightList[0])) | |
|
665 | 665 | minHei = self.dataOut.heightList[0] |
|
666 | 666 | |
|
667 | 667 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): |
|
668 |
print |
|
|
669 |
print |
|
|
668 | print('maxHei: %.2f is out of the heights range'%(maxHei)) | |
|
669 | print('maxHei is setting to %.2f'%(self.dataOut.heightList[-1])) | |
|
670 | 670 | maxHei = self.dataOut.heightList[-1] |
|
671 | 671 | |
|
672 | 672 | # validacion de velocidades |
@@ -679,13 +679,13 class SpectraLagsProc(ProcessingUnit): | |||
|
679 | 679 | maxVel = velrange[-1] |
|
680 | 680 | |
|
681 | 681 | if (minVel < velrange[0]) or (minVel > maxVel): |
|
682 |
print |
|
|
683 |
print |
|
|
682 | print('minVel: %.2f is out of the velocity range'%(minVel)) | |
|
683 | print('minVel is setting to %.2f'%(velrange[0])) | |
|
684 | 684 | minVel = velrange[0] |
|
685 | 685 | |
|
686 | 686 | if (maxVel > velrange[-1]) or (maxVel < minVel): |
|
687 |
print |
|
|
688 |
print |
|
|
687 | print('maxVel: %.2f is out of the velocity range'%(maxVel)) | |
|
688 | print('maxVel is setting to %.2f'%(velrange[-1])) | |
|
689 | 689 | maxVel = velrange[-1] |
|
690 | 690 | |
|
691 | 691 | # seleccion de indices para rango |
@@ -707,7 +707,7 class SpectraLagsProc(ProcessingUnit): | |||
|
707 | 707 | maxIndex = len(heights) |
|
708 | 708 | |
|
709 | 709 | if (minIndex < 0) or (minIndex > maxIndex): |
|
710 |
raise ValueError |
|
|
710 | raise ValueError("some value in (%d,%d) is not valid" % (minIndex, maxIndex)) | |
|
711 | 711 | |
|
712 | 712 | if (maxIndex >= self.dataOut.nHeights): |
|
713 | 713 | maxIndex = self.dataOut.nHeights-1 |
@@ -736,4 +736,4 class SpectraLagsProc(ProcessingUnit): | |||
|
736 | 736 | |
|
737 | 737 | self.dataOut.noise_estimation = noise.copy() |
|
738 | 738 | |
|
739 |
return 1 |
|
|
739 | return 1 No newline at end of file |
@@ -1,8 +1,9 | |||
|
1 | 1 | import sys |
|
2 | 2 | import numpy |
|
3 | 3 | from scipy import interpolate |
|
4 | from schainpy import cSchain | |
|
5 | from jroproc_base import ProcessingUnit, Operation | |
|
4 | #TODO | |
|
5 | #from schainpy import cSchain | |
|
6 | from .jroproc_base import ProcessingUnit, Operation | |
|
6 | 7 | from schainpy.model.data.jrodata import Voltage |
|
7 | 8 | from time import time |
|
8 | 9 | |
@@ -71,7 +72,7 class VoltageProc(ProcessingUnit): | |||
|
71 | 72 | |
|
72 | 73 | for channel in channelList: |
|
73 | 74 | if channel not in self.dataOut.channelList: |
|
74 |
raise ValueError |
|
|
75 | raise ValueError("Channel %d is not in %s" %(channel, str(self.dataOut.channelList))) | |
|
75 | 76 | |
|
76 | 77 | index = self.dataOut.channelList.index(channel) |
|
77 | 78 | channelIndexList.append(index) |
@@ -99,8 +100,8 class VoltageProc(ProcessingUnit): | |||
|
99 | 100 | |
|
100 | 101 | for channelIndex in channelIndexList: |
|
101 | 102 | if channelIndex not in self.dataOut.channelIndexList: |
|
102 |
print |
|
|
103 |
raise ValueError |
|
|
103 | print(channelIndexList) | |
|
104 | raise ValueError("The value %d in channelIndexList is not valid" %channelIndex) | |
|
104 | 105 | |
|
105 | 106 | if self.dataOut.flagDataAsBlock: |
|
106 | 107 | """ |
@@ -184,7 +185,7 class VoltageProc(ProcessingUnit): | |||
|
184 | 185 | """ |
|
185 | 186 | |
|
186 | 187 | if (minIndex < 0) or (minIndex > maxIndex): |
|
187 |
raise ValueError |
|
|
188 | raise ValueError("Height index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |
|
188 | 189 | |
|
189 | 190 | if (maxIndex >= self.dataOut.nHeights): |
|
190 | 191 | maxIndex = self.dataOut.nHeights |
@@ -204,7 +205,7 class VoltageProc(ProcessingUnit): | |||
|
204 | 205 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] |
|
205 | 206 | |
|
206 | 207 | if self.dataOut.nHeights <= 1: |
|
207 |
raise ValueError |
|
|
208 | raise ValueError("selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)) | |
|
208 | 209 | |
|
209 | 210 | return 1 |
|
210 | 211 | |
@@ -221,7 +222,7 class VoltageProc(ProcessingUnit): | |||
|
221 | 222 | newheights = (self.dataOut.nHeights-r)/window |
|
222 | 223 | |
|
223 | 224 | if newheights <= 1: |
|
224 |
raise ValueError |
|
|
225 | raise ValueError("filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window)) | |
|
225 | 226 | |
|
226 | 227 | if self.dataOut.flagDataAsBlock: |
|
227 | 228 | """ |
@@ -257,7 +258,7 class VoltageProc(ProcessingUnit): | |||
|
257 | 258 | |
|
258 | 259 | if self.dataOut.flagDataAsBlock: |
|
259 | 260 | flip = self.flip |
|
260 | profileList = range(self.dataOut.nProfiles) | |
|
261 | profileList = list(range(self.dataOut.nProfiles)) | |
|
261 | 262 | |
|
262 | 263 | if not channelList: |
|
263 | 264 | for thisProfile in profileList: |
@@ -306,7 +307,7 class VoltageProc(ProcessingUnit): | |||
|
306 | 307 | else: |
|
307 | 308 | nHeights = self.dataOut.data.shape[2] |
|
308 | 309 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) |
|
309 | y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)] | |
|
310 | y = self.dataOut.data[:,:,list(range(botLim))+list(range(topLim+1,nHeights))] | |
|
310 | 311 | f = interpolate.interp1d(x, y, axis = 2) |
|
311 | 312 | xnew = numpy.arange(botLim,topLim+1) |
|
312 | 313 | ynew = f(xnew) |
@@ -355,7 +356,7 class CohInt(Operation): | |||
|
355 | 356 | self.stride = stride |
|
356 | 357 | |
|
357 | 358 | if n == None and timeInterval == None: |
|
358 |
raise ValueError |
|
|
359 | raise ValueError("n or timeInterval should be specified ...") | |
|
359 | 360 | |
|
360 | 361 | if n != None: |
|
361 | 362 | self.n = n |
@@ -613,7 +614,7 class Decoder(Operation): | |||
|
613 | 614 | self.__nHeis = dataOut.nHeights |
|
614 | 615 | |
|
615 | 616 | if self.__nHeis < self.nBaud: |
|
616 |
raise ValueError |
|
|
617 | raise ValueError('Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)) | |
|
617 | 618 | |
|
618 | 619 | #Frequency |
|
619 | 620 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) |
@@ -666,7 +667,7 class Decoder(Operation): | |||
|
666 | 667 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) |
|
667 | 668 | junk = junk.flatten() |
|
668 | 669 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) |
|
669 |
profilesList = |
|
|
670 | profilesList = range(self.__nProfiles) | |
|
670 | 671 | |
|
671 | 672 | for i in range(self.__nChannels): |
|
672 | 673 | for j in profilesList: |
@@ -675,7 +676,7 class Decoder(Operation): | |||
|
675 | 676 | |
|
676 | 677 | def __convolutionByBlockInFreq(self, data): |
|
677 | 678 | |
|
678 |
raise NotImplementedError |
|
|
679 | raise NotImplementedError("Decoder by frequency fro Blocks not implemented") | |
|
679 | 680 | |
|
680 | 681 | |
|
681 | 682 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
@@ -692,13 +693,13 class Decoder(Operation): | |||
|
692 | 693 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): |
|
693 | 694 | |
|
694 | 695 | if dataOut.flagDecodeData: |
|
695 |
print |
|
|
696 | print("This data is already decoded, recoding again ...") | |
|
696 | 697 | |
|
697 | 698 | if not self.isConfig: |
|
698 | 699 | |
|
699 | 700 | if code is None: |
|
700 | 701 | if dataOut.code is None: |
|
701 |
raise ValueError |
|
|
702 | raise ValueError("Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type) | |
|
702 | 703 | |
|
703 | 704 | code = dataOut.code |
|
704 | 705 | else: |
@@ -714,7 +715,7 class Decoder(Operation): | |||
|
714 | 715 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") |
|
715 | 716 | |
|
716 | 717 | if self.code is None: |
|
717 |
print |
|
|
718 | print("Fail decoding: Code is not defined.") | |
|
718 | 719 | return |
|
719 | 720 | |
|
720 | 721 | self.__nProfiles = dataOut.nProfiles |
@@ -746,7 +747,7 class Decoder(Operation): | |||
|
746 | 747 | datadec = self.__convolutionInFreqOpt(dataOut.data) |
|
747 | 748 | |
|
748 | 749 | if datadec is None: |
|
749 |
raise ValueError |
|
|
750 | raise ValueError("Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode) | |
|
750 | 751 | |
|
751 | 752 | dataOut.code = self.code |
|
752 | 753 | dataOut.nCode = self.nCode |
@@ -803,7 +804,7 class ProfileConcat(Operation): | |||
|
803 | 804 | self.isConfig = True |
|
804 | 805 | |
|
805 | 806 | if dataOut.flagDataAsBlock: |
|
806 |
raise ValueError |
|
|
807 | raise ValueError("ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False") | |
|
807 | 808 | |
|
808 | 809 | else: |
|
809 | 810 | self.concat(dataOut.data) |
@@ -883,7 +884,7 class ProfileSelector(Operation): | |||
|
883 | 884 | if profileRangeList != None: |
|
884 | 885 | minIndex = profileRangeList[0] |
|
885 | 886 | maxIndex = profileRangeList[1] |
|
886 | profileList = range(minIndex, maxIndex+1) | |
|
887 | profileList = list(range(minIndex, maxIndex+1)) | |
|
887 | 888 | |
|
888 | 889 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] |
|
889 | 890 | |
@@ -895,7 +896,7 class ProfileSelector(Operation): | |||
|
895 | 896 | minIndex = thisRange[0] |
|
896 | 897 | maxIndex = thisRange[1] |
|
897 | 898 | |
|
898 | profileList.extend(range(minIndex, maxIndex+1)) | |
|
899 | profileList.extend(list(range(minIndex, maxIndex+1))) | |
|
899 | 900 | |
|
900 | 901 | dataOut.data = dataOut.data[:,profileList,:] |
|
901 | 902 | |
@@ -974,7 +975,7 class ProfileSelector(Operation): | |||
|
974 | 975 | |
|
975 | 976 | return True |
|
976 | 977 | |
|
977 |
raise ValueError |
|
|
978 | raise ValueError("ProfileSelector needs profileList, profileRangeList or rangeList parameter") | |
|
978 | 979 | |
|
979 | 980 | return False |
|
980 | 981 | |
@@ -1015,21 +1016,21 class Reshaper(Operation): | |||
|
1015 | 1016 | def __checkInputs(self, dataOut, shape, nTxs): |
|
1016 | 1017 | |
|
1017 | 1018 | if shape is None and nTxs is None: |
|
1018 |
raise ValueError |
|
|
1019 | raise ValueError("Reshaper: shape of factor should be defined") | |
|
1019 | 1020 | |
|
1020 | 1021 | if nTxs: |
|
1021 | 1022 | if nTxs < 0: |
|
1022 |
raise ValueError |
|
|
1023 | raise ValueError("nTxs should be greater than 0") | |
|
1023 | 1024 | |
|
1024 | 1025 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: |
|
1025 |
raise ValueError |
|
|
1026 | raise ValueError("nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs))) | |
|
1026 | 1027 | |
|
1027 | 1028 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] |
|
1028 | 1029 | |
|
1029 | 1030 | return shape, nTxs |
|
1030 | 1031 | |
|
1031 | 1032 | if len(shape) != 2 and len(shape) != 3: |
|
1032 |
raise ValueError |
|
|
1033 | raise ValueError("shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights)) | |
|
1033 | 1034 | |
|
1034 | 1035 | if len(shape) == 2: |
|
1035 | 1036 | shape_tuple = [dataOut.nChannels] |
@@ -1069,7 +1070,7 class Reshaper(Operation): | |||
|
1069 | 1070 | profileIndex = dataOut.profileIndex*nTxs |
|
1070 | 1071 | |
|
1071 | 1072 | else: |
|
1072 |
raise ValueError |
|
|
1073 | raise ValueError("nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)") | |
|
1073 | 1074 | |
|
1074 | 1075 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1075 | 1076 | |
@@ -1098,7 +1099,7 class SplitProfiles(Operation): | |||
|
1098 | 1099 | shape = dataOut.data.shape |
|
1099 | 1100 | |
|
1100 | 1101 | if shape[2] % n != 0: |
|
1101 |
raise ValueError |
|
|
1102 | raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[2])) | |
|
1102 | 1103 | |
|
1103 | 1104 | new_shape = shape[0], shape[1]*n, shape[2]/n |
|
1104 | 1105 | |
@@ -1109,7 +1110,7 class SplitProfiles(Operation): | |||
|
1109 | 1110 | |
|
1110 | 1111 | else: |
|
1111 | 1112 | |
|
1112 |
raise ValueError |
|
|
1113 | raise ValueError("Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)") | |
|
1113 | 1114 | |
|
1114 | 1115 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1115 | 1116 | |
@@ -1141,7 +1142,7 class CombineProfiles(Operation): | |||
|
1141 | 1142 | new_shape = shape[0], shape[1]/n, shape[2]*n |
|
1142 | 1143 | |
|
1143 | 1144 | if shape[1] % n != 0: |
|
1144 |
raise ValueError |
|
|
1145 | raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[1])) | |
|
1145 | 1146 | |
|
1146 | 1147 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1147 | 1148 | dataOut.flagNoData = False |
@@ -1316,4 +1317,4 class CombineProfiles(Operation): | |||
|
1316 | 1317 | # |
|
1317 | 1318 | # self.__startIndex += self.__newNSamples |
|
1318 | 1319 | # |
|
1319 |
# return |
|
|
1320 | # return No newline at end of file |
@@ -11,7 +11,7 from time import gmtime | |||
|
11 | 11 | |
|
12 | 12 | from numpy import transpose |
|
13 | 13 | |
|
14 | from jroproc_base import ProcessingUnit, Operation | |
|
14 | from .jroproc_base import ProcessingUnit, Operation | |
|
15 | 15 | from schainpy.model.data.jrodata import Parameters |
|
16 | 16 | |
|
17 | 17 |
@@ -3,7 +3,7 Created on Jul 15, 2014 | |||
|
3 | 3 | |
|
4 | 4 | @author: Miguel Urco |
|
5 | 5 | ''' |
|
6 | from serializer import DynamicSerializer | |
|
6 | from .serializer import DynamicSerializer | |
|
7 | 7 | |
|
8 | 8 | DEFAULT_SERIALIZER = None #'cPickle', 'msgpack', "yaml" |
|
9 | 9 | |
@@ -20,7 +20,7 def isDictFormat(thisValue): | |||
|
20 | 20 | if type(thisValue) != type({}): |
|
21 | 21 | return False |
|
22 | 22 | |
|
23 | if CLASSNAME_KEY not in thisValue.keys(): | |
|
23 | if CLASSNAME_KEY not in list(thisValue.keys()): | |
|
24 | 24 | return False |
|
25 | 25 | |
|
26 | 26 | return True |
@@ -28,13 +28,13 def isDictFormat(thisValue): | |||
|
28 | 28 | def obj2Dict(myObj, keyList=[]): |
|
29 | 29 | |
|
30 | 30 | if not keyList: |
|
31 | keyList = myObj.__dict__.keys() | |
|
31 | keyList = list(myObj.__dict__.keys()) | |
|
32 | 32 | |
|
33 | 33 | myDict = {} |
|
34 | 34 | |
|
35 | 35 | myDict[CLASSNAME_KEY] = myObj.__class__.__name__ |
|
36 | 36 | |
|
37 | for thisKey, thisValue in myObj.__dict__.items(): | |
|
37 | for thisKey, thisValue in list(myObj.__dict__.items()): | |
|
38 | 38 | |
|
39 | 39 | if thisKey not in keyList: |
|
40 | 40 | continue |
@@ -52,14 +52,14 def dict2Obj(myDict): | |||
|
52 | 52 | ''' |
|
53 | 53 | ''' |
|
54 | 54 | |
|
55 | if CLASSNAME_KEY not in myDict.keys(): | |
|
55 | if CLASSNAME_KEY not in list(myDict.keys()): | |
|
56 | 56 | return None |
|
57 | 57 | |
|
58 | 58 | className = eval(myDict[CLASSNAME_KEY]) |
|
59 | 59 | |
|
60 | 60 | myObj = className() |
|
61 | 61 | |
|
62 | for thisKey, thisValue in myDict.items(): | |
|
62 | for thisKey, thisValue in list(myDict.items()): | |
|
63 | 63 | |
|
64 | 64 | if thisKey == CLASSNAME_KEY: |
|
65 | 65 | continue |
@@ -111,4 +111,4 def serial2Obj(mySerial, metadataDict = {}, serializer=DEFAULT_SERIALIZER): | |||
|
111 | 111 | metadataDict.update(myDataDict) |
|
112 | 112 | myObj = dict2Obj(metadataDict) |
|
113 | 113 | |
|
114 |
return myObj |
|
|
114 | return myObj No newline at end of file |
@@ -7,7 +7,7 Created on Jul 17, 2014 | |||
|
7 | 7 | DEFAULT_SERIALIZER = None |
|
8 | 8 | |
|
9 | 9 | try: |
|
10 |
import |
|
|
10 | import pickle | |
|
11 | 11 | DEFAULT_SERIALIZER = 'cPickle' |
|
12 | 12 | except: |
|
13 | 13 | pass |
@@ -86,7 +86,7 class DynamicSerializer(Serializer): | |||
|
86 | 86 | def __init__(self, module = None): |
|
87 | 87 | |
|
88 | 88 | if not DEFAULT_SERIALIZER: |
|
89 |
raise ImportError |
|
|
89 | raise ImportError("Install a python serializer like cPickle or msgpack") | |
|
90 | 90 | |
|
91 | 91 | if not module: |
|
92 | 92 | module == DEFAULT_SERIALIZER |
@@ -7,7 +7,7 matching signatures. | |||
|
7 | 7 | $Id$ |
|
8 | 8 | ''' |
|
9 | 9 | |
|
10 | import urllib | |
|
10 | import urllib.request, urllib.parse, urllib.error | |
|
11 | 11 | import os |
|
12 | 12 | import re |
|
13 | 13 | import yaml # YAML Ain't Markup Language |
@@ -40,7 +40,7 class Object(object): | |||
|
40 | 40 | elif isinstance(object_uri, str): |
|
41 | 41 | if object_uri.endswith('.yml'): |
|
42 | 42 | # URI is a web hyper-linked yaml file - read it. |
|
43 | self.yaml = urllib.urlopen(object_uri).read() | |
|
43 | self.yaml = urllib.request.urlopen(object_uri).read() | |
|
44 | 44 | else: |
|
45 | 45 | # URI is a (hyper-linked?) directory - try reading it. |
|
46 | 46 | #print "URI is a directory." |
@@ -55,12 +55,12 class Object(object): | |||
|
55 | 55 | for fn in self.files: |
|
56 | 56 | self.yaml.append(Object(fn)) |
|
57 | 57 | else: |
|
58 |
print |
|
|
58 | print("Invalid URI supplied: %s"%(object_uri,)) | |
|
59 | 59 | |
|
60 | 60 | def __parseLink(self, object_uri, recursive): |
|
61 | 61 | """ Returns a listing of all YAML files located in the |
|
62 | 62 | hyper-link directory given by page. """ |
|
63 | page = urllib.urlopen(object_uri).read() | |
|
63 | page = urllib.request.urlopen(object_uri).read() | |
|
64 | 64 | #print "URI is a URL directory: %s"%(object_uri,) |
|
65 | 65 | pattern = re.compile(r'<a href="[^"]*">') |
|
66 | 66 | |
@@ -120,8 +120,8 class Object(object): | |||
|
120 | 120 | |
|
121 | 121 | if not isinstance(obj, Object): return False |
|
122 | 122 | |
|
123 | self_keys = self.__dict__.keys() | |
|
124 | obj_keys = obj.__dict__.keys() | |
|
123 | self_keys = list(self.__dict__.keys()) | |
|
124 | obj_keys = list(obj.__dict__.keys()) | |
|
125 | 125 | if not self_keys == obj_keys: |
|
126 | 126 | return False |
|
127 | 127 | for key in self_keys: |
@@ -132,8 +132,8 class Object(object): | |||
|
132 | 132 | if not self_value.equals(obj_value, compare_time_created): |
|
133 | 133 | return False |
|
134 | 134 | elif isinstance(self_value, np.ndarray): |
|
135 | m1 = map(repr,self_value.flat) | |
|
136 | m2 = map(repr,obj_value.flat) | |
|
135 | m1 = list(map(repr,self_value.flat)) | |
|
136 | m2 = list(map(repr,obj_value.flat)) | |
|
137 | 137 | ret = m1 == m2 |
|
138 | 138 | if not ret: |
|
139 | 139 | return False |
@@ -147,7 +147,7 class Object(object): | |||
|
147 | 147 | def sizeof(self): |
|
148 | 148 | """ Recursively computes the size in bytes of the given Dynamic Object """ |
|
149 | 149 | sz = 0 |
|
150 | values = self.__dict__.values() | |
|
150 | values = list(self.__dict__.values()) | |
|
151 | 151 | for val in values: |
|
152 | 152 | if isinstance(val, Object): sz += val.sizeof() |
|
153 | 153 | elif isinstance(val, np.ndarray): sz += val.nbytes |
@@ -281,7 +281,7 def __ref_constructor(loader, node): | |||
|
281 | 281 | return _Reference(loader.construct_mapping(node)) |
|
282 | 282 | else: |
|
283 | 283 | return _Reference(loader.construct_scalar(node)) |
|
284 |
add_constructor( |
|
|
284 | add_constructor('!ref', __ref_constructor) | |
|
285 | 285 | |
|
286 | 286 | # Method constructor using !method tag: |
|
287 | 287 | def __method_constructor(loader, node): |
@@ -289,7 +289,7 def __method_constructor(loader, node): | |||
|
289 | 289 | return _Method(loader.construct_mapping(node)) |
|
290 | 290 | else: |
|
291 | 291 | return _Method(loader.construct_scalar(node)) |
|
292 |
add_constructor( |
|
|
292 | add_constructor('!method', __method_constructor) | |
|
293 | 293 | |
|
294 | 294 | # Generic constructor for any _BuiltinDtype |
|
295 | 295 | def __dtype_constructor(loader, node): |
@@ -302,8 +302,8 def __dtype_constructor(loader, node): | |||
|
302 | 302 | return ret |
|
303 | 303 | |
|
304 | 304 | # Register YAML constructors for each builtin type: |
|
305 | for dtype in Lookup.numpy_dtypes.keys() + Lookup.builtin_objects.keys(): | |
|
306 |
add_constructor( |
|
|
305 | for dtype in list(Lookup.numpy_dtypes.keys()) + list(Lookup.builtin_objects.keys()): | |
|
306 | add_constructor('!%s'%(dtype,), __dtype_constructor) | |
|
307 | 307 | |
|
308 | 308 | class FactoryLoader(OrderedYAML.Loader): |
|
309 | 309 | """ A YAML Loader specifically designed to load YAML object definitions |
@@ -311,7 +311,7 class FactoryLoader(OrderedYAML.Loader): | |||
|
311 | 311 | |
|
312 | 312 | def construct_yaml_timestamp(self, node): |
|
313 | 313 | """ Make empty timestamps (None/null) acceptable, otherwise parse the timestamp """ |
|
314 |
if node.value == |
|
|
314 | if node.value == '': | |
|
315 | 315 | name = 'YAML_DEFN_LOADED_INCORRECTLY' # in case we forget to fix the name... |
|
316 | 316 | return _Parameter(name, hasDefault=False, classType=datetime.datetime) |
|
317 | 317 | else: |
@@ -319,7 +319,7 class FactoryLoader(OrderedYAML.Loader): | |||
|
319 | 319 | |
|
320 | 320 | # Override default timestamp constructor: |
|
321 | 321 | FactoryLoader.add_constructor( |
|
322 |
|
|
|
322 | 'tag:yaml.org,2002:timestamp', | |
|
323 | 323 | FactoryLoader.construct_yaml_timestamp |
|
324 | 324 | ) |
|
325 | 325 | |
@@ -414,7 +414,7 class Factory: | |||
|
414 | 414 | return _Parameter(sigName, True, default, length=None) |
|
415 | 415 | |
|
416 | 416 | # Is the object an array with length and default value given?: |
|
417 | if isinstance(sig.yamlString, dict) and "len" in sig.yamlString.keys(): | |
|
417 | if isinstance(sig.yamlString, dict) and "len" in list(sig.yamlString.keys()): | |
|
418 | 418 | length = sig.yamlString["len"] |
|
419 | 419 | |
|
420 | 420 | # Shape is given as something like [[],[]], not [2,2] - convert |
@@ -495,7 +495,7 class Factory: | |||
|
495 | 495 | |
|
496 | 496 | # List of names of classes we've created so far: |
|
497 | 497 | #print [x for x in objClasses] |
|
498 | names = objClasses.keys() | |
|
498 | names = list(objClasses.keys()) | |
|
499 | 499 | |
|
500 | 500 | if ref_object.yamlString in names: |
|
501 | 501 | defaultType = objClasses[ref_object.yamlString] |
@@ -594,7 +594,7 class Factory: | |||
|
594 | 594 | setattr(_self, classData[i].name, arg) |
|
595 | 595 | |
|
596 | 596 | # Set named attributes (given by dictionary kwargs): |
|
597 | for key,value in kwargs.items(): | |
|
597 | for key,value in list(kwargs.items()): | |
|
598 | 598 | |
|
599 | 599 | try: keyIndex = [param.name for param in classData].index(key) |
|
600 | 600 | except ValueError: |
@@ -605,7 +605,7 class Factory: | |||
|
605 | 605 | |
|
606 | 606 | |
|
607 | 607 | # Object instantiation / creation time (if not already present): |
|
608 |
if |
|
|
608 | if '__time_created' not in kwargs: | |
|
609 | 609 | setattr(_self, "__time_created", np.float64(time.time())) |
|
610 | 610 | |
|
611 | 611 | return init, attributes |
@@ -616,7 +616,7 class Factory: | |||
|
616 | 616 | a KeyError if the class cannot be found. """ |
|
617 | 617 | |
|
618 | 618 | # If class definition was in the YAML file, extend that one: |
|
619 | if className in localClasses.keys(): | |
|
619 | if className in list(localClasses.keys()): | |
|
620 | 620 | return localClasses[className] |
|
621 | 621 | |
|
622 | 622 | # Else try finding the class definition in our global scope: |
@@ -647,7 +647,7 class Factory: | |||
|
647 | 647 | # Each document can contain multiple objects - build each one. |
|
648 | 648 | # (NOTE: objects can cross reference each other in the same document |
|
649 | 649 | # need to resolve Reference objects as last step) |
|
650 | for objClassName in document.keys(): | |
|
650 | for objClassName in list(document.keys()): | |
|
651 | 651 | |
|
652 | 652 | # The dictionary containing method & data signatures: |
|
653 | 653 | objDict = document[objClassName] |
@@ -659,9 +659,9 class Factory: | |||
|
659 | 659 | classBases = [Object] |
|
660 | 660 | |
|
661 | 661 | # List structured documents result in a list of dicts each with one key: |
|
662 | if isinstance(objDict, list): keys = [param.keys()[0] for param in objDict] | |
|
662 | if isinstance(objDict, list): keys = [list(param.keys())[0] for param in objDict] | |
|
663 | 663 | # Otherwise the parameter names are just the keys of the dict |
|
664 | else: keys = objDict.keys() # if key not found, raises AttributeError | |
|
664 | else: keys = list(objDict.keys()) # if key not found, raises AttributeError | |
|
665 | 665 | |
|
666 | 666 | for sigName in keys: |
|
667 | 667 | #print sigName |
@@ -696,7 +696,7 class Factory: | |||
|
696 | 696 | else: |
|
697 | 697 | msg = "Factory abstract base class doesn't " +\ |
|
698 | 698 | "support the following signature: %r \"%s\""%(sig.__class__,str(sig)) |
|
699 |
print |
|
|
699 | print(sig.__class__) | |
|
700 | 700 | raise SignatureException(msg) |
|
701 | 701 | |
|
702 | 702 | # Built-in attribute for all Dynamic Objects: |
@@ -731,12 +731,12 class Factory: | |||
|
731 | 731 | def construct_dynamic_object(loader, node): |
|
732 | 732 | kwargs = loader.construct_mapping(node) |
|
733 | 733 | # Remove revision control from loaded objects (info is in the class object!) |
|
734 | for arg in kwargs.keys(): | |
|
734 | for arg in list(kwargs.keys()): | |
|
735 | 735 | if arg in getattr(Object, 'getters') and arg != '__time_created': |
|
736 | 736 | del kwargs[arg] |
|
737 | 737 | return cls(**kwargs) |
|
738 | 738 | revision = cls.meta_attributes["__revision_number"] |
|
739 |
DynamicYAML.Loader.add_constructor( |
|
|
739 | DynamicYAML.Loader.add_constructor('!%s.%s'%(str(objClassName),revision), construct_dynamic_object) | |
|
740 | 740 | |
|
741 | 741 | represent_dynamic_object = DynamicYAML.Dumper.represent_dynamic_object |
|
742 | 742 | DynamicYAML.Dumper.add_representer(cls, represent_dynamic_object) |
@@ -748,19 +748,19 class Factory: | |||
|
748 | 748 | except KeyError: |
|
749 | 749 | # Now look for reference to class object loaded from any YAML defn file, loading the |
|
750 | 750 | # most recent version / revision (number) of the definition |
|
751 | for dynClass in Object.dynamicClasses.keys()[::-1]: | |
|
751 | for dynClass in list(Object.dynamicClasses.keys())[::-1]: | |
|
752 | 752 | if dynClass.startswith(className): |
|
753 | 753 | return Object.dynamicClasses[dynClass] |
|
754 | 754 | |
|
755 | 755 | # Still unresolved - raise exception: |
|
756 | allDynamicClasses = repr(objClasses.keys() + Object.dynamicClasses.keys()) | |
|
756 | allDynamicClasses = repr(list(objClasses.keys()) + list(Object.dynamicClasses.keys())) | |
|
757 | 757 | raise UnresolvedTypeException("Cannot resolve type '%s': Name not found in %s"%(className,allDynamicClasses)) |
|
758 | 758 | |
|
759 | 759 | |
|
760 | 760 | def resolve(param): |
|
761 | 761 | |
|
762 | 762 | # Reference is just a string - that's the class name: |
|
763 |
if isinstance(param.classType.yamlObject, |
|
|
763 | if isinstance(param.classType.yamlObject, str): | |
|
764 | 764 | className = str(param.classType.yamlObject) |
|
765 | 765 | param.classType = findClass(className) |
|
766 | 766 | return |
@@ -796,7 +796,7 class Factory: | |||
|
796 | 796 | param.hasDefault = False # for good measure |
|
797 | 797 | |
|
798 | 798 | # Is it an object array?: |
|
799 | if "len" in refDict.keys(): | |
|
799 | if "len" in list(refDict.keys()): | |
|
800 | 800 | param.length = refDict["len"] |
|
801 | 801 | |
|
802 | 802 | # Resolve any unresolved data-types: |
@@ -810,7 +810,6 class Factory: | |||
|
810 | 810 | def load_defn(yaml): |
|
811 | 811 | """ Shortcut for producing a single DynamicObject class object from |
|
812 | 812 | the provided yaml definition in string format """ |
|
813 | return Factory(yaml=yaml).classes.values()[0] | |
|
814 | ||
|
813 | return list(Factory(yaml=yaml).classes.values())[0] | |
|
815 | 814 | |
|
816 | 815 |
@@ -66,4 +66,4 class DynamicSerializer: | |||
|
66 | 66 | |
|
67 | 67 | if __name__ == "__main__": |
|
68 | 68 | DynamicSerializer() |
|
69 |
print |
|
|
69 | print("DynamicSerializer ran") No newline at end of file |
@@ -54,7 +54,7 class Loader(OrderedYAML.Loader): | |||
|
54 | 54 | data = self.construct_mapping(self, node) |
|
55 | 55 | self.constructed_objects[node] = data |
|
56 | 56 | del self.recursive_objects[node] |
|
57 |
if |
|
|
57 | if '__revision_source' in data: | |
|
58 | 58 | # TODO: Handle password authentication |
|
59 | 59 | client = pysvn.Client() |
|
60 | 60 | source = data['__revision_source'] |
@@ -85,11 +85,11 class Dumper(OrderedYAML.Dumper): | |||
|
85 | 85 | """ |
|
86 | 86 | |
|
87 | 87 | state = {} |
|
88 | state.update(obj.__dict__.items()) | |
|
89 | state.update(obj.__class__.meta_attributes.items()) | |
|
88 | state.update(list(obj.__dict__.items())) | |
|
89 | state.update(list(obj.__class__.meta_attributes.items())) | |
|
90 | 90 | name = obj.getObjectName() # obj.__class__.__name__ |
|
91 | 91 | revision = obj.getRevisionNumber() |
|
92 |
return self.represent_mapping( |
|
|
92 | return self.represent_mapping('!%s.%s' % (name, revision), state) | |
|
93 | 93 | |
|
94 | 94 | # Dtypes to be stored as hex in YAML streams / strings |
|
95 | 95 | hex_dtypes = ['float', 'complex', 'half', 'single', 'double'] |
@@ -98,7 +98,7 hex_dtypes = ['float', 'complex', 'half', 'single', 'double'] | |||
|
98 | 98 | dtypes = Lookup.numpy_dtypes |
|
99 | 99 | |
|
100 | 100 | # Inverse lookup for accessing tags given a class instance: |
|
101 | cls_dtypes = dict([(v,k) for (k,v) in dtypes.items()]) | |
|
101 | cls_dtypes = dict([(v,k) for (k,v) in list(dtypes.items())]) | |
|
102 | 102 | |
|
103 | 103 | # Representer for numpy arrays: |
|
104 | 104 | def ndarray_representer(dumper, obj): |
@@ -108,23 +108,23 def ndarray_representer(dumper, obj): | |||
|
108 | 108 | np_ary = obj |
|
109 | 109 | #hex_ary = np.empty(np_ary.shape, dtype=yaml.nodes.ScalarNode) |
|
110 | 110 | np_flat, hex_flat = np_ary.flat, [] #hex_ary.flat |
|
111 |
hex_flat.append(dumper.represent_sequence( |
|
|
111 | hex_flat.append(dumper.represent_sequence('tag:yaml.org,2002:seq', list(np_ary.shape), flow_style=True)) | |
|
112 | 112 | if hexlify: |
|
113 | 113 | lst = [] |
|
114 | 114 | for i in range(len(np_flat)): |
|
115 |
value = |
|
|
116 |
node = dumper.represent_scalar( |
|
|
115 | value = '%s'%(np_flat[i],) | |
|
116 | node = dumper.represent_scalar('tag:yaml.org,2002:str', value, style='') | |
|
117 | 117 | lst.append(node) |
|
118 |
hex_flat.append(yaml.nodes.SequenceNode( |
|
|
118 | hex_flat.append(yaml.nodes.SequenceNode('tag:yaml.org,2002:seq', lst, flow_style=True)) | |
|
119 | 119 | lst = [] |
|
120 | 120 | for i in range(len(np_flat)): |
|
121 |
if hexlify: value = |
|
|
122 |
else: value = |
|
|
123 |
node = dumper.represent_scalar( |
|
|
121 | if hexlify: value = '%s'%(binascii.hexlify(np_flat[i]),) | |
|
122 | else: value = '%s'%(np_flat[i],) | |
|
123 | node = dumper.represent_scalar('tag:yaml.org,2002:str', value, style='') | |
|
124 | 124 | if hexlify: lst.append(node) |
|
125 | 125 | else: hex_flat.append(node) |
|
126 |
if hexlify: hex_flat.append(yaml.nodes.SequenceNode( |
|
|
127 |
return yaml.nodes.SequenceNode( |
|
|
126 | if hexlify: hex_flat.append(yaml.nodes.SequenceNode('tag:yaml.org,2002:seq', lst, flow_style=True)) | |
|
127 | return yaml.nodes.SequenceNode('!%s'%(tag,), hex_flat, flow_style=True) | |
|
128 | 128 | Dumper.add_representer(np.ndarray, ndarray_representer) |
|
129 | 129 | |
|
130 | 130 | # Constructor for ndarrays with arbitrary (specified) dtype: |
@@ -172,9 +172,9 class __dtype_con: | |||
|
172 | 172 | def dtype_representer(dumper, obj): |
|
173 | 173 | tag, hexlify, dtype = self.fncn_attributes |
|
174 | 174 | if isinstance(obj, float): obj = np.float64(obj) |
|
175 |
if hexlify: value = |
|
|
176 |
else: value = |
|
|
177 |
try: tag = |
|
|
175 | if hexlify: value = '%s'%(binascii.hexlify(obj),) | |
|
176 | else: value = '%s'%(obj,) | |
|
177 | try: tag = '!%s'%(cls_dtypes[obj.__class__]) # 'dtype.'+obj.__class__.__name__ # bullshit... | |
|
178 | 178 | except KeyError: tag = '' |
|
179 | 179 | node = dumper.represent_scalar(tag, value, style='') |
|
180 | 180 | return node |
@@ -182,40 +182,39 class __dtype_con: | |||
|
182 | 182 | self.dtype_constructor = dtype_constructor |
|
183 | 183 | self.dtype_representer = dtype_representer |
|
184 | 184 | |
|
185 | keys = [x for x in dtypes.keys() if x != 'dtype.int' and x != 'dtype.bool'] | |
|
186 |
print |
|
|
185 | keys = [x for x in list(dtypes.keys()) if x != 'dtype.int' and x != 'dtype.bool'] | |
|
186 | print(keys) | |
|
187 | 187 | |
|
188 | 188 | n = len(keys) |
|
189 |
print |
|
|
189 | print(n) | |
|
190 | 190 | i=0 |
|
191 | 191 | |
|
192 | 192 | for tag in keys: |
|
193 | 193 | dtype = __dtype_con(tag) |
|
194 | 194 | dtype_constructor = dtype.dtype_constructor |
|
195 | 195 | dtype_representer = dtype.dtype_representer |
|
196 |
Loader.add_constructor( |
|
|
196 | Loader.add_constructor('!%s'%(tag,), dtype_constructor) | |
|
197 | 197 | Dumper.add_representer(dtypes[tag], dtype_representer) |
|
198 | 198 | |
|
199 | 199 | # Precision time constructors & representers: |
|
200 | 200 | def ns_rep(dumper, obj): |
|
201 | 201 | state = {'second': obj.__dict__['second'], 'nanosecond': obj.__dict__['nanosecond']} |
|
202 |
return dumper.represent_mapping( |
|
|
202 | return dumper.represent_mapping('!timestamp_ns', state) | |
|
203 | 203 | def ps_rep(dumper, obj): |
|
204 | 204 | state = {'second': obj.__dict__['second'], 'picosecond': obj.__dict__['picosecond']} |
|
205 |
return dumper.represent_mapping( |
|
|
205 | return dumper.represent_mapping('!timestamp_ps', state) | |
|
206 | 206 | def ns_con(loader, node): return PrecisionTime.nsTime(**loader.construct_mapping(node)) |
|
207 | 207 | def ps_con(loader, node): return PrecisionTime.psTime(**loader.construct_mapping(node)) |
|
208 | 208 | |
|
209 | 209 | Dumper.add_representer(PrecisionTime.nsTime, ns_rep) |
|
210 | 210 | Dumper.add_representer(PrecisionTime.psTime, ps_rep) |
|
211 |
Loader.add_constructor( |
|
|
212 |
Loader.add_constructor( |
|
|
213 |
Loader.add_constructor( |
|
|
214 |
Loader.add_constructor( |
|
|
211 | Loader.add_constructor('!timestamp_ns', ns_con) | |
|
212 | Loader.add_constructor('!timestamp_nanosecond', ns_con) | |
|
213 | Loader.add_constructor('!timestamp_ps', ps_con) | |
|
214 | Loader.add_constructor('!timestamp_picosecond', ps_con) | |
|
215 | 215 | |
|
216 | 216 | # Binary object constructor & representer: |
|
217 |
def bin_rep(dumper, obj): return dumper.represent_mapping( |
|
|
217 | def bin_rep(dumper, obj): return dumper.represent_mapping('!binary', obj.__dict__) | |
|
218 | 218 | def bin_con(loader, node): return DynamicObject.Binary(**loader.construct_mapping(node)) |
|
219 | 219 | Dumper.add_representer(DynamicObject.Binary, bin_rep) |
|
220 |
Loader.add_constructor( |
|
|
221 | ||
|
220 | Loader.add_constructor('!binary', bin_con) |
@@ -15,8 +15,8 import platform | |||
|
15 | 15 | import collections |
|
16 | 16 | |
|
17 | 17 | # Implicit Types: |
|
18 |
python_dtypes = tuple([bool,int, |
|
|
19 |
set,dict,tuple, |
|
|
18 | python_dtypes = tuple([bool,int,int,float,str,datetime.datetime,list, | |
|
19 | set,dict,tuple,str]) | |
|
20 | 20 | |
|
21 | 21 | # Numpy Data-types: |
|
22 | 22 | numpy_dtypes = {'dtype.bool': bool, 'dtype.int': np.int, 'dtype.int8': np.int8, |
@@ -53,10 +53,9 builtin_objects_simple = {'nsTime': PrecisionTime.nsTime, 'psTime': PrecisionTim | |||
|
53 | 53 | 'Binary': Binary} |
|
54 | 54 | |
|
55 | 55 | # Inverse lookup for accessing tags given a class instance: |
|
56 | cls_dtypes = dict([(v,k) for (k,v) in numpy_dtypes.items()]) | |
|
57 | obj_dtypes = dict([(v,k) for (k,v) in builtin_objects_simple.items()]) | |
|
56 | cls_dtypes = dict([(v,k) for (k,v) in list(numpy_dtypes.items())]) | |
|
57 | obj_dtypes = dict([(v,k) for (k,v) in list(builtin_objects_simple.items())]) | |
|
58 | 58 | |
|
59 | 59 | # Pointer to the list of all Object classes created, as located in the Object module / class: |
|
60 | 60 | dynamicClasses = DynamicObject.Object.dynamicClasses |
|
61 | 61 | |
|
62 |
@@ -18,15 +18,15 class nsTime: | |||
|
18 | 18 | def __init__(self, second, nanosecond): |
|
19 | 19 | self.second = int(second) |
|
20 | 20 | if self.second < 0: |
|
21 |
raise ValueError |
|
|
22 |
nanosecond = |
|
|
21 | raise ValueError('seconds must be greater than 0, not %i' % (self.second)) | |
|
22 | nanosecond = int(nanosecond) | |
|
23 | 23 | if nanosecond < 0: |
|
24 |
raise ValueError |
|
|
24 | raise ValueError('nanoseconds must be greater 0, not %i' % (nanosecond)) | |
|
25 | 25 | addSec = nanosecond / 1000000000 |
|
26 | 26 | if addSec > 0: |
|
27 | 27 | self.second += addSec |
|
28 | 28 | self.nanosecond = nanosecond % 1000000000 |
|
29 |
self.totalNS = |
|
|
29 | self.totalNS = int(self.nanosecond) + int(self.second) * 1000000000 | |
|
30 | 30 | |
|
31 | 31 | |
|
32 | 32 | def __add__(self, other): |
@@ -46,7 +46,7 class nsTime: | |||
|
46 | 46 | addSec = int(nsResult / 1000000000) |
|
47 | 47 | self.second = self.second + other.second + addSec |
|
48 | 48 | self.nanosecond = nsResult % 1000000000 |
|
49 |
self.totalNS = |
|
|
49 | self.totalNS = int(self.nanosecond) + int(self.second) * 1000000000 | |
|
50 | 50 | |
|
51 | 51 | |
|
52 | 52 | def __sub__(self, other): |
@@ -65,8 +65,8 class nsTime: | |||
|
65 | 65 | def multiply(self, factor): |
|
66 | 66 | """multiply this nsTime times an integer |
|
67 | 67 | """ |
|
68 |
if type(factor) not in ( |
|
|
69 |
raise ValueError |
|
|
68 | if type(factor) not in (int, int): | |
|
69 | raise ValueError('Illegal type %s passed into nsTime.multiply' % (str(type(factor)))) | |
|
70 | 70 | newTotalNS = self.totalNS * factor |
|
71 | 71 | newSeconds = int(newTotalNS / 1000000000) |
|
72 | 72 | newNanoseconds = int(newTotalNS - (newSeconds * 1000000000)) |
@@ -85,7 +85,7 class nsTime: | |||
|
85 | 85 | def __mod__(self, other): |
|
86 | 86 | """__mod__ implements self % other. |
|
87 | 87 | """ |
|
88 |
if type(other) in ( |
|
|
88 | if type(other) in (int, int): | |
|
89 | 89 | return self.totalNS % other |
|
90 | 90 | else: |
|
91 | 91 | return self.totalNS % other.totalNS |
@@ -118,15 +118,15 class psTime: | |||
|
118 | 118 | def __init__(self, second, picosecond): |
|
119 | 119 | self.second = int(second) |
|
120 | 120 | if self.second < 0: |
|
121 |
raise ValueError |
|
|
122 |
picosecond = |
|
|
121 | raise ValueError('seconds must be greater than 0, not %i' % (self.second)) | |
|
122 | picosecond = int(picosecond) | |
|
123 | 123 | if picosecond < 0: |
|
124 |
raise ValueError |
|
|
124 | raise ValueError('picoseconds must be greater 0, not %i' % (picosecond)) | |
|
125 | 125 | addSec = picosecond / 1000000000000 |
|
126 | 126 | if addSec > 0: |
|
127 | 127 | self.second += addSec |
|
128 | 128 | self.picosecond = picosecond % 1000000000000 |
|
129 |
self.totalPS = |
|
|
129 | self.totalPS = int(self.picosecond) + int(self.second) * 1000000000000 | |
|
130 | 130 | |
|
131 | 131 | |
|
132 | 132 | def __add__(self, other): |
@@ -146,7 +146,7 class psTime: | |||
|
146 | 146 | addSec = int(psResult / 1000000000000) |
|
147 | 147 | self.second = self.second + other.second + addSec |
|
148 | 148 | self.picosecond = psResult % 1000000000000 |
|
149 |
self.totalPS = |
|
|
149 | self.totalPS = int(self.picosecond) + int(self.second) * 1000000000000 | |
|
150 | 150 | |
|
151 | 151 | |
|
152 | 152 | def __sub__(self, other): |
@@ -165,8 +165,8 class psTime: | |||
|
165 | 165 | def multiply(self, factor): |
|
166 | 166 | """multiply this psTime times an integer |
|
167 | 167 | """ |
|
168 |
if type(factor) not in ( |
|
|
169 |
raise ValueError |
|
|
168 | if type(factor) not in (int, int): | |
|
169 | raise ValueError('Illegal type %s passed into psTime.multiply' % (str(type(factor)))) | |
|
170 | 170 | newTotalPS = self.totalPS * factor |
|
171 | 171 | newSeconds = int(newTotalPS / 1000000000000) |
|
172 | 172 | newPicoseconds = int(newTotalPS - (newSeconds * 1000000000000)) |
@@ -185,7 +185,7 class psTime: | |||
|
185 | 185 | def __mod__(self, other): |
|
186 | 186 | """__mod__ implements self % other. |
|
187 | 187 | """ |
|
188 |
if type(other) in ( |
|
|
188 | if type(other) in (int, int): | |
|
189 | 189 | return self.totalPS % other |
|
190 | 190 | else: |
|
191 | 191 | return self.totalPS % other.totalPS |
@@ -208,4 +208,3 class psTime: | |||
|
208 | 208 | def __str__(self): |
|
209 | 209 | return '%d.%12d' % (self.second, self.picosecond) |
|
210 | 210 | |
|
211 |
@@ -82,16 +82,16 class YAMLSerializer(Serializer): | |||
|
82 | 82 | |
|
83 | 83 | # Regular expression taken from yaml.constructor.py |
|
84 | 84 | timestamp_regexp_str = str(\ |
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
85 | r'^(?P<year>[0-9][0-9][0-9][0-9])' | |
|
86 | r'-(?P<month>[0-9][0-9]?)' | |
|
87 | r'-(?P<day>[0-9][0-9]?)' | |
|
88 | r'(?:(?:[Tt]|[ \t]+)' | |
|
89 | r'(?P<hour>[0-9][0-9]?)' | |
|
90 | r':(?P<minute>[0-9][0-9])' | |
|
91 | r':(?P<second>[0-9][0-9])' | |
|
92 | r'(?:\.(?P<fraction>[0-9]*))?' | |
|
93 | r'(?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)' | |
|
94 | r'(?::(?P<tz_minute>[0-9][0-9]))?))?)?$') | |
|
95 | 95 | timestamp_regexp = re.compile(timestamp_regexp_str, re.X) |
|
96 | 96 | |
|
97 | 97 | def construct_timestamp(value): |
@@ -133,10 +133,10 class MessagePackSerializer(Serializer): | |||
|
133 | 133 | def __fromSerial(self, msg_dict): |
|
134 | 134 | if not isinstance(msg_dict, (dict, list, tuple)): |
|
135 | 135 | return msg_dict # msg_dict is a value - return it |
|
136 |
if isinstance(msg_dict, dict) and |
|
|
136 | if isinstance(msg_dict, dict) and '__meta_attributes' in msg_dict: | |
|
137 | 137 | meta_attr = msg_dict['__meta_attributes'] |
|
138 | 138 | msg_dict.pop('__meta_attributes') |
|
139 |
if |
|
|
139 | if 'type' in meta_attr: | |
|
140 | 140 | if meta_attr['type'] == 'datetime': |
|
141 | 141 | return construct_timestamp(str(msg_dict['ts'])) |
|
142 | 142 | elif meta_attr['type'] == 'nsTime': |
@@ -147,7 +147,7 class MessagePackSerializer(Serializer): | |||
|
147 | 147 | except KeyError: dtype = Lookup.builtin_objects[meta_attr['type']] |
|
148 | 148 | return dtype(**msg_dict) |
|
149 | 149 | else: |
|
150 | for key in msg_dict.keys(): | |
|
150 | for key in list(msg_dict.keys()): | |
|
151 | 151 | msg_dict[key] = self.__fromSerial(msg_dict[key]) |
|
152 | 152 | cls = Lookup.dynamicClasses['%s.%s'%(meta_attr['__object_name'],meta_attr['__revision_number'])] |
|
153 | 153 | return cls(**msg_dict) |
@@ -159,7 +159,7 class MessagePackSerializer(Serializer): | |||
|
159 | 159 | return np.frombuffer(value, dtype=Lookup.numpy_dtypes[msg_dict[1]])[0] |
|
160 | 160 | |
|
161 | 161 | tup = isinstance(msg_dict, tuple) |
|
162 | if tup and len(msg_dict) > 1 and msg_dict[0] in Lookup.numpy_dtypes.keys(): | |
|
162 | if tup and len(msg_dict) > 1 and msg_dict[0] in list(Lookup.numpy_dtypes.keys()): | |
|
163 | 163 | msg_flat = list(msg_dict) |
|
164 | 164 | dtypeName = msg_flat.pop(0) |
|
165 | 165 | dtype = Lookup.numpy_dtypes[dtypeName] |
@@ -192,7 +192,7 class MessagePackSerializer(Serializer): | |||
|
192 | 192 | return msg_dict |
|
193 | 193 | elif isinstance(obj, DynamicObject.Object): |
|
194 | 194 | msg_dict = {} |
|
195 | for key, value in obj.__dict__.items(): | |
|
195 | for key, value in list(obj.__dict__.items()): | |
|
196 | 196 | msg_dict[key] = self.__toSerial(value) |
|
197 | 197 | |
|
198 | 198 | msg_dict['__meta_attributes'] = obj.__class__.meta_attributes |
@@ -210,7 +210,7 class MessagePackSerializer(Serializer): | |||
|
210 | 210 | msg_flat.append(toSer) |
|
211 | 211 | return list(msg_flat) |
|
212 | 212 | |
|
213 | is_builtin = obj.__class__ in Lookup.numpy_dtypes.values() | |
|
213 | is_builtin = obj.__class__ in list(Lookup.numpy_dtypes.values()) | |
|
214 | 214 | #is_python = isinstance(obj, Lookup.python_dtypes) |
|
215 | 215 | if is_builtin: # and not is_python: |
|
216 | 216 | try: |
@@ -246,7 +246,7 class HDF5Serializer(Serializer): | |||
|
246 | 246 | if isinstance(grp, h5py.Dataset): |
|
247 | 247 | return grp.value |
|
248 | 248 | |
|
249 | elif isinstance(grp, h5py.Group) and '__type' in grp.keys(): | |
|
249 | elif isinstance(grp, h5py.Group) and '__type' in list(grp.keys()): | |
|
250 | 250 | typ = grp['__type'].value |
|
251 | 251 | if typ == 'datetime': |
|
252 | 252 | return construct_timestamp(str(grp['ts'].value)) |
@@ -259,7 +259,7 class HDF5Serializer(Serializer): | |||
|
259 | 259 | try: cls = Lookup.builtin_objects_simple[typ] |
|
260 | 260 | except KeyError: cls = Lookup.dynamicClasses[typ] |
|
261 | 261 | args = [] |
|
262 | for key in grp.keys(): | |
|
262 | for key in list(grp.keys()): | |
|
263 | 263 | fromSer = self.__fromSerial(grp[key]) |
|
264 | 264 | args.append((key, fromSer)) |
|
265 | 265 | kwargs = dict(args) |
@@ -299,7 +299,7 class HDF5Serializer(Serializer): | |||
|
299 | 299 | elif isinstance(obj, tuple(Lookup.builtin_objects_simple.values())): |
|
300 | 300 | sub_grp = grp.create_group(name) |
|
301 | 301 | sub_grp['__type'] = Lookup.obj_dtypes[obj.__class__] |
|
302 | for key, value in obj.__dict__.items(): | |
|
302 | for key, value in list(obj.__dict__.items()): | |
|
303 | 303 | if value != None and key not in ['totalNS', 'totalPS']: |
|
304 | 304 | sub_grp[key] = value |
|
305 | 305 | |
@@ -313,7 +313,7 class HDF5Serializer(Serializer): | |||
|
313 | 313 | tag = '%s.%s'%(obj.getObjectName(), obj.getRevisionNumber()) |
|
314 | 314 | sub_grp['__type'] = tag |
|
315 | 315 | # Put all of the DynamicObject's attributes into the new h5py group |
|
316 | for key, value in obj.__dict__.items(): | |
|
316 | for key, value in list(obj.__dict__.items()): | |
|
317 | 317 | self.__toSerial(value, sub_grp, key) |
|
318 | 318 | |
|
319 | 319 | elif isinstance(obj, tuple): |
@@ -356,7 +356,7 class jsonSerializer(Serializer): | |||
|
356 | 356 | #return json.dumps(string) |
|
357 | 357 | return jsonpickle.encode(string, max_depth=500) |
|
358 | 358 | |
|
359 | # Dict mapping from serializer type to corresponding class object: | |
|
359 | # Dict mapping from .serializer type to corresponding class object: | |
|
360 | 360 | serializers = {'yaml': YAMLSerializer, |
|
361 | 361 | 'msgpack': MessagePackSerializer, |
|
362 | 362 | 'hdf5': HDF5Serializer, |
@@ -367,7 +367,6 instances = {'yaml': YAMLSerializer(), | |||
|
367 | 367 | 'hdf5': HDF5Serializer(), |
|
368 | 368 | 'json': jsonSerializer()} |
|
369 | 369 | |
|
370 | serial_types = dict([(v,u) for u,v in serializers.items()]) | |
|
370 | serial_types = dict([(v,u) for u,v in list(serializers.items())]) | |
|
371 | 371 | |
|
372 | 372 | compression_types = ['gzip', ''] |
|
373 |
@@ -157,7 +157,7 datastr = serializer.toSerial(source_object) | |||
|
157 | 157 | |
|
158 | 158 | dest_object = serializer.fromSerial(datastr) |
|
159 | 159 | |
|
160 |
print |
|
|
160 | print("dest_object=",dest_object) | |
|
161 | 161 | |
|
162 | 162 | myObject = StateListObject(hierarchical="yes",state=np.array([1,2,3.0])) |
|
163 | 163 | |
@@ -168,7 +168,7 packed = msgpack.packb(datastr) | |||
|
168 | 168 | try: |
|
169 | 169 | r= redis.StrictRedis(host='localhost',port=6379,db=0) |
|
170 | 170 | except Exception as eobj: |
|
171 |
print |
|
|
171 | print("is the redis server running?",eobj) | |
|
172 | 172 | else: |
|
173 | 173 | |
|
174 | 174 | r.set('baz',packed) # converts to string |
@@ -178,10 +178,9 unpacked = msgpack.unpackb(x) | |||
|
178 | 178 | |
|
179 | 179 | dest_object = serializer.fromSerial(unpacked) |
|
180 | 180 | |
|
181 |
print |
|
|
181 | print("val1=",dest_object.hierarchical) | |
|
182 | 182 | val2 = dest_object.state |
|
183 |
print |
|
|
183 | print("val2=",val2) | |
|
184 | 184 | # can numpy array be used as array? |
|
185 |
print |
|
|
186 | ||
|
185 | print(val2.shape) | |
|
187 | 186 |
@@ -4,5 +4,5 $Author: murco $ | |||
|
4 | 4 | $Id: Processor.py 1 2012-11-12 18:56:07Z murco $ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | from jroutils_ftp import * | |
|
8 | from jroutils_publish import * | |
|
7 | from .jroutils_ftp import * | |
|
8 | from .jroutils_publish import * |
@@ -9,7 +9,7 try: | |||
|
9 | 9 | import paramiko |
|
10 | 10 | import scp |
|
11 | 11 | except: |
|
12 |
print |
|
|
12 | print("You should install paramiko and scp libraries \nif you want to use SSH protocol to upload files to the server") | |
|
13 | 13 | |
|
14 | 14 | import time |
|
15 | 15 | |
@@ -64,9 +64,9 class Remote(Thread): | |||
|
64 | 64 | |
|
65 | 65 | self.stopFlag = False |
|
66 | 66 | |
|
67 |
print |
|
|
67 | print("[Remote Server] Opening server: %s" %self.__server) | |
|
68 | 68 | if self.open(self.__server, self.__username, self.__password, self.__remotefolder): |
|
69 |
print |
|
|
69 | print("[Remote Server] %s server was opened successfully" %self.__server) | |
|
70 | 70 | |
|
71 | 71 | self.close() |
|
72 | 72 | |
@@ -81,31 +81,31 class Remote(Thread): | |||
|
81 | 81 | """ |
|
82 | 82 | Connect to server and create a connection class (FTP or SSH) to remote server. |
|
83 | 83 | """ |
|
84 |
raise NotImplementedError |
|
|
84 | raise NotImplementedError("Implement this method in child class") | |
|
85 | 85 | |
|
86 | 86 | def close(self): |
|
87 | 87 | """ |
|
88 | 88 | Close connection to server |
|
89 | 89 | """ |
|
90 |
raise NotImplementedError |
|
|
90 | raise NotImplementedError("Implement this method in child class") | |
|
91 | 91 | |
|
92 | 92 | def mkdir(self, remotefolder): |
|
93 | 93 | """ |
|
94 | 94 | Create a folder remotely |
|
95 | 95 | """ |
|
96 |
raise NotImplementedError |
|
|
96 | raise NotImplementedError("Implement this method in child class") | |
|
97 | 97 | |
|
98 | 98 | def cd(self, remotefolder): |
|
99 | 99 | """ |
|
100 | 100 | Change working directory in remote server |
|
101 | 101 | """ |
|
102 |
raise NotImplementedError |
|
|
102 | raise NotImplementedError("Implement this method in child class") | |
|
103 | 103 | |
|
104 | 104 | def download(self, filename, localfolder=None): |
|
105 | 105 | """ |
|
106 | 106 | Download a file from server to local host |
|
107 | 107 | """ |
|
108 |
raise NotImplementedError |
|
|
108 | raise NotImplementedError("Implement this method in child class") | |
|
109 | 109 | |
|
110 | 110 | def sendFile(self, fullfilename): |
|
111 | 111 | """ |
@@ -117,7 +117,7 class Remote(Thread): | |||
|
117 | 117 | Returns: |
|
118 | 118 | 0 in error case else 1 |
|
119 | 119 | """ |
|
120 |
raise NotImplementedError |
|
|
120 | raise NotImplementedError("Implement this method in child class") | |
|
121 | 121 | |
|
122 | 122 | def upload(self, fullfilename, remotefolder=None): |
|
123 | 123 | """ |
@@ -132,7 +132,7 class Remote(Thread): | |||
|
132 | 132 | Returns: |
|
133 | 133 | 0 in error case else 1 |
|
134 | 134 | """ |
|
135 |
print |
|
|
135 | print("[Remote Server] Uploading %s to %s:%s" %(fullfilename, self.server, self.remotefolder)) | |
|
136 | 136 | |
|
137 | 137 | if not self.status: |
|
138 | 138 | return 0 |
@@ -144,10 +144,10 class Remote(Thread): | |||
|
144 | 144 | return 0 |
|
145 | 145 | |
|
146 | 146 | if not self.sendFile(fullfilename): |
|
147 |
print |
|
|
147 | print("[Remote Server] Error uploading file %s" %fullfilename) | |
|
148 | 148 | return 0 |
|
149 | 149 | |
|
150 |
print |
|
|
150 | print("[Remote Server] upload finished successfully") | |
|
151 | 151 | |
|
152 | 152 | return 1 |
|
153 | 153 | |
@@ -180,11 +180,11 class Remote(Thread): | |||
|
180 | 180 | def run(self): |
|
181 | 181 | |
|
182 | 182 | if not self.status: |
|
183 |
print |
|
|
183 | print("Finishing FTP service") | |
|
184 | 184 | return |
|
185 | 185 | |
|
186 | 186 | if not self.cd(self.remotefolder): |
|
187 |
raise ValueError |
|
|
187 | raise ValueError("Could not access to the new remote directory: %s" %self.remotefolder) | |
|
188 | 188 | |
|
189 | 189 | while True: |
|
190 | 190 | |
@@ -199,7 +199,7 class Remote(Thread): | |||
|
199 | 199 | # self.bussy = True |
|
200 | 200 | self.mutex.acquire() |
|
201 | 201 | |
|
202 |
print |
|
|
202 | print("[Remote Server] Opening %s" %self.__server) | |
|
203 | 203 | if not self.open(self.__server, self.__username, self.__password, self.__remotefolder): |
|
204 | 204 | self.mutex.release() |
|
205 | 205 | continue |
@@ -207,13 +207,13 class Remote(Thread): | |||
|
207 | 207 | for thisFile in self.fileList: |
|
208 | 208 | self.upload(thisFile, self.remotefolder) |
|
209 | 209 | |
|
210 |
print |
|
|
210 | print("[Remote Server] Closing %s" %self.__server) | |
|
211 | 211 | self.close() |
|
212 | 212 | |
|
213 | 213 | self.mutex.release() |
|
214 | 214 | # self.bussy = False |
|
215 | 215 | |
|
216 |
print |
|
|
216 | print("[Remote Server] Thread stopped successfully") | |
|
217 | 217 | |
|
218 | 218 | class FTPClient(Remote): |
|
219 | 219 | |
@@ -247,29 +247,29 class FTPClient(Remote): | |||
|
247 | 247 | """ |
|
248 | 248 | |
|
249 | 249 | if server == None: |
|
250 |
raise ValueError |
|
|
250 | raise ValueError("FTP server should be defined") | |
|
251 | 251 | |
|
252 | 252 | if username == None: |
|
253 |
raise ValueError |
|
|
253 | raise ValueError("FTP username should be defined") | |
|
254 | 254 | |
|
255 | 255 | if password == None: |
|
256 |
raise ValueError |
|
|
256 | raise ValueError("FTP password should be defined") | |
|
257 | 257 | |
|
258 | 258 | if remotefolder == None: |
|
259 |
raise ValueError |
|
|
259 | raise ValueError("FTP remote folder should be defined") | |
|
260 | 260 | |
|
261 | 261 | try: |
|
262 | 262 | ftpClientObj = ftplib.FTP(server) |
|
263 |
except ftplib.all_errors |
|
|
264 |
print |
|
|
265 |
print |
|
|
263 | except ftplib.all_errors as e: | |
|
264 | print("[FTP Server]: FTP server connection fail: %s" %server) | |
|
265 | print("[FTP Server]:", e) | |
|
266 | 266 | self.status = 0 |
|
267 | 267 | return 0 |
|
268 | 268 | |
|
269 | 269 | try: |
|
270 | 270 | ftpClientObj.login(username, password) |
|
271 | 271 | except ftplib.all_errors: |
|
272 |
print |
|
|
272 | print("[FTP Server]: FTP username or password are incorrect") | |
|
273 | 273 | self.status = 0 |
|
274 | 274 | return 0 |
|
275 | 275 | |
@@ -279,7 +279,7 class FTPClient(Remote): | |||
|
279 | 279 | try: |
|
280 | 280 | ftpClientObj.cwd(remotefolder) |
|
281 | 281 | except ftplib.all_errors: |
|
282 |
print |
|
|
282 | print("[FTP Server]: FTP remote folder is invalid: %s" %remotefolder) | |
|
283 | 283 | remotefolder = ftpClientObj.pwd() |
|
284 | 284 | |
|
285 | 285 | self.server = server |
@@ -316,7 +316,7 class FTPClient(Remote): | |||
|
316 | 316 | try: |
|
317 | 317 | self.__ftpClientObj.mkd(dirname) |
|
318 | 318 | except ftplib.all_errors: |
|
319 |
print |
|
|
319 | print("[FTP Server]: Error creating remote folder: %s" %remotefolder) | |
|
320 | 320 | return 0 |
|
321 | 321 | |
|
322 | 322 | return 1 |
@@ -343,11 +343,11 class FTPClient(Remote): | |||
|
343 | 343 | try: |
|
344 | 344 | self.__ftpClientObj.cwd(remotefolder) |
|
345 | 345 | except ftplib.all_errors: |
|
346 |
print |
|
|
347 |
print |
|
|
346 | print('[FTP Server]: Error changing to %s' %remotefolder) | |
|
347 | print('[FTP Server]: Trying to create remote folder') | |
|
348 | 348 | |
|
349 | 349 | if not self.mkdir(remotefolder): |
|
350 |
print |
|
|
350 | print('[FTP Server]: Remote folder could not be created') | |
|
351 | 351 | return 0 |
|
352 | 352 | |
|
353 | 353 | try: |
@@ -372,14 +372,14 class FTPClient(Remote): | |||
|
372 | 372 | |
|
373 | 373 | try: |
|
374 | 374 | self.__ftpClientObj.storbinary(command, fp) |
|
375 |
except ftplib.all_errors |
|
|
376 |
print |
|
|
375 | except ftplib.all_errors as e: | |
|
376 | print("[FTP Server]:", e) | |
|
377 | 377 | return 0 |
|
378 | 378 | |
|
379 | 379 | try: |
|
380 | 380 | self.__ftpClientObj.sendcmd('SITE CHMOD 755 ' + filename) |
|
381 |
except ftplib.all_errors |
|
|
382 |
print |
|
|
381 | except ftplib.all_errors as e: | |
|
382 | print("[FTP Server]:", e) | |
|
383 | 383 | |
|
384 | 384 | fp.close() |
|
385 | 385 | |
@@ -418,16 +418,16 class SSHClient(Remote): | |||
|
418 | 418 | import socket |
|
419 | 419 | |
|
420 | 420 | if server == None: |
|
421 |
raise ValueError |
|
|
421 | raise ValueError("SSH server should be defined") | |
|
422 | 422 | |
|
423 | 423 | if username == None: |
|
424 |
raise ValueError |
|
|
424 | raise ValueError("SSH username should be defined") | |
|
425 | 425 | |
|
426 | 426 | if password == None: |
|
427 |
raise ValueError |
|
|
427 | raise ValueError("SSH password should be defined") | |
|
428 | 428 | |
|
429 | 429 | if remotefolder == None: |
|
430 |
raise ValueError |
|
|
430 | raise ValueError("SSH remote folder should be defined") | |
|
431 | 431 | |
|
432 | 432 | sshClientObj = paramiko.SSHClient() |
|
433 | 433 | |
@@ -437,16 +437,16 class SSHClient(Remote): | |||
|
437 | 437 | self.status = 0 |
|
438 | 438 | try: |
|
439 | 439 | sshClientObj.connect(server, username=username, password=password, port=port) |
|
440 |
except paramiko.AuthenticationException |
|
|
440 | except paramiko.AuthenticationException as e: | |
|
441 | 441 | # print "SSH username or password are incorrect: %s" |
|
442 |
print |
|
|
442 | print("[SSH Server]:", e) | |
|
443 | 443 | return 0 |
|
444 |
except SSHException |
|
|
445 |
print |
|
|
444 | except SSHException as e: | |
|
445 | print("[SSH Server]:", e) | |
|
446 | 446 | return 0 |
|
447 | 447 | except socket.error: |
|
448 | 448 | self.status = 0 |
|
449 |
print |
|
|
449 | print("[SSH Server]:", e) | |
|
450 | 450 | return 0 |
|
451 | 451 | |
|
452 | 452 | self.status = 1 |
@@ -463,7 +463,7 class SSHClient(Remote): | |||
|
463 | 463 | self.status = 1 |
|
464 | 464 | |
|
465 | 465 | if not self.cd(remotefolder): |
|
466 |
raise ValueError |
|
|
466 | raise ValueError("[SSH Server]: Could not access to remote folder: %s" %remotefolder) | |
|
467 | 467 | return 0 |
|
468 | 468 | |
|
469 | 469 | self.remotefolder = remotefolder |
@@ -564,8 +564,8 class SSHClient(Remote): | |||
|
564 | 564 | |
|
565 | 565 | try: |
|
566 | 566 | self.__scpClientObj.put(fullfilename, remote_path=self.remotefolder) |
|
567 |
except scp.ScpError |
|
|
568 |
print |
|
|
567 | except scp.ScpError as e: | |
|
568 | print("[SSH Server]", str(e)) | |
|
569 | 569 | return 0 |
|
570 | 570 | |
|
571 | 571 | remotefile = os.path.join(self.remotefolder, os.path.split(fullfilename)[-1]) |
@@ -596,7 +596,7 class SendToServer(ProcessingUnit): | |||
|
596 | 596 | self.clientObj = SSHClient(server, username, password, remotefolder, period) |
|
597 | 597 | |
|
598 | 598 | if not self.clientObj: |
|
599 |
raise ValueError |
|
|
599 | raise ValueError("%s has been chosen as remote access protocol but it is not valid" %protocol) | |
|
600 | 600 | |
|
601 | 601 | self.clientObj.start() |
|
602 | 602 | |
@@ -614,7 +614,7 class SendToServer(ProcessingUnit): | |||
|
614 | 614 | |
|
615 | 615 | for thisFolder in folderList: |
|
616 | 616 | |
|
617 |
print |
|
|
617 | print("[Remote Server]: Searching files on %s" %thisFolder) | |
|
618 | 618 | |
|
619 | 619 | filenameList = glob.glob1(thisFolder, '*%s' %self.ext) |
|
620 | 620 | |
@@ -643,18 +643,18 class SendToServer(ProcessingUnit): | |||
|
643 | 643 | self.isConfig = True |
|
644 | 644 | |
|
645 | 645 | if not self.clientObj.is_alive(): |
|
646 |
print |
|
|
646 | print("[Remote Server]: Restarting connection ") | |
|
647 | 647 | self.setup(**kwargs) |
|
648 | 648 | |
|
649 | 649 | if time.time() - self.init >= self.period: |
|
650 | 650 | fullfilenameList = self.findFiles() |
|
651 | 651 | |
|
652 | 652 | if self.clientObj.updateFileList(fullfilenameList): |
|
653 |
print |
|
|
653 | print("[Remote Server]: Sending the next files ", str(fullfilenameList)) | |
|
654 | 654 | self.init = time.time() |
|
655 | 655 | |
|
656 | 656 | def close(self): |
|
657 |
print |
|
|
657 | print("[Remote Server] Stopping thread") | |
|
658 | 658 | self.clientObj.stop() |
|
659 | 659 | |
|
660 | 660 | |
@@ -710,7 +710,7 class FTP(object): | |||
|
710 | 710 | # print 'Connect to FTP Server: Successfully' |
|
711 | 711 | |
|
712 | 712 | except ftplib.all_errors: |
|
713 |
print |
|
|
713 | print('Error FTP Service') | |
|
714 | 714 | self.status = 1 |
|
715 | 715 | return |
|
716 | 716 | |
@@ -721,14 +721,14 class FTP(object): | |||
|
721 | 721 | try: |
|
722 | 722 | self.dirList = self.ftp.nlst() |
|
723 | 723 | |
|
724 |
except ftplib.error_perm |
|
|
724 | except ftplib.error_perm as resp: | |
|
725 | 725 | if str(resp) == "550 No files found": |
|
726 |
print |
|
|
726 | print("no files in this directory") | |
|
727 | 727 | self.status = 1 |
|
728 | 728 | return |
|
729 | 729 | |
|
730 | 730 | except ftplib.all_errors: |
|
731 |
print |
|
|
731 | print('Error Displaying Dir-Files') | |
|
732 | 732 | self.status = 1 |
|
733 | 733 | return |
|
734 | 734 | |
@@ -763,7 +763,7 class FTP(object): | |||
|
763 | 763 | try: |
|
764 | 764 | self.ftp.mkd(dirname) |
|
765 | 765 | except: |
|
766 |
print |
|
|
766 | print('Error creating remote folder:%s'%dirname) | |
|
767 | 767 | return 1 |
|
768 | 768 | |
|
769 | 769 | return 0 |
@@ -783,7 +783,7 class FTP(object): | |||
|
783 | 783 | try: |
|
784 | 784 | self.ftp.delete(filename) |
|
785 | 785 | except: |
|
786 |
print |
|
|
786 | print('Error deleting remote file:%s'%filename) | |
|
787 | 787 | return 1 |
|
788 | 788 | |
|
789 | 789 | return 0 |
@@ -805,7 +805,7 class FTP(object): | |||
|
805 | 805 | |
|
806 | 806 | |
|
807 | 807 | if not(filename in self.fileList): |
|
808 |
print |
|
|
808 | print('filename:%s not exists'%filename) | |
|
809 | 809 | self.status = 1 |
|
810 | 810 | return self.status |
|
811 | 811 | |
@@ -814,11 +814,11 class FTP(object): | |||
|
814 | 814 | self.file = open(newfilename, 'wb') |
|
815 | 815 | |
|
816 | 816 | try: |
|
817 |
print |
|
|
817 | print('Download: ' + filename) | |
|
818 | 818 | self.ftp.retrbinary('RETR ' + filename, self.__handleDownload) |
|
819 |
print |
|
|
819 | print('Download Complete') | |
|
820 | 820 | except ftplib.all_errors: |
|
821 |
print |
|
|
821 | print('Error Downloading ' + filename) | |
|
822 | 822 | self.status = 1 |
|
823 | 823 | return self.status |
|
824 | 824 | |
@@ -861,12 +861,12 class FTP(object): | |||
|
861 | 861 | |
|
862 | 862 | command = "STOR " + tail |
|
863 | 863 | |
|
864 |
print |
|
|
864 | print('Uploading: ' + tail) | |
|
865 | 865 | self.ftp.storbinary(command, self.file) |
|
866 |
print |
|
|
866 | print('Upload Completed') | |
|
867 | 867 | |
|
868 | 868 | except ftplib.all_errors: |
|
869 |
print |
|
|
869 | print('Error Uploading ' + tail) | |
|
870 | 870 | self.status = 1 |
|
871 | 871 | return self.status |
|
872 | 872 | |
@@ -895,11 +895,11 class FTP(object): | |||
|
895 | 895 | """ |
|
896 | 896 | |
|
897 | 897 | self.remotefolder = remotefolder |
|
898 |
print |
|
|
898 | print('Change to ' + self.remotefolder) | |
|
899 | 899 | try: |
|
900 | 900 | self.ftp.cwd(remotefolder) |
|
901 | 901 | except ftplib.all_errors: |
|
902 |
print |
|
|
902 | print('Error Change to ' + self.remotefolder) | |
|
903 | 903 | infoList = None |
|
904 | 904 | self.folderList = None |
|
905 | 905 | return infoList,self.folderList |
@@ -909,14 +909,14 class FTP(object): | |||
|
909 | 909 | try: |
|
910 | 910 | self.dirList = self.ftp.nlst() |
|
911 | 911 | |
|
912 |
except ftplib.error_perm |
|
|
912 | except ftplib.error_perm as resp: | |
|
913 | 913 | if str(resp) == "550 No files found": |
|
914 |
print |
|
|
914 | print("no files in this directory") | |
|
915 | 915 | infoList = None |
|
916 | 916 | self.folderList = None |
|
917 | 917 | return infoList,self.folderList |
|
918 | 918 | except ftplib.all_errors: |
|
919 |
print |
|
|
919 | print('Error Displaying Dir-Files') | |
|
920 | 920 | infoList = None |
|
921 | 921 | self.folderList = None |
|
922 | 922 | return infoList,self.folderList |
@@ -957,8 +957,8 class SendByFTP(Operation): | |||
|
957 | 957 | |
|
958 | 958 | def error_print(self, ValueError): |
|
959 | 959 | |
|
960 |
print |
|
|
961 |
print |
|
|
960 | print(ValueError, 'Error FTP') | |
|
961 | print("don't worry the program is running...") | |
|
962 | 962 | |
|
963 | 963 | def worker_ftp(self, server, username, password, remotefolder, filenameList): |
|
964 | 964 | |
@@ -981,7 +981,7 class SendByFTP(Operation): | |||
|
981 | 981 | if p.is_alive(): |
|
982 | 982 | p.terminate() |
|
983 | 983 | p.join() |
|
984 |
print |
|
|
984 | print('killing ftp process...') | |
|
985 | 985 | self.status = 0 |
|
986 | 986 | return |
|
987 | 987 | |
@@ -1005,4 +1005,4 class SendByFTP(Operation): | |||
|
1005 | 1005 | |
|
1006 | 1006 | self.counter = 0 |
|
1007 | 1007 | |
|
1008 |
self.status = 1 |
|
|
1008 | self.status = 1 No newline at end of file |
@@ -56,7 +56,7 def get_plot_code(s): | |||
|
56 | 56 | |
|
57 | 57 | def roundFloats(obj): |
|
58 | 58 | if isinstance(obj, list): |
|
59 | return map(roundFloats, obj) | |
|
59 | return list(map(roundFloats, obj)) | |
|
60 | 60 | elif isinstance(obj, float): |
|
61 | 61 | return round(obj, 2) |
|
62 | 62 | |
@@ -241,7 +241,7 class Data(object): | |||
|
241 | 241 | H.sort() |
|
242 | 242 | for key in self.data: |
|
243 | 243 | shape = self.shape(key)[:-1] + H.shape |
|
244 | for tm, obj in self.data[key].items(): | |
|
244 | for tm, obj in list(self.data[key].items()): | |
|
245 | 245 | h = self.__heights[self.__times.index(tm)] |
|
246 | 246 | if H.size == h.size: |
|
247 | 247 | continue |
@@ -285,7 +285,7 class Data(object): | |||
|
285 | 285 | else: |
|
286 | 286 | ret['pairs'] = [] |
|
287 | 287 | |
|
288 | for key, value in self.meta.items(): | |
|
288 | for key, value in list(self.meta.items()): | |
|
289 | 289 | ret[key] = value |
|
290 | 290 | |
|
291 | 291 | return json.dumps(ret) |
@@ -460,7 +460,7 class PublishData(Operation): | |||
|
460 | 460 | 'yData': yData |
|
461 | 461 | } |
|
462 | 462 | else: |
|
463 |
print |
|
|
463 | print("Tipo de grafico invalido") | |
|
464 | 464 | payload = { |
|
465 | 465 | 'data': 'None', |
|
466 | 466 | 'timestamp': 'None', |
@@ -805,7 +805,7 class SendToFTP(Operation, Process): | |||
|
805 | 805 | |
|
806 | 806 | try: |
|
807 | 807 | self.ftp.storbinary(command, fp, blocksize=1024) |
|
808 |
except Exception |
|
|
808 | except Exception as e: | |
|
809 | 809 | log.error('{}'.format(e), self.name) |
|
810 | 810 | if self.ftp is not None: |
|
811 | 811 | self.ftp.close() |
@@ -814,7 +814,7 class SendToFTP(Operation, Process): | |||
|
814 | 814 | |
|
815 | 815 | try: |
|
816 | 816 | self.ftp.sendcmd('SITE CHMOD 755 {}'.format(dst)) |
|
817 |
except Exception |
|
|
817 | except Exception as e: | |
|
818 | 818 | log.error('{}'.format(e), self.name) |
|
819 | 819 | if self.ftp is not None: |
|
820 | 820 | self.ftp.close() |
@@ -866,4 +866,4 class SendToFTP(Operation, Process): | |||
|
866 | 866 | |
|
867 | 867 | if self.ftp is not None: |
|
868 | 868 | self.ftp.close() |
|
869 |
self.terminate() |
|
|
869 | self.terminate() No newline at end of file |
@@ -63,9 +63,9 def formatArgs(op): | |||
|
63 | 63 | argsAsKey = ["\t'{}'".format(x) for x in args] |
|
64 | 64 | argsFormatted = ": 'string',\n".join(argsAsKey) |
|
65 | 65 | |
|
66 |
print |
|
|
67 |
print |
|
|
68 |
print |
|
|
66 | print(op) | |
|
67 | print("parameters = { \n" + argsFormatted + ": 'string',\n }") | |
|
68 | print('\n') | |
|
69 | 69 | |
|
70 | 70 | |
|
71 | 71 | if __name__ == "__main__": |
@@ -103,8 +103,8 def printSpeed(deltaTime, mySerial): | |||
|
103 | 103 | size = len(mySerial)/1024. |
|
104 | 104 | vel = 1.0*size / deltaTime |
|
105 | 105 | |
|
106 |
print |
|
|
107 |
print |
|
|
106 | print("Index [", replayerObj.getProfileIndex(), "]: ", end=' ') | |
|
107 | print("Total time %5.2f ms, Data size %5.2f KB, Speed %5.2f MB/s" %(deltaTime, size, vel)) | |
|
108 | 108 | #################### |
|
109 | 109 | |
|
110 | 110 | if __name__ == '__main__': |
@@ -131,7 +131,7 if __name__ == '__main__': | |||
|
131 | 131 | deltaTime = (time.time() - ini)*1024 |
|
132 | 132 | |
|
133 | 133 | if not mySerialData: |
|
134 |
print |
|
|
134 | print("No more data") | |
|
135 | 135 | break |
|
136 | 136 | |
|
137 | 137 | # myDataDict = SERIALIZER.loads(mySerialData) |
@@ -10,4 +10,4 if __name__ == '__main__': | |||
|
10 | 10 | c = zerorpc.Client() |
|
11 | 11 | c.connect("tcp://127.0.0.1:4242") |
|
12 | 12 | c.load("file2") # AAAHH! The previously loaded model gets overwritten here! |
|
13 |
print |
|
|
13 | print(c.getModelName()) No newline at end of file |
@@ -25,9 +25,9 if __name__ == '__main__': | |||
|
25 | 25 | |
|
26 | 26 | replayerObj.start() |
|
27 | 27 | |
|
28 |
print |
|
|
28 | print("Initializing 'zerorpc' server") | |
|
29 | 29 | s = zerorpc.Server(replayerObj) |
|
30 | 30 | s.bind("tcp://0.0.0.0:4242") |
|
31 | 31 | s.run() |
|
32 | 32 | |
|
33 |
print |
|
|
33 | print("End") No newline at end of file |
@@ -22,7 +22,7 def isDictFormat(thisValue): | |||
|
22 | 22 | if type(thisValue) != type({}): |
|
23 | 23 | return False |
|
24 | 24 | |
|
25 | if '__name__' not in thisValue.keys(): | |
|
25 | if '__name__' not in list(thisValue.keys()): | |
|
26 | 26 | return False |
|
27 | 27 | |
|
28 | 28 | return True |
@@ -33,7 +33,7 def obj2Dict(myObj): | |||
|
33 | 33 | |
|
34 | 34 | myDict['__name__'] = myObj.__class__.__name__ |
|
35 | 35 | |
|
36 | for thisKey, thisValue in myObj.__dict__.items(): | |
|
36 | for thisKey, thisValue in list(myObj.__dict__.items()): | |
|
37 | 37 | |
|
38 | 38 | if isNotClassVar(thisValue): |
|
39 | 39 | myDict[thisKey] = thisValue |
@@ -49,14 +49,14 def dict2Obj(myDict): | |||
|
49 | 49 | ''' |
|
50 | 50 | ''' |
|
51 | 51 | |
|
52 | if '__name__' not in myDict.keys(): | |
|
52 | if '__name__' not in list(myDict.keys()): | |
|
53 | 53 | return None |
|
54 | 54 | |
|
55 | 55 | className = eval(myDict['__name__']) |
|
56 | 56 | |
|
57 | 57 | myObj = className() |
|
58 | 58 | |
|
59 | for thisKey, thisValue in myDict.items(): | |
|
59 | for thisKey, thisValue in list(myDict.items()): | |
|
60 | 60 | |
|
61 | 61 | if thisKey == '__name__': |
|
62 | 62 | continue |
@@ -129,7 +129,7 def myMsgPackTest(): | |||
|
129 | 129 | x_enc = m.encode(x) |
|
130 | 130 | x_rec = m.decode(x_enc) |
|
131 | 131 | |
|
132 |
print |
|
|
132 | print(x_rec) | |
|
133 | 133 | # |
|
134 | 134 | # x_enc = msgpack.packb(x, default=m.encoder) |
|
135 | 135 | # x_rec = msgpack.unpackb(x_enc, object_hook=m.decoder) |
@@ -159,19 +159,19 if __name__ == '__main__': | |||
|
159 | 159 | # print myNewObj.__dict__ |
|
160 | 160 | |
|
161 | 161 | # sys.exit() |
|
162 |
print |
|
|
162 | print(myDict) | |
|
163 | 163 | |
|
164 | 164 | newSerial = serializerObj.encode(myDict) |
|
165 | 165 | # print newSerial |
|
166 | 166 | |
|
167 | 167 | newDict = serializerObj.decode(newSerial) |
|
168 |
print |
|
|
168 | print(newDict) | |
|
169 | 169 | |
|
170 | 170 | myNewObj = dict2Obj(newDict) |
|
171 | 171 | |
|
172 | ||
|
173 | ||
|
174 |
print |
|
|
175 |
print |
|
|
176 |
print |
|
|
172 | print() | |
|
173 | print() | |
|
174 | print(50*'###') | |
|
175 | print(myTestObj.__dict__) | |
|
176 | print(myNewObj.__dict__) | |
|
177 | 177 | No newline at end of file |
@@ -5,7 +5,7 Created on Jul 15, 2014 | |||
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | import sys |
|
8 |
import |
|
|
8 | import pickle | |
|
9 | 9 | |
|
10 | 10 | from schainpy.model.data.jrodata import Voltage |
|
11 | 11 | # from schainpy.model.io.jrodataIO import USRPReaderMP |
@@ -37,10 +37,10 if __name__ == "__main__": | |||
|
37 | 37 | # print newValue |
|
38 | 38 | |
|
39 | 39 | |
|
40 |
print |
|
|
41 |
print |
|
|
42 |
newSerialized = |
|
|
40 | print('###########CPICKLE##################') | |
|
41 | print(myDict) | |
|
42 | newSerialized = pickle.dumps(myDict, 2) | |
|
43 | 43 | # print newValue |
|
44 | 44 | |
|
45 |
newDict = |
|
|
46 |
print |
|
|
45 | newDict = pickle.loads(newSerialized) | |
|
46 | print(newDict) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now