[chronojump] enc analyze table with Inertia and MAX. Also fixed problem in SD (was using also avg)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] enc analyze table with Inertia and MAX. Also fixed problem in SD (was using also avg)
- Date: Wed, 2 Mar 2016 13:24:46 +0000 (UTC)
commit da3fa309fa49238de0b0f37c2bd51a0e90e2c334
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Mar 2 14:21:53 2016 +0100
enc analyze table with Inertia and MAX. Also fixed problem in SD (was using also avg)
encoder/graph.R | 53 ++++++++++++++++++++++++++++++-------------
src/encoder.cs | 28 ++++++++++++++--------
src/gui/encoder.cs | 2 +-
src/gui/encoderTreeviews.cs | 53 +++++++++++++++++++++++++++++-------------
4 files changed, 92 insertions(+), 44 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 348da23..42705e7 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2906,13 +2906,18 @@ doProcess <- function(options)
}
if(op$Analysis == "curves" || writeCurves) {
- #this columns are going to be removed from paf:
+ #create pafCurves to be printed on CSV. This columns are going to be removed:
+
+ #print("---- 1 ----")
+ #print(paf)
#write("paf and pafCurves", stderr())
#write(paf$meanSpeed, stderr())
- pafCurves <- subset( paf, select = -c(mass, massBody, massExtra, inertiaMomentum) )
+ pafCurves <- subset( paf, select = -c(mass, massBody, massExtra) )
#write(pafCurves$meanSpeed, stderr())
+ #print("---- 2 ----")
+ #print(pafCurves)
if(singleFile)
pafCurves = cbind(
@@ -2942,47 +2947,63 @@ doProcess <- function(options)
"meanPower","peakPower","peakPowerT",
"pp_ppt",
"meanForce", "maxForce", "maxForceT",
- "laterality"
+ "laterality", "inertiaM"
)
- #Add "AVG" and "SD" when analyzing, not on "curves"
+ #Add "Max", "AVG" and "SD" when analyzing, not on "curves"
if(op$Analysis != "curves") {
addSD = FALSE
if(length(pafCurves[,1]) > 1)
addSD = TRUE
if(typeof(pafCurves) == "list") {
- #1) AVG
- pafCurves = rbind(pafCurves,
- c("","", mean(pafCurves$massBody),
mean(pafCurves$massExtra),
+ #1) MAX
+ pafCurvesMax = c("","", max(pafCurves$massBody),
max(pafCurves$massExtra),
+
max(pafCurves$start),max(pafCurves$width),max(pafCurves$height),
+
mean(pafCurves$meanSpeed),max(pafCurves$maxSpeed),max(pafCurves$maxSpeedT),
+
mean(pafCurves$meanPower),max(pafCurves$peakPower),max(pafCurves$peakPowerT),
+ mean(pafCurves$pp_ppt),
+ max(pafCurves$meanForce),
max(pafCurves$maxForce), max(pafCurves$maxForceT),
+ "", max(pafCurves$inertiaM)
+ )
+
+ #2) AVG
+ pafCurvesAVG = c("","", mean(pafCurves$massBody),
mean(pafCurves$massExtra),
mean(pafCurves$start),mean(pafCurves$width),mean(pafCurves$height),
mean(pafCurves$meanSpeed),mean(pafCurves$maxSpeed),mean(pafCurves$maxSpeedT),
mean(pafCurves$meanPower),mean(pafCurves$peakPower),mean(pafCurves$peakPowerT),
mean(pafCurves$pp_ppt),
mean(pafCurves$meanForce),
mean(pafCurves$maxForce), mean(pafCurves$maxForceT),
- ""
+ "", mean(pafCurves$inertiaM)
)
- )
- rownames(pafCurves)[length(pafCurves[,1])] = "AVG"
- #2) Add SD if there's more than one data row.
- if(addSD) {
- pafCurves = rbind(pafCurves,
- c("","", sd(pafCurves$massBody),
sd(pafCurves$massExtra),
+ #3) Add SD if there's more than one data row.
+ if(addSD)
+ pafCurvesSD = c("","", sd(pafCurves$massBody),
sd(pafCurves$massExtra),
sd(pafCurves$start),sd(pafCurves$width),sd(pafCurves$height),
sd(pafCurves$meanSpeed),sd(pafCurves$maxSpeed),sd(pafCurves$maxSpeedT),
sd(pafCurves$meanPower),sd(pafCurves$peakPower),sd(pafCurves$peakPowerT),
sd(pafCurves$pp_ppt),
sd(pafCurves$meanForce),
sd(pafCurves$maxForce), sd(pafCurves$maxForceT),
- ""
+ "", sd(pafCurves$inertiaM)
)
- )
+
+
+ pafCurves = rbind(pafCurves, pafCurvesMax)
+ rownames(pafCurves)[length(pafCurves[,1])] = "MAX"
+
+ pafCurves = rbind(pafCurves, pafCurvesAVG)
+ rownames(pafCurves)[length(pafCurves[,1])] = "AVG"
+
+ if(addSD) {
+ pafCurves = rbind(pafCurves, pafCurvesSD)
rownames(pafCurves)[length(pafCurves[,1])] = "SD"
}
}
}
+ print("---- 3 ----")
print(pafCurves)
write.csv(pafCurves, op$OutputData1, quote=FALSE)
diff --git a/src/encoder.cs b/src/encoder.cs
index dcef4d8..c9a2ecc 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -214,6 +214,7 @@ public class EncoderCurve
public string Laterality; //only on analyze
public double ExtraWeight;
public double DisplacedWeight;
+ public int Inertia;
public string Start;
public string Duration;
public string Height;
@@ -261,6 +262,7 @@ public class EncoderCurve
public EncoderCurve (string n, string series, string exercise,
string laterality,
double extraWeight, double displacedWeight,
+ int inertia,
string start, string duration, string height,
string meanSpeed, string maxSpeed, string maxSpeedT,
string meanPower, string peakPower, string peakPowerT,
@@ -273,6 +275,7 @@ public class EncoderCurve
this.Laterality = laterality;
this.ExtraWeight = extraWeight;
this.DisplacedWeight = displacedWeight;
+ this.Inertia = inertia;
this.Start = start;
this.Duration = duration;
this.Height = height;
@@ -319,25 +322,30 @@ public class EncoderCurve
}
//at least for RenderNAnalyze
public bool IsValidN() {
- if (N == "AVG" || N == "SD" || IsNumberN() || IsNumberNandEorC())
+ if (N == "MAX" || N == "AVG" || N == "SD" || IsNumberN() || IsNumberNandEorC())
return true;
return false;
}
- public string ToCSV(string decimalSeparator) {
+ public string ToCSV(bool captureOrAnalyze, string decimalSeparator) {
+
//latin: 2,3 ; 2,5
//non-latin: 2.3 , 2.5
string sep = ":::";
- string str =
- N + sep + Series + sep + Exercise + sep + Laterality + sep +
- ExtraWeight + sep + DisplacedWeight + sep +
- Start + sep + Duration + sep + Height + sep +
- MeanSpeed + sep + MaxSpeed + sep + MaxSpeedT + sep +
- MeanPower + sep + PeakPower + sep + PeakPowerT + sep +
- PP_PPT + sep +
- MeanForce + sep + MaxForce + sep + MaxForceT;
+
+ string str = "";
+ //TODO: if capture not shown because some variables like Inertia are not defined
+ if(! captureOrAnalyze)
+ str =
+ N + sep + Series + sep + Exercise + sep + Laterality + sep +
+ ExtraWeight + sep + DisplacedWeight + sep + Inertia + sep +
+ Start + sep + Duration + sep + Height + sep +
+ MeanSpeed + sep + MaxSpeed + sep + MaxSpeedT + sep +
+ MeanPower + sep + PeakPower + sep + PeakPowerT + sep +
+ PP_PPT + sep +
+ MeanForce + sep + MaxForce + sep + MaxForceT;
if(decimalSeparator == "COMMA")
str = Util.ConvertToComma(str);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index b7a4fd2..c9bcb1c 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -3778,7 +3778,7 @@ public partial class ChronoJumpWindow
//write curves rows
ArrayList array = getTreeViewCurves(encoderAnalyzeListStore);
foreach (EncoderCurve ec in array)
- writer.WriteLine(ec.ToCSV(preferences.CSVExportDecimalSeparator));
+ writer.WriteLine(ec.ToCSV(false,
preferences.CSVExportDecimalSeparator));
}
writer.Flush();
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index ebe0a01..6c964cf 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -513,6 +513,7 @@ public partial class ChronoJumpWindow
Catalog.GetString("Laterality") + "\n",
Catalog.GetString("Extra weight") + "\n (Kg)",
Catalog.GetString("Total weight") + "\n (Kg)",
+ Catalog.GetString("Inertia M.") + "\n (Kg*cm^2)",
Catalog.GetString("Start") + "\n (s)",
Catalog.GetString("Duration") + "\n (s)",
Catalog.GetString("Distance") + "\n (cm)",
@@ -580,7 +581,7 @@ public partial class ChronoJumpWindow
//don't show the DisplacedWeight on AVG or SD because there can be
many exercises
//(with different exercisePercentBodyWeight) and persons
- if(cells[0] == "AVG" || cells[0] == "SD")
+ if(cells[0] == "MAX" || cells[0] == "AVG" || cells[0] == "SD")
totalMass = -1; //mark to not be shown
else
totalMass =
Convert.ToDouble(Util.ChangeDecimalSeparator(cells[3])) *
@@ -597,6 +598,7 @@ public partial class ChronoJumpWindow
cells[18], //laterality
Convert.ToDouble(Util.ChangeDecimalSeparator(cells[4])),
totalMass,
+ Convert.ToInt32(cells[19]),
cells[5], cells[6], cells[7],
cells[8], cells[9], cells[10],
cells[11], cells[12], cells[13],
@@ -648,42 +650,45 @@ public partial class ChronoJumpWindow
aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderDisplacedWeight));
break;
case 6:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderStart));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderInertia));
break;
case 7:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderDuration));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderStart));
break;
case 8:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderHeight));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderDuration));
break;
case 9:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMeanSpeed));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderHeight));
break;
case 10:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxSpeed));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMeanSpeed));
break;
case 11:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxSpeedT));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxSpeed));
break;
case 12:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMeanPower));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxSpeedT));
break;
case 13:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderPeakPower));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMeanPower));
break;
case 14:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderPeakPowerT));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderPeakPower));
break;
case 15:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderPP_PPT));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderPeakPowerT));
break;
case 16:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMeanForce));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderPP_PPT));
break;
case 17:
- aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxForce));
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMeanForce));
break;
case 18:
+ aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxForce));
+ break;
+ case 19:
aColumn.SetCellDataFunc (aCell, new Gtk.TreeCellDataFunc
(RenderMaxForceT));
break;
}
@@ -867,7 +872,7 @@ public partial class ChronoJumpWindow
//Check if it's number
if(! curve.IsNumberN()) {
(cell as Gtk.CellRendererText).Text = "";
- LogB.Error("Curve is not number at RenderN:" + curve.ToCSV("COMMA"));
+ LogB.Error("Curve is not number at RenderN:" + curve.ToCSV(true, "COMMA"));
return;
}
@@ -908,11 +913,11 @@ public partial class ChronoJumpWindow
//Check if it's valid
if(! curve.IsValidN()) {
(cell as Gtk.CellRendererText).Text = "";
- LogB.Error("Curve is not valid at RenderNAnalyze:" + curve.ToCSV("COMMA"));
+ LogB.Error("Curve is not valid at RenderNAnalyze:" + curve.ToCSV(false, "COMMA"));
return;
}
- if(curve.N == "AVG" || curve.N == "SD") {
+ if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD") {
(cell as Gtk.CellRendererText).Markup = "<b>" + Catalog.GetString(curve.N) + "</b>";
return;
}
@@ -976,7 +981,7 @@ public partial class ChronoJumpWindow
private void renderBoldIfNeeded(Gtk.CellRenderer cell, EncoderCurve curve, string str)
{
- if(curve.N == "AVG" || curve.N == "SD")
+ if(curve.N == "MAX" || curve.N == "AVG" || curve.N == "SD")
(cell as Gtk.CellRendererText).Markup = "<b>" + str + "</b>";
else
(cell as Gtk.CellRendererText).Text = str;
@@ -1006,6 +1011,16 @@ public partial class ChronoJumpWindow
renderBoldIfNeeded(cell, curve, str);
}
+
+ private void RenderInertia (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
+ {
+ EncoderCurve curve = (EncoderCurve) model.GetValue (iter, 0);
+
+ string str =
String.Format(UtilGtk.TVNumPrint(curve.Inertia.ToString(),3,0),Convert.ToInt32(curve.Inertia));
+
+ renderBoldIfNeeded(cell, curve, str);
+ }
+
private void RenderStart (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
{
@@ -1315,6 +1330,10 @@ public partial class ChronoJumpWindow
//cells[18] laterality
+ //inertia comes as Kg*m^2, convert it to Kg*cm^2
+ double inertiaInM = Convert.ToDouble(Util.ChangeDecimalSeparator(cells[19]));
+ cells[19] = (Convert.ToInt32(inertiaInM * 10000)).ToString();
+
return cells;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]