@neaps/tide-predictor
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -956,5 +956,7 @@ (function (global, factory) { | ||
harmonics.prediction = () => { | ||
harmonics.prediction = options => { | ||
options = | ||
typeof options !== 'undefined' ? options : { timeFidelity: 10 * 60 }; | ||
return predictionFactory({ | ||
timeline: getTimeline(start, end), | ||
timeline: getTimeline(start, end, options.timeFidelity), | ||
constituents: constituents$1, | ||
@@ -991,6 +993,6 @@ start: start | ||
getExtremesPrediction: ({ start, end, labels, offsets }) => { | ||
getExtremesPrediction: ({ start, end, labels, offsets, timeFidelity }) => { | ||
return harmonicsFactory(harmonicsOptions) | ||
.setTimeSpan(start, end) | ||
.prediction() | ||
.prediction({ timeFidelity: timeFidelity }) | ||
.getExtremesPrediction(labels, offsets) | ||
@@ -997,0 +999,0 @@ }, |
@@ -98,5 +98,8 @@ "use strict"; | ||
harmonics.prediction = function () { | ||
harmonics.prediction = function (options) { | ||
options = typeof options !== 'undefined' ? options : { | ||
timeFidelity: 10 * 60 | ||
}; | ||
return (0, _prediction["default"])({ | ||
timeline: getTimeline(start, end), | ||
timeline: getTimeline(start, end, options.timeFidelity), | ||
constituents: constituents, | ||
@@ -103,0 +106,0 @@ start: start |
@@ -950,5 +950,7 @@ const d2r = Math.PI / 180.0; | ||
harmonics.prediction = () => { | ||
harmonics.prediction = options => { | ||
options = | ||
typeof options !== 'undefined' ? options : { timeFidelity: 10 * 60 }; | ||
return predictionFactory({ | ||
timeline: getTimeline(start, end), | ||
timeline: getTimeline(start, end, options.timeFidelity), | ||
constituents: constituents$1, | ||
@@ -985,6 +987,6 @@ start: start | ||
getExtremesPrediction: ({ start, end, labels, offsets }) => { | ||
getExtremesPrediction: ({ start, end, labels, offsets, timeFidelity }) => { | ||
return harmonicsFactory(harmonicsOptions) | ||
.setTimeSpan(start, end) | ||
.prediction() | ||
.prediction({ timeFidelity: timeFidelity }) | ||
.getExtremesPrediction(labels, offsets) | ||
@@ -991,0 +993,0 @@ }, |
@@ -37,4 +37,7 @@ "use strict"; | ||
labels = _ref2.labels, | ||
offsets = _ref2.offsets; | ||
return (0, _index["default"])(harmonicsOptions).setTimeSpan(start, end).prediction().getExtremesPrediction(labels, offsets); | ||
offsets = _ref2.offsets, | ||
timeFidelity = _ref2.timeFidelity; | ||
return (0, _index["default"])(harmonicsOptions).setTimeSpan(start, end).prediction({ | ||
timeFidelity: timeFidelity | ||
}).getExtremesPrediction(labels, offsets); | ||
}, | ||
@@ -41,0 +44,0 @@ getWaterLevelAtTime: function getWaterLevelAtTime(_ref3) { |
{ | ||
"name": "@neaps/tide-predictor", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Tide predictor", | ||
@@ -5,0 +5,0 @@ "main": "", |
@@ -7,2 +7,4 @@ [![CircleCI](https://circleci.com/gh/neaps/tide-predictor.svg?style=svg)](https://circleci.com/gh/neaps/tide-predictor) [![Coverage Status](https://coveralls.io/repos/github/neaps/tide-predictor/badge.svg?branch=master)](https://coveralls.io/github/neaps/tide-predictor?branch=master) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fneaps%2Ftide-predictor.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fneaps%2Ftide-predictor?ref=badge_shield) | ||
<!-- START DOCS --> | ||
## Warning | ||
@@ -20,4 +22,2 @@ | ||
Once published, use: | ||
``` | ||
@@ -37,2 +37,4 @@ # yarn | ||
Note that, for now, Neaps **will not** do any timezone corrections. This means you need to pass date objects that align with whatever timezone the constituents are in. | ||
```javascript | ||
@@ -110,4 +112,5 @@ import TidePrediction from '@neaps/tide-prediction' | ||
- `startDate` - **Required ** - The date & time to start looking for high and low tides | ||
- `endDate` - **Required ** - The date & time to stop looking for high and low tides | ||
- `start` - **Required ** - The date & time to start looking for high and low tides | ||
- `end` - **Required ** - The date & time to stop looking for high and low tides | ||
- `timeFidelity` - Number of seconds accurate the time should be, defaults to 10 minutes. | ||
- `labels` - An object to define the human-readable labels for the tides | ||
@@ -114,0 +117,0 @@ - `high` - The human-readable label for high tides |
@@ -59,2 +59,11 @@ import mockConstituents from '../__mocks__/constituents' | ||
test('it predicts the tidal extremes with high fidelity', () => { | ||
const results = tidePrediction(mockConstituents).getExtremesPrediction({ | ||
start: startDate, | ||
end: endDate, | ||
timeFidelity: 60 | ||
}) | ||
expect(results[0].level).toBeCloseTo(-1.565389, 4) | ||
}) | ||
test('it fetches a single water level', () => { | ||
@@ -61,0 +70,0 @@ const result = tidePrediction(mockConstituents).getWaterLevelAtTime({ |
@@ -90,2 +90,14 @@ import harmonics from '../index' | ||
}) | ||
test('it finds high and low tides with high fidelity', () => { | ||
const results = harmonics({ | ||
harmonicConstituents: mockHarmonicConstituents, | ||
phaseKey: 'phase_GMT', | ||
offset: false | ||
}) | ||
.setTimeSpan(startDate, extremesEndDate) | ||
.prediction({ timeFidelity: 60 }) | ||
.getExtremesPrediction() | ||
expect(results[0].level).toBeCloseTo(-1.5653894, 4) | ||
}) | ||
}) | ||
@@ -92,0 +104,0 @@ |
@@ -73,5 +73,7 @@ import prediction from './prediction' | ||
harmonics.prediction = () => { | ||
harmonics.prediction = options => { | ||
options = | ||
typeof options !== 'undefined' ? options : { timeFidelity: 10 * 60 } | ||
return prediction({ | ||
timeline: getTimeline(start, end), | ||
timeline: getTimeline(start, end, options.timeFidelity), | ||
constituents: constituents, | ||
@@ -78,0 +80,0 @@ start: start |
@@ -26,6 +26,6 @@ import harmonics from './harmonics/index' | ||
getExtremesPrediction: ({ start, end, labels, offsets }) => { | ||
getExtremesPrediction: ({ start, end, labels, offsets, timeFidelity }) => { | ||
return harmonics(harmonicsOptions) | ||
.setTimeSpan(start, end) | ||
.prediction() | ||
.prediction({ timeFidelity: timeFidelity }) | ||
.getExtremesPrediction(labels, offsets) | ||
@@ -32,0 +32,0 @@ }, |
174249
4791
202