signalk-polar-performance-plugin 0.0.24 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,17 +42,19 @@ In the plugin configuration you can toggle the following options:
42
42
  - Wind angle for maximum speed at this wind speed
43
43
  - Fill up the ends of the polar diagram
44
44
  - Visualisation of the polar diagram
45
+ - Configurable damping alorithm on inputs
46
+ - Extrapolation of polar data towards 0
47
+ - Configurable overall performance adjustment ratio
45
48
 
46
49
  ### To-do list
47
50
  - Improved interpolation
48
51
  - Make moment to do calculation smarter/configurable
49
52
  - API to see JSON of polar
50
- - Extrapolation of polar data
53
+ - Extrapolation of polar data towards 50 kts?
51
54
  - Create polar from live data
52
55
  -- Save polar info to file
53
56
  -- Save new record speed for angle in polar
54
57
  -- Determine if we're on a steady course to avoid fake records
55
- -- Dampening algoritms
56
58
  -- Configure the resolution of the polar diagram
57
59
  - Support multiple polar diagrams
58
60
  - Capture heel in polar diagram
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signalk-polar-performance-plugin",
3
- "version": "0.0.24",
3
+ "version": "0.0.27",
4
4
  "description": "A plugin that calculates performance information based on a (CSV) polar diagram.",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {
package/plugin/index.js CHANGED
@@ -50,6 +50,12 @@ module.exports = function (app) {
50
50
  type: 'boolean',
51
51
  title: 'Enable writing of maximum speed angle and boat speed for a given TWS'
52
52
  },
53
+ perfAdjust: {
54
+ type: 'number',
55
+ description: 'This ratio allows you to lower the polar boat speeds in case you are not expecting to meet 100% due to e.g. weight. 1 = 100%, 0.8 = 80% etc',
56
+ title: 'Performance adjustment ratio',
57
+ default: 1
58
+ },
53
59
  dampingTWA: {
54
60
  type: 'number',
55
61
  description: 'If data appears erratic or too sensitive, damping may be applied to amke information appear more stable. With damping set to 0, the data is presented in raw form wih no damping applied.',
@@ -402,7 +408,7 @@ module.exports = function (app) {
402
408
  performance.polarSpeedRatio = BSP / performance.polarSpeed
403
409
  if (options.VMG == true) {
404
410
  performance.velocityMadeGood = Math.abs(BSP * Math.cos(TWA))
405
- performance.polarVelocityMadeGood = Math.abs(performance.polarSpeed * Math.cos(TWA))
411
+ performance.polarVelocityMadeGood = Math.abs(performance.polarSpeed * Math.cos(targetTWA))
406
412
  performance.polarVelocityMadeGoodRatio = performance.velocityMadeGood / performance.polarVelocityMadeGood
407
413
  }
408
414
  } else {
@@ -462,7 +468,7 @@ module.exports = function (app) {
462
468
  for (let index = 0; index < row.length-1; index++) {
463
469
  if (row[index+1] != 0) {
464
470
  polar[index][angleName] = angle
465
- let tbs = ktsToMs(Number(row[index+1]))
471
+ let tbs = ktsToMs(Number(row[index+1])) * (options.perfAdjust || 1)
466
472
  let vmg = tbs * Math.abs(Math.cos(angle))
467
473
  polar[index][VMGName] = roundDec(vmg)
468
474
  if (typeof polar[index]['twa'] == 'undefined') {
@@ -483,7 +489,7 @@ module.exports = function (app) {
483
489
  if (typeof polar[index].twa == 'undefined') {
484
490
  polar[index].twa = []
485
491
  }
486
- let tbs = ktsToMs(Number(row[index+1]))
492
+ let tbs = ktsToMs(Number(row[index+1])) * (options.perfAdjust || 1)
487
493
  let vmg = tbs * Math.abs(Math.cos(angle))
488
494
  let Obj = {"twa": angle, "tbs": tbs, "vmg": vmg}
489
495
  // app.debug('Adding Obj: %s', JSON.stringify(Obj))
@@ -546,6 +552,23 @@ module.exports = function (app) {
546
552
  }
547
553
 
548
554
  // And now fill in some missing ends to avoid doing expensive calculations in the main loop
555
+ if (polar[0].tws > 0) {
556
+ // Add a 0 line to allow interpolation at very low wind speeds
557
+ app.debug('Add a 0 line to allow interpolation at very low wind speeds')
558
+ let Obj = {
559
+ tws: 0.0001,
560
+ 'Beat angle': polar[0]['Beat angle'],
561
+ 'Beat VMG': polar[0]['Beat VMG'],
562
+ 'Run angle': polar[0]['Run angle'],
563
+ 'Run VMG': polar[0]['Run VMG'],
564
+ twa: []
565
+ }
566
+ Object.keys(polar[0].twa).forEach(twaObj => {
567
+ Obj.twa.push({twa: twaObj.twa, tbs: 0})
568
+ })
569
+ polar.unshift(Obj)
570
+ }
571
+
549
572
  for (let index = 0; index < polar.length; index++) {
550
573
  // Sorted on angle, so first is lowest
551
574
  let tws = polar[index].tws
@@ -568,7 +591,7 @@ module.exports = function (app) {
568
591
  polar[index].twa = topArray.concat(twaArray)
569
592
  }
570
593
 
571
- for (let index = 0; index < polar.length-1; index++) {
594
+ for (let index = 0; index < polar.length; index++) {
572
595
  let tws = polar[index].tws
573
596
  let twaArray = polar[index].twa
574
597
  let highTBS = twaArray[twaArray.length-1].tbs
@@ -635,6 +658,8 @@ module.exports = function (app) {
635
658
  data.datasets[index].pointRadius.push(radius)
636
659
  }
637
660
  }
661
+ // Remove 0 kts line
662
+ data.datasets.shift()
638
663
  return data
639
664
  }
640
665