ATLAS Offline Software
Loading...
Searching...
No Matches
python.libcore Namespace Reference

Functions

 dcsofl_cool_record ()
 make_multi_mapping (iterable)
 map_channels (iovs, mapping, folder)
 connect_adjacent_iovs_defect (generator)

Variables

 log

Function Documentation

◆ connect_adjacent_iovs_defect()

python.libcore.connect_adjacent_iovs_defect ( generator)

Definition at line 69 of file libcore.py.

69def connect_adjacent_iovs_defect(generator):
70 previous = None
71 for iov in generator:
72 if (previous and previous.connected_to(iov) and
73 previous.comment==iov.comment and previous.channel==iov.channel and
74 previous.present==iov.present):
75 previous = previous._replace(until=iov.until)
76 else:
77 if previous:
78 yield previous
79 previous = iov
80 if previous:
81 yield previous
82

◆ dcsofl_cool_record()

python.libcore.dcsofl_cool_record ( )

Definition at line 8 of file libcore.py.

8def dcsofl_cool_record():
9 from PyCool import cool
10 ST = cool.StorageType
11 return [("Code", ST.Int32),
12 ("deadFrac", ST.Float),
13 ("Thrust", ST.Float),
14 ("NConfig", ST.Int32),
15 ("NWorking", ST.Int32)]
16

◆ make_multi_mapping()

python.libcore.make_multi_mapping ( iterable)
When more than one value can map to the same key, we need 
{key, [value1, value2]}. 

This function builds it out of [(key, value1), (key, value2)]

Beware, values cannot be lists.

Definition at line 17 of file libcore.py.

17def make_multi_mapping(iterable):
18 """
19 When more than one value can map to the same key, we need
20 {key, [value1, value2]}.
21
22 This function builds it out of [(key, value1), (key, value2)]
23
24 Beware, values cannot be lists.
25 """
26
27 result = {}
28
29 for key, value in iterable:
30 if key in result and not isinstance(result[key], list):
31 result[key] = [result[key], value]
32 elif key in result:
33 result[key].append(value)
34 else:
35 result[key] = value
36
37 return result
38

◆ map_channels()

python.libcore.map_channels ( iovs,
mapping,
folder )
Remap the input channel identifiers.  Returns a new IOVSet 
with the channel number changed according to the provided mapping

Definition at line 39 of file libcore.py.

39def map_channels(iovs, mapping, folder):
40 """
41 Remap the input channel identifiers. Returns a new IOVSet
42 with the channel number changed according to the provided mapping
43 """
44
45 # look for unmapped channels
46 bad_channels = set()
47 def has_channel(c):
48 result = c in mapping
49 if not result:
50 bad_channels.add(c)
51 return result
52
53 IOVSet = iovs.empty
54 iovs = IOVSet(iov._replace(channel=mapping[iov.channel])
55 for iov in iovs if has_channel(iov.channel))
56
57 if bad_channels:
58 log.debug("WARNING: %s has %i unmapped channels %r",
59 folder, len(bad_channels), repr(bad_channels))
60
61 # Remove lists from channel field of iovs
62 iovs = flatten_channels(iovs)
63
64 # Traditional COOL ordering
65 iovs.sort(key=lambda iov: (iov.channel, iov.since))
66
67 return IOVSet(iovs)
68
STL class.

Variable Documentation

◆ log

python.libcore.log

Definition at line 3 of file libcore.py.