##// 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 47 __MAXNUMX = 80
48 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 54 def __init__(self, **kwargs):
51 55
52 56 Operation.__init__(self, plot=True, **kwargs)
@@ -380,7 +384,7 class PlotData(Operation, Process):
380 384 [tick.set_visible(False)
381 385 for tick in self.pf_axes[n].get_yticklabels()]
382 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 388 ax.cbar.ax.tick_params(labelsize=8)
385 389 ax.cbar.ax.press = None
386 390 if self.cb_label:
@@ -553,7 +553,10 class JRODataIO:
553 553 return dtype_width
554 554
555 555 def getAllowedArgs(self):
556 return inspect.getargspec(self.run).args
556 if hasattr(self, '__attrs__'):
557 return self.__attrs__
558 else:
559 return inspect.getargspec(self.run).args
557 560
558 561
559 562 class JRODataReader(JRODataIO):
@@ -513,10 +513,8 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODa
513 513 self.dataOut = Spectra()
514 514 self.profileIndex = 1 # Always
515 515 self.dataOut.flagNoData = False
516 self.dataOut.nRdPairs = 0
517 self.dataOut.pairsList = []
518 self.dataOut.data_spc = None
519 self.dataOut.noise = []
516 self.dataOut.nRdPairs = 0
517 self.dataOut.data_spc = None
520 518 self.dataOut.velocityX = []
521 519 self.dataOut.velocityY = []
522 520 self.dataOut.velocityV = []
@@ -494,17 +494,14 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
494 494 self.dataOut = Spectra()
495 495 self.profileIndex = 1 # Always
496 496 self.dataOut.flagNoData = False
497 self.dataOut.nRdPairs = 0
498 self.dataOut.pairsList = []
499 self.dataOut.data_spc = None
500
501 self.dataOut.normFactor = 1
497 self.dataOut.nRdPairs = 0
498 self.dataOut.data_spc = None
502 499 self.nextfileflag = True
503 500 self.dataOut.RadarConst = 0
504 501 self.dataOut.HSDV = []
505 502 self.dataOut.NPW = []
506 503 self.dataOut.COFA = []
507 self.dataOut.noise = 0
504 # self.dataOut.noise = 0
508 505
509 506 def Files2Read(self, fp):
510 507 '''
@@ -588,6 +585,7 class MIRA35CReader (ProcessingUnit, FileHeaderMIRA35c, SRVIHeader, RecordHeader
588 585 self.dataOut.noise = self.dataOut.getNoise()
589 586 # print 'ACAAAAAA', self.dataOut.noise
590 587 self.dataOut.data_spc = self.dataOut.data_spc + self.dataOut.noise
588 self.dataOut.normFactor = 1
591 589 # print 'self.dataOut.noise',self.dataOut.noise
592 590
593 591 return self.dataOut.data_spc
@@ -71,7 +71,10 class ProcessingUnit(object):
71 71 checkKwargs(self.run, kwargs)
72 72
73 73 def getAllowedArgs(self):
74 return inspect.getargspec(self.run).args
74 if hasattr(self, '__attrs__'):
75 return self.__attrs__
76 else:
77 return inspect.getargspec(self.run).args
75 78
76 79 def addOperationKwargs(self, objId, **kwargs):
77 80 '''
@@ -318,7 +321,10 class Operation(object):
318 321 checkKwargs(self.run, kwargs)
319 322
320 323 def getAllowedArgs(self):
321 return inspect.getargspec(self.run).args
324 if hasattr(self, '__attrs__'):
325 return self.__attrs__
326 else:
327 return inspect.getargspec(self.run).args
322 328
323 329 def setup(self):
324 330
@@ -250,6 +250,8 class PublishData(Operation):
250 250 Operation to send data over zmq.
251 251 '''
252 252
253 __attrs__ = ['host', 'port', 'delay', 'zeromq', 'mqtt', 'verbose']
254
253 255 def __init__(self, **kwargs):
254 256 """Inicio."""
255 257 Operation.__init__(self, **kwargs)
@@ -434,6 +436,8 class PublishData(Operation):
434 436
435 437 class ReceiverData(ProcessingUnit):
436 438
439 __attrs__ = ['server']
440
437 441 def __init__(self, **kwargs):
438 442
439 443 ProcessingUnit.__init__(self, **kwargs)
@@ -472,6 +476,7 class ReceiverData(ProcessingUnit):
472 476 class PlotterReceiver(ProcessingUnit, Process):
473 477
474 478 throttle_value = 5
479 __attrs__ = ['server', 'plottypes', 'realtime', 'localtime', 'throttle']
475 480
476 481 def __init__(self, **kwargs):
477 482
@@ -1,6 +1,5
1 1 import schainpy
2 2 from schainpy.model import Operation, ProcessingUnit
3 from importlib import import_module
4 3 from pydoc import locate
5 4
6 5 def clean_modules(module):
@@ -11,17 +10,17 def clean_modules(module):
11 10
12 11 def check_module(possible, instance):
13 12 def check(x):
14 try:
13 try:
15 14 instancia = locate('schainpy.model.{}'.format(x))
16 15 return isinstance(instancia(), instance)
17 16 except Exception as e:
18 return False
17 return False
19 18 clean = clean_modules(possible)
20 19 return [x for x in clean if check(x)]
21 20
22 21
23 22 def getProcs():
24 module = dir(import_module('schainpy.model'))
23 module = dir(schainpy.model)
25 24 procs = check_module(module, ProcessingUnit)
26 25 try:
27 26 procs.remove('ProcessingUnit')
@@ -30,7 +29,7 def getProcs():
30 29 return procs
31 30
32 31 def getOperations():
33 module = dir(import_module('schainpy.model'))
32 module = dir(schainpy.model)
34 33 noProcs = [x for x in module if not x.endswith('Proc')]
35 34 operations = check_module(noProcs, Operation)
36 35 try:
@@ -53,7 +52,7 def getArgs(op):
53 52 return args
54 53
55 54 def getAll():
56 allModules = dir(import_module('schainpy.model'))
55 allModules = dir(schainpy.model)
57 56 modules = check_module(allModules, Operation)
58 57 modules.extend(check_module(allModules, ProcessingUnit))
59 58 return modules
General Comments 0
You need to be logged in to leave comments. Login now