@neaps/tide-predictor 0.0.3 → 0.1.1
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.cjs +18 -0
- package/.github/workflows/test.yml +21 -0
- package/.prettierrc +2 -1
- package/README.md +21 -5
- package/{lib/index.es6.js → dist/commonjs/index.js} +59 -59
- package/dist/commonjs/package.json +1 -0
- package/dist/{tide-predictor.js → web/tide-predictor.js} +58 -60
- package/dist/web/tide-predictor.min.js +1 -0
- package/package.json +24 -33
- package/rollup.config.js +2 -2
- package/src/astronomy/coefficients.js +6 -6
- package/src/astronomy/index.js +7 -7
- package/src/constituents/compound-constituent.js +6 -7
- package/src/constituents/constituent.js +9 -10
- package/src/constituents/index.js +5 -5
- package/src/harmonics/index.js +12 -12
- package/src/harmonics/prediction.js +14 -14
- package/src/index.js +3 -3
- package/src/node-corrections/index.js +2 -2
- package/{src/__mocks__ → test/_mocks}/constituents.js +0 -0
- package/{src/__mocks__ → test/_mocks}/secondary-station.js +0 -0
- package/{src/harmonics/__mocks__ → test/_mocks}/water-levels.js +0 -0
- package/test/astronomy/coefficients.js +15 -0
- package/test/astronomy/index.js +98 -0
- package/test/constituents/compound-constituent.js +46 -0
- package/test/constituents/constituent.js +67 -0
- package/test/constituents/index.js +35 -0
- package/{src/harmonics/__tests__ → test/harmonics}/index.js +24 -22
- package/{src/harmonics/__tests__ → test/harmonics}/prediction.js +29 -23
- package/{src/__tests__ → test}/index.js +21 -20
- package/test/lib/close-to.js +7 -0
- package/test/noaa.js +110 -0
- package/test/node-corrections/index.js +116 -0
- package/.circleci/config.yml +0 -26
- package/.eslintrc.js +0 -21
- package/Gruntfile.js +0 -87
- package/babel.config.js +0 -9
- package/lib/astronomy/coefficients.js +0 -31
- package/lib/astronomy/constants.js +0 -10
- package/lib/astronomy/index.js +0 -199
- package/lib/constituents/compound-constituent.js +0 -67
- package/lib/constituents/constituent.js +0 -74
- package/lib/constituents/index.js +0 -140
- package/lib/harmonics/index.js +0 -113
- package/lib/harmonics/prediction.js +0 -195
- package/lib/index.js +0 -53
- package/lib/node-corrections/index.js +0 -147
- package/src/__tests__/noaa.js +0 -92
- package/src/astronomy/__tests__/coefficients.js +0 -12
- package/src/astronomy/__tests__/index.js +0 -96
- package/src/constituents/__tests__/compound-constituent.js +0 -44
- package/src/constituents/__tests__/constituent.js +0 -65
- package/src/constituents/__tests__/index.js +0 -34
- package/src/node-corrections/__tests__/index.js +0 -114
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import closeTo from '../lib/close-to.js'
|
|
3
|
+
import harmonics from '../../src/harmonics/index.js'
|
|
4
|
+
import mockHarmonicConstituents from '../_mocks/constituents.js'
|
|
5
|
+
import mockSecondaryStation from '../_mocks/secondary-station.js'
|
|
4
6
|
|
|
5
7
|
const startDate = new Date()
|
|
6
8
|
startDate.setFullYear(2019)
|
|
@@ -40,15 +42,15 @@ const setUpPrediction = () => {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
describe('harmonic prediction', () => {
|
|
43
|
-
|
|
45
|
+
it('it creates a timeline prediction', () => {
|
|
44
46
|
const testPrediction = setUpPrediction()
|
|
45
47
|
const results = testPrediction.getTimelinePrediction()
|
|
46
48
|
const lastResult = results.pop()
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
closeTo(results[0].level, -1.347125, 3)
|
|
50
|
+
closeTo(lastResult.level, 2.85263589, 3)
|
|
49
51
|
})
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
it('it creates a timeline prediction with a non-default phase key', () => {
|
|
52
54
|
const results = harmonics({
|
|
53
55
|
harmonicConstituents: mockHarmonicConstituents,
|
|
54
56
|
phaseKey: 'phase_local',
|
|
@@ -57,11 +59,11 @@ describe('harmonic prediction', () => {
|
|
|
57
59
|
.setTimeSpan(startDate, endDate)
|
|
58
60
|
.prediction()
|
|
59
61
|
.getTimelinePrediction()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
closeTo(results[0].level, 2.7560979, 3)
|
|
63
|
+
closeTo(results.pop().level, -2.9170977, 3)
|
|
62
64
|
})
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
it('it finds high and low tides', () => {
|
|
65
67
|
const results = harmonics({
|
|
66
68
|
harmonicConstituents: mockHarmonicConstituents,
|
|
67
69
|
phaseKey: 'phase_GMT',
|
|
@@ -70,7 +72,7 @@ describe('harmonic prediction', () => {
|
|
|
70
72
|
.setTimeSpan(startDate, extremesEndDate)
|
|
71
73
|
.prediction()
|
|
72
74
|
.getExtremesPrediction()
|
|
73
|
-
|
|
75
|
+
closeTo(results[0].level, -1.5650332, 4)
|
|
74
76
|
|
|
75
77
|
const customLabels = {
|
|
76
78
|
high: 'Super high',
|
|
@@ -85,10 +87,10 @@ describe('harmonic prediction', () => {
|
|
|
85
87
|
.setTimeSpan(startDate, extremesEndDate)
|
|
86
88
|
.prediction()
|
|
87
89
|
.getExtremesPrediction({ labels: customLabels })
|
|
88
|
-
|
|
90
|
+
assert.ok(labelResults[0].label === customLabels.low)
|
|
89
91
|
})
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
it('it finds high and low tides with high fidelity', () => {
|
|
92
94
|
const results = harmonics({
|
|
93
95
|
harmonicConstituents: mockHarmonicConstituents,
|
|
94
96
|
phaseKey: 'phase_GMT',
|
|
@@ -97,12 +99,12 @@ describe('harmonic prediction', () => {
|
|
|
97
99
|
.setTimeSpan(startDate, extremesEndDate)
|
|
98
100
|
.prediction({ timeFidelity: 60 })
|
|
99
101
|
.getExtremesPrediction()
|
|
100
|
-
|
|
102
|
+
closeTo(results[0].level, -1.5653894, 4)
|
|
101
103
|
})
|
|
102
104
|
})
|
|
103
105
|
|
|
104
106
|
describe('Secondary stations', () => {
|
|
105
|
-
|
|
107
|
+
it('it can add offsets to secondary stations', () => {
|
|
106
108
|
const regularResults = harmonics({
|
|
107
109
|
harmonicConstituents: mockHarmonicConstituents,
|
|
108
110
|
phaseKey: 'phase_GMT',
|
|
@@ -123,24 +125,28 @@ describe('Secondary stations', () => {
|
|
|
123
125
|
|
|
124
126
|
offsetResults.forEach((offsetResult, index) => {
|
|
125
127
|
if (offsetResult.low) {
|
|
126
|
-
|
|
128
|
+
closeTo(
|
|
129
|
+
offsetResult.level,
|
|
127
130
|
regularResults[index].level * mockSecondaryStation.height_offset.low,
|
|
128
131
|
4
|
|
129
132
|
)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
assert.ok(
|
|
134
|
+
offsetResult.time.getTime() ===
|
|
135
|
+
regularResults[index].time.getTime() +
|
|
136
|
+
mockSecondaryStation.time_offset.low * 60 * 1000
|
|
133
137
|
)
|
|
134
138
|
}
|
|
135
139
|
if (offsetResult.high) {
|
|
136
|
-
|
|
140
|
+
closeTo(
|
|
141
|
+
offsetResult.level,
|
|
137
142
|
regularResults[index].level * mockSecondaryStation.height_offset.high,
|
|
138
143
|
4
|
|
139
144
|
)
|
|
140
145
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
assert.ok(
|
|
147
|
+
offsetResult.time.getTime() ===
|
|
148
|
+
regularResults[index].time.getTime() +
|
|
149
|
+
mockSecondaryStation.time_offset.high * 60 * 1000
|
|
144
150
|
)
|
|
145
151
|
}
|
|
146
152
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import closeTo from './lib/close-to.js'
|
|
3
|
+
import mockConstituents from './_mocks/constituents.js'
|
|
4
|
+
import tidePrediction from '../src/index.js'
|
|
3
5
|
|
|
4
6
|
const startDate = new Date()
|
|
5
7
|
startDate.setFullYear(2019)
|
|
@@ -20,63 +22,62 @@ endDate.setSeconds(0)
|
|
|
20
22
|
endDate.setMilliseconds(0)
|
|
21
23
|
|
|
22
24
|
describe('Tidal station', () => {
|
|
23
|
-
|
|
25
|
+
it('it is created correctly', () => {
|
|
24
26
|
let stationCreated = true
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
try {
|
|
27
|
-
|
|
29
|
+
tidePrediction(mockConstituents)
|
|
28
30
|
} catch (e) {
|
|
29
31
|
stationCreated = false
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
assert.ok(stationCreated)
|
|
32
34
|
|
|
33
|
-
testStation = {}
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
|
+
tidePrediction(mockConstituents)
|
|
36
37
|
} catch (e) {
|
|
37
38
|
stationCreated = false
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
assert.ok(stationCreated)
|
|
40
41
|
})
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
it('it predicts the tides in a timeline', () => {
|
|
43
44
|
const results = tidePrediction(mockConstituents).getTimelinePrediction({
|
|
44
45
|
start: startDate,
|
|
45
46
|
end: endDate
|
|
46
47
|
})
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
closeTo(results[0].level, -1.34712509, 3)
|
|
49
|
+
closeTo(results.pop().level, 2.85263589, 3)
|
|
49
50
|
})
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
it('it predicts the tidal extremes', () => {
|
|
52
53
|
const results = tidePrediction(mockConstituents).getExtremesPrediction({
|
|
53
54
|
start: startDate,
|
|
54
55
|
end: endDate
|
|
55
56
|
})
|
|
56
|
-
|
|
57
|
+
closeTo(results[0].level, -1.565033, 4)
|
|
57
58
|
})
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
it('it predicts the tidal extremes with high fidelity', () => {
|
|
60
61
|
const results = tidePrediction(mockConstituents).getExtremesPrediction({
|
|
61
62
|
start: startDate,
|
|
62
63
|
end: endDate,
|
|
63
64
|
timeFidelity: 60
|
|
64
65
|
})
|
|
65
|
-
|
|
66
|
+
closeTo(results[0].level, -1.565389, 4)
|
|
66
67
|
})
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
it('it fetches a single water level', () => {
|
|
69
70
|
const result = tidePrediction(mockConstituents).getWaterLevelAtTime({
|
|
70
71
|
time: startDate
|
|
71
72
|
})
|
|
72
|
-
|
|
73
|
+
closeTo(result.level, -1.34712509, 4)
|
|
73
74
|
})
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
it('it adds offset phases', () => {
|
|
76
77
|
const results = tidePrediction(mockConstituents, {
|
|
77
78
|
offset: 3
|
|
78
79
|
}).getExtremesPrediction({ start: startDate, end: endDate })
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
closeTo(results[0].level, 1.43496678, 4)
|
|
81
82
|
})
|
|
82
83
|
})
|
package/test/noaa.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import https from 'https'
|
|
4
|
+
import tidePrediction from '../src/index.js'
|
|
5
|
+
|
|
6
|
+
// Create a directory for test cache
|
|
7
|
+
if (!fs.existsSync('./.test-cache')) {
|
|
8
|
+
fs.mkdirSync('./.test-cache')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const stations = ['9413450', '9411340', '2695535', '8761724', '8410140']
|
|
12
|
+
|
|
13
|
+
const makeRequest = (url) =>
|
|
14
|
+
new Promise((resolve, reject) => {
|
|
15
|
+
https.get(url, (response) => {
|
|
16
|
+
const data = []
|
|
17
|
+
|
|
18
|
+
response.on('data', (fragment) => {
|
|
19
|
+
data.push(fragment)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
response.on('end', () => {
|
|
23
|
+
const body = Buffer.concat(data)
|
|
24
|
+
resolve(JSON.parse(body.toString()))
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
response.on('error', (error) => {
|
|
28
|
+
reject(error)
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const getStation = (station, callback) => {
|
|
34
|
+
const filePath = `./.test-cache/${station}.json`
|
|
35
|
+
if (fs.existsSync(filePath)) {
|
|
36
|
+
fs.readFile(filePath, (err, data) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
throw new Error('Cannot access test cache')
|
|
39
|
+
}
|
|
40
|
+
callback(JSON.parse(data))
|
|
41
|
+
})
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
const stationData = {}
|
|
45
|
+
const tasks = []
|
|
46
|
+
|
|
47
|
+
tasks.push(
|
|
48
|
+
makeRequest(
|
|
49
|
+
`https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations/${station}/harcon.json?units=metric`
|
|
50
|
+
).then((data) => {
|
|
51
|
+
stationData.harmonics = data
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
tasks.push(
|
|
56
|
+
makeRequest(
|
|
57
|
+
`https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?date=recent&station=${station}&product=predictions&datum=MTL&time_zone=gmt&units=metric&format=json`
|
|
58
|
+
).then((data) => {
|
|
59
|
+
stationData.levels = data
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
tasks.push(
|
|
64
|
+
makeRequest(
|
|
65
|
+
`https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations/${station}/datums.json?units=metric`
|
|
66
|
+
).then((data) => {
|
|
67
|
+
stationData.info = data
|
|
68
|
+
})
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
Promise.all(tasks).then(() => {
|
|
72
|
+
fs.writeFile(filePath, JSON.stringify(stationData), (error) => {
|
|
73
|
+
if (error) {
|
|
74
|
+
throw new Error('Cannot write to test cache')
|
|
75
|
+
}
|
|
76
|
+
callback(stationData)
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe('Results compare to NOAA', () => {
|
|
82
|
+
stations.forEach((station) => {
|
|
83
|
+
it(`it compares with station ${station}`, (done) => {
|
|
84
|
+
getStation(station, ({ harmonics, levels, info }) => {
|
|
85
|
+
let mtl = 0
|
|
86
|
+
let mllw = 0
|
|
87
|
+
info.datums.forEach((datum) => {
|
|
88
|
+
if (datum.name === 'MTL') {
|
|
89
|
+
mtl = datum.value
|
|
90
|
+
}
|
|
91
|
+
if (datum.name === 'MLLW') {
|
|
92
|
+
mllw = datum.value
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
const tideStation = tidePrediction(
|
|
96
|
+
harmonics.HarmonicConstituents,
|
|
97
|
+
mtl - mllw
|
|
98
|
+
)
|
|
99
|
+
levels.predictions.forEach((prediction) => {
|
|
100
|
+
const neapsPrediction = tideStation.getWaterLevelAtTime({
|
|
101
|
+
time: new Date(prediction.t)
|
|
102
|
+
})
|
|
103
|
+
assert.ok(parseFloat(prediction.v) >= neapsPrediction.level - 0.5)
|
|
104
|
+
assert.ok(parseFloat(prediction.v) <= neapsPrediction.level + 0.5)
|
|
105
|
+
})
|
|
106
|
+
done()
|
|
107
|
+
})
|
|
108
|
+
}).timeout(20000)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import closeTo from '../lib/close-to.js'
|
|
3
|
+
import nodeCorrections from '../../src/node-corrections/index.js'
|
|
4
|
+
|
|
5
|
+
const testItems = {
|
|
6
|
+
i: {
|
|
7
|
+
value: 5
|
|
8
|
+
},
|
|
9
|
+
I: { value: 6 },
|
|
10
|
+
omega: { value: 3 },
|
|
11
|
+
nu: { value: 4 },
|
|
12
|
+
nup: { value: 4 },
|
|
13
|
+
nupp: { value: 2 },
|
|
14
|
+
P: { value: 14 },
|
|
15
|
+
xi: {
|
|
16
|
+
value: 4
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('Node corrections', () => {
|
|
21
|
+
it('have correct unity', () => {
|
|
22
|
+
assert.ok(nodeCorrections.fUnity() === 1)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('calculates Schureman equations 73, 65 (f_Mm)', () => {
|
|
26
|
+
closeTo(nodeCorrections.fMm(testItems), 0.999051998091, 4)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('calculates Schureman equations 74, 66 (f_Mf)', () => {
|
|
30
|
+
closeTo(nodeCorrections.fMf(testItems), 4.00426673883, 4)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('calculates Schureman equations 75, 67 (f_O1)', () => {
|
|
34
|
+
closeTo(nodeCorrections.fO1(testItems), 2.00076050158, 4)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('calculates Schureman equations 76, 68 (f_J1)', () => {
|
|
38
|
+
closeTo(nodeCorrections.fJ1(testItems), 2.0119685329, 4)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('calculates Schureman equations 77, 69 (f_OO1)', () => {
|
|
42
|
+
closeTo(nodeCorrections.fOO1(testItems), 8.01402871709, 4)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('calculates Schureman equations 78, 70 (f_M2)', () => {
|
|
46
|
+
closeTo(nodeCorrections.fM2(testItems), 0.999694287563, 4)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('calculates Schureman equations 227, 226, 68 (f_K1)', () => {
|
|
50
|
+
closeTo(nodeCorrections.fK1(testItems), 1.23843964182, 4)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('calculates Schureman equations 215, 213, 204 (f_L2)', () => {
|
|
54
|
+
closeTo(nodeCorrections.fL2(testItems), 0.98517860327, 4)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('calculates Schureman equations 235, 234, 71 (f_K2)', () => {
|
|
58
|
+
closeTo(nodeCorrections.fK2(testItems), 1.09775430048, 4)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('calculates Schureman equations 206, 207, 195 (f_M1)', () => {
|
|
62
|
+
closeTo(nodeCorrections.fM1(testItems), 3.90313810168, 4)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('calculates e.g. Schureman equation 149 (f_Modd)', () => {
|
|
66
|
+
closeTo(nodeCorrections.fModd(testItems, 3), 0.999541466395, 4)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('has a zero for u_zero', () => {
|
|
70
|
+
assert.ok(nodeCorrections.uZero() === 0.0)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('calculates u_Mf', () => {
|
|
74
|
+
assert.ok(nodeCorrections.uMf(testItems) === -8.0)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('calculates u_O1', () => {
|
|
78
|
+
assert.ok(nodeCorrections.uO1(testItems) === 4.0)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('calculates u_J1', () => {
|
|
82
|
+
assert.ok(nodeCorrections.uJ1(testItems) === -4)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('calculates u_OO1', () => {
|
|
86
|
+
assert.ok(nodeCorrections.uOO1(testItems) === -12.0)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('calculates u_M2', () => {
|
|
90
|
+
assert.ok(nodeCorrections.uM2(testItems) === 0.0)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('calculates u_K1', () => {
|
|
94
|
+
assert.ok(nodeCorrections.uK1(testItems) === -4)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('calculates u_L2', () => {
|
|
98
|
+
closeTo(nodeCorrections.uL2(testItems), -0.449812364499, 4)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('calculates u_K2', () => {
|
|
102
|
+
assert.ok(nodeCorrections.uK2(testItems) === -4.0)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('calculates u_K2', () => {
|
|
106
|
+
assert.ok(nodeCorrections.uK2(testItems) === -4.0)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('calculates u_M1', () => {
|
|
110
|
+
closeTo(nodeCorrections.uM1(testItems), 7.09154172301, 4)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('calculates u_Modd', () => {
|
|
114
|
+
assert.ok(nodeCorrections.uModd(testItems, 3) === 0)
|
|
115
|
+
})
|
|
116
|
+
})
|
package/.circleci/config.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
version: 2.1
|
|
2
|
-
jobs:
|
|
3
|
-
build:
|
|
4
|
-
docker:
|
|
5
|
-
- image: circleci/node:10.16.3
|
|
6
|
-
steps:
|
|
7
|
-
- checkout
|
|
8
|
-
- restore_cache:
|
|
9
|
-
keys:
|
|
10
|
-
- test-cache-{{ .Branch }}-
|
|
11
|
-
- test-cache-
|
|
12
|
-
- run:
|
|
13
|
-
name: install
|
|
14
|
-
command: 'yarn install --production=false'
|
|
15
|
-
- run:
|
|
16
|
-
name: test
|
|
17
|
-
command: 'yarn run circleci'
|
|
18
|
-
environment:
|
|
19
|
-
JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml'
|
|
20
|
-
- run:
|
|
21
|
-
name: coverage
|
|
22
|
-
command: 'yarn run coverage'
|
|
23
|
-
- save_cache:
|
|
24
|
-
key: test-cache-{{ .Branch }}
|
|
25
|
-
paths:
|
|
26
|
-
- '.test-cache'
|
package/.eslintrc.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
es6: true,
|
|
5
|
-
node: true,
|
|
6
|
-
'jest/globals': true
|
|
7
|
-
},
|
|
8
|
-
extends: ['standard'],
|
|
9
|
-
globals: {
|
|
10
|
-
Atomics: 'readonly',
|
|
11
|
-
SharedArrayBuffer: 'readonly'
|
|
12
|
-
},
|
|
13
|
-
plugins: ['jest'],
|
|
14
|
-
parserOptions: {
|
|
15
|
-
ecmaVersion: 2018,
|
|
16
|
-
sourceType: 'module'
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
'space-before-function-paren': 0
|
|
20
|
-
}
|
|
21
|
-
}
|
package/Gruntfile.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
/* eslint-disable no-process-env, camelcase */
|
|
3
|
-
|
|
4
|
-
module.exports = function(grunt) {
|
|
5
|
-
grunt.initConfig({
|
|
6
|
-
pkg: grunt.file.readJSON('package.json'),
|
|
7
|
-
eslint: {
|
|
8
|
-
options: {},
|
|
9
|
-
files: ['src/**/*.js', 'test/**/*.js']
|
|
10
|
-
},
|
|
11
|
-
clean: ['lib', 'dist'],
|
|
12
|
-
exec: {
|
|
13
|
-
rollup: {
|
|
14
|
-
command: 'BABEL_ENV=build rollup -c'
|
|
15
|
-
},
|
|
16
|
-
test: {
|
|
17
|
-
command: 'yarn run test'
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
uglify: {
|
|
21
|
-
options: {
|
|
22
|
-
mangle: true,
|
|
23
|
-
compress: true,
|
|
24
|
-
preserveComments: 'some'
|
|
25
|
-
},
|
|
26
|
-
dist: {
|
|
27
|
-
files: [
|
|
28
|
-
{
|
|
29
|
-
cwd: 'dist/',
|
|
30
|
-
expand: true,
|
|
31
|
-
src: ['*.js', '!*.min.js'],
|
|
32
|
-
dest: 'dist/',
|
|
33
|
-
rename: function(dest, src) {
|
|
34
|
-
return dest + src.replace(/\.js$/, '.min.js')
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
babel: {
|
|
41
|
-
cjs: {
|
|
42
|
-
files: [
|
|
43
|
-
{
|
|
44
|
-
cwd: 'src/',
|
|
45
|
-
expand: true,
|
|
46
|
-
src: ['**/*.js', '!**/__tests__/**', '!**/__mocks__/**'],
|
|
47
|
-
dest: 'lib/'
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
watch: {
|
|
53
|
-
scripts: {
|
|
54
|
-
options: {
|
|
55
|
-
atBegin: true
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
files: ['src/**/*.js', 'test/**/*.js'],
|
|
59
|
-
tasks: ['eslint', 'exec:test']
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
coveralls: {
|
|
63
|
-
options: {
|
|
64
|
-
force: false
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
coverage: {
|
|
68
|
-
src: 'coverage/lcov.info'
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
eslint: {
|
|
72
|
-
target: ['src/**/*.js']
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
this.registerTask(
|
|
76
|
-
'build',
|
|
77
|
-
'Builds a distributable version of the current project',
|
|
78
|
-
['clean', 'eslint', 'exec:test', 'babel', 'exec:rollup']
|
|
79
|
-
)
|
|
80
|
-
grunt.loadNpmTasks('grunt-eslint')
|
|
81
|
-
grunt.loadNpmTasks('grunt-contrib-clean')
|
|
82
|
-
grunt.loadNpmTasks('grunt-contrib-uglify')
|
|
83
|
-
grunt.loadNpmTasks('grunt-contrib-watch')
|
|
84
|
-
grunt.loadNpmTasks('grunt-babel')
|
|
85
|
-
grunt.loadNpmTasks('grunt-exec')
|
|
86
|
-
grunt.loadNpmTasks('grunt-coveralls')
|
|
87
|
-
}
|
package/babel.config.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sexagesimalToDecimal = exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
// Convert a sexagesimal angle into decimal degrees
|
|
9
|
-
var sexagesimalToDecimal = function sexagesimalToDecimal(degrees, arcmins, arcsecs, mas, muas) {
|
|
10
|
-
arcmins = typeof arcmins !== 'undefined' ? arcmins : 0;
|
|
11
|
-
arcsecs = typeof arcsecs !== 'undefined' ? arcsecs : 0;
|
|
12
|
-
mas = typeof mas !== 'undefined' ? mas : 0;
|
|
13
|
-
muas = typeof muas !== 'undefined' ? muas : 0;
|
|
14
|
-
return degrees + arcmins / 60.0 + arcsecs / (60.0 * 60.0) + mas / (60.0 * 60.0 * 1e3) + muas / (60.0 * 60.0 * 1e6);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.sexagesimalToDecimal = sexagesimalToDecimal;
|
|
18
|
-
var coefficients = {
|
|
19
|
-
// Meeus formula 21.3
|
|
20
|
-
terrestrialObliquity: [sexagesimalToDecimal(23, 26, 21.448), -sexagesimalToDecimal(0, 0, 4680.93), -sexagesimalToDecimal(0, 0, 1.55), sexagesimalToDecimal(0, 0, 1999.25), -sexagesimalToDecimal(0, 0, 51.38), -sexagesimalToDecimal(0, 0, 249.67), -sexagesimalToDecimal(0, 0, 39.05), sexagesimalToDecimal(0, 0, 7.12), sexagesimalToDecimal(0, 0, 27.87), sexagesimalToDecimal(0, 0, 5.79), sexagesimalToDecimal(0, 0, 2.45)].map(function (number, index) {
|
|
21
|
-
return number * Math.pow(1e-2, index);
|
|
22
|
-
}),
|
|
23
|
-
solarPerigee: [280.46645 - 357.5291, 36000.76932 - 35999.0503, 0.0003032 + 0.0001559, 0.00000048],
|
|
24
|
-
solarLongitude: [280.46645, 36000.76983, 0.0003032],
|
|
25
|
-
lunarInclination: [5.145],
|
|
26
|
-
lunarLongitude: [218.3164591, 481267.88134236, -0.0013268, 1 / 538841.0 - 1 / 65194000.0],
|
|
27
|
-
lunarNode: [125.044555, -1934.1361849, 0.0020762, 1 / 467410.0, -1 / 60616000.0],
|
|
28
|
-
lunarPerigee: [83.353243, 4069.0137111, -0.0103238, -1 / 80053.0, 1 / 18999000.0]
|
|
29
|
-
};
|
|
30
|
-
var _default = coefficients;
|
|
31
|
-
exports["default"] = _default;
|