@neaps/tide-predictor 0.2.1 → 0.4.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 +32 -36
- package/dist/index.cjs +1082 -372
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -61
- package/dist/index.d.ts +9 -61
- package/dist/index.js +1082 -372
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,28 +20,25 @@ npm install @neaps/tide-predictor
|
|
|
20
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).
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import TidePredictor from
|
|
23
|
+
import TidePredictor from "@neaps/tide-predictor";
|
|
24
24
|
|
|
25
25
|
const constituents = [
|
|
26
26
|
{
|
|
27
|
-
|
|
28
|
-
phase_local: 313.7,
|
|
27
|
+
phase: 98.7,
|
|
29
28
|
amplitude: 2.687,
|
|
30
|
-
name:
|
|
31
|
-
speed: 28.984104
|
|
32
|
-
}
|
|
29
|
+
name: "M2",
|
|
30
|
+
speed: 28.984104,
|
|
31
|
+
},
|
|
33
32
|
//....there are usually many, read the docs
|
|
34
|
-
]
|
|
33
|
+
];
|
|
35
34
|
|
|
36
|
-
const highLowTides = TidePredictor(constituents
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end: new Date('2019-01-10')
|
|
41
|
-
})
|
|
35
|
+
const highLowTides = TidePredictor(constituents).getExtremesPrediction({
|
|
36
|
+
start: new Date("2019-01-01"),
|
|
37
|
+
end: new Date("2019-01-10"),
|
|
38
|
+
});
|
|
42
39
|
```
|
|
43
40
|
|
|
44
|
-
Note that
|
|
41
|
+
Note that all times internally are evaluated as UTC, so be sure to specify a timezone offset when constructing dates if you want to work in a local time. For example, to get tides for January 1st, 2019 in New York (UTC-5), create a date `new Date('2019-01-01T00:00:00-05:00')`
|
|
45
42
|
|
|
46
43
|
## Tide prediction object
|
|
47
44
|
|
|
@@ -49,7 +46,6 @@ Calling `tidePredictor` will generate a new tide prediction object. It accepts t
|
|
|
49
46
|
|
|
50
47
|
- `constituents` - An array of [constituent objects](#constituent-object)
|
|
51
48
|
- `options` - An object with one of:
|
|
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`).
|
|
53
49
|
- `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.
|
|
54
50
|
|
|
55
51
|
### Tide prediction methods
|
|
@@ -61,17 +57,17 @@ The returned tide prediction object has various methods. All of these return reg
|
|
|
61
57
|
Returns the predicted high and low tides between a start and end date.
|
|
62
58
|
|
|
63
59
|
```typescript
|
|
64
|
-
const startDate = new Date()
|
|
65
|
-
const endDate = new Date(startDate + 3 * 24 * 60 * 60 * 1000)
|
|
60
|
+
const startDate = new Date();
|
|
61
|
+
const endDate = new Date(startDate + 3 * 24 * 60 * 60 * 1000);
|
|
66
62
|
const tides = TidePredictor(constituents).getExtremesPrediction({
|
|
67
63
|
start: startDate,
|
|
68
64
|
end: endDate,
|
|
69
65
|
labels: {
|
|
70
66
|
//optional human-readable labels
|
|
71
|
-
high:
|
|
72
|
-
low:
|
|
73
|
-
}
|
|
74
|
-
})
|
|
67
|
+
high: "High tide",
|
|
68
|
+
low: "Low tide",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
75
71
|
```
|
|
76
72
|
|
|
77
73
|
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:
|
|
@@ -83,14 +79,14 @@ const tides = TidePredictor(constituents).getExtremesPrediction({
|
|
|
83
79
|
offset: {
|
|
84
80
|
height_offset: {
|
|
85
81
|
high: 1,
|
|
86
|
-
low: 2
|
|
82
|
+
low: 2,
|
|
87
83
|
},
|
|
88
84
|
time_offset: {
|
|
89
85
|
high: 1,
|
|
90
|
-
low: 2
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
86
|
+
low: 2,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
94
90
|
```
|
|
95
91
|
|
|
96
92
|
##### Options
|
|
@@ -121,8 +117,8 @@ Gives you the predicted water level at a specific time.
|
|
|
121
117
|
|
|
122
118
|
```typescript
|
|
123
119
|
const waterLevel = TidePredictor(constituents).getWaterLevelAtTime({
|
|
124
|
-
time: new Date()
|
|
125
|
-
})
|
|
120
|
+
time: new Date(),
|
|
121
|
+
});
|
|
126
122
|
```
|
|
127
123
|
|
|
128
124
|
##### Options
|
|
@@ -146,19 +142,19 @@ Tidal constituents should be an array of objects with at least:
|
|
|
146
142
|
|
|
147
143
|
- `name` - **string** - The NOAA constituent name, all upper-case.
|
|
148
144
|
- `amplitude` - **float** - The constituent amplitude
|
|
149
|
-
- `
|
|
145
|
+
- `phase` - **float** - The phase of the constituent.
|
|
150
146
|
|
|
151
|
-
```
|
|
147
|
+
```json
|
|
152
148
|
[
|
|
153
149
|
{
|
|
154
|
-
name:
|
|
155
|
-
amplitude: 1.3,
|
|
156
|
-
phase: 1.33
|
|
150
|
+
"name": "[constituent name]",
|
|
151
|
+
"amplitude": 1.3,
|
|
152
|
+
"phase": 1.33
|
|
157
153
|
},
|
|
158
154
|
{
|
|
159
|
-
name:
|
|
160
|
-
amplitude: 1.3,
|
|
161
|
-
phase: 1.33
|
|
155
|
+
"name": "[constituent name 2]",
|
|
156
|
+
"amplitude": 1.3,
|
|
157
|
+
"phase": 1.33
|
|
162
158
|
}
|
|
163
159
|
]
|
|
164
160
|
```
|