def _tr_event_id_sqs_pnccd(self, values, obj): """Translates euxfel train event ID from data source into a hummingbird one""" timestamp = numpy.array(obj['timestamp.tid'], dtype='int') rec = Record('Timestamp', timestamp, ureg.s) # rec.trainId = [numpy.array(obj['data.trainId'], dtype='int')] rec.timestamp = [timestamp] values[rec.name] = rec
def __getitem__(self, key): """Calls psana to retrieve and translate the EPICS item""" if(key not in self._cache): pv = self.epics.getPV(key) if(pv is None): raise KeyError('%s is not a valid EPICS key' %(key)) rec = Record(key, pv.value(0)) rec.pv = pv self._cache[key] = rec return self._cache[key]
def __getitem__(self, key): """Calls psana to retrieve and translate the EPICS item""" if (key not in self._cache): pv = self.epics.getPV(key) if (pv is None): raise KeyError('%s is not a valid EPICS key' % (key)) rec = Record(key, pv.value(0)) rec.pv = pv self._cache[key] = rec return self._cache[key]
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 timestamp = int(obj['timestamp.tid']) + 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['data.trainId']) rec.timestamp = timestamp values[rec.name] = rec
def _tr_event_id(self, values, obj): """Translates LCLS eventID into a hummingbird one""" timestamp = obj.time()[0] + obj.time()[1] * 1e-9 time = datetime.datetime.fromtimestamp(timestamp, tz=timezone('utc')) time = time.astimezone(tz=timezone('US/Pacific')) rec = Record('Timestamp', time, ureg.s) time = datetime.datetime.fromtimestamp(obj.time()[0]) rec.datetime64 = numpy.datetime64(time, 'ns') + obj.time()[1] rec.fiducials = obj.fiducials() rec.run = obj.run() rec.ticks = obj.ticks() rec.vector = obj.vector() rec.timestamp = timestamp rec.timestamp2 = obj.time()[0] << 32 | obj.time()[1] values[rec.name] = rec
def _tr_acqiris(self, values, obj, evt_key): """Translates Acqiris TOF data to hummingbird numpy array""" config_store = self.data_source.env().configStore() acq_config = config_store.get(psana.Acqiris.ConfigV1, evt_key.src()) samp_interval = acq_config.horiz().sampInterval() n_channels = obj.data_shape()[0] for i in range(0, n_channels): vert = acq_config.vert()[i] elem = obj.data(i) timestamp = elem.timestamp()[0].value() raw = elem.waveforms()[0] if(elem.nbrSamplesInSeg() == 0): logging.warning("Warning: TOF data for " "detector %s is missing.", evt_key) data = raw*vert.slope() - vert.offset() rec = Record('%s Channel %d' %(self._s2c[str(evt_key.src())], i), data, ureg.V) rec.time = (timestamp + samp_interval * numpy.arange(0, elem.nbrSamplesInSeg())) values[rec.name] = rec
def _tr_event_id(self, values, obj): """Translates LCLS eventID into a hummingbird one""" timestamp = obj.time()[0]+obj.time()[1]*1e-9 time = datetime.datetime.fromtimestamp(timestamp, tz=timezone('utc')) time = time.astimezone(tz=timezone('US/Pacific')) rec = Record('Timestamp', time, ureg.s) time = datetime.datetime.fromtimestamp(obj.time()[0]) rec.datetime64 = numpy.datetime64(time, 'ns')+obj.time()[1] rec.fiducials = obj.fiducials() rec.run = obj.run() rec.ticks = obj.ticks() rec.vector = obj.vector() rec.timestamp = timestamp rec.timestamp2 = obj.time()[0] << 32 | obj.time()[1] values[rec.name] = rec
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