Newer
Older
Valerio Mariani
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# This file is part of cfelpyutils.
#
# cfelpyutils is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cfelpyutils is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
"""
Utilities for the psana python module.
This module provides utilities that build on the functionality provided by the
psana python module (developed at the SLAC National Laboratories).
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
def first_event_inspection(source):
"""Inspect the content of the first psana event.
Takes psana source string (e.g. exp=CXI/cxix....) and inspect the
content in the first event in the data described by the string.
Print information about the the content of the event.
Args:
source (str): a psana source string (e.g. exp=CXI/cxix....).
"""
# Import the psana module.
import psana
# Print the name of the source.
print('\n\n')
print('data source :{}'.format(source))
print('\n')
print('Opening dataset...')
# Open the psana data source.
dsource = psana.DataSource(source)
# Print the content of the Epics portion of the data.
# First the Epics names.
print('\n')
print('Epics pv Names:')
print(dsource.env().epicsStore().pvNames())
# Then the Epics aliases.
print('\n')
print('Epics aliases (the not so confusing ones):')
print(dsource.env().epicsStore().aliases())
# Move to the first event in the data.
print('\n')
print('Event structure:')
itr = dsource.events()
evt = itr.next()
# Print the content of the first event.
for k in evt.keys():
print(
'Type: {0} Source: {1} Alias: {2}'
'Key: {3}'.format(
k.type(),
k.src(),
k.alias(),
k.key()
)
)
print('')
for k in evt.keys():
print(k)
# Extract and print the photon energy.
beam = evt.get(psana.Bld.BldDataEBeamV7, psana.Source('BldInfo(EBeam)'))
print('Photon energy: %f' % beam.ebeamPhotonEnergy())