Skip to content

Commit

Permalink
Fix and extend getIntervalsByLHCModes
Browse files Browse the repository at this point in the history
  • Loading branch information
rdemaria committed Sep 5, 2017
1 parent d4ca6a7 commit e77ee2e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pytimber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .pagestore import PageStore

__version__ = "2.5.0"
__version__ = "2.5.1"

__cmmnbuild_deps__ = [
"accsoft-cals-extr-client",
Expand Down
28 changes: 20 additions & 8 deletions pytimber/pytimber.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,22 +609,34 @@ def getLHCFillsByTime(self, t1, t2, beam_modes=None, unixtime=True):
for fill in fills.getFillNumbers()
]

def getIntervalsByLHCModes(self, t1, t2, mode1, mode2,unixtime=True, ):
def getIntervalsByLHCModes(self, t1, t2, mode1, mode2, unixtime=True,
mode1time='startTime', mode2time='endTime',
mode1idx=0, mode2idx=-1):
"""Returns a list of the fill numbers and interval between t1 and
t2 between the starting time of first beam mode in mode1 and the
ending time of the first beam mode . """
t2 between the startTime of first beam mode in mode1 and the
endTime of the first beam mode.
The optional parameters 'mode[12]time' can take
'startTime' or 'endTime'
The otional parameter 'mode[12]idx' selects which mode in case of
multiple occurrence of mode
"""
ts1 = self.toTimestamp(t1)
ts2 = self.toTimestamp(t2)
fills=self.getLHCFillsByTime(ts1,ts2,[mode1,mode2])
out=[]
for fill in fills:
fn=[fill['fillNumber']]
mode1=[]
mode2=[]
for bm in fill['beamModes']:
if len(fn)==1 and bm['mode']==mode1:
fn.append(bm['startTime'])
elif len(fn)==2 and bm['mode']==mode2:
fn.append(bm['startTime'])
out.append(fn)
if bm['mode']==mode1:
mode1.append(bm[mode1time])
if bm['mode']==mode2:
mode2.append(bm[mode2time])
out.append([fn,mode1[mode1idx],mode2[mode2idx]])
return out
def getMetaData(self,pattern_or_list):
"""Get All MetaData for a variable defined by a pattern_or_list"""
Expand Down

0 comments on commit e77ee2e

Please sign in to comment.