[chronojump] Fixed hang of R on RaceAnalyzer sprint after failing model on graph with length(totalTime +1) != len
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed hang of R on RaceAnalyzer sprint after failing model on graph with length(totalTime +1) != len
- Date: Mon, 21 Feb 2022 12:14:06 +0000 (UTC)
commit a0a6338264179c2cf6c05258bc432b42973c463d
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Feb 21 13:13:06 2022 +0100
Fixed hang of R on RaceAnalyzer sprint after failing model on graph with length(totalTime +1) !=
length(speed)
r-scripts/sprintEncoder.R | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/r-scripts/sprintEncoder.R b/r-scripts/sprintEncoder.R
index 64a46e8bc..b8de2b9e0 100644
--- a/r-scripts/sprintEncoder.R
+++ b/r-scripts/sprintEncoder.R
@@ -221,16 +221,25 @@ getSprintFromEncoder <- function(filename, testLength, Mass, Temperature = 25, H
if (! regression$regressionDone)
{
print("NLS regression problem")
- plot(totalTime[2:length(totalTime)], speed, type = "l",
- #ylim = c(min(speed), testLength)*1.05,
- xlab = "Time (s)", ylab = "Speed (m/s)")
- #abline(h = testLength, lty = 2)
- # text(x = (totalTime[length(totalTime)] + totalTime[1])/2,
- # y = testLength,
- # labels = (paste("Configured test length :", testLength, " m", sep = "")),
- # pos = 3)
- text(x = (totalTime[length(totalTime)] + totalTime[1])/2, max(speed) /2,
- labels = "The graph doesn't seem a sprint", cex = 2, pos = 3)
+ if((length(totalTime) +1) == length(speed))
+ {
+ plot(totalTime[2:length(totalTime)], speed, type = "l",
+ #ylim = c(min(speed), testLength)*1.05,
+ xlab = "Time (s)", ylab = "Speed (m/s)")
+ #abline(h = testLength, lty = 2)
+ # text(x = (totalTime[length(totalTime)] + totalTime[1])/2,
+ # y = testLength,
+ # labels = (paste("Configured test length :", testLength, " m", sep = "")),
+ # pos = 3)
+ text(x = (totalTime[length(totalTime)] + totalTime[1])/2, max(speed) /2,
+ labels = "The graph doesn't seem a sprint", cex = 2, pos = 3)
+ }
+ else
+ {
+ plot(0,0,type="n",axes=F,xlab="",ylab="")
+ text(x=0, y=0, adj=0.5, cex=1.2, col="red", "This data does not seem a sprint.")
+ }
+
return(list(longEnough = longEnough, regressionDone = regression$regressionDone))
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]