@@ -13,8 +13,7 import datetime | |||
|
13 | 13 | |
|
14 | 14 | import numpy |
|
15 | 15 | import h5py |
|
16 | ||
|
17 | from schainpy.model.io.jroIO_base import JRODataReader | |
|
16 | from schainpy.model.io.jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
|
18 | 17 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator |
|
19 | 18 | from schainpy.model.data.jrodata import Parameters |
|
20 | 19 | from schainpy.utils import log |
@@ -28,18 +27,20 except: | |||
|
28 | 27 | |
|
29 | 28 | DEF_CATALOG = { |
|
30 | 29 | 'principleInvestigator': 'Marco Milla', |
|
31 |
'expPurpose': |
|
|
32 |
'cycleTime': |
|
|
33 |
'correlativeExp': |
|
|
34 |
'sciRemarks': |
|
|
35 |
'instRemarks': |
|
|
30 | 'expPurpose': '', | |
|
31 | 'cycleTime': '', | |
|
32 | 'correlativeExp': '', | |
|
33 | 'sciRemarks': '', | |
|
34 | 'instRemarks': '' | |
|
36 | 35 | } |
|
36 | ||
|
37 | 37 | DEF_HEADER = { |
|
38 |
'kindatDesc': |
|
|
38 | 'kindatDesc': '', | |
|
39 | 39 | 'analyst': 'Jicamarca User', |
|
40 |
'comments': |
|
|
41 |
'history': |
|
|
40 | 'comments': '', | |
|
41 | 'history': '' | |
|
42 | 42 | } |
|
43 | ||
|
43 | 44 | MNEMONICS = { |
|
44 | 45 | 10: 'jro', |
|
45 | 46 | 11: 'jbr', |
@@ -48,6 +49,8 MNEMONICS = { | |||
|
48 | 49 | 1000: 'pbr', |
|
49 | 50 | 1001: 'hbr', |
|
50 | 51 | 1002: 'obr', |
|
52 | 400: 'clr' | |
|
53 | ||
|
51 | 54 | } |
|
52 | 55 | |
|
53 | 56 | UT1970 = datetime.datetime(1970, 1, 1) - datetime.timedelta(seconds=time.timezone) |
@@ -63,7 +66,7 def load_json(obj): | |||
|
63 | 66 | iterable = obj |
|
64 | 67 | |
|
65 | 68 | if isinstance(iterable, dict): |
|
66 | return {str(k): load_json(v) if isinstance(v, dict) else str(v) if isinstance(v, str) else v | |
|
69 | return {str(k): load_json(v) if isinstance(v, dict) else str(v) if isinstance(v, (str,unicode)) else v | |
|
67 | 70 | for k, v in list(iterable.items())} |
|
68 | 71 | elif isinstance(iterable, (list, tuple)): |
|
69 | 72 | return [str(v) if isinstance(v, str) else v for v in iterable] |
@@ -192,7 +195,7 class MADReader(JRODataReader, ProcessingUnit): | |||
|
192 | 195 | self.parameters = one + two |
|
193 | 196 | self.parameters_d = one_d + two_d |
|
194 | 197 | |
|
195 |
log.success('Parameters found: {}'.format( |
|
|
198 | log.success('Parameters found: {}'.format(self.parameters), | |
|
196 | 199 | 'MADReader') |
|
197 | 200 | if s_parameters: |
|
198 | 201 | log.success('Spatial parameters: {}'.format(','.join(str(s_parameters))), |
@@ -361,8 +364,8 class MADReader(JRODataReader, ProcessingUnit): | |||
|
361 | 364 | if self.ext == '.txt': |
|
362 | 365 | y = self.parameters.index(self.ind2DList[0].lower()) |
|
363 | 366 | ranges = self.buffer[:,y] |
|
364 | if self.ranges.size == ranges.size: | |
|
365 | continue | |
|
367 | #if self.ranges.size == ranges.size: | |
|
368 | # continue | |
|
366 | 369 | index = numpy.where(numpy.in1d(self.ranges, ranges))[0] |
|
367 | 370 | dummy = numpy.zeros(self.ranges.shape) + numpy.nan |
|
368 | 371 | dummy[index] = self.buffer[:,x] |
@@ -406,14 +409,14 class MADReader(JRODataReader, ProcessingUnit): | |||
|
406 | 409 | |
|
407 | 410 | return 1 |
|
408 | 411 | |
|
409 | ||
|
412 | @MPDecorator | |
|
410 | 413 | class MADWriter(Operation): |
|
411 | 414 | |
|
412 | 415 | missing = -32767 |
|
413 | 416 | |
|
414 |
def __init__(self |
|
|
417 | def __init__(self): | |
|
415 | 418 | |
|
416 |
Operation.__init__(self |
|
|
419 | Operation.__init__(self) | |
|
417 | 420 | self.dataOut = Parameters() |
|
418 | 421 | self.counter = 0 |
|
419 | 422 | self.path = None |
@@ -451,7 +454,7 class MADWriter(Operation): | |||
|
451 | 454 | |
|
452 | 455 | self.dataOut = dataOut |
|
453 | 456 | self.putData() |
|
454 | return | |
|
457 | return 1 | |
|
455 | 458 | |
|
456 | 459 | def setup(self, path, oneDDict, ind2DList, twoDDict, metadata, format, **kwargs): |
|
457 | 460 | ''' |
@@ -596,7 +599,7 class MADWriter(Operation): | |||
|
596 | 599 | self.fp.append(rec) |
|
597 | 600 | if self.ext == '.hdf5' and self.counter % 500 == 0 and self.counter > 0: |
|
598 | 601 | self.fp.dump() |
|
599 |
if self.counter % |
|
|
602 | if self.counter % 20 == 0 and self.counter > 0: | |
|
600 | 603 | log.log( |
|
601 | 604 | 'Writing {} records'.format( |
|
602 | 605 | self.counter), |
@@ -294,11 +294,17 def MPDecorator(BaseClass): | |||
|
294 | 294 | elif optype == 'other' and not self.dataOut.flagNoData: |
|
295 | 295 | self.dataOut = op.run(self.dataOut, **kwargs) |
|
296 | 296 | elif optype == 'external' and not self.dataOut.flagNoData: |
|
297 | if not self.dataOut.flagNoData or self.dataOut.error: | |
|
298 | 297 |
|
|
299 | 298 | |
|
300 | 299 | if not self.dataOut.flagNoData or self.dataOut.error: |
|
301 | 300 | self.publish(self.dataOut, self.id) |
|
301 | for op, optype, opId, kwargs in self.operations: | |
|
302 | if optype == 'self' and self.dataOut.error: | |
|
303 | op(**kwargs) | |
|
304 | elif optype == 'other' and self.dataOut.error: | |
|
305 | self.dataOut = op.run(self.dataOut, **kwargs) | |
|
306 | elif optype == 'external' and self.dataOut.error: | |
|
307 | self.publish(self.dataOut, opId) | |
|
302 | 308 | |
|
303 | 309 | if self.dataIn.error: |
|
304 | 310 | break |
General Comments 0
You need to be logged in to leave comments.
Login now