Ejemplo n.º 1
0
 def _tr_event_id(self, values, obj):
     """Translates euxfel event ID from some source into a hummingbird one"""
     pulseid = int(obj["image.pulseId"])
     timestamp = int(obj['timestamp.sec']) + int(
         obj['timestamp.frac']) * 1e-18 + pulseid * 1e-2
     time = datetime.datetime.fromtimestamp(timestamp, tz=timezone('utc'))
     time = time.astimezone(tz=timezone('CET'))
     rec = Record('Timestamp', time, ureg.s)
     rec.pulseId = int(obj['image.pulseId'])
     rec.cellId = int(obj['image.cellId'])
     rec.trainId = int(obj['image.trainId'])
     rec.timestamp = timestamp
     values[rec.name] = rec
Ejemplo n.º 2
0
 def _tr_event_id(self, values, obj):
     """Translates euxfel train event ID from data source into a hummingbird one"""
     train_length = numpy.array(obj["image.pulseId"]).shape[-1]
     cells = self._cell_filter[:train_length]
     pulseid = numpy.array(obj["image.pulseId"][..., cells], dtype='int')
     tsec = numpy.array(obj['timestamp.sec'], dtype='int')
     tfrac = numpy.array(obj['timestamp.frac'], dtype='int') * 1e-18
     timestamp = tsec + tfrac + (pulseid / 760.)
     time = numpy.array([
         datetime.datetime.fromtimestamp(t, tz=timezone('utc'))
         for t in timestamp
     ])
     rec = Record('Timestamp', time, ureg.s)
     rec.pulseId = pulseid
     rec.cellId = numpy.array(obj['image.cellId'][..., cells], dtype='int')
     rec.badCells = numpy.array(obj['image.cellId'][..., ~cells],
                                dtype='int')
     rec.trainId = numpy.array(obj['image.trainId'][..., cells],
                               dtype='int')
     rec.timestamp = timestamp
     values[rec.name] = rec