@neaps/tide-predictor 0.0.4
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/.eslintrc.js +22 -0
- package/.github/workflows/test.yml +15 -0
- package/.prettierrc +4 -0
- package/Gruntfile.js +87 -0
- package/LICENSE +21 -0
- package/README.md +199 -0
- package/babel.config.js +9 -0
- package/dist/tide-predictor.js +1013 -0
- package/examples/browser/index.html +51 -0
- package/jest.config.js +14 -0
- package/lib/astronomy/coefficients.js +31 -0
- package/lib/astronomy/constants.js +10 -0
- package/lib/astronomy/index.js +199 -0
- package/lib/constituents/compound-constituent.js +67 -0
- package/lib/constituents/constituent.js +74 -0
- package/lib/constituents/index.js +140 -0
- package/lib/harmonics/index.js +113 -0
- package/lib/harmonics/prediction.js +195 -0
- package/lib/index.es6.js +1005 -0
- package/lib/index.js +53 -0
- package/lib/node-corrections/index.js +147 -0
- package/package.json +45 -0
- package/rollup.config.js +21 -0
- package/src/__mocks__/constituents.js +335 -0
- package/src/__mocks__/secondary-station.js +11 -0
- package/src/__tests__/index.js +81 -0
- package/src/__tests__/noaa.js +92 -0
- package/src/astronomy/__tests__/coefficients.js +12 -0
- package/src/astronomy/__tests__/index.js +96 -0
- package/src/astronomy/coefficients.js +72 -0
- package/src/astronomy/constants.js +4 -0
- package/src/astronomy/index.js +201 -0
- package/src/constituents/__tests__/compound-constituent.js +44 -0
- package/src/constituents/__tests__/constituent.js +65 -0
- package/src/constituents/__tests__/index.js +34 -0
- package/src/constituents/compound-constituent.js +55 -0
- package/src/constituents/constituent.js +74 -0
- package/src/constituents/index.js +119 -0
- package/src/harmonics/__mocks__/water-levels.js +0 -0
- package/src/harmonics/__tests__/index.js +123 -0
- package/src/harmonics/__tests__/prediction.js +148 -0
- package/src/harmonics/index.js +87 -0
- package/src/harmonics/prediction.js +175 -0
- package/src/index.js +45 -0
- package/src/node-corrections/__tests__/index.js +114 -0
- package/src/node-corrections/index.js +208 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _constituent = _interopRequireDefault(require("./constituent"));
|
|
9
|
+
|
|
10
|
+
var _compoundConstituent = _interopRequireDefault(require("./compound-constituent"));
|
|
11
|
+
|
|
12
|
+
var _index = _interopRequireDefault(require("../node-corrections/index"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
var constituents = {}; // Long Term
|
|
17
|
+
|
|
18
|
+
constituents.Z0 = (0, _constituent["default"])('Z0', [0, 0, 0, 0, 0, 0, 0], _index["default"].uZero, _index["default"].fUnity);
|
|
19
|
+
constituents.SA = (0, _constituent["default"])('Sa', [0, 0, 1, 0, 0, 0, 0], _index["default"].uZero, _index["default"].fUnity);
|
|
20
|
+
constituents.SSA = (0, _constituent["default"])('Ssa', [0, 0, 2, 0, 0, 0, 0], _index["default"].uZero, _index["default"].fUnity);
|
|
21
|
+
constituents.MM = (0, _constituent["default"])('MM', [0, 1, 0, -1, 0, 0, 0], _index["default"].uZero, _index["default"].fMm);
|
|
22
|
+
constituents.MF = (0, _constituent["default"])('MF', [0, 2, 0, 0, 0, 0, 0], _index["default"].uMf, _index["default"].fMf); // Diurnals
|
|
23
|
+
|
|
24
|
+
constituents.Q1 = (0, _constituent["default"])('Q1', [1, -2, 0, 1, 0, 0, 1], _index["default"].uO1, _index["default"].fO1);
|
|
25
|
+
constituents.O1 = (0, _constituent["default"])('O1', [1, -1, 0, 0, 0, 0, 1], _index["default"].uO1, _index["default"].fO1);
|
|
26
|
+
constituents.K1 = (0, _constituent["default"])('K1', [1, 1, 0, 0, 0, 0, -1], _index["default"].uK1, _index["default"].fK1);
|
|
27
|
+
constituents.J1 = (0, _constituent["default"])('J1', [1, 2, 0, -1, 0, 0, -1], _index["default"].uJ1, _index["default"].fJ1);
|
|
28
|
+
constituents.M1 = (0, _constituent["default"])('M1', [1, 0, 0, 0, 0, 0, 1], _index["default"].uM1, _index["default"].fM1);
|
|
29
|
+
constituents.P1 = (0, _constituent["default"])('P1', [1, 1, -2, 0, 0, 0, 1], _index["default"].uZero, _index["default"].fUnity);
|
|
30
|
+
constituents.S1 = (0, _constituent["default"])('S1', [1, 1, -1, 0, 0, 0, 0], _index["default"].uZero, _index["default"].fUnity);
|
|
31
|
+
constituents.OO1 = (0, _constituent["default"])('OO1', [1, 3, 0, 0, 0, 0, -1], _index["default"].uOO1, _index["default"].fOO1); // Semi diurnals
|
|
32
|
+
|
|
33
|
+
constituents['2N2'] = (0, _constituent["default"])('2N2', [2, -2, 0, 2, 0, 0, 0], _index["default"].uM2, _index["default"].fM2);
|
|
34
|
+
constituents.N2 = (0, _constituent["default"])('N2', [2, -1, 0, 1, 0, 0, 0], _index["default"].uM2, _index["default"].fM2);
|
|
35
|
+
constituents.NU2 = (0, _constituent["default"])('NU2', [2, -1, 2, -1, 0, 0, 0], _index["default"].uM2, _index["default"].fM2);
|
|
36
|
+
constituents.M2 = (0, _constituent["default"])('M2', [2, 0, 0, 0, 0, 0, 0], _index["default"].uM2, _index["default"].fM2);
|
|
37
|
+
constituents.LAM2 = (0, _constituent["default"])('LAM2', [2, 1, -2, 1, 0, 0, 2], _index["default"].uM2, _index["default"].fM2);
|
|
38
|
+
constituents.L2 = (0, _constituent["default"])('L2', [2, 1, 0, -1, 0, 0, 2], _index["default"].uL2, _index["default"].fL2);
|
|
39
|
+
constituents.T2 = (0, _constituent["default"])('T2', [2, 2, -3, 0, 0, 1, 0], _index["default"].uZero, _index["default"].fUnity);
|
|
40
|
+
constituents.S2 = (0, _constituent["default"])('S2', [2, 2, -2, 0, 0, 0, 0], _index["default"].uZero, _index["default"].fUnity);
|
|
41
|
+
constituents.R2 = (0, _constituent["default"])('R2', [2, 2, -1, 0, 0, -1, 2], _index["default"].uZero, _index["default"].fUnity);
|
|
42
|
+
constituents.K2 = (0, _constituent["default"])('K2', [2, 2, 0, 0, 0, 0, 0], _index["default"].uK2, _index["default"].fK2); // Third diurnal
|
|
43
|
+
|
|
44
|
+
constituents.M3 = (0, _constituent["default"])('M3', [3, 0, 0, 0, 0, 0, 0], function (a) {
|
|
45
|
+
return _index["default"].uModd(a, 3);
|
|
46
|
+
}, function (a) {
|
|
47
|
+
return _index["default"].fModd(a, 3);
|
|
48
|
+
}); // Compound
|
|
49
|
+
|
|
50
|
+
constituents.MSF = (0, _compoundConstituent["default"])('MSF', [{
|
|
51
|
+
constituent: constituents.S2,
|
|
52
|
+
factor: 1
|
|
53
|
+
}, {
|
|
54
|
+
constituent: constituents.M2,
|
|
55
|
+
factor: -1
|
|
56
|
+
}]); // Diurnal
|
|
57
|
+
|
|
58
|
+
constituents['2Q1'] = (0, _compoundConstituent["default"])('2Q1', [{
|
|
59
|
+
constituent: constituents.N2,
|
|
60
|
+
factor: 1
|
|
61
|
+
}, {
|
|
62
|
+
constituent: constituents.J1,
|
|
63
|
+
factor: -1
|
|
64
|
+
}]);
|
|
65
|
+
constituents.RHO = (0, _compoundConstituent["default"])('RHO', [{
|
|
66
|
+
constituent: constituents.NU2,
|
|
67
|
+
factor: 1
|
|
68
|
+
}, {
|
|
69
|
+
constituent: constituents.K1,
|
|
70
|
+
factor: -1
|
|
71
|
+
}]); // Semi-Diurnal
|
|
72
|
+
|
|
73
|
+
constituents.MU2 = (0, _compoundConstituent["default"])('MU2', [{
|
|
74
|
+
constituent: constituents.M2,
|
|
75
|
+
factor: 2
|
|
76
|
+
}, {
|
|
77
|
+
constituent: constituents.S2,
|
|
78
|
+
factor: -1
|
|
79
|
+
}]);
|
|
80
|
+
constituents['2SM2'] = (0, _compoundConstituent["default"])('2SM2', [{
|
|
81
|
+
constituent: constituents.S2,
|
|
82
|
+
factor: 2
|
|
83
|
+
}, {
|
|
84
|
+
constituent: constituents.M2,
|
|
85
|
+
factor: -1
|
|
86
|
+
}]); // Third-Diurnal
|
|
87
|
+
|
|
88
|
+
constituents['2MK3'] = (0, _compoundConstituent["default"])('2MK3', [{
|
|
89
|
+
constituent: constituents.M2,
|
|
90
|
+
factor: 1
|
|
91
|
+
}, {
|
|
92
|
+
constituent: constituents.O1,
|
|
93
|
+
factor: 1
|
|
94
|
+
}]);
|
|
95
|
+
constituents.MK3 = (0, _compoundConstituent["default"])('MK3', [{
|
|
96
|
+
constituent: constituents.M2,
|
|
97
|
+
factor: 1
|
|
98
|
+
}, {
|
|
99
|
+
constituent: constituents.K1,
|
|
100
|
+
factor: 1
|
|
101
|
+
}]); // Quarter-Diurnal
|
|
102
|
+
|
|
103
|
+
constituents.MN4 = (0, _compoundConstituent["default"])('MN4', [{
|
|
104
|
+
constituent: constituents.M2,
|
|
105
|
+
factor: 1
|
|
106
|
+
}, {
|
|
107
|
+
constituent: constituents.N2,
|
|
108
|
+
factor: 1
|
|
109
|
+
}]);
|
|
110
|
+
constituents.M4 = (0, _compoundConstituent["default"])('M4', [{
|
|
111
|
+
constituent: constituents.M2,
|
|
112
|
+
factor: 2
|
|
113
|
+
}]);
|
|
114
|
+
constituents.MS4 = (0, _compoundConstituent["default"])('MS4', [{
|
|
115
|
+
constituent: constituents.M2,
|
|
116
|
+
factor: 1
|
|
117
|
+
}, {
|
|
118
|
+
constituent: constituents.S2,
|
|
119
|
+
factor: 1
|
|
120
|
+
}]);
|
|
121
|
+
constituents.S4 = (0, _compoundConstituent["default"])('S4', [{
|
|
122
|
+
constituent: constituents.S2,
|
|
123
|
+
factor: 2
|
|
124
|
+
}]); // Sixth-Diurnal
|
|
125
|
+
|
|
126
|
+
constituents.M6 = (0, _compoundConstituent["default"])('M6', [{
|
|
127
|
+
constituent: constituents.M2,
|
|
128
|
+
factor: 3
|
|
129
|
+
}]);
|
|
130
|
+
constituents.S6 = (0, _compoundConstituent["default"])('S6', [{
|
|
131
|
+
constituent: constituents.S2,
|
|
132
|
+
factor: 3
|
|
133
|
+
}]); // Eighth-Diurnals
|
|
134
|
+
|
|
135
|
+
constituents.M8 = (0, _compoundConstituent["default"])('M8', [{
|
|
136
|
+
constituent: constituents.M2,
|
|
137
|
+
factor: 4
|
|
138
|
+
}]);
|
|
139
|
+
var _default = constituents;
|
|
140
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTimeline = exports.getDate = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _prediction = _interopRequireDefault(require("./prediction"));
|
|
9
|
+
|
|
10
|
+
var _index = _interopRequireDefault(require("../constituents/index"));
|
|
11
|
+
|
|
12
|
+
var _constants = require("../astronomy/constants");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
var getDate = function getDate(time) {
|
|
17
|
+
if (time instanceof Date) {
|
|
18
|
+
return time;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof time === 'number') {
|
|
22
|
+
return new Date(time * 1000);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
throw new Error('Invalid date format, should be a Date object, or timestamp');
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.getDate = getDate;
|
|
29
|
+
|
|
30
|
+
var getTimeline = function getTimeline(start, end, seconds) {
|
|
31
|
+
seconds = typeof seconds !== 'undefined' ? seconds : 10 * 60;
|
|
32
|
+
var timeline = [];
|
|
33
|
+
var endTime = end.getTime() / 1000;
|
|
34
|
+
var lastTime = start.getTime() / 1000;
|
|
35
|
+
var startTime = lastTime;
|
|
36
|
+
var hours = [];
|
|
37
|
+
|
|
38
|
+
while (lastTime <= endTime) {
|
|
39
|
+
timeline.push(new Date(lastTime * 1000));
|
|
40
|
+
hours.push((lastTime - startTime) / (60 * 60));
|
|
41
|
+
lastTime += seconds;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
items: timeline,
|
|
46
|
+
hours: hours
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.getTimeline = getTimeline;
|
|
51
|
+
|
|
52
|
+
var harmonicsFactory = function harmonicsFactory(_ref) {
|
|
53
|
+
var harmonicConstituents = _ref.harmonicConstituents,
|
|
54
|
+
phaseKey = _ref.phaseKey,
|
|
55
|
+
offset = _ref.offset;
|
|
56
|
+
|
|
57
|
+
if (!Array.isArray(harmonicConstituents)) {
|
|
58
|
+
throw new Error('Harmonic constituents are not an array');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var constituents = [];
|
|
62
|
+
harmonicConstituents.forEach(function (constituent, index) {
|
|
63
|
+
if (typeof constituent.name === 'undefined') {
|
|
64
|
+
throw new Error('Harmonic constituents must have a name property');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof _index["default"][constituent.name] !== 'undefined') {
|
|
68
|
+
constituent._model = _index["default"][constituent.name];
|
|
69
|
+
constituent._phase = _constants.d2r * constituent[phaseKey];
|
|
70
|
+
constituents.push(constituent);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (offset !== false) {
|
|
75
|
+
constituents.push({
|
|
76
|
+
name: 'Z0',
|
|
77
|
+
_model: _index["default"].Z0,
|
|
78
|
+
_phase: 0,
|
|
79
|
+
amplitude: offset
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var start = new Date();
|
|
84
|
+
var end = new Date();
|
|
85
|
+
var harmonics = {};
|
|
86
|
+
|
|
87
|
+
harmonics.setTimeSpan = function (startTime, endTime) {
|
|
88
|
+
start = getDate(startTime);
|
|
89
|
+
end = getDate(endTime);
|
|
90
|
+
|
|
91
|
+
if (start.getTime() >= end.getTime()) {
|
|
92
|
+
throw new Error('Start time must be before end time');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return harmonics;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
harmonics.prediction = function (options) {
|
|
99
|
+
options = typeof options !== 'undefined' ? options : {
|
|
100
|
+
timeFidelity: 10 * 60
|
|
101
|
+
};
|
|
102
|
+
return (0, _prediction["default"])({
|
|
103
|
+
timeline: getTimeline(start, end, options.timeFidelity),
|
|
104
|
+
constituents: constituents,
|
|
105
|
+
start: start
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return Object.freeze(harmonics);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
var _default = harmonicsFactory;
|
|
113
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _index = _interopRequireDefault(require("../astronomy/index"));
|
|
9
|
+
|
|
10
|
+
var _constants = require("../astronomy/constants");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
14
|
+
var modulus = function modulus(a, b) {
|
|
15
|
+
return (a % b + b) % b;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var addExtremesOffsets = function addExtremesOffsets(extreme, offsets) {
|
|
19
|
+
if (typeof offsets === 'undefined' || !offsets) {
|
|
20
|
+
return extreme;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (extreme.high && offsets.height_offset && offsets.height_offset.high) {
|
|
24
|
+
extreme.level *= offsets.height_offset.high;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (extreme.low && offsets.height_offset && offsets.height_offset.low) {
|
|
28
|
+
extreme.level *= offsets.height_offset.low;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (extreme.high && offsets.time_offset && offsets.time_offset.high) {
|
|
32
|
+
extreme.time = new Date(extreme.time.getTime() + offsets.time_offset.high * 60 * 1000);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (extreme.low && offsets.time_offset && offsets.time_offset.low) {
|
|
36
|
+
extreme.time = new Date(extreme.time.getTime() + offsets.time_offset.low * 60 * 1000);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return extreme;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var getExtremeLabel = function getExtremeLabel(label, highLowLabels) {
|
|
43
|
+
if (typeof highLowLabels !== 'undefined' && typeof highLowLabels[label] !== 'undefined') {
|
|
44
|
+
return highLowLabels[label];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var labels = {
|
|
48
|
+
high: 'High',
|
|
49
|
+
low: 'Low'
|
|
50
|
+
};
|
|
51
|
+
return labels[label];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var predictionFactory = function predictionFactory(_ref) {
|
|
55
|
+
var timeline = _ref.timeline,
|
|
56
|
+
constituents = _ref.constituents,
|
|
57
|
+
start = _ref.start;
|
|
58
|
+
|
|
59
|
+
var getLevel = function getLevel(hour, modelBaseSpeed, modelU, modelF, modelBaseValue) {
|
|
60
|
+
var amplitudes = [];
|
|
61
|
+
var result = 0;
|
|
62
|
+
constituents.forEach(function (constituent) {
|
|
63
|
+
var amplitude = constituent.amplitude;
|
|
64
|
+
var phase = constituent._phase;
|
|
65
|
+
var f = modelF[constituent.name];
|
|
66
|
+
var speed = modelBaseSpeed[constituent.name];
|
|
67
|
+
var u = modelU[constituent.name];
|
|
68
|
+
var V0 = modelBaseValue[constituent.name];
|
|
69
|
+
amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase));
|
|
70
|
+
}); // sum up each row
|
|
71
|
+
|
|
72
|
+
amplitudes.forEach(function (item) {
|
|
73
|
+
result += item;
|
|
74
|
+
});
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var prediction = {};
|
|
79
|
+
|
|
80
|
+
prediction.getExtremesPrediction = function (options) {
|
|
81
|
+
var _ref2 = typeof options !== 'undefined' ? options : {},
|
|
82
|
+
labels = _ref2.labels,
|
|
83
|
+
offsets = _ref2.offsets;
|
|
84
|
+
|
|
85
|
+
var results = [];
|
|
86
|
+
|
|
87
|
+
var _prepare = prepare(),
|
|
88
|
+
baseSpeed = _prepare.baseSpeed,
|
|
89
|
+
u = _prepare.u,
|
|
90
|
+
f = _prepare.f,
|
|
91
|
+
baseValue = _prepare.baseValue;
|
|
92
|
+
|
|
93
|
+
var goingUp = false;
|
|
94
|
+
var goingDown = false;
|
|
95
|
+
var lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue);
|
|
96
|
+
timeline.items.forEach(function (time, index) {
|
|
97
|
+
var hour = timeline.hours[index];
|
|
98
|
+
var level = getLevel(hour, baseSpeed, u[index], f[index], baseValue); // Compare this level to the last one, if we
|
|
99
|
+
// are changing angle, then the last one was high or low
|
|
100
|
+
|
|
101
|
+
if (level > lastLevel && goingDown) {
|
|
102
|
+
results.push(addExtremesOffsets({
|
|
103
|
+
time: timeline.items[index - 1],
|
|
104
|
+
level: lastLevel,
|
|
105
|
+
high: false,
|
|
106
|
+
low: true,
|
|
107
|
+
label: getExtremeLabel('low', labels)
|
|
108
|
+
}, offsets));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (level < lastLevel && goingUp) {
|
|
112
|
+
results.push(addExtremesOffsets({
|
|
113
|
+
time: timeline.items[index - 1],
|
|
114
|
+
level: lastLevel,
|
|
115
|
+
high: true,
|
|
116
|
+
low: false,
|
|
117
|
+
label: getExtremeLabel('high', labels)
|
|
118
|
+
}, offsets));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (level > lastLevel) {
|
|
122
|
+
goingUp = true;
|
|
123
|
+
goingDown = false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (level < lastLevel) {
|
|
127
|
+
goingUp = false;
|
|
128
|
+
goingDown = true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
lastLevel = level;
|
|
132
|
+
});
|
|
133
|
+
return results;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
prediction.getTimelinePrediction = function () {
|
|
137
|
+
var results = [];
|
|
138
|
+
|
|
139
|
+
var _prepare2 = prepare(),
|
|
140
|
+
baseSpeed = _prepare2.baseSpeed,
|
|
141
|
+
u = _prepare2.u,
|
|
142
|
+
f = _prepare2.f,
|
|
143
|
+
baseValue = _prepare2.baseValue;
|
|
144
|
+
|
|
145
|
+
timeline.items.forEach(function (time, index) {
|
|
146
|
+
var hour = timeline.hours[index];
|
|
147
|
+
var prediction = {
|
|
148
|
+
time: time,
|
|
149
|
+
hour: hour,
|
|
150
|
+
level: getLevel(hour, baseSpeed, u[index], f[index], baseValue)
|
|
151
|
+
};
|
|
152
|
+
results.push(prediction);
|
|
153
|
+
});
|
|
154
|
+
return results;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var prepare = function prepare() {
|
|
158
|
+
var baseAstro = (0, _index["default"])(start);
|
|
159
|
+
var baseValue = {};
|
|
160
|
+
var baseSpeed = {};
|
|
161
|
+
var u = [];
|
|
162
|
+
var f = [];
|
|
163
|
+
constituents.forEach(function (constituent) {
|
|
164
|
+
var value = constituent._model.value(baseAstro);
|
|
165
|
+
|
|
166
|
+
var speed = constituent._model.speed(baseAstro);
|
|
167
|
+
|
|
168
|
+
baseValue[constituent.name] = _constants.d2r * value;
|
|
169
|
+
baseSpeed[constituent.name] = _constants.d2r * speed;
|
|
170
|
+
});
|
|
171
|
+
timeline.items.forEach(function (time) {
|
|
172
|
+
var uItem = {};
|
|
173
|
+
var fItem = {};
|
|
174
|
+
var itemAstro = (0, _index["default"])(time);
|
|
175
|
+
constituents.forEach(function (constituent) {
|
|
176
|
+
var constituentU = modulus(constituent._model.u(itemAstro), 360);
|
|
177
|
+
uItem[constituent.name] = _constants.d2r * constituentU;
|
|
178
|
+
fItem[constituent.name] = modulus(constituent._model.f(itemAstro), 360);
|
|
179
|
+
});
|
|
180
|
+
u.push(uItem);
|
|
181
|
+
f.push(fItem);
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
baseValue: baseValue,
|
|
185
|
+
baseSpeed: baseSpeed,
|
|
186
|
+
u: u,
|
|
187
|
+
f: f
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return Object.freeze(prediction);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
var _default = predictionFactory;
|
|
195
|
+
exports["default"] = _default;
|