##// END OF EJS Templates
Add __attrs__ attribute to Process clasess to improve CLI finder
Juan C. Espinoza -
r1097:fefd86c58472
parent child
Show More
@@ -47,6 +47,10 class PlotData(Operation, Process):
47 __MAXNUMX = 80
47 __MAXNUMX = 80
48 __missing = 1E30
48 __missing = 1E30
49
49
50 __attrs__ = ['show', 'save', 'xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax',
51 'zlimits', 'xlabel', 'ylabel', 'cb_label', 'title', 'titles', 'colorbar',
52 'bgcolor', 'width', 'height', 'localtime', 'oneFigure', 'showprofile']
53
50 def __init__(self, **kwargs):
54 def __init__(self, **kwargs):
51
55
52 Operation.__init__(self, plot=True, **kwargs)
56 Operation.__init__(self, plot=True, **kwargs)
@@ -380,7 +384,7 class PlotData(Operation, Process):
380 [tick.set_visible(False)
384 [tick.set_visible(False)
381 for tick in self.pf_axes[n].get_yticklabels()]
385 for tick in self.pf_axes[n].get_yticklabels()]
382 if self.colorbar:
386 if self.colorbar:
383 ax.cbar = plt.colorbar(ax.plt, ax=ax, fraction=0.1, pad=0.02, aspect=10)
387 ax.cbar = plt.colorbar(ax.plt, ax=ax, fraction=0.05, pad=0.02, aspect=10)
384 ax.cbar.ax.tick_params(labelsize=8)
388 ax.cbar.ax.tick_params(labelsize=8)
385 ax.cbar.ax.press = None
389 ax.cbar.ax.press = None
386 if self.cb_label:
390 if self.cb_label:
@@ -553,6 +553,9 class JRODataIO:
553 return dtype_width
553 return dtype_width
554
554
555 def getAllowedArgs(self):
555 def getAllowedArgs(self):
556 if hasattr(self, '__attrs__'):
557 return self.__attrs__
558 else:
556 return inspect.getargspec(self.run).args
559 return inspect.getargspec(self.run).args
557
560
558
561
@@ -514,9 +514,7 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa
514 self.profileIndex = 1 # Always
514 self.profileIndex = 1 # Always
515 self.dataOut.flagNoData = False
515 self.dataOut.flagNoData = False
516 self.dataOut.nRdPairs = 0
516 self.dataOut.nRdPairs = 0
517 self.dataOut.pairsList = []
518 self.dataOut.data_spc = None
517 self.dataOut.data_spc = None
519 self.dataOut.noise = []
520 self.dataOut.velocityX = []
518 self.dataOut.velocityX = []
521 self.dataOut.velocityY = []
519 self.dataOut.velocityY = []
522 self.dataOut.velocityV = []
520 self.dataOut.velocityV = []
@@ -495,16 +495,13 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
495 self.profileIndex = 1 # Always
495 self.profileIndex = 1 # Always
496 self.dataOut.flagNoData = False
496 self.dataOut.flagNoData = False
497 self.dataOut.nRdPairs = 0
497 self.dataOut.nRdPairs = 0
498 self.dataOut.pairsList = []
499 self.dataOut.data_spc = None
498 self.dataOut.data_spc = None
500
501 self.dataOut.normFactor = 1
502 self.nextfileflag = True
499 self.nextfileflag = True
503 self.dataOut.RadarConst = 0
500 self.dataOut.RadarConst = 0
504 self.dataOut.HSDV = []
501 self.dataOut.HSDV = []
505 self.dataOut.NPW = []
502 self.dataOut.NPW = []
506 self.dataOut.COFA = []
503 self.dataOut.COFA = []
507 self.dataOut.noise = 0
504 # self.dataOut.noise = 0
508
505
509 def Files2Read(self, fp):
506 def Files2Read(self, fp):
510 '''
507 '''
@@ -588,6 +585,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
588 self.dataOut.noise = self.dataOut.getNoise()
585 self.dataOut.noise = self.dataOut.getNoise()
589 # print 'ACAAAAAA', self.dataOut.noise
586 # print 'ACAAAAAA', self.dataOut.noise
590 self.dataOut.data_spc = self.dataOut.data_spc + self.dataOut.noise
587 self.dataOut.data_spc = self.dataOut.data_spc + self.dataOut.noise
588 self.dataOut.normFactor = 1
591 # print 'self.dataOut.noise',self.dataOut.noise
589 # print 'self.dataOut.noise',self.dataOut.noise
592
590
593 return self.dataOut.data_spc
591 return self.dataOut.data_spc
@@ -71,6 +71,9 class ProcessingUnit(object):
71 checkKwargs(self.run, kwargs)
71 checkKwargs(self.run, kwargs)
72
72
73 def getAllowedArgs(self):
73 def getAllowedArgs(self):
74 if hasattr(self, '__attrs__'):
75 return self.__attrs__
76 else:
74 return inspect.getargspec(self.run).args
77 return inspect.getargspec(self.run).args
75
78
76 def addOperationKwargs(self, objId, **kwargs):
79 def addOperationKwargs(self, objId, **kwargs):
@@ -318,6 +321,9 class Operation(object):
318 checkKwargs(self.run, kwargs)
321 checkKwargs(self.run, kwargs)
319
322
320 def getAllowedArgs(self):
323 def getAllowedArgs(self):
324 if hasattr(self, '__attrs__'):
325 return self.__attrs__
326 else:
321 return inspect.getargspec(self.run).args
327 return inspect.getargspec(self.run).args
322
328
323 def setup(self):
329 def setup(self):
@@ -250,6 +250,8 class PublishData(Operation):
250 Operation to send data over zmq.
250 Operation to send data over zmq.
251 '''
251 '''
252
252
253 __attrs__ = ['host', 'port', 'delay', 'zeromq', 'mqtt', 'verbose']
254
253 def __init__(self, **kwargs):
255 def __init__(self, **kwargs):
254 """Inicio."""
256 """Inicio."""
255 Operation.__init__(self, **kwargs)
257 Operation.__init__(self, **kwargs)
@@ -434,6 +436,8 class PublishData(Operation):
434
436
435 class ReceiverData(ProcessingUnit):
437 class ReceiverData(ProcessingUnit):
436
438
439 __attrs__ = ['server']
440
437 def __init__(self, **kwargs):
441 def __init__(self, **kwargs):
438
442
439 ProcessingUnit.__init__(self, **kwargs)
443 ProcessingUnit.__init__(self, **kwargs)
@@ -472,6 +476,7 class ReceiverData(ProcessingUnit):
472 class PlotterReceiver(ProcessingUnit, Process):
476 class PlotterReceiver(ProcessingUnit, Process):
473
477
474 throttle_value = 5
478 throttle_value = 5
479 __attrs__ = ['server', 'plottypes', 'realtime', 'localtime', 'throttle']
475
480
476 def __init__(self, **kwargs):
481 def __init__(self, **kwargs):
477
482
@@ -1,6 +1,5
1 import schainpy
1 import schainpy
2 from schainpy.model import Operation, ProcessingUnit
2 from schainpy.model import Operation, ProcessingUnit
3 from importlib import import_module
4 from pydoc import locate
3 from pydoc import locate
5
4
6 def clean_modules(module):
5 def clean_modules(module):
@@ -21,7 +20,7 def check_module(possible, instance):
21
20
22
21
23 def getProcs():
22 def getProcs():
24 module = dir(import_module('schainpy.model'))
23 module = dir(schainpy.model)
25 procs = check_module(module, ProcessingUnit)
24 procs = check_module(module, ProcessingUnit)
26 try:
25 try:
27 procs.remove('ProcessingUnit')
26 procs.remove('ProcessingUnit')
@@ -30,7 +29,7 def getProcs():
30 return procs
29 return procs
31
30
32 def getOperations():
31 def getOperations():
33 module = dir(import_module('schainpy.model'))
32 module = dir(schainpy.model)
34 noProcs = [x for x in module if not x.endswith('Proc')]
33 noProcs = [x for x in module if not x.endswith('Proc')]
35 operations = check_module(noProcs, Operation)
34 operations = check_module(noProcs, Operation)
36 try:
35 try:
@@ -53,7 +52,7 def getArgs(op):
53 return args
52 return args
54
53
55 def getAll():
54 def getAll():
56 allModules = dir(import_module('schainpy.model'))
55 allModules = dir(schainpy.model)
57 modules = check_module(allModules, Operation)
56 modules = check_module(allModules, Operation)
58 modules.extend(check_module(allModules, ProcessingUnit))
57 modules.extend(check_module(allModules, ProcessingUnit))
59 return modules
58 return modules
General Comments 0
You need to be logged in to leave comments. Login now