@neaps/tide-predictor 0.0.5 → 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.
Files changed (52) hide show
  1. package/README.md +41 -48
  2. package/dist/index.cjs +931 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +150 -0
  5. package/dist/index.d.ts +150 -0
  6. package/dist/index.js +930 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +20 -36
  9. package/.eslintrc.js +0 -22
  10. package/.github/workflows/test.yml +0 -15
  11. package/.prettierrc +0 -4
  12. package/Gruntfile.js +0 -87
  13. package/LICENSE +0 -21
  14. package/babel.config.js +0 -9
  15. package/dist/tide-predictor.js +0 -1013
  16. package/examples/browser/index.html +0 -51
  17. package/jest.config.js +0 -14
  18. package/lib/astronomy/coefficients.js +0 -31
  19. package/lib/astronomy/constants.js +0 -10
  20. package/lib/astronomy/index.js +0 -199
  21. package/lib/constituents/compound-constituent.js +0 -67
  22. package/lib/constituents/constituent.js +0 -74
  23. package/lib/constituents/index.js +0 -140
  24. package/lib/harmonics/index.js +0 -113
  25. package/lib/harmonics/prediction.js +0 -195
  26. package/lib/index.es6.js +0 -1005
  27. package/lib/index.js +0 -53
  28. package/lib/node-corrections/index.js +0 -147
  29. package/rollup.config.js +0 -21
  30. package/src/__mocks__/constituents.js +0 -335
  31. package/src/__mocks__/secondary-station.js +0 -11
  32. package/src/__tests__/index.js +0 -81
  33. package/src/__tests__/noaa.js +0 -92
  34. package/src/astronomy/__tests__/coefficients.js +0 -12
  35. package/src/astronomy/__tests__/index.js +0 -96
  36. package/src/astronomy/coefficients.js +0 -72
  37. package/src/astronomy/constants.js +0 -4
  38. package/src/astronomy/index.js +0 -201
  39. package/src/constituents/__tests__/compound-constituent.js +0 -44
  40. package/src/constituents/__tests__/constituent.js +0 -65
  41. package/src/constituents/__tests__/index.js +0 -34
  42. package/src/constituents/compound-constituent.js +0 -55
  43. package/src/constituents/constituent.js +0 -74
  44. package/src/constituents/index.js +0 -119
  45. package/src/harmonics/__mocks__/water-levels.js +0 -0
  46. package/src/harmonics/__tests__/index.js +0 -123
  47. package/src/harmonics/__tests__/prediction.js +0 -148
  48. package/src/harmonics/index.js +0 -87
  49. package/src/harmonics/prediction.js +0 -175
  50. package/src/index.js +0 -45
  51. package/src/node-corrections/__tests__/index.js +0 -114
  52. package/src/node-corrections/index.js +0 -208
package/README.md CHANGED
@@ -1,62 +1,55 @@
1
- ![example workflow](https://github.com/neaps/tide-predictor/actions/workflows/test.yml/badge.svg) [![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)
1
+ # @neaps/tide-predictor
2
2
 
3
- # Tide predictor
4
-
5
- A Javascript tide harmonic calculator.
3
+ A tide harmonic calculator written in TypeScript.
6
4
 
7
5
  <!-- START DOCS -->
8
6
 
9
- ## 🚨Warning🚨
10
-
11
- **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.**
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
 
19
- ```
20
- # yarn
21
- yarn install @neaps/tide-prediction
22
-
23
- #npm
24
- npm install --save @neaps/tide-prediction
14
+ ```sh
15
+ npm install @neaps/tide-predictor
25
16
  ```
26
17
 
27
18
  # Usage
28
19
 
29
- Neaps requires that you [provide your own tidal harmonics information](#constituent-object) to generate a prediction.
30
-
31
- 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).
32
21
 
33
- 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.
22
+ ```typescript
23
+ import TidePredictor from '@neaps/tide-predictor'
34
24
 
35
- ```javascript
36
- import TidePrediction from '@neaps/tide-prediction'
37
25
  const constituents = [
38
26
  {
39
27
  phase_GMT: 98.7,
40
28
  phase_local: 313.7,
41
29
  amplitude: 2.687,
42
30
  name: 'M2',
43
- speed: 28.984104,
44
- },
31
+ speed: 28.984104
32
+ }
45
33
  //....there are usually many, read the docs
46
34
  ]
47
35
 
48
- const highLowTides = tidePrediction(constituents, {
49
- phaseKey: 'phase_GMT',
50
- }).getExtremesPrediction(new Date('2019-01-01'), new Date('2019-01-10'))
36
+ const highLowTides = TidePredictor(constituents, {
37
+ phaseKey: 'phase_GMT'
38
+ }).getExtremesPrediction({
39
+ start: new Date('2019-01-01'),
40
+ end: new Date('2019-01-10')
41
+ })
51
42
  ```
52
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
+
53
46
  ## Tide prediction object
54
47
 
55
- Calling `tidePrediction` will generate a new tide prediction object. It accepts the following arguments:
48
+ Calling `tidePredictor` will generate a new tide prediction object. It accepts the following arguments:
56
49
 
57
50
  - `constituents` - An array of [constituent objects](#constituent-object)
58
51
  - `options` - An object with one of:
59
- - `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`).
60
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.
61
54
 
62
55
  ### Tide prediction methods
@@ -67,36 +60,36 @@ The returned tide prediction object has various methods. All of these return reg
67
60
 
68
61
  Returns the predicted high and low tides between a start and end date.
69
62
 
70
- ```javascript
63
+ ```typescript
71
64
  const startDate = new Date()
72
65
  const endDate = new Date(startDate + 3 * 24 * 60 * 60 * 1000)
73
- const tides = tidePrediction(constituents).getExtremesPrediction({
66
+ const tides = TidePredictor(constituents).getExtremesPrediction({
74
67
  start: startDate,
75
68
  end: endDate,
76
69
  labels: {
77
70
  //optional human-readable labels
78
71
  high: 'High tide',
79
- low: 'Low tide',
80
- },
72
+ low: 'Low tide'
73
+ }
81
74
  })
82
75
  ```
83
76
 
84
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:
85
78
 
86
- ```javascript
87
- const tides = tidePrediction(constituents).getExtremesPrediction({
79
+ ```typescript
80
+ const tides = TidePredictor(constituents).getExtremesPrediction({
88
81
  start: startDate,
89
82
  end: endDate,
90
83
  offset: {
91
84
  height_offset: {
92
85
  high: 1,
93
- low: 2,
86
+ low: 2
94
87
  },
95
88
  time_offset: {
96
89
  high: 1,
97
- low: 2,
98
- },
99
- },
90
+ low: 2
91
+ }
92
+ }
100
93
  })
101
94
  ```
102
95
 
@@ -126,9 +119,9 @@ High and low tides are returned as arrays of objects:
126
119
 
127
120
  Gives you the predicted water level at a specific time.
128
121
 
129
- ```javascript
130
- const waterLevel = tidePrediction(constituents).getWaterLevelAtTime({
131
- time: new Date(),
122
+ ```typescript
123
+ const waterLevel = TidePredictor(constituents).getWaterLevelAtTime({
124
+ time: new Date()
132
125
  })
133
126
  ```
134
127
 
@@ -172,22 +165,22 @@ Tidal constituents should be an array of objects with at least:
172
165
 
173
166
  ### <a name="subservient-station"></a>Subservient station definitions
174
167
 
175
- Some stations do not have defined harmonic data, but do have published offets 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:
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:
176
169
 
177
- - `height_offset` - **object** - An object of height offets, in the same units as the reference station.
170
+ - `height` - **object** - An object of height offsets, in the same units as the reference station.
178
171
  - `high` - **float** - The offset to be added to high tide (can be negative)
179
172
  - `low` - **float** - The offset to be added to low tide (can be negative)
180
- - `time_offset` - **object** - An object of time offets, in number of minutes
173
+ - `time` - **object** - An object of time offsets, in number of minutes
181
174
  - `high` - **float** - The number of minutes to add to high tide times (can be negative)
182
175
  - `low` - **float** - The number of minutes to add to low tide times (can be negative)
183
176
 
184
177
  ```
185
178
  {
186
- height_offset: {
179
+ height: {
187
180
  high: 1,
188
181
  low: 2
189
182
  },
190
- time_offset: {
183
+ time: {
191
184
  high: 1,
192
185
  low: 2
193
186
  }