@neaps/tide-predictor 0.1.1 → 0.2.0
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 +27 -50
- package/dist/index.cjs +931 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +150 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +930 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -23
- package/.eslintrc.cjs +0 -18
- package/.github/workflows/test.yml +0 -21
- package/.prettierrc +0 -5
- package/LICENSE +0 -21
- package/dist/commonjs/index.js +0 -1005
- package/dist/commonjs/package.json +0 -1
- package/dist/web/tide-predictor.js +0 -1011
- package/dist/web/tide-predictor.min.js +0 -1
- package/examples/browser/index.html +0 -51
- package/jest.config.js +0 -14
- package/rollup.config.js +0 -21
- package/src/astronomy/coefficients.js +0 -72
- package/src/astronomy/constants.js +0 -4
- package/src/astronomy/index.js +0 -201
- package/src/constituents/compound-constituent.js +0 -54
- package/src/constituents/constituent.js +0 -73
- package/src/constituents/index.js +0 -119
- package/src/harmonics/index.js +0 -87
- package/src/harmonics/prediction.js +0 -175
- package/src/index.js +0 -45
- package/src/node-corrections/index.js +0 -208
- package/test/_mocks/constituents.js +0 -335
- package/test/_mocks/secondary-station.js +0 -11
- package/test/_mocks/water-levels.js +0 -0
- package/test/astronomy/coefficients.js +0 -15
- package/test/astronomy/index.js +0 -98
- package/test/constituents/compound-constituent.js +0 -46
- package/test/constituents/constituent.js +0 -67
- package/test/constituents/index.js +0 -35
- package/test/harmonics/index.js +0 -125
- package/test/harmonics/prediction.js +0 -154
- package/test/index.js +0 -83
- package/test/lib/close-to.js +0 -7
- package/test/noaa.js +0 -110
- package/test/node-corrections/index.js +0 -116
package/README.md
CHANGED
|
@@ -1,51 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
# @neaps/tide-predictor
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
A Javascript tide harmonic calculator.
|
|
3
|
+
A tide harmonic calculator written in TypeScript.
|
|
6
4
|
|
|
7
5
|
<!-- START DOCS -->
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Tide predictions are only as good as the harmonics data available, and these can be inconsistent and vary widely based on the accuracy of the source data and local conditions.
|
|
14
|
-
|
|
15
|
-
The tide predictions do not factor events such as storm surge, wind waves, uplift, tsunamis, or sadly, climate change. 😢
|
|
7
|
+
> [!WARNING]
|
|
8
|
+
> **Not for navigational use**
|
|
9
|
+
>
|
|
10
|
+
> Do not use calculations from this project for navigation, or depend on them in any situation where inaccuracies could result in harm to a person or property. Tide predictions are only as good as the harmonics data available, and these can be inconsistent and vary widely based on the accuracy of the source data and local conditions. The tide predictions do not factor events such as storm surge, wind waves, uplift, tsunamis, or sadly, climate change. 😢
|
|
16
11
|
|
|
17
12
|
# Installation
|
|
18
13
|
|
|
14
|
+
```sh
|
|
15
|
+
npm install @neaps/tide-predictor
|
|
19
16
|
```
|
|
20
|
-
#npm
|
|
21
|
-
npm install @neaps/tide-prediction
|
|
22
|
-
|
|
23
|
-
# yarn
|
|
24
|
-
yarn add @neaps/tide-prediction
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Importing
|
|
29
|
-
|
|
30
|
-
You can import the module using Ecmascript, or CommonJS. Note that the CommonJS export is transpiled, so deep debugging the module that way will be difficult.
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import TidePrediction from '@neaps/tide-prediction'
|
|
34
|
-
const TidePrediction = require('@neaps/tide-prediction')
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
There are also packaged and minified versions for the browser in `dist/web`.
|
|
38
17
|
|
|
39
18
|
# Usage
|
|
40
19
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Because many constituent datum come with multiple phases (in the case of NOAA's data, they are `phase_local` and `phase_GMT`), there is a `phaseKey` option for choosing which to use.
|
|
20
|
+
`@neaps/tide-predictor` requires that you [provide your own tidal harmonics information](#constituent-object) to generate a prediction. For a complete tide prediction solution, including finding nearby stations and their harmonics, check out the [`neaps` package](https://github.com/neaps/neaps).
|
|
44
21
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
import TidePrediction from '@neaps/tide-prediction'
|
|
22
|
+
```typescript
|
|
23
|
+
import TidePredictor from '@neaps/tide-predictor'
|
|
49
24
|
|
|
50
25
|
const constituents = [
|
|
51
26
|
{
|
|
@@ -58,7 +33,7 @@ const constituents = [
|
|
|
58
33
|
//....there are usually many, read the docs
|
|
59
34
|
]
|
|
60
35
|
|
|
61
|
-
const highLowTides =
|
|
36
|
+
const highLowTides = TidePredictor(constituents, {
|
|
62
37
|
phaseKey: 'phase_GMT'
|
|
63
38
|
}).getExtremesPrediction({
|
|
64
39
|
start: new Date('2019-01-01'),
|
|
@@ -66,13 +41,15 @@ const highLowTides = tidePrediction(constituents, {
|
|
|
66
41
|
})
|
|
67
42
|
```
|
|
68
43
|
|
|
44
|
+
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.
|
|
45
|
+
|
|
69
46
|
## Tide prediction object
|
|
70
47
|
|
|
71
|
-
Calling `
|
|
48
|
+
Calling `tidePredictor` will generate a new tide prediction object. It accepts the following arguments:
|
|
72
49
|
|
|
73
50
|
- `constituents` - An array of [constituent objects](#constituent-object)
|
|
74
51
|
- `options` - An object with one of:
|
|
75
|
-
- `phaseKey` - The name of the parameter within constituents that is considered the "phase"
|
|
52
|
+
- `phaseKey` - The name of the parameter within constituents that is considered the "phase" because many constituent datum come with multiple phases (in the case of NOAA's data, they are `phase_local` and `phase_GMT`).
|
|
76
53
|
- `offset` - A value to add to **all** values predicted. This is useful if you want to, for example, offset tides by mean high water, etc.
|
|
77
54
|
|
|
78
55
|
### Tide prediction methods
|
|
@@ -83,10 +60,10 @@ The returned tide prediction object has various methods. All of these return reg
|
|
|
83
60
|
|
|
84
61
|
Returns the predicted high and low tides between a start and end date.
|
|
85
62
|
|
|
86
|
-
```
|
|
63
|
+
```typescript
|
|
87
64
|
const startDate = new Date()
|
|
88
65
|
const endDate = new Date(startDate + 3 * 24 * 60 * 60 * 1000)
|
|
89
|
-
const tides =
|
|
66
|
+
const tides = TidePredictor(constituents).getExtremesPrediction({
|
|
90
67
|
start: startDate,
|
|
91
68
|
end: endDate,
|
|
92
69
|
labels: {
|
|
@@ -99,8 +76,8 @@ const tides = tidePrediction(constituents).getExtremesPrediction({
|
|
|
99
76
|
|
|
100
77
|
If you want predictions for a subservient station, first set the reference station in the prediction, and pass the [subservient station offests](#subservient-station) to the `getExtremesPrediction` method:
|
|
101
78
|
|
|
102
|
-
```
|
|
103
|
-
const tides =
|
|
79
|
+
```typescript
|
|
80
|
+
const tides = TidePredictor(constituents).getExtremesPrediction({
|
|
104
81
|
start: startDate,
|
|
105
82
|
end: endDate,
|
|
106
83
|
offset: {
|
|
@@ -142,8 +119,8 @@ High and low tides are returned as arrays of objects:
|
|
|
142
119
|
|
|
143
120
|
Gives you the predicted water level at a specific time.
|
|
144
121
|
|
|
145
|
-
```
|
|
146
|
-
const waterLevel =
|
|
122
|
+
```typescript
|
|
123
|
+
const waterLevel = TidePredictor(constituents).getWaterLevelAtTime({
|
|
147
124
|
time: new Date()
|
|
148
125
|
})
|
|
149
126
|
```
|
|
@@ -188,22 +165,22 @@ Tidal constituents should be an array of objects with at least:
|
|
|
188
165
|
|
|
189
166
|
### <a name="subservient-station"></a>Subservient station definitions
|
|
190
167
|
|
|
191
|
-
Some stations do not have defined harmonic data, but do have published
|
|
168
|
+
Some stations do not have defined harmonic data, but do have published offsets and a reference station. These include the offsets in time or amplitude of the high and low tides. Subservient station definitions are objects that include:
|
|
192
169
|
|
|
193
|
-
- `
|
|
170
|
+
- `height` - **object** - An object of height offsets, in the same units as the reference station.
|
|
194
171
|
- `high` - **float** - The offset to be added to high tide (can be negative)
|
|
195
172
|
- `low` - **float** - The offset to be added to low tide (can be negative)
|
|
196
|
-
- `
|
|
173
|
+
- `time` - **object** - An object of time offsets, in number of minutes
|
|
197
174
|
- `high` - **float** - The number of minutes to add to high tide times (can be negative)
|
|
198
175
|
- `low` - **float** - The number of minutes to add to low tide times (can be negative)
|
|
199
176
|
|
|
200
177
|
```
|
|
201
178
|
{
|
|
202
|
-
|
|
179
|
+
height: {
|
|
203
180
|
high: 1,
|
|
204
181
|
low: 2
|
|
205
182
|
},
|
|
206
|
-
|
|
183
|
+
time: {
|
|
207
184
|
high: 1,
|
|
208
185
|
low: 2
|
|
209
186
|
}
|