Permalink
Browse files

add time to first stay to mwm

  • Loading branch information...
1 parent f67e3f6 commit d22e958d382f4531446154925b9823e8ef46211c @bahniks committed May 17, 2015
Showing with 82 additions and 2 deletions.
  1. +6 −0 Stuff/Modules/cm.py
  2. +71 −1 Stuff/Modules/mwm.py
  3. +5 −1 Stuff/Modules/parameters.py
View
@@ -128,6 +128,12 @@ def _processHeader(self, file):
if strg[i] == "(":
pos = i
self.arenaDiameter = eval(strg[pos+1])
+ elif "FeederParameters" in line and "//" not in line:
+ strg = line.split()
+ for i in range(len(strg)):
+ if strg[i] == "(":
+ pos = i
+ self.entranceLatency = eval(strg[pos+1])
elif "END_HEADER" in line:
break
View
@@ -46,6 +46,8 @@ def __init__(self, nameA, *_):
if not self.data:
raise Exception("Failure in data initialization.")
+ print(self.getT1Stay())
+
def _addReinforcedSector(self, string, position):
self.platformX = eval(string[position+1])
@@ -54,9 +56,36 @@ def _addReinforcedSector(self, string, position):
+ def getT1(self, time = 1, startTime = 0, lastTime = "fromParameter"):
+ """computes time to get to the platform and stay there (in seconds),
+ argument 'time' is time of the session
+ argument 'lastTime' decides whether the last time point is obtained from 'time' parameter
+ or data
+ """
+ start = self.findStart(startTime)
+ time *= 60000 # conversion from minutes to miliseconds
+ startTime *= 60000
+ T1 = 0
+ for content in self.data[start:]:
+ if content[5] < 2:
+ continue
+ elif content[5] in [2, 3]:
+ T1 = content[1] - startTime
+ break
+
+ if T1 == 0 or T1 > time - startTime:
+ if lastTime == "fromData": # not used - may be added as an option in the future
+ T1 = min(time, self.data[-1][1]) - startTime
+ elif lastTime == "fromParameter":
+ T1 = time - startTime
+
+ T1 = T1 / 1000 # conversion from miliseconds to seconds
+ return format(T1, "0.1f")
+
+
def getT1Pass(self, time = 1, startTime = 0, lastTime = "fromParameter"):
- """computes time to first shock (in seconds),
+ """computes time to first pass through the platform (in seconds),
argument 'time' is time of the session
argument 'lastTime' decides whether the last time point is obtained from 'time' parameter
or data
@@ -81,6 +110,47 @@ def getT1Pass(self, time = 1, startTime = 0, lastTime = "fromParameter"):
return format(T1, "0.1f")
+ def getT1Stay(self, time = 1, startTime = 0, platformAdjustment = 2, lastTime = "fromParameter"):
+ """computes time to first stay in the vicinity of the platform (in seconds),
+ argument 'time' is time of the session
+ argument 'lastTime' decides whether the last time point is obtained from 'time' parameter
+ or data
+ """
+ time = time * 60000 # conversion from minutes to miliseconds
+ start = self.findStart(startTime)
+ T1 = 0
+ x, y = self.platformX, self.platformY
+ passTime = None
+ for content in self.data[start:]:
+ if content[5] == 0:
+ if passTime:
+ distanceToTarget = sqrt((content[2] - x)**2 + (content[3] - y)**2)
+ if distanceToTarget < self.platformRadius * platformAdjustment:
+ if content[1] - passTime >= self.entranceLatency:
+ T1 = content[1] - startTime
+ break
+ else:
+ passTime = None
+ elif content[5] in [2, 3]:
+ T1 = content[1] - startTime
+ break
+ elif content[5] == 1:
+ if not passTime:
+ passTime = content[1]
+ elif content[1] - passTime >= self.entranceLatency:
+ T1 = content[1] - startTime
+ break
+
+ if T1 == 0 or T1 > time - startTime:
+ if lastTime == "fromData": # not used - may be added as an option in the future
+ T1 = min(time, self.data[-1][1]) - startTime
+ elif lastTime == "fromParameter":
+ T1 = time - startTime
+
+ T1 = T1 / 1000 # conversion from miliseconds to seconds
+ return format(T1, "0.1f")
+
+
def getPasses(self, time = 1, startTime = 0):
"""computes number of entrances,
argument 'time' is time of the session
@@ -181,7 +181,11 @@ def __init__(self):
"Computed from every [in rows]"),
"minDifference": (Opt('MinDiffParAvgDistance', 0, ['int', 'float']),
"Minimal distance counted [in pixels]")
- })
+ })
+ self["Time to first stay"] = Par("getT1Stay", "experimental", {
+ "platformAdjustment": (Opt('platformAdjustmentT1Stay', 2, ['int', 'float']),
+ "Platform adjustment")
+ })
self["Average distance from chosen"] = Par("getAvgDistanceChosen", "advanced", {
"angle": (Opt('angleParAvgDistanceCustom', 180, ['int', 'float', 'list']),
"Angle of chosen location relative to the target [in degrees]"),

0 comments on commit d22e958

Please sign in to comment.