From 972919fb87110617feee1273c6875f6bc96f6b23 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 23 May 2016 15:34:14 +0100 Subject: [PATCH] Some .gcharts to test .. added to test/charts [skip ci] --- test/charts/Interval Discovery.gchart | 19 ++++++++ test/charts/PMC.gchart | 33 ++++++++++++++ test/charts/Ride.gchart | 63 +++++++++++++++++++++++++++ test/charts/TSB v IF.gchart | 19 ++++++++ test/charts/W'bal Sum.gchart | 19 ++++++++ test/charts/eCP (LM).gchart | 19 ++++++++ 6 files changed, 172 insertions(+) create mode 100644 test/charts/Interval Discovery.gchart create mode 100644 test/charts/PMC.gchart create mode 100644 test/charts/Ride.gchart create mode 100644 test/charts/TSB v IF.gchart create mode 100644 test/charts/W'bal Sum.gchart create mode 100644 test/charts/eCP (LM).gchart diff --git a/test/charts/Interval Discovery.gchart b/test/charts/Interval Discovery.gchart new file mode 100644 index 000000000..0b7eced8f --- /dev/null +++ b/test/charts/Interval Discovery.gchart @@ -0,0 +1,19 @@ +{ + "CHART":{ + "VERSION":"1", + "VIEW":"analysis", + "TYPE":"38", + "PROPERTIES":{ + "title":"Interval Discovery ", + "subtitle":" ", + "widthFactor":"2", + "heightFactor":"2", + "style":"0", + "resizable":"0", + "script":"## Interval Discovery\n\n## plots time series to wide thin\nGC.page(width=1000,height=600)\npar(mar=c(6,6,6,6))\n\nrequire(changepoint)\n\n## Get your activity\ny <- GC.activity()$power\n\n# create a time series\n$$myts <- ts(y, start=c(1), \n end=c(length(y)), frequency= 1)\n\n## Discover your intervals, \n## change the ?pen.value? to adjust \n## the penalty separating intervals\n$$disc <- cpt.mean($$myts,\n penalty=\"Manual\",\n pen.value=\"60000*log(n)\",\n method=\"PELT\")\n## Do a happy dance that you can now do this right in GC!\n\nplot($$disc, xlab=\"seconds\",\n ylab=\"watts\", \n main=\"Interval Discovery\", \n ylim=c(0, max(y)*1.1),\n cpt.col=\"gold\", cpt.width=5,\n col=\"#303030\")\n\nabline(h=225,slope=0,col=\"darkgrey\")\n\n## second series - w'bal\n#par(new=TRUE)\n#wb <- GC.activity.wbal()\n#plot(x=seq(1,length(wb),1), y=wb, \n# xaxt=\"n\", yaxt=\"n\",\n# xlab=\"\", ylab=\"\",\n# ylim=c(0,20000),\n# type=\"l\", lwd=4, col=\"darkred\")\n#axis(4)\n#mtext(\"W'bal\",side=4, line=3)\n\n ", + "state":" ", + "showConsole":"0", + "__LAST__":"1", + } + } +} \ No newline at end of file diff --git a/test/charts/PMC.gchart b/test/charts/PMC.gchart new file mode 100644 index 000000000..dc1b87a04 --- /dev/null +++ b/test/charts/PMC.gchart @@ -0,0 +1,33 @@ +{ + "CHART":{ + "VERSION":"1", + "VIEW":"home", + "TYPE":"7", + "PROPERTIES":{ + "title":"PMC ", + "subtitle":" ", + "widthFactor":"2", + "heightFactor":"2", + "style":"0", + "resizable":"0", + "preset":"0", + "bin":"0", + "shade":"0", + "data":"0", + "stack":"0", + "stackWidth":"2", + "legend":"1", + "events":"1", + "filter":"search: ", + "fromDate":"Sat Jan 1 2000", + "toDate":"Sat Jan 1 2000", + "startDate":"Sat Aug 17 2013", + "lastN":"7", + "lastNX":"0", + "prevN":"0", + "settings":"AAAAGABQAE0AQwAgACgAQwBvAGcAZwBhAG4AKQAAABIATABhAHQAZQAgADIAMAAwADkAJXWLAAAAAP8AJXYFAAAAAP8AAAABAAH///////////////8AAAAQAAAABAAAAAIAAAAAFABjAG8AZwBnAGEAbgBfAGEAdABsAAAANABDAG8AZwBnAGEAbgAgAEEAYwB1AHQAZQAgAFQAcgBhAGkAbgBpAG4AZwAgAEwAbwBhAGQAAAA0AEMAbwBnAGcAYQBuACAAQQBjAHUAdABlACAAVAByAGEAaQBuAGkAbgBnACAATABvAGEAZAAAAAwAUwB0AHIAZQBzAHMAAAAAAAMAAAAAAAAAAAAAAAABAAB/qAAAAAABcip4AAAAAAAAAAH//////////wH/////AAD//wAAAAAAAD/wAAAAAAAAAAAAAAH//wAAAAAAAAAAAAAAAAAAAAACAAAOEP////8AAAAKAAAAAAAAAAAAAAAADAAyACAAUABhAHIAbQAAAAAAAAPnAAAOEAAAAAAA//////////8AAAAB/////wAAAAIAAAAAFABjAG8AZwBnAGEAbgBfAGMAdABsAAAAOABDAG8AZwBnAGEAbgAgAEMAaAByAG8AbgBpAGMAIABUAHIAYQBpAG4AaQBuAGcAIABMAG8AYQBkAAAAOABDAG8AZwBnAGEAbgAgAEMAaAByAG8AbgBpAGMAIABUAHIAYQBpAG4AaQBuAGcAIABMAG8AYQBkAAAADABTAHQAcgBlAHMAcwAAAAAAAwAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAQAAH+o6y0O+v//////////Af//AAD/////AAAAAAAAP/AAAAAAAAAAAAAAAf//AAAAAAAAAAAAAAAAAAAAAAIAAA4Q/////wAAAAoAAAAAAAAAAAAAAAAMADIAIABQAGEAcgBtAAAAAAAAA+cAAA4QAAAAAAD//////////wAAAAH/////AAAAAgAAAAAUAGMAbwBnAGcAYQBuAF8AdABzAGIAAAA8AEMAbwBnAGcAYQBuACAAVAByAGEAaQBuAGkAbgBnACAAUwB0AHIAZQBzAHMAIABCAGEAbABhAG4AYwBlAAAAPABDAG8AZwBnAGEAbgAgAFQAcgBhAGkAbgBpAG4AZwAgAFMAdAByAGUAcwBzACAAQgBhAGwAYQBuAGMAZQAAAAwAUwB0AHIAZQBzAHMAAAAAAAMAAAAAwI84AAAAAAABAAAAAAAAAAAAAAABAAB/qOzDjbD//////////wH///////8AAAAAAAAAAD/wAAAAAAAAAAAAAAH//wAAAAAAAAAAAAAAAAAAAAACAAAOEP////8AAAAKAAAAAAAAAAADAAAADAAyACAAUABhAHIAbQAAAAAAAAPnAAAOEAAAAAAA//////////8AAAAB/////wAAAAcAAAAAFABjAG8AZwBnAGEAbgBfAHQAcwBzAAAABgBUAFMAUwAAAAYAVABTAFMAAAAMAFMAdAByAGUAcwBzAAAAAAADAAAAAAAAAAAAAAAAAQAAf3YAAAAAAAABQAAAAAANQBbw//////////8B//9VVf//f38AAAAAAAA/8AAAAAAAAAAAAAAB//8AAAAAAAAAAAAAAAABAAAAAAAADhAAAAAaAGMAbwBnAGcAYQBuAF8AdABzAHMAXwByAHIAAAABAAAAAAAAAAADAAAADAAyACAAUABhAHIAbQAAAAAAAAPnAAAOEAAAAAAD//////////8AAAAB/////wAAAAAAAg==", + "useSelected":"4", + "__LAST__":"1", + } + } +} \ No newline at end of file diff --git a/test/charts/Ride.gchart b/test/charts/Ride.gchart new file mode 100644 index 000000000..0f4cc415b --- /dev/null +++ b/test/charts/Ride.gchart @@ -0,0 +1,63 @@ +{ + "CHART":{ + "VERSION":"1", + "VIEW":"analysis", + "TYPE":"2", + "PROPERTIES":{ + "title":"Ride ", + "subtitle":" ", + "widthFactor":"1", + "heightFactor":"1.35135", + "style":"0", + "resizable":"0", + "stacked":"1", + "byseries":"1", + "stackWidth":"5", + "showGrid":"0", + "showFull":"0", + "showInterval":"2", + "hovering":"1", + "showHelp":"0", + "showATISS":"0", + "showANTISS":"0", + "showNP":"0", + "showXP":"0", + "showAP":"0", + "showSpeed":"2", + "showAccel":"0", + "showCad":"2", + "showTorque":"0", + "showPower":"1", + "showSlope":"0", + "showAltSlope":"1", + "showHr":"2", + "showTcore":"0", + "showCadD":"0", + "showTorqueD":"0", + "showPowerD":"0", + "showHrD":"0", + "showAlt":"0", + "showBalance":"2", + "showTE":"0", + "showPS":"0", + "showPCO":"0", + "showDC":"0", + "showPPP":"0", + "showTemp":"0", + "showW":"2", + "showRV":"0", + "showRCad":"0", + "showRGCT":"0", + "showSmO2":"2", + "showtHb":"2", + "showO2Hb":"2", + "showHHb":"2", + "showGear":"2", + "byDistance":"0", + "smoothing":"2", + "paintBrush":"1", + "userData":" ", + "__LAST__":"1", + } + } +} \ No newline at end of file diff --git a/test/charts/TSB v IF.gchart b/test/charts/TSB v IF.gchart new file mode 100644 index 000000000..93507c7ec --- /dev/null +++ b/test/charts/TSB v IF.gchart @@ -0,0 +1,19 @@ +{ + "CHART":{ + "VERSION":"1", + "VIEW":"home", + "TYPE":"39", + "PROPERTIES":{ + "title":"TSB v IF ", + "subtitle":" ", + "widthFactor":"2", + "heightFactor":"2", + "style":"0", + "resizable":"0", + "script":"##\n## TSB v IF with TSS\n##\n## How fresh were we and how hard did we go\n## and how much stress did we elicit.\n## A more meaningful way of reviewing the\n## PMC data in terms of managing load\/intensity\n\nGC.page(width=800, height=600)\n\n## get data\ncompares <- GC.season.metrics(compare=TRUE)\n\n## all pmc data\npmc <- GC.season.pmc(all=TRUE, metric=\"TSS\")\n\n# bigger margins please\npar(mar=c(6,6,6,6))\n\nplot(x=c(-30), y=c(0), \n ylim=c(0.6,1.1), xlim=c(-60,+60),\n xlab=\"\", main=\"\", ylab=\"\")\n\n## grid lines\ngrid(col=\"#404040\", lty=\"solid\", lwd=1)\n\n## title\ntitle(main=\"\", \n xlab=\"TSB\",\n ylab=\"IF\")\n\n## abline\nabline(h=0.85, slope=0, lty=\"dashed\", col=\"white\")\nabline(v=0, slope=1, lty=\"dashed\", col=\"white\")\n\nfor (compare in compares) {\n\n # combine pmc and metric data\n z <- merge(compare$metrics, pmc, by=\"date\")\n\n # area of circle should be proportional\n radius <- sqrt( z$Duration\/ 3.1415927 )\n\n # plot using ride colors if not comparing\n # or only one date range selected\n if (length(compares) == 1) {\n\n # make transparent for overlapping\n colors <- adjustcolor(z$color, 0.6)\n\n symbols(z$\"4\", z$IF, \n circles=radius,\n inches=0.4,\n add=TRUE,\n bg=colors,fg=colors,\n xlab=\"\", ylab=\"\")\n } else {\n\n # make transparent for overlapping\n color <- adjustcolor(compare$color, 0.6)\n\n symbols(z$\"4\", z$IF, \n circles=radius,\n inches=0.4,\n add=TRUE,\n bg=color,\n fg=color,\n xlab=\"\", ylab=\"\")\n\n\n }\n\n # labels for each bubble\n ##text(z$\"4\", z$IF, z$Workout_Code, col=\"gray\", cex=0.5)\n}\n\n## name the quadrants\ntext(-30,0.6, \"Maintain\", col=\"darkgray\", cex=1)\ntext(30,1.09, \"Race\", col=\"darkgray\", cex=1)\ntext(-30,1.09, \"Overload\", col=\"darkgray\", cex=1)\ntext(30,0.6, \"Junk\", col=\"darkgray\", cex=1) ", + "state":" ", + "showConsole":"0", + "__LAST__":"1", + } + } +} \ No newline at end of file diff --git a/test/charts/W'bal Sum.gchart b/test/charts/W'bal Sum.gchart new file mode 100644 index 000000000..0d4bed8db --- /dev/null +++ b/test/charts/W'bal Sum.gchart @@ -0,0 +1,19 @@ +{ + "CHART":{ + "VERSION":"1", + "VIEW":"analysis", + "TYPE":"38", + "PROPERTIES":{ + "title":"W'bal Sum ", + "subtitle":" ", + "widthFactor":"2", + "heightFactor":"2", + "style":"0", + "resizable":"0", + "script":"## Get Wbal data \nGC.page(height=600,width=800)\npar(bty=\"n\")\n\nwbal <- GC.activity.wbal(compare=FALSE)\nwbal <- as.vector(wbal, mode = \"any\")\n\nconfig <- GC.athlete.zones(sport=\"bike\",\n date=GC.activity.metrics()$date)\n\n## Set W'\nW <- config$wprime[1]\n\n## Calc the sustained Wbal deficit\ncwbal <- cumsum((W-wbal)\/3600)\n\n## Get your activity\nact <- GC.activity()\n\n## Extract your ride power data \nP <- act$power\n\n## Set CP\nCP <- config$cp[1]\n\n## Calc the cumulative Wbal cycled\ndwbal <- P - CP\n\ndwbal[dwbal < 0] <- 0\n\ncdwbal <- cumsum(dwbal)\n\nmxw <- max(cwbal)\n\n## plot the results\n\nplot(cwbal, ylim= c(0, max(cwbal)), \n main=\"\", col=\"cyan\",\n type=\"l\", lwd=\"2\", xlab='seconds')\ngrid(col=\"#404040\", lty=\"solid\")\nlines(cdwbal\/10, col='red')\n\nlegend(\"topleft\", c(\"Load Joules*Hours\", \"Cycled Joules\/10\"), inset = .05, lwd=c(2.5,2.5), bty=\"n\", col=c('white', 'red')) \n\ntext(length(cwbal)\/2,mxw\/10,paste(\"TSS=\",round(GC.activity.metrics()$TSS,0), \"cwb kJ=\", round(mxw\/1000,1)) ) ", + "state":" ", + "showConsole":"0", + "__LAST__":"1", + } + } +} \ No newline at end of file diff --git a/test/charts/eCP (LM).gchart b/test/charts/eCP (LM).gchart new file mode 100644 index 000000000..f2ce4c6c7 --- /dev/null +++ b/test/charts/eCP (LM).gchart @@ -0,0 +1,19 @@ +{ + "CHART":{ + "VERSION":"1", + "VIEW":"home", + "TYPE":"39", + "PROPERTIES":{ + "title":"eCP (LM) ", + "subtitle":" ", + "widthFactor":"2", + "heightFactor":"2", + "style":"0", + "resizable":"0", + "script":"##\n## LM fit of eCP model\n##\n## And visualise all 3 energy systems\n##\nlibrary(minpack.lm)\n##library(corrplot)\n\nGC.page(height=600, width=900)\npar(bty=\"n\")\n## two plots are shown\n## 1) PD model fit and 3 energy systems\n## 2) Residuals from the fit\n##par(mfrow=c(1,2))\n\n##-------------------------------------------------\n## THE eCP MODEL\n##-------------------------------------------------\n\n# eCP function used to compute the residuals during \n# the fit -- note inf and nan are checked for as they\n# can occur with zero values for parms and will break\n# the regression fit, so we return zero instead\necp <- function(x,paa,paadec,cp,tau,taudel,cpdel,cpdec,cpdecdel) {\n\n x = x\/60.00\n\n rt = (\n\n paa*(1.20-0.20*exp(-1*x))*exp(paadec*(x))\n + ( cp * (1-exp(taudel*x)) * \n (1-exp(cpdel*x)) * \n (1+cpdec*exp(cpdecdel\/x)) * \n (tau\/(x)))\n + ( cp * (1-exp(taudel*x)) * \n (1-exp(cpdel*x)) * \n (1+cpdec*exp(cpdecdel\/x)) * \n (1))\n )\n\n if (is.infinite(rt) || is.nan(rt)) rt <- 0;\n return(rt)\n\n}\n\n## set an empty plot\nplot(x=c(1,1,1), y=c(1,1,1), pch=20,\n type=\"n\",\n xlim=c(1,5400),\n ylim=c(1,900),\n log=\"x\",\n xlab=\"seconds\", \n ylab=\"watts\")\n\n##-------------------------------------------------\n## PERFORM THE FIT\n##-------------------------------------------------\n\ncompares <- GC.season.meanmax(compare=TRUE)\n\nfor (compare in compares) {\n\n# get meanmax and make a dataframe\nmm <- head(compare$meanmax$power, n=5400)\ny <- tail(mm, length(mm)-1)\nx <- seq(1,length(y),1)\ndata <- data.frame(x,y)\n\n## fit using nls\nfit <- nlsLM(y~ecp(x,paa,paadec,cp,tau,taudel,\n cpdel,cpdec,cpdecdel), \n data = data,\n start = list(paa = 811.241,\n paadec = -2.08695, \n cp = 280.131,\n tau = 1.20846,\n taudel = -4.8,\n cpdel = -0.9,\n cpdec = -0.583937,\n cpdecdel = -180),\n trace = FALSE)\n\n# capture parameter estimates\nPAA <- coef(fit)[[1]]\nPAADEC <- coef(fit)[[2]]\nCP <- coef(fit)[[3]]\nTAU <- coef(fit)[[4]]\nTAUDEL <- coef(fit)[[5]]\nCPDEL <- coef(fit)[[6]]\nCPDEC <- coef(fit)[[7]]\nCPDECDEL <- coef(fit)[[8]]\n\n\n##-------------------------------------------------\n## FORMULAS TO PLOT CURVES\n##-------------------------------------------------\n\n## function to plot full PD model\ncp <- function(x) {\n return (ecp(x,PAA,PAADEC,CP,TAU,\n TAUDEL,CPDEL,CPDEC,CPDECDEL))\n}\n\n## aerobic\nacp <- function(x,paa,paadec,cp,tau,taudel,cpdel,cpdec,cpdecdel) {\n\n x = x\/60.00\n rt = (CP * (1-exp(TAUDEL*x)) * \n (1-exp(CPDEL*x)) * \n (1+CPDEC*exp(CPDECDEL\/x)) * \n (1))\n\n if (is.infinite(rt) || is.nan(rt)) rt <- 0;\n return(rt)\n\n}\n\n## immediate\nicp <- function(x) {\n x = x\/60.00\n rt = PAA *(1.20-0.20*exp(-1*x))*exp(PAADEC*(x))\n if (is.infinite(rt) || is.nan(rt)) rt <- 0;\n return(rt)\n}\n\n## intermediate\nncp <- function(x) {\n x = x\/60.00\n rt = (CP * (1-exp(TAUDEL*x)) * \n (1-exp(CPDEL*x)) * \n (1+CPDEC*exp(CPDECDEL\/x)) * \n (TAU\/(x)))\n if (is.infinite(rt) || is.nan(rt)) rt <- 0;\n return(rt)\n}\n\n\n\n##-------------------------------------------------\n## PLOT THE INPUTS AND RESULTS\n##-------------------------------------------------\n\n## plot the mean max first, so we can overlay\n## the model curves\nlines(x=seq(1,length(y),1), y=y, pch=20, \n add=TRUE, log=\"x\", type=\"p\",\n col=compare$color)\n\n# grid lines\ngrid(col=\"#404040\", lty=\"solid\")\n\n## plot the eCP curve using the fit object\nlines(x,fitted(fit), col=compare$color, lty=\"dotted\")\n\n## 3 energy systems\nt <- length(mm)\n#curve(acp, from=1, to=t, add=TRUE, \n# lty=\"dashed\", col=\"gold\")\n\n##curve(icp, from=1, to=t, add=TRUE, \n## lty=\"dashed\", col=\"cyan\")\n\n#curve(ncp, from=1, to=t, add=TRUE, \n# lty=\"dashed\", col=\"green\")\n\n# plot both glycolysis systems together\n##fn <- function(x) { return(ncp(x)+acp(x)) }\n##curve(fn,\n## from=1, to=t, add=TRUE,\n## lty=\"solid\", col=\"white\")\n\n\n## display results on the plot\nif (length(compares)==1) {\n cp <- coef(fit)[[3]]\n wprime <- cp * coef(fit)[[4]] * 60\n text(x=1000,y=700, paste(\"CP=\", round(cp,0)))\n text(x=1000,y=600, paste(\"W'=\", round(wprime,0)))\n}\n\n##-------------------------------------------------\n## PLOT THE RESIDUALS\n##-------------------------------------------------\n#res <- resid(fit)\n#plot(y,res,col=\"green\",pch=20, \n# ylab=\"Watts\", xlab=\"Residuals\")\n#grid(lty=\"solid\", col=\"#404040\")\n\n##-------------------------------------------------\n## CORRELATION MATRIX\n##-------------------------------------------------\n\n##cm <- summary(fit, correlation=TRUE)$correlation\n##corrplot(cm, bg=\"black\", order=\"hclust\")\n\n}\n\n ", + "state":" ", + "showConsole":"0", + "__LAST__":"1", + } + } +} \ No newline at end of file