@neaps/tide-predictor 0.2.0 → 0.3.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 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 '@neaps/tide-predictor'
23
+ import TidePredictor from "@neaps/tide-predictor";
24
24
 
25
25
  const constituents = [
26
26
  {
27
- phase_GMT: 98.7,
28
- phase_local: 313.7,
27
+ phase: 98.7,
29
28
  amplitude: 2.687,
30
- name: 'M2',
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
- phaseKey: 'phase_GMT'
38
- }).getExtremesPrediction({
39
- start: new Date('2019-01-01'),
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, 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.
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: 'High tide',
72
- low: 'Low tide'
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
- - `[phase]` - **float** - The phase of the constituent. Because several services provide different phase values, you can choose which one to use when building your tide prediction.
145
+ - `phase` - **float** - The phase of the constituent.
150
146
 
151
- ```
147
+ ```json
152
148
  [
153
149
  {
154
- name: '[constituent 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: '[constituent name 2]',
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
  ```
package/dist/index.cjs CHANGED
@@ -79,9 +79,9 @@ const T = (t) => {
79
79
  return (JD(t) - 2451545) / 36525;
80
80
  };
81
81
  const JD = (t) => {
82
- let Y = t.getFullYear();
83
- let M = t.getMonth() + 1;
84
- const D = t.getDate() + t.getHours() / 24 + t.getMinutes() / 1440 + t.getSeconds() / (1440 * 60) + t.getMilliseconds() / (1440 * 60 * 1e6);
82
+ let Y = t.getUTCFullYear();
83
+ let M = t.getUTCMonth() + 1;
84
+ const D = t.getUTCDate() + t.getUTCHours() / 24 + t.getUTCMinutes() / 1440 + t.getUTCSeconds() / (1440 * 60) + t.getUTCMilliseconds() / (1440 * 60 * 1e6);
85
85
  if (M <= 2) {
86
86
  Y = Y - 1;
87
87
  M = M + 12;
@@ -210,7 +210,7 @@ const predictionFactory = ({ timeline, constituents: constituents$1, start }) =>
210
210
  let result = 0;
211
211
  constituents$1.forEach((constituent) => {
212
212
  const amplitude = constituent.amplitude;
213
- const phase = constituent._phase;
213
+ const phase = constituent.phase;
214
214
  const f = modelF[constituent.name];
215
215
  const speed = modelBaseSpeed[constituent.name];
216
216
  const u = modelU[constituent.name];
@@ -861,7 +861,7 @@ const getTimeline = (start, end, seconds = 600) => {
861
861
  hours
862
862
  };
863
863
  };
864
- const harmonicsFactory = ({ harmonicConstituents, phaseKey, offset }) => {
864
+ const harmonicsFactory = ({ harmonicConstituents, offset }) => {
865
865
  if (!Array.isArray(harmonicConstituents)) throw new Error("Harmonic constituents are not an array");
866
866
  const constituents$1 = [];
867
867
  harmonicConstituents.forEach((constituent) => {
@@ -869,13 +869,13 @@ const harmonicsFactory = ({ harmonicConstituents, phaseKey, offset }) => {
869
869
  if (constituents_default[constituent.name] !== void 0) constituents$1.push({
870
870
  ...constituent,
871
871
  _model: constituents_default[constituent.name],
872
- _phase: d2r * constituent[phaseKey]
872
+ phase: d2r * constituent.phase
873
873
  });
874
874
  });
875
875
  if (offset !== false) constituents$1.push({
876
876
  name: "Z0",
877
877
  _model: constituents_default.Z0,
878
- _phase: 0,
878
+ phase: 0,
879
879
  amplitude: offset
880
880
  });
881
881
  let start = /* @__PURE__ */ new Date();
@@ -903,13 +903,12 @@ var harmonics_default = harmonicsFactory;
903
903
  const tidePredictionFactory = (constituents$1, options = {}) => {
904
904
  const harmonicsOptions = {
905
905
  harmonicConstituents: constituents$1,
906
- phaseKey: "phase_GMT",
907
906
  offset: false,
908
907
  ...options
909
908
  };
910
909
  return {
911
- getTimelinePrediction: ({ start, end }) => {
912
- return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction().getTimelinePrediction();
910
+ getTimelinePrediction: ({ start, end, timeFidelity }) => {
911
+ return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction({ timeFidelity }).getTimelinePrediction();
913
912
  },
914
913
  getExtremesPrediction: ({ start, end, labels, offsets, timeFidelity }) => {
915
914
  return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction({ timeFidelity }).getExtremesPrediction({
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["coefficients: Coefficients","result: number[]","modulus","result: any","polynomials: Record<string, number[]>","coefficients","functions: Record<\n string,\n (N: number, i: number, omega: number) => number\n >","amplitudes: number[]","prediction: Prediction","results: Extreme[]","results: TimelinePoint[]","prediction: TimelinePoint","prediction","astro","baseValue: Record<string, number>","baseSpeed: Record<string, number>","u: Record<string, number>[]","f: Record<string, number>[]","uItem: Record<string, number>","fItem: Record<string, number>","corrections: NodeCorrections","results: number[]","astro","coefficients","constituent: Constituent","nodeCorrections","coefficients: number[]","coefficients","compoundConstituent: CompoundConstituent","astro","f: number[]","constituents: Partial<Constituents>","constituent","nc","compoundConstituent","items: Date[]","hours: number[]","constituents: InternalHarmonicConstituent[]","constituentModels","harmonics: Harmonics","prediction","constituents","harmonics"],"sources":["../src/astronomy/constants.ts","../src/astronomy/coefficients.ts","../src/astronomy/index.ts","../src/harmonics/prediction.ts","../src/node-corrections/index.ts","../src/constituents/constituent.ts","../src/constituents/compound-constituent.ts","../src/constituents/index.ts","../src/harmonics/index.ts","../src/index.ts"],"sourcesContent":["export const d2r = Math.PI / 180.0\nexport const r2d = 180.0 / Math.PI\n","// Convert a sexagesimal angle into decimal degrees\nconst sexagesimalToDecimal = (\n degrees: number,\n arcmins: number = 0,\n arcsecs: number = 0,\n mas: number = 0,\n muas: number = 0\n): number => {\n return (\n degrees +\n arcmins / 60.0 +\n arcsecs / (60.0 * 60.0) +\n mas / (60.0 * 60.0 * 1e3) +\n muas / (60.0 * 60.0 * 1e6)\n )\n}\n\ninterface Coefficients {\n terrestrialObliquity: number[]\n solarPerigee: number[]\n solarLongitude: number[]\n lunarInclination: number[]\n lunarLongitude: number[]\n lunarNode: number[]\n lunarPerigee: number[]\n}\n\nconst coefficients: Coefficients = {\n // Meeus formula 21.3\n terrestrialObliquity: [\n sexagesimalToDecimal(23, 26, 21.448),\n -sexagesimalToDecimal(0, 0, 4680.93),\n -sexagesimalToDecimal(0, 0, 1.55),\n sexagesimalToDecimal(0, 0, 1999.25),\n -sexagesimalToDecimal(0, 0, 51.38),\n -sexagesimalToDecimal(0, 0, 249.67),\n -sexagesimalToDecimal(0, 0, 39.05),\n sexagesimalToDecimal(0, 0, 7.12),\n sexagesimalToDecimal(0, 0, 27.87),\n sexagesimalToDecimal(0, 0, 5.79),\n sexagesimalToDecimal(0, 0, 2.45)\n ].map((number, index) => {\n return number * Math.pow(1e-2, index)\n }),\n\n solarPerigee: [\n 280.46645 - 357.5291,\n 36000.76932 - 35999.0503,\n 0.0003032 + 0.0001559,\n 0.00000048\n ],\n\n solarLongitude: [280.46645, 36000.76983, 0.0003032],\n\n lunarInclination: [5.145],\n\n lunarLongitude: [\n 218.3164591,\n 481267.88134236,\n -0.0013268,\n 1 / 538841.0 - 1 / 65194000.0\n ],\n\n lunarNode: [\n 125.044555,\n -1934.1361849,\n 0.0020762,\n 1 / 467410.0,\n -1 / 60616000.0\n ],\n\n lunarPerigee: [\n 83.353243,\n 4069.0137111,\n -0.0103238,\n -1 / 80053.0,\n 1 / 18999000.0\n ]\n}\n\nexport default coefficients\nexport { sexagesimalToDecimal }\nexport type { Coefficients }\n","import { d2r, r2d } from './constants.js'\nimport coefficients from './coefficients.js'\n\nexport interface AstroValue {\n value: number\n speed: number\n}\n\nexport interface AstroData {\n s: AstroValue\n h: AstroValue\n p: AstroValue\n N: AstroValue\n pp: AstroValue\n '90': AstroValue\n omega: AstroValue\n i: AstroValue\n I: AstroValue\n xi: AstroValue\n nu: AstroValue\n nup: AstroValue\n nupp: AstroValue\n 'T+h-s': AstroValue\n P: AstroValue\n}\n\n// Evaluates a polynomial at argument\nconst polynomial = (coefficients: number[], argument: number): number => {\n const result: number[] = []\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * Math.pow(argument, index))\n })\n return result.reduce((a, b) => a + b)\n}\n\n// Evaluates a derivative polynomial at argument\nconst derivativePolynomial = (\n coefficients: number[],\n argument: number\n): number => {\n const result: number[] = []\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * index * Math.pow(argument, index - 1))\n })\n return result.reduce((a, b) => a + b)\n}\n\n// Meeus formula 11.1\nconst T = (t: Date): number => {\n return (JD(t) - 2451545.0) / 36525\n}\n\n// Meeus formula 7.1\nconst JD = (t: Date): number => {\n let Y = t.getFullYear()\n let M = t.getMonth() + 1\n const D =\n t.getDate() +\n t.getHours() / 24.0 +\n t.getMinutes() / (24.0 * 60.0) +\n t.getSeconds() / (24.0 * 60.0 * 60.0) +\n t.getMilliseconds() / (24.0 * 60.0 * 60.0 * 1e6)\n if (M <= 2) {\n Y = Y - 1\n M = M + 12\n }\n const A = Math.floor(Y / 100.0)\n const B = 2 - A + Math.floor(A / 4.0)\n return (\n Math.floor(365.25 * (Y + 4716)) +\n Math.floor(30.6001 * (M + 1)) +\n D +\n B -\n 1524.5\n )\n}\n\nconst _I = (N: number, i: number, omega: number): number => {\n N = d2r * N\n i = d2r * i\n omega = d2r * omega\n const cosI =\n Math.cos(i) * Math.cos(omega) - Math.sin(i) * Math.sin(omega) * Math.cos(N)\n return r2d * Math.acos(cosI)\n}\n\nconst _xi = (N: number, i: number, omega: number): number => {\n N = d2r * N\n i = d2r * i\n omega = d2r * omega\n let e1 =\n (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n let e2 =\n (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n e1 = Math.atan(e1)\n e2 = Math.atan(e2)\n e1 = e1 - 0.5 * N\n e2 = e2 - 0.5 * N\n return -(e1 + e2) * r2d\n}\n\nconst _nu = (N: number, i: number, omega: number): number => {\n N = d2r * N\n i = d2r * i\n omega = d2r * omega\n let e1 =\n (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n let e2 =\n (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n e1 = Math.atan(e1)\n e2 = Math.atan(e2)\n e1 = e1 - 0.5 * N\n e2 = e2 - 0.5 * N\n return (e1 - e2) * r2d\n}\n\n// Schureman equation 224\nconst _nup = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega)\n const nu = d2r * _nu(N, i, omega)\n return (\n r2d *\n Math.atan(\n (Math.sin(2 * I) * Math.sin(nu)) /\n (Math.sin(2 * I) * Math.cos(nu) + 0.3347)\n )\n )\n}\n\n// Schureman equation 232\nconst _nupp = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega)\n const nu = d2r * _nu(N, i, omega)\n const tan2nupp =\n (Math.sin(I) ** 2 * Math.sin(2 * nu)) /\n (Math.sin(I) ** 2 * Math.cos(2 * nu) + 0.0727)\n return r2d * 0.5 * Math.atan(tan2nupp)\n}\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b\n}\n\nconst astro = (time: Date): AstroData => {\n // This gets cast to `AstroData` later, but we build it up step by step here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: any = {}\n\n const polynomials: Record<string, number[]> = {\n s: coefficients.lunarLongitude,\n h: coefficients.solarLongitude,\n p: coefficients.lunarPerigee,\n N: coefficients.lunarNode,\n pp: coefficients.solarPerigee,\n '90': [90.0],\n omega: coefficients.terrestrialObliquity,\n i: coefficients.lunarInclination\n }\n\n // Polynomials are in T, that is Julian Centuries; we want our speeds to be\n // in the more convenient unit of degrees per hour.\n const dTdHour = 1 / (24 * 365.25 * 100)\n for (const name in polynomials) {\n result[name] = {\n value: modulus(polynomial(polynomials[name], T(time)), 360.0),\n speed: derivativePolynomial(polynomials[name], T(time)) * dTdHour\n }\n }\n\n // Some other parameters defined by Schureman which are dependent on the\n // parameters N, i, omega for use in node factor calculations. We don't need\n // their speeds.\n const functions: Record<\n string,\n (N: number, i: number, omega: number) => number\n > = {\n I: _I,\n xi: _xi,\n nu: _nu,\n nup: _nup,\n nupp: _nupp\n }\n Object.keys(functions).forEach((name) => {\n const functionCall = functions[name]\n result[name] = {\n value: modulus(\n functionCall(result.N.value, result.i.value, result.omega.value),\n 360.0\n ),\n speed: null\n }\n })\n\n // We don't work directly with the T (hours) parameter, instead our spanning\n // set for equilibrium arguments #is given by T+h-s, s, h, p, N, pp, 90.\n // This is in line with convention.\n const hour = {\n value: (JD(time) - Math.floor(JD(time))) * 360.0,\n speed: 15.0\n }\n\n result['T+h-s'] = {\n value: hour.value + result.h.value - result.s.value,\n speed: hour.speed + result.h.speed - result.s.speed\n }\n\n // It is convenient to calculate Schureman's P here since several node\n // factors need it, although it could be argued that these\n // (along with I, xi, nu etc) belong somewhere else.\n result.P = {\n value: result.p.value - (result.xi.value % 360.0),\n speed: null\n }\n\n return result as AstroData\n}\n\nexport default astro\nexport { polynomial, derivativePolynomial, T, JD, _I, _xi, _nu, _nup, _nupp }\n","import astro from '../astronomy/index.js'\nimport { d2r } from '../astronomy/constants.js'\nimport type { Constituent } from '../constituents/constituent.js'\nimport type { CompoundConstituent } from '../constituents/compound-constituent.js'\n\nexport interface Timeline {\n items: Date[]\n hours: number[]\n}\n\nexport interface HarmonicConstituent {\n name: string\n amplitude: number\n // This needs refactored to support generics with the `phaseKey` option\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nexport interface InternalHarmonicConstituent extends HarmonicConstituent {\n _phase: number\n _model: Constituent | CompoundConstituent\n}\n\nexport interface TimelinePoint {\n time: Date\n hour: number\n level: number\n}\n\nexport interface Extreme {\n time: Date\n level: number\n high: boolean\n low: boolean\n label: string\n}\n\nexport interface ExtremeOffsets {\n height?: {\n high?: number\n low?: number\n type?: 'fixed' | 'ratio'\n }\n time?: {\n high?: number\n low?: number\n }\n}\n\nexport interface ExtremeLabels {\n high?: string\n low?: string\n}\n\nexport interface ExtremesOptions {\n labels?: ExtremeLabels\n offsets?: ExtremeOffsets\n}\n\nexport interface Prediction {\n getExtremesPrediction: (options?: ExtremesOptions) => Extreme[]\n getTimelinePrediction: () => TimelinePoint[]\n}\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b\n}\n\nconst addExtremesOffsets = (\n extreme: Extreme,\n offsets?: ExtremeOffsets\n): Extreme => {\n if (typeof offsets === 'undefined' || !offsets) {\n return extreme\n }\n\n if (extreme.high && offsets.height?.high) {\n if (offsets.height.type === 'fixed') {\n extreme.level += offsets.height.high\n } else {\n extreme.level *= offsets.height.high\n }\n }\n if (extreme.low && offsets.height?.low) {\n if (offsets.height.type === 'fixed') {\n extreme.level += offsets.height.low\n } else {\n extreme.level *= offsets.height.low\n }\n }\n if (extreme.high && offsets.time?.high) {\n extreme.time = new Date(\n extreme.time.getTime() + offsets.time.high * 60 * 1000\n )\n }\n if (extreme.low && offsets.time?.low) {\n extreme.time = new Date(\n extreme.time.getTime() + offsets.time.low * 60 * 1000\n )\n }\n return extreme\n}\n\nconst getExtremeLabel = (\n label: 'high' | 'low',\n highLowLabels?: ExtremeLabels\n): string => {\n if (\n typeof highLowLabels !== 'undefined' &&\n typeof highLowLabels[label] !== 'undefined'\n ) {\n return highLowLabels[label]!\n }\n const labels = {\n high: 'High',\n low: 'Low'\n }\n return labels[label]\n}\n\ninterface PredictionFactoryParams {\n timeline: Timeline\n constituents: InternalHarmonicConstituent[]\n start: Date\n}\n\nconst predictionFactory = ({\n timeline,\n constituents,\n start\n}: PredictionFactoryParams): Prediction => {\n const getLevel = (\n hour: number,\n modelBaseSpeed: Record<string, number>,\n modelU: Record<string, number>,\n modelF: Record<string, number>,\n modelBaseValue: Record<string, number>\n ): number => {\n const amplitudes: number[] = []\n let result = 0\n\n constituents.forEach((constituent) => {\n const amplitude = constituent.amplitude\n const phase = constituent._phase\n const f = modelF[constituent.name]\n const speed = modelBaseSpeed[constituent.name]\n const u = modelU[constituent.name]\n const V0 = modelBaseValue[constituent.name]\n amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase))\n })\n // sum up each row\n amplitudes.forEach((item) => {\n result += item\n })\n return result\n }\n\n const prediction: Prediction = {} as Prediction\n\n prediction.getExtremesPrediction = (options?: ExtremesOptions): Extreme[] => {\n const { labels, offsets } = typeof options !== 'undefined' ? options : {}\n const results: Extreme[] = []\n const { baseSpeed, u, f, baseValue } = prepare()\n let goingUp = false\n let goingDown = false\n let lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue)\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index]\n const level = getLevel(hour, baseSpeed, u[index], f[index], baseValue)\n // Compare this level to the last one, if we\n // are changing angle, then the last one was high or low\n if (level > lastLevel && goingDown) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: false,\n low: true,\n label: getExtremeLabel('low', labels)\n },\n offsets\n )\n )\n }\n if (level < lastLevel && goingUp) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: true,\n low: false,\n label: getExtremeLabel('high', labels)\n },\n offsets\n )\n )\n }\n if (level > lastLevel) {\n goingUp = true\n goingDown = false\n }\n if (level < lastLevel) {\n goingUp = false\n goingDown = true\n }\n lastLevel = level\n })\n return results\n }\n\n prediction.getTimelinePrediction = (): TimelinePoint[] => {\n const results: TimelinePoint[] = []\n const { baseSpeed, u, f, baseValue } = prepare()\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index]\n const prediction: TimelinePoint = {\n time,\n hour,\n level: getLevel(hour, baseSpeed, u[index], f[index], baseValue)\n }\n\n results.push(prediction)\n })\n return results\n }\n\n const prepare = () => {\n const baseAstro = astro(start)\n\n const baseValue: Record<string, number> = {}\n const baseSpeed: Record<string, number> = {}\n const u: Record<string, number>[] = []\n const f: Record<string, number>[] = []\n constituents.forEach((constituent) => {\n const value = constituent._model.value(baseAstro)\n const speed = constituent._model.speed(baseAstro)\n baseValue[constituent.name] = d2r * value\n baseSpeed[constituent.name] = d2r * speed\n })\n timeline.items.forEach((time) => {\n const uItem: Record<string, number> = {}\n const fItem: Record<string, number> = {}\n const itemAstro = astro(time)\n constituents.forEach((constituent) => {\n const constituentU = modulus(constituent._model.u(itemAstro), 360)\n\n uItem[constituent.name] = d2r * constituentU\n fItem[constituent.name] = modulus(constituent._model.f(itemAstro), 360)\n })\n u.push(uItem)\n f.push(fItem)\n })\n\n return {\n baseValue,\n baseSpeed,\n u,\n f\n }\n }\n\n return Object.freeze(prediction)\n}\n\nexport default predictionFactory\n","import { d2r, r2d } from '../astronomy/constants.js'\nimport type { AstroData } from '../astronomy/index.js'\n\nexport type NodeCorrectionFunction = (\n a: AstroData,\n ...args: unknown[]\n) => number\n\nexport interface NodeCorrections {\n fUnity: () => number\n fMm: (a: AstroData) => number\n fMf: (a: AstroData) => number\n fO1: (a: AstroData) => number\n fJ1: (a: AstroData) => number\n fOO1: (a: AstroData) => number\n fM2: (a: AstroData) => number\n fK1: (a: AstroData) => number\n fL2: (a: AstroData) => number\n fK2: (a: AstroData) => number\n fM1: (a: AstroData) => number\n fModd: (a: AstroData, n: number) => number\n uZero: () => number\n uMf: (a: AstroData) => number\n uO1: (a: AstroData) => number\n uJ1: (a: AstroData) => number\n uOO1: (a: AstroData) => number\n uM2: (a: AstroData) => number\n uK1: (a: AstroData) => number\n uL2: (a: AstroData) => number\n uK2: (a: AstroData) => number\n uM1: (a: AstroData) => number\n uModd: (a: AstroData, n: number) => number\n}\n\nconst corrections: NodeCorrections = {\n fUnity(): number {\n return 1\n },\n\n // Schureman equations 73, 65\n fMm(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n (2 / 3.0 - Math.pow(Math.sin(omega), 2)) *\n (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2))\n return (2 / 3.0 - Math.pow(Math.sin(I), 2)) / mean\n },\n\n // Schureman equations 74, 66\n fMf(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean = Math.pow(Math.sin(omega), 2) * Math.pow(Math.cos(0.5 * i), 4)\n return Math.pow(Math.sin(I), 2) / mean\n },\n\n // Schureman equations 75, 67\n fO1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.sin(omega) *\n Math.pow(Math.cos(0.5 * omega), 2) *\n Math.pow(Math.cos(0.5 * i), 4)\n return (Math.sin(I) * Math.pow(Math.cos(0.5 * I), 2)) / mean\n },\n\n // Schureman equations 76, 68\n fJ1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2))\n return Math.sin(2 * I) / mean\n },\n\n // Schureman equations 77, 69\n fOO1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.sin(omega) *\n Math.pow(Math.sin(0.5 * omega), 2) *\n Math.pow(Math.cos(0.5 * i), 4)\n return (Math.sin(I) * Math.pow(Math.sin(0.5 * I), 2)) / mean\n },\n\n // Schureman equations 78, 70\n fM2(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.pow(Math.cos(0.5 * omega), 4) * Math.pow(Math.cos(0.5 * i), 4)\n return Math.pow(Math.cos(0.5 * I), 4) / mean\n },\n\n // Schureman equations 227, 226, 68\n // Should probably eventually include the derivations of the magic numbers (0.5023 etc).\n fK1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const nu = d2r * a.nu.value\n const sin2IcosnuMean =\n Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2))\n const mean = 0.5023 * sin2IcosnuMean + 0.1681\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(2 * I), 2) +\n 0.1689 * Math.sin(2 * I) * Math.cos(nu) +\n 0.0283,\n 0.5\n ) / mean\n )\n },\n\n // Schureman equations 215, 213, 204\n // It can be (and has been) confirmed that the exponent for R_a reads 1/2 via Schureman Table 7\n fL2(a: AstroData): number {\n const P = d2r * a.P.value\n const I = d2r * a.I.value\n const rAInv = Math.pow(\n 1 -\n 12 * Math.pow(Math.tan(0.5 * I), 2) * Math.cos(2 * P) +\n 36 * Math.pow(Math.tan(0.5 * I), 4),\n 0.5\n )\n return corrections.fM2(a) * rAInv\n },\n\n // Schureman equations 235, 234, 71\n // Again, magic numbers\n fK2(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const nu = d2r * a.nu.value\n const sinsqIcos2nuMean =\n Math.sin(omega) ** 2 * (1 - (3 / 2.0) * Math.sin(i) ** 2)\n const mean = 0.5023 * sinsqIcos2nuMean + 0.0365\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(I), 4) +\n 0.0367 * Math.pow(Math.sin(I), 2) * Math.cos(2 * nu) +\n 0.0013,\n 0.5\n ) / mean\n )\n },\n\n // Schureman equations 206, 207, 195\n fM1(a: AstroData): number {\n const P = d2r * a.P.value\n const I = d2r * a.I.value\n const qAInv = Math.pow(\n 0.25 +\n 1.5 *\n Math.cos(I) *\n Math.cos(2 * P) *\n Math.pow(Math.cos(0.5 * I), -0.5) +\n 2.25 * Math.pow(Math.cos(I), 2) * Math.pow(Math.cos(0.5 * I), -4),\n 0.5\n )\n return corrections.fO1(a) * qAInv\n },\n\n // See e.g. Schureman equation 149\n fModd(a: AstroData, n: number): number {\n return Math.pow(corrections.fM2(a), n / 2.0)\n },\n\n // Node factors u, see Table 2 of Schureman.\n\n uZero(): number {\n return 0.0\n },\n\n uMf(a: AstroData): number {\n return -2.0 * a.xi.value\n },\n\n uO1(a: AstroData): number {\n return 2.0 * a.xi.value - a.nu.value\n },\n\n uJ1(a: AstroData): number {\n return -a.nu.value\n },\n\n uOO1(a: AstroData): number {\n return -2.0 * a.xi.value - a.nu.value\n },\n\n uM2(a: AstroData): number {\n return 2.0 * a.xi.value - 2.0 * a.nu.value\n },\n\n uK1(a: AstroData): number {\n return -a.nup.value\n },\n\n // Schureman 214\n uL2(a: AstroData): number {\n const I = d2r * a.I.value\n const P = d2r * a.P.value\n const R =\n r2d *\n Math.atan(\n Math.sin(2 * P) /\n ((1 / 6.0) * Math.pow(Math.tan(0.5 * I), -2) - Math.cos(2 * P))\n )\n return 2.0 * a.xi.value - 2.0 * a.nu.value - R\n },\n\n uK2(a: AstroData): number {\n return -2.0 * a.nupp.value\n },\n\n // Schureman 202\n uM1(a: AstroData): number {\n const I = d2r * a.I.value\n const P = d2r * a.P.value\n const Q =\n r2d *\n Math.atan(((5 * Math.cos(I) - 1) / (7 * Math.cos(I) + 1)) * Math.tan(P))\n return a.xi.value - a.nu.value + Q\n },\n\n uModd(a: AstroData, n: number): number {\n return (n / 2.0) * corrections.uM2(a)\n }\n}\n\nexport default corrections\n","import nodeCorrections from '../node-corrections/index.js'\nimport type { AstroData } from '../astronomy/index.js'\nimport type { NodeCorrectionFunction } from '../node-corrections/index.js'\n\n/**\n * Computes the dot notation of two arrays\n */\nconst dotArray = (a: number[], b: number[]): number => {\n const results: number[] = []\n a.forEach((value, index) => {\n results.push(value * b[index])\n })\n return results.reduce((total, value) => total + value)\n}\n\nconst astronimicDoodsonNumber = (\n astro: AstroData\n): AstroData[keyof AstroData][] => {\n return [\n astro['T+h-s'],\n astro.s,\n astro.h,\n astro.p,\n astro.N,\n astro.pp,\n astro['90']\n ]\n}\n\nconst astronomicSpeed = (astro: AstroData): number[] => {\n const results: number[] = []\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.speed)\n })\n return results\n}\n\nconst astronomicValues = (astro: AstroData): number[] => {\n const results: number[] = []\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.value)\n })\n return results\n}\n\nexport interface Constituent {\n name: string\n coefficients: number[]\n value: (astro: AstroData) => number\n speed: (astro: AstroData) => number\n u: NodeCorrectionFunction\n f: NodeCorrectionFunction\n}\n\nconst constituentFactory = (\n name: string,\n coefficients: number[],\n u?: NodeCorrectionFunction,\n f?: NodeCorrectionFunction\n): Constituent => {\n if (!coefficients) {\n throw new Error('Coefficient must be defined for a constituent')\n }\n\n const constituent: Constituent = {\n name,\n coefficients,\n\n value: (astro: AstroData): number => {\n return dotArray(coefficients, astronomicValues(astro))\n },\n\n speed(astro: AstroData): number {\n return dotArray(coefficients, astronomicSpeed(astro))\n },\n\n u: typeof u !== 'undefined' ? u : nodeCorrections.uZero,\n\n f: typeof f !== 'undefined' ? f : nodeCorrections.fUnity\n }\n\n return Object.freeze(constituent)\n}\n\nexport default constituentFactory\nexport { astronimicDoodsonNumber, astronomicSpeed, astronomicValues }\n","import type { Constituent } from './constituent.js'\nimport type { AstroData } from '../astronomy/index.js'\n\nexport interface ConstituentMember {\n constituent: Constituent\n factor: number\n}\n\nexport interface CompoundConstituent {\n name: string\n coefficients: number[]\n speed: (astro: AstroData) => number\n value: (astro: AstroData) => number\n u: (astro: AstroData) => number\n f: (astro: AstroData) => number\n}\n\nconst compoundConstituentFactory = (\n name: string,\n members: ConstituentMember[]\n): CompoundConstituent => {\n const coefficients: number[] = []\n members.forEach(({ constituent, factor }) => {\n constituent.coefficients.forEach((coefficient, index) => {\n if (typeof coefficients[index] === 'undefined') {\n coefficients[index] = 0\n }\n coefficients[index] += coefficient * factor\n })\n })\n\n const compoundConstituent: CompoundConstituent = {\n name,\n coefficients,\n\n speed: (astro: AstroData): number => {\n let speed = 0\n members.forEach(({ constituent, factor }) => {\n speed += constituent.speed(astro) * factor\n })\n return speed\n },\n\n value: (astro: AstroData): number => {\n let value = 0\n members.forEach(({ constituent, factor }) => {\n value += constituent.value(astro) * factor\n })\n return value\n },\n\n u: (astro: AstroData): number => {\n let u = 0\n members.forEach(({ constituent, factor }) => {\n u += constituent.u(astro) * factor\n })\n return u\n },\n\n f: (astro: AstroData): number => {\n const f: number[] = []\n members.forEach(({ constituent, factor }) => {\n f.push(Math.pow(constituent.f(astro), Math.abs(factor)))\n })\n return f.reduce((previous, value) => previous * value)\n }\n }\n\n return Object.freeze(compoundConstituent)\n}\n\nexport default compoundConstituentFactory\n","import constituent from './constituent.js'\nimport compoundConstituent from './compound-constituent.js'\nimport nc from '../node-corrections/index.js'\nimport type { Constituent } from './constituent.js'\nimport type { CompoundConstituent } from './compound-constituent.js'\n\nexport interface Constituents {\n Z0: Constituent\n SA: Constituent\n SSA: Constituent\n MM: Constituent\n MF: Constituent\n Q1: Constituent\n O1: Constituent\n K1: Constituent\n J1: Constituent\n M1: Constituent\n P1: Constituent\n S1: Constituent\n OO1: Constituent\n '2N2': Constituent\n N2: Constituent\n NU2: Constituent\n M2: Constituent\n LAM2: Constituent\n L2: Constituent\n T2: Constituent\n S2: Constituent\n R2: Constituent\n K2: Constituent\n M3: Constituent\n MSF: CompoundConstituent\n '2Q1': CompoundConstituent\n RHO: CompoundConstituent\n MU2: CompoundConstituent\n '2SM2': CompoundConstituent\n '2MK3': CompoundConstituent\n MK3: CompoundConstituent\n MN4: CompoundConstituent\n M4: CompoundConstituent\n MS4: CompoundConstituent\n S4: CompoundConstituent\n M6: CompoundConstituent\n S6: CompoundConstituent\n M8: CompoundConstituent\n [key: string]: Constituent | CompoundConstituent\n}\n\nconst constituents: Partial<Constituents> = {}\n\n// Long Term\nconstituents.Z0 = constituent('Z0', [0, 0, 0, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.SA = constituent('Sa', [0, 0, 1, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.SSA = constituent(\n 'Ssa',\n [0, 0, 2, 0, 0, 0, 0],\n nc.uZero,\n nc.fUnity\n)\nconstituents.MM = constituent('MM', [0, 1, 0, -1, 0, 0, 0], nc.uZero, nc.fMm)\nconstituents.MF = constituent('MF', [0, 2, 0, 0, 0, 0, 0], nc.uMf, nc.fMf)\n// Diurnals\nconstituents.Q1 = constituent('Q1', [1, -2, 0, 1, 0, 0, 1], nc.uO1, nc.fO1)\nconstituents.O1 = constituent('O1', [1, -1, 0, 0, 0, 0, 1], nc.uO1, nc.fO1)\nconstituents.K1 = constituent('K1', [1, 1, 0, 0, 0, 0, -1], nc.uK1, nc.fK1)\nconstituents.J1 = constituent('J1', [1, 2, 0, -1, 0, 0, -1], nc.uJ1, nc.fJ1)\nconstituents.M1 = constituent('M1', [1, 0, 0, 0, 0, 0, 1], nc.uM1, nc.fM1)\nconstituents.P1 = constituent('P1', [1, 1, -2, 0, 0, 0, 1], nc.uZero, nc.fUnity)\nconstituents.S1 = constituent('S1', [1, 1, -1, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.OO1 = constituent('OO1', [1, 3, 0, 0, 0, 0, -1], nc.uOO1, nc.fOO1)\n// Semi diurnals\nconstituents['2N2'] = constituent('2N2', [2, -2, 0, 2, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.N2 = constituent('N2', [2, -1, 0, 1, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.NU2 = constituent('NU2', [2, -1, 2, -1, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.M2 = constituent('M2', [2, 0, 0, 0, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.LAM2 = constituent('LAM2', [2, 1, -2, 1, 0, 0, 2], nc.uM2, nc.fM2)\nconstituents.L2 = constituent('L2', [2, 1, 0, -1, 0, 0, 2], nc.uL2, nc.fL2)\nconstituents.T2 = constituent('T2', [2, 2, -3, 0, 0, 1, 0], nc.uZero, nc.fUnity)\nconstituents.S2 = constituent('S2', [2, 2, -2, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.R2 = constituent(\n 'R2',\n [2, 2, -1, 0, 0, -1, 2],\n nc.uZero,\n nc.fUnity\n)\nconstituents.K2 = constituent('K2', [2, 2, 0, 0, 0, 0, 0], nc.uK2, nc.fK2)\n// Third diurnal\nconstituents.M3 = constituent(\n 'M3',\n [3, 0, 0, 0, 0, 0, 0],\n (a) => {\n return nc.uModd(a, 3)\n },\n (a) => {\n return nc.fModd(a, 3)\n }\n)\n// Compound\nconstituents.MSF = compoundConstituent('MSF', [\n { constituent: constituents.S2!, factor: 1 },\n { constituent: constituents.M2!, factor: -1 }\n])\n\n// Diurnal\nconstituents['2Q1'] = compoundConstituent('2Q1', [\n { constituent: constituents.N2!, factor: 1 },\n { constituent: constituents.J1!, factor: -1 }\n])\nconstituents.RHO = compoundConstituent('RHO', [\n { constituent: constituents.NU2!, factor: 1 },\n { constituent: constituents.K1!, factor: -1 }\n])\n\n// Semi-Diurnal\n\nconstituents.MU2 = compoundConstituent('MU2', [\n { constituent: constituents.M2!, factor: 2 },\n { constituent: constituents.S2!, factor: -1 }\n])\nconstituents['2SM2'] = compoundConstituent('2SM2', [\n { constituent: constituents.S2!, factor: 2 },\n { constituent: constituents.M2!, factor: -1 }\n])\n\n// Third-Diurnal\nconstituents['2MK3'] = compoundConstituent('2MK3', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.O1!, factor: 1 }\n])\nconstituents.MK3 = compoundConstituent('MK3', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.K1!, factor: 1 }\n])\n\n// Quarter-Diurnal\nconstituents.MN4 = compoundConstituent('MN4', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.N2!, factor: 1 }\n])\nconstituents.M4 = compoundConstituent('M4', [\n { constituent: constituents.M2!, factor: 2 }\n])\nconstituents.MS4 = compoundConstituent('MS4', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.S2!, factor: 1 }\n])\nconstituents.S4 = compoundConstituent('S4', [\n { constituent: constituents.S2!, factor: 2 }\n])\n\n// Sixth-Diurnal\nconstituents.M6 = compoundConstituent('M6', [\n { constituent: constituents.M2!, factor: 3 }\n])\nconstituents.S6 = compoundConstituent('S6', [\n { constituent: constituents.S2!, factor: 3 }\n])\n\n// Eighth-Diurnals\nconstituents.M8 = compoundConstituent('M8', [\n { constituent: constituents.M2!, factor: 4 }\n])\n\nexport default constituents as Constituents\n","import prediction from './prediction.js'\nimport constituentModels from '../constituents/index.js'\nimport { d2r } from '../astronomy/constants.js'\nimport type {\n HarmonicConstituent,\n InternalHarmonicConstituent,\n Prediction\n} from './prediction.js'\n\nexport type * from './prediction.js'\n\nexport interface HarmonicsOptions {\n harmonicConstituents: HarmonicConstituent[]\n phaseKey: string\n offset: number | false\n}\n\nexport interface PredictionOptions {\n timeFidelity?: number\n}\n\nexport interface Harmonics {\n setTimeSpan: (startTime: Date | number, endTime: Date | number) => Harmonics\n prediction: (options?: PredictionOptions) => Prediction\n}\n\nconst getDate = (time: Date | number): Date => {\n if (time instanceof Date) {\n return time\n }\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n throw new Error('Invalid date format, should be a Date object, or timestamp')\n}\n\nconst getTimeline = (start: Date, end: Date, seconds: number = 10 * 60) => {\n const items: Date[] = []\n const endTime = end.getTime() / 1000\n let lastTime = start.getTime() / 1000\n const startTime = lastTime\n const hours: number[] = []\n while (lastTime <= endTime) {\n items.push(new Date(lastTime * 1000))\n hours.push((lastTime - startTime) / (60 * 60))\n lastTime += seconds\n }\n\n return {\n items,\n hours\n }\n}\n\nconst harmonicsFactory = ({\n harmonicConstituents,\n phaseKey,\n offset\n}: HarmonicsOptions): Harmonics => {\n if (!Array.isArray(harmonicConstituents)) {\n throw new Error('Harmonic constituents are not an array')\n }\n const constituents: InternalHarmonicConstituent[] = []\n harmonicConstituents.forEach((constituent) => {\n if (typeof constituent.name === 'undefined') {\n throw new Error('Harmonic constituents must have a name property')\n }\n if (constituentModels[constituent.name] !== undefined) {\n constituents.push({\n ...constituent,\n _model: constituentModels[constituent.name],\n _phase: d2r * constituent[phaseKey]\n })\n }\n })\n\n if (offset !== false) {\n constituents.push({\n name: 'Z0',\n _model: constituentModels.Z0,\n _phase: 0,\n amplitude: offset\n })\n }\n\n let start = new Date()\n let end = new Date()\n\n const harmonics: Harmonics = {} as Harmonics\n\n harmonics.setTimeSpan = (\n startTime: Date | number,\n endTime: Date | number\n ): Harmonics => {\n start = getDate(startTime)\n end = getDate(endTime)\n if (start.getTime() >= end.getTime()) {\n throw new Error('Start time must be before end time')\n }\n return harmonics\n }\n\n harmonics.prediction = (options?: PredictionOptions): Prediction => {\n const opts =\n typeof options !== 'undefined' ? options : { timeFidelity: 10 * 60 }\n return prediction({\n timeline: getTimeline(start, end, opts.timeFidelity),\n constituents,\n start\n })\n }\n\n return Object.freeze(harmonics)\n}\n\nexport default harmonicsFactory\nexport { getDate, getTimeline }\n","import harmonics from './harmonics/index.js'\nimport { default as constituents } from './constituents/index.js'\nimport type { HarmonicConstituent } from './harmonics/index.js'\nimport type {\n TimelinePoint,\n Extreme,\n ExtremeOffsets\n} from './harmonics/prediction.js'\n\nexport interface TidePredictionOptions {\n phaseKey?: string\n offset?: number | false\n}\n\nexport interface TimeSpan {\n start: Date\n end: Date\n}\n\nexport interface ExtremesInput extends TimeSpan {\n labels?: {\n high?: string\n low?: string\n }\n offsets?: ExtremeOffsets\n timeFidelity?: number\n}\n\nexport interface TidePrediction {\n getTimelinePrediction: (params: TimeSpan) => TimelinePoint[]\n getExtremesPrediction: (params: ExtremesInput) => Extreme[]\n getWaterLevelAtTime: (params: { time: Date }) => TimelinePoint\n}\n\nconst tidePredictionFactory = (\n constituents: HarmonicConstituent[],\n options: TidePredictionOptions = {}\n): TidePrediction => {\n const harmonicsOptions = {\n harmonicConstituents: constituents,\n phaseKey: 'phase_GMT',\n offset: false as number | false,\n ...options\n }\n\n const tidePrediction: TidePrediction = {\n getTimelinePrediction: ({ start, end }: TimeSpan): TimelinePoint[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction()\n .getTimelinePrediction()\n },\n\n getExtremesPrediction: ({\n start,\n end,\n labels,\n offsets,\n timeFidelity\n }: ExtremesInput): Extreme[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction({ timeFidelity })\n .getExtremesPrediction({ labels, offsets })\n },\n\n getWaterLevelAtTime: ({ time }: { time: Date }): TimelinePoint => {\n const endDate = new Date(time.getTime() + 10 * 60 * 1000)\n return harmonics(harmonicsOptions)\n .setTimeSpan(time, endDate)\n .prediction()\n .getTimelinePrediction()[0]\n }\n }\n\n return tidePrediction\n}\n\n// Make constituents available on factory for reference\ntidePredictionFactory.constituents = constituents\n\nexport default tidePredictionFactory\nexport type { HarmonicConstituent, TimelinePoint, Extreme }\n"],"mappings":";;AAAA,MAAa,MAAM,KAAK,KAAK;AAC7B,MAAa,MAAM,MAAQ,KAAK;;;;ACAhC,MAAM,wBACJ,SACA,UAAkB,GAClB,UAAkB,GAClB,MAAc,GACd,OA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ACJ,gBACA,UAAiC,EAAE,KAChB;CACnB,MAAM,mBAAmB;EACvB,sBAAsBC;EACtB,UAAU;EACV,QAAQ;EACR,GAAG;EACJ;AAgCD,QA9BuC;EACrC,wBAAwB,EAAE,OAAO,UAAqC;AACpE,UAAOC,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,YAAY,CACZ,uBAAuB;;EAG5B,wBAAwB,EACtB,OACA,KACA,QACA,SACA,mBAC8B;AAC9B,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,sBAAsB;IAAE;IAAQ;IAAS,CAAC;;EAG/C,sBAAsB,EAAE,WAA0C;GAChE,MAAM,UAAU,IAAI,KAAK,KAAK,SAAS,GAAG,MAAU,IAAK;AACzD,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,MAAM,QAAQ,CAC1B,YAAY,CACZ,uBAAuB,CAAC;;EAE9B;;AAMH,sBAAsB,eAAeD;AAErC,kBAAe"}
1
+ {"version":3,"file":"index.cjs","names":["coefficients: Coefficients","result: number[]","modulus","result: any","polynomials: Record<string, number[]>","coefficients","functions: Record<string, (N: number, i: number, omega: number) => number>","amplitudes: number[]","prediction: Prediction","results: Extreme[]","results: TimelinePoint[]","prediction: TimelinePoint","prediction","astro","baseValue: Record<string, number>","baseSpeed: Record<string, number>","u: Record<string, number>[]","f: Record<string, number>[]","uItem: Record<string, number>","fItem: Record<string, number>","corrections: NodeCorrections","results: number[]","astro","coefficients","constituent: Constituent","nodeCorrections","coefficients: number[]","coefficients","compoundConstituent: CompoundConstituent","astro","f: number[]","constituents: Partial<Constituents>","constituent","nc","compoundConstituent","items: Date[]","hours: number[]","constituents: InternalHarmonicConstituent[]","constituentModels","harmonics: Harmonics","prediction","constituents","harmonics"],"sources":["../src/astronomy/constants.ts","../src/astronomy/coefficients.ts","../src/astronomy/index.ts","../src/harmonics/prediction.ts","../src/node-corrections/index.ts","../src/constituents/constituent.ts","../src/constituents/compound-constituent.ts","../src/constituents/index.ts","../src/harmonics/index.ts","../src/index.ts"],"sourcesContent":["export const d2r = Math.PI / 180.0;\nexport const r2d = 180.0 / Math.PI;\n","// Convert a sexagesimal angle into decimal degrees\nconst sexagesimalToDecimal = (\n degrees: number,\n arcmins: number = 0,\n arcsecs: number = 0,\n mas: number = 0,\n muas: number = 0,\n): number => {\n return (\n degrees +\n arcmins / 60.0 +\n arcsecs / (60.0 * 60.0) +\n mas / (60.0 * 60.0 * 1e3) +\n muas / (60.0 * 60.0 * 1e6)\n );\n};\n\ninterface Coefficients {\n terrestrialObliquity: number[];\n solarPerigee: number[];\n solarLongitude: number[];\n lunarInclination: number[];\n lunarLongitude: number[];\n lunarNode: number[];\n lunarPerigee: number[];\n}\n\nconst coefficients: Coefficients = {\n // Meeus formula 21.3\n terrestrialObliquity: [\n sexagesimalToDecimal(23, 26, 21.448),\n -sexagesimalToDecimal(0, 0, 4680.93),\n -sexagesimalToDecimal(0, 0, 1.55),\n sexagesimalToDecimal(0, 0, 1999.25),\n -sexagesimalToDecimal(0, 0, 51.38),\n -sexagesimalToDecimal(0, 0, 249.67),\n -sexagesimalToDecimal(0, 0, 39.05),\n sexagesimalToDecimal(0, 0, 7.12),\n sexagesimalToDecimal(0, 0, 27.87),\n sexagesimalToDecimal(0, 0, 5.79),\n sexagesimalToDecimal(0, 0, 2.45),\n ].map((number, index) => {\n return number * Math.pow(1e-2, index);\n }),\n\n solarPerigee: [280.46645 - 357.5291, 36000.76932 - 35999.0503, 0.0003032 + 0.0001559, 0.00000048],\n\n solarLongitude: [280.46645, 36000.76983, 0.0003032],\n\n lunarInclination: [5.145],\n\n lunarLongitude: [218.3164591, 481267.88134236, -0.0013268, 1 / 538841.0 - 1 / 65194000.0],\n\n lunarNode: [125.044555, -1934.1361849, 0.0020762, 1 / 467410.0, -1 / 60616000.0],\n\n lunarPerigee: [83.353243, 4069.0137111, -0.0103238, -1 / 80053.0, 1 / 18999000.0],\n};\n\nexport default coefficients;\nexport { sexagesimalToDecimal };\nexport type { Coefficients };\n","import { d2r, r2d } from \"./constants.js\";\nimport coefficients from \"./coefficients.js\";\n\nexport interface AstroValue {\n value: number;\n speed: number;\n}\n\nexport interface AstroData {\n s: AstroValue;\n h: AstroValue;\n p: AstroValue;\n N: AstroValue;\n pp: AstroValue;\n \"90\": AstroValue;\n omega: AstroValue;\n i: AstroValue;\n I: AstroValue;\n xi: AstroValue;\n nu: AstroValue;\n nup: AstroValue;\n nupp: AstroValue;\n \"T+h-s\": AstroValue;\n P: AstroValue;\n}\n\n// Evaluates a polynomial at argument\nconst polynomial = (coefficients: number[], argument: number): number => {\n const result: number[] = [];\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * Math.pow(argument, index));\n });\n return result.reduce((a, b) => a + b);\n};\n\n// Evaluates a derivative polynomial at argument\nconst derivativePolynomial = (coefficients: number[], argument: number): number => {\n const result: number[] = [];\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * index * Math.pow(argument, index - 1));\n });\n return result.reduce((a, b) => a + b);\n};\n\n// Meeus formula 11.1\nconst T = (t: Date): number => {\n return (JD(t) - 2451545.0) / 36525;\n};\n\n// Meeus formula 7.1\nconst JD = (t: Date): number => {\n let Y = t.getUTCFullYear();\n let M = t.getUTCMonth() + 1;\n const D =\n t.getUTCDate() +\n t.getUTCHours() / 24.0 +\n t.getUTCMinutes() / (24.0 * 60.0) +\n t.getUTCSeconds() / (24.0 * 60.0 * 60.0) +\n t.getUTCMilliseconds() / (24.0 * 60.0 * 60.0 * 1e6);\n if (M <= 2) {\n Y = Y - 1;\n M = M + 12;\n }\n const A = Math.floor(Y / 100.0);\n const B = 2 - A + Math.floor(A / 4.0);\n return Math.floor(365.25 * (Y + 4716)) + Math.floor(30.6001 * (M + 1)) + D + B - 1524.5;\n};\n\nconst _I = (N: number, i: number, omega: number): number => {\n N = d2r * N;\n i = d2r * i;\n omega = d2r * omega;\n const cosI = Math.cos(i) * Math.cos(omega) - Math.sin(i) * Math.sin(omega) * Math.cos(N);\n return r2d * Math.acos(cosI);\n};\n\nconst _xi = (N: number, i: number, omega: number): number => {\n N = d2r * N;\n i = d2r * i;\n omega = d2r * omega;\n let e1 = (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) * Math.tan(0.5 * N);\n let e2 = (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) * Math.tan(0.5 * N);\n e1 = Math.atan(e1);\n e2 = Math.atan(e2);\n e1 = e1 - 0.5 * N;\n e2 = e2 - 0.5 * N;\n return -(e1 + e2) * r2d;\n};\n\nconst _nu = (N: number, i: number, omega: number): number => {\n N = d2r * N;\n i = d2r * i;\n omega = d2r * omega;\n let e1 = (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) * Math.tan(0.5 * N);\n let e2 = (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) * Math.tan(0.5 * N);\n e1 = Math.atan(e1);\n e2 = Math.atan(e2);\n e1 = e1 - 0.5 * N;\n e2 = e2 - 0.5 * N;\n return (e1 - e2) * r2d;\n};\n\n// Schureman equation 224\nconst _nup = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega);\n const nu = d2r * _nu(N, i, omega);\n return (\n r2d * Math.atan((Math.sin(2 * I) * Math.sin(nu)) / (Math.sin(2 * I) * Math.cos(nu) + 0.3347))\n );\n};\n\n// Schureman equation 232\nconst _nupp = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega);\n const nu = d2r * _nu(N, i, omega);\n const tan2nupp =\n (Math.sin(I) ** 2 * Math.sin(2 * nu)) / (Math.sin(I) ** 2 * Math.cos(2 * nu) + 0.0727);\n return r2d * 0.5 * Math.atan(tan2nupp);\n};\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b;\n};\n\nconst astro = (time: Date): AstroData => {\n // This gets cast to `AstroData` later, but we build it up step by step here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: any = {};\n\n const polynomials: Record<string, number[]> = {\n s: coefficients.lunarLongitude,\n h: coefficients.solarLongitude,\n p: coefficients.lunarPerigee,\n N: coefficients.lunarNode,\n pp: coefficients.solarPerigee,\n \"90\": [90.0],\n omega: coefficients.terrestrialObliquity,\n i: coefficients.lunarInclination,\n };\n\n // Polynomials are in T, that is Julian Centuries; we want our speeds to be\n // in the more convenient unit of degrees per hour.\n const dTdHour = 1 / (24 * 365.25 * 100);\n for (const name in polynomials) {\n result[name] = {\n value: modulus(polynomial(polynomials[name], T(time)), 360.0),\n speed: derivativePolynomial(polynomials[name], T(time)) * dTdHour,\n };\n }\n\n // Some other parameters defined by Schureman which are dependent on the\n // parameters N, i, omega for use in node factor calculations. We don't need\n // their speeds.\n const functions: Record<string, (N: number, i: number, omega: number) => number> = {\n I: _I,\n xi: _xi,\n nu: _nu,\n nup: _nup,\n nupp: _nupp,\n };\n Object.keys(functions).forEach((name) => {\n const functionCall = functions[name];\n result[name] = {\n value: modulus(functionCall(result.N.value, result.i.value, result.omega.value), 360.0),\n speed: null,\n };\n });\n\n // We don't work directly with the T (hours) parameter, instead our spanning\n // set for equilibrium arguments #is given by T+h-s, s, h, p, N, pp, 90.\n // This is in line with convention.\n const hour = {\n value: (JD(time) - Math.floor(JD(time))) * 360.0,\n speed: 15.0,\n };\n\n result[\"T+h-s\"] = {\n value: hour.value + result.h.value - result.s.value,\n speed: hour.speed + result.h.speed - result.s.speed,\n };\n\n // It is convenient to calculate Schureman's P here since several node\n // factors need it, although it could be argued that these\n // (along with I, xi, nu etc) belong somewhere else.\n result.P = {\n value: result.p.value - (result.xi.value % 360.0),\n speed: null,\n };\n\n return result as AstroData;\n};\n\nexport default astro;\nexport { polynomial, derivativePolynomial, T, JD, _I, _xi, _nu, _nup, _nupp };\n","import astro from \"../astronomy/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { Constituent } from \"../constituents/constituent.js\";\nimport type { CompoundConstituent } from \"../constituents/compound-constituent.js\";\n\nexport interface Timeline {\n items: Date[];\n hours: number[];\n}\n\nexport interface HarmonicConstituent {\n name: string;\n amplitude: number;\n phase: number;\n speed?: number;\n description?: string;\n}\n\nexport interface InternalHarmonicConstituent extends HarmonicConstituent {\n _model: Constituent | CompoundConstituent;\n}\n\nexport interface TimelinePoint {\n time: Date;\n hour: number;\n level: number;\n}\n\nexport interface Extreme {\n time: Date;\n level: number;\n high: boolean;\n low: boolean;\n label: string;\n}\n\nexport interface ExtremeOffsets {\n height?: {\n high?: number;\n low?: number;\n type?: \"fixed\" | \"ratio\";\n };\n time?: {\n high?: number;\n low?: number;\n };\n}\n\nexport interface ExtremeLabels {\n high?: string;\n low?: string;\n}\n\nexport interface ExtremesOptions {\n labels?: ExtremeLabels;\n offsets?: ExtremeOffsets;\n}\n\nexport interface Prediction {\n getExtremesPrediction: (options?: ExtremesOptions) => Extreme[];\n getTimelinePrediction: () => TimelinePoint[];\n}\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b;\n};\n\nconst addExtremesOffsets = (extreme: Extreme, offsets?: ExtremeOffsets): Extreme => {\n if (typeof offsets === \"undefined\" || !offsets) {\n return extreme;\n }\n\n if (extreme.high && offsets.height?.high) {\n if (offsets.height.type === \"fixed\") {\n extreme.level += offsets.height.high;\n } else {\n extreme.level *= offsets.height.high;\n }\n }\n if (extreme.low && offsets.height?.low) {\n if (offsets.height.type === \"fixed\") {\n extreme.level += offsets.height.low;\n } else {\n extreme.level *= offsets.height.low;\n }\n }\n if (extreme.high && offsets.time?.high) {\n extreme.time = new Date(extreme.time.getTime() + offsets.time.high * 60 * 1000);\n }\n if (extreme.low && offsets.time?.low) {\n extreme.time = new Date(extreme.time.getTime() + offsets.time.low * 60 * 1000);\n }\n return extreme;\n};\n\nconst getExtremeLabel = (label: \"high\" | \"low\", highLowLabels?: ExtremeLabels): string => {\n if (typeof highLowLabels !== \"undefined\" && typeof highLowLabels[label] !== \"undefined\") {\n return highLowLabels[label]!;\n }\n const labels = {\n high: \"High\",\n low: \"Low\",\n };\n return labels[label];\n};\n\ninterface PredictionFactoryParams {\n timeline: Timeline;\n constituents: InternalHarmonicConstituent[];\n start: Date;\n}\n\nconst predictionFactory = ({\n timeline,\n constituents,\n start,\n}: PredictionFactoryParams): Prediction => {\n const getLevel = (\n hour: number,\n modelBaseSpeed: Record<string, number>,\n modelU: Record<string, number>,\n modelF: Record<string, number>,\n modelBaseValue: Record<string, number>,\n ): number => {\n const amplitudes: number[] = [];\n let result = 0;\n\n constituents.forEach((constituent) => {\n const amplitude = constituent.amplitude;\n const phase = constituent.phase;\n const f = modelF[constituent.name];\n const speed = modelBaseSpeed[constituent.name];\n const u = modelU[constituent.name];\n const V0 = modelBaseValue[constituent.name];\n amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase));\n });\n // sum up each row\n amplitudes.forEach((item) => {\n result += item;\n });\n return result;\n };\n\n const prediction: Prediction = {} as Prediction;\n\n prediction.getExtremesPrediction = (options?: ExtremesOptions): Extreme[] => {\n const { labels, offsets } = typeof options !== \"undefined\" ? options : {};\n const results: Extreme[] = [];\n const { baseSpeed, u, f, baseValue } = prepare();\n let goingUp = false;\n let goingDown = false;\n let lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue);\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index];\n const level = getLevel(hour, baseSpeed, u[index], f[index], baseValue);\n // Compare this level to the last one, if we\n // are changing angle, then the last one was high or low\n if (level > lastLevel && goingDown) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: false,\n low: true,\n label: getExtremeLabel(\"low\", labels),\n },\n offsets,\n ),\n );\n }\n if (level < lastLevel && goingUp) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: true,\n low: false,\n label: getExtremeLabel(\"high\", labels),\n },\n offsets,\n ),\n );\n }\n if (level > lastLevel) {\n goingUp = true;\n goingDown = false;\n }\n if (level < lastLevel) {\n goingUp = false;\n goingDown = true;\n }\n lastLevel = level;\n });\n return results;\n };\n\n prediction.getTimelinePrediction = (): TimelinePoint[] => {\n const results: TimelinePoint[] = [];\n const { baseSpeed, u, f, baseValue } = prepare();\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index];\n const prediction: TimelinePoint = {\n time,\n hour,\n level: getLevel(hour, baseSpeed, u[index], f[index], baseValue),\n };\n\n results.push(prediction);\n });\n return results;\n };\n\n const prepare = () => {\n const baseAstro = astro(start);\n\n const baseValue: Record<string, number> = {};\n const baseSpeed: Record<string, number> = {};\n const u: Record<string, number>[] = [];\n const f: Record<string, number>[] = [];\n constituents.forEach((constituent) => {\n const value = constituent._model.value(baseAstro);\n const speed = constituent._model.speed(baseAstro);\n baseValue[constituent.name] = d2r * value;\n baseSpeed[constituent.name] = d2r * speed;\n });\n timeline.items.forEach((time) => {\n const uItem: Record<string, number> = {};\n const fItem: Record<string, number> = {};\n const itemAstro = astro(time);\n constituents.forEach((constituent) => {\n const constituentU = modulus(constituent._model.u(itemAstro), 360);\n\n uItem[constituent.name] = d2r * constituentU;\n fItem[constituent.name] = modulus(constituent._model.f(itemAstro), 360);\n });\n u.push(uItem);\n f.push(fItem);\n });\n\n return {\n baseValue,\n baseSpeed,\n u,\n f,\n };\n };\n\n return Object.freeze(prediction);\n};\n\nexport default predictionFactory;\n","import { d2r, r2d } from \"../astronomy/constants.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\n\nexport type NodeCorrectionFunction = (a: AstroData, ...args: unknown[]) => number;\n\nexport interface NodeCorrections {\n fUnity: () => number;\n fMm: (a: AstroData) => number;\n fMf: (a: AstroData) => number;\n fO1: (a: AstroData) => number;\n fJ1: (a: AstroData) => number;\n fOO1: (a: AstroData) => number;\n fM2: (a: AstroData) => number;\n fK1: (a: AstroData) => number;\n fL2: (a: AstroData) => number;\n fK2: (a: AstroData) => number;\n fM1: (a: AstroData) => number;\n fModd: (a: AstroData, n: number) => number;\n uZero: () => number;\n uMf: (a: AstroData) => number;\n uO1: (a: AstroData) => number;\n uJ1: (a: AstroData) => number;\n uOO1: (a: AstroData) => number;\n uM2: (a: AstroData) => number;\n uK1: (a: AstroData) => number;\n uL2: (a: AstroData) => number;\n uK2: (a: AstroData) => number;\n uM1: (a: AstroData) => number;\n uModd: (a: AstroData, n: number) => number;\n}\n\nconst corrections: NodeCorrections = {\n fUnity(): number {\n return 1;\n },\n\n // Schureman equations 73, 65\n fMm(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean =\n (2 / 3.0 - Math.pow(Math.sin(omega), 2)) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2));\n return (2 / 3.0 - Math.pow(Math.sin(I), 2)) / mean;\n },\n\n // Schureman equations 74, 66\n fMf(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean = Math.pow(Math.sin(omega), 2) * Math.pow(Math.cos(0.5 * i), 4);\n return Math.pow(Math.sin(I), 2) / mean;\n },\n\n // Schureman equations 75, 67\n fO1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean =\n Math.sin(omega) * Math.pow(Math.cos(0.5 * omega), 2) * Math.pow(Math.cos(0.5 * i), 4);\n return (Math.sin(I) * Math.pow(Math.cos(0.5 * I), 2)) / mean;\n },\n\n // Schureman equations 76, 68\n fJ1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean = Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2));\n return Math.sin(2 * I) / mean;\n },\n\n // Schureman equations 77, 69\n fOO1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean =\n Math.sin(omega) * Math.pow(Math.sin(0.5 * omega), 2) * Math.pow(Math.cos(0.5 * i), 4);\n return (Math.sin(I) * Math.pow(Math.sin(0.5 * I), 2)) / mean;\n },\n\n // Schureman equations 78, 70\n fM2(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean = Math.pow(Math.cos(0.5 * omega), 4) * Math.pow(Math.cos(0.5 * i), 4);\n return Math.pow(Math.cos(0.5 * I), 4) / mean;\n },\n\n // Schureman equations 227, 226, 68\n // Should probably eventually include the derivations of the magic numbers (0.5023 etc).\n fK1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const nu = d2r * a.nu.value;\n const sin2IcosnuMean = Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2));\n const mean = 0.5023 * sin2IcosnuMean + 0.1681;\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(2 * I), 2) + 0.1689 * Math.sin(2 * I) * Math.cos(nu) + 0.0283,\n 0.5,\n ) / mean\n );\n },\n\n // Schureman equations 215, 213, 204\n // It can be (and has been) confirmed that the exponent for R_a reads 1/2 via Schureman Table 7\n fL2(a: AstroData): number {\n const P = d2r * a.P.value;\n const I = d2r * a.I.value;\n const rAInv = Math.pow(\n 1 -\n 12 * Math.pow(Math.tan(0.5 * I), 2) * Math.cos(2 * P) +\n 36 * Math.pow(Math.tan(0.5 * I), 4),\n 0.5,\n );\n return corrections.fM2(a) * rAInv;\n },\n\n // Schureman equations 235, 234, 71\n // Again, magic numbers\n fK2(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const nu = d2r * a.nu.value;\n const sinsqIcos2nuMean = Math.sin(omega) ** 2 * (1 - (3 / 2.0) * Math.sin(i) ** 2);\n const mean = 0.5023 * sinsqIcos2nuMean + 0.0365;\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(I), 4) +\n 0.0367 * Math.pow(Math.sin(I), 2) * Math.cos(2 * nu) +\n 0.0013,\n 0.5,\n ) / mean\n );\n },\n\n // Schureman equations 206, 207, 195\n fM1(a: AstroData): number {\n const P = d2r * a.P.value;\n const I = d2r * a.I.value;\n const qAInv = Math.pow(\n 0.25 +\n 1.5 * Math.cos(I) * Math.cos(2 * P) * Math.pow(Math.cos(0.5 * I), -0.5) +\n 2.25 * Math.pow(Math.cos(I), 2) * Math.pow(Math.cos(0.5 * I), -4),\n 0.5,\n );\n return corrections.fO1(a) * qAInv;\n },\n\n // See e.g. Schureman equation 149\n fModd(a: AstroData, n: number): number {\n return Math.pow(corrections.fM2(a), n / 2.0);\n },\n\n // Node factors u, see Table 2 of Schureman.\n\n uZero(): number {\n return 0.0;\n },\n\n uMf(a: AstroData): number {\n return -2.0 * a.xi.value;\n },\n\n uO1(a: AstroData): number {\n return 2.0 * a.xi.value - a.nu.value;\n },\n\n uJ1(a: AstroData): number {\n return -a.nu.value;\n },\n\n uOO1(a: AstroData): number {\n return -2.0 * a.xi.value - a.nu.value;\n },\n\n uM2(a: AstroData): number {\n return 2.0 * a.xi.value - 2.0 * a.nu.value;\n },\n\n uK1(a: AstroData): number {\n return -a.nup.value;\n },\n\n // Schureman 214\n uL2(a: AstroData): number {\n const I = d2r * a.I.value;\n const P = d2r * a.P.value;\n const R =\n r2d *\n Math.atan(Math.sin(2 * P) / ((1 / 6.0) * Math.pow(Math.tan(0.5 * I), -2) - Math.cos(2 * P)));\n return 2.0 * a.xi.value - 2.0 * a.nu.value - R;\n },\n\n uK2(a: AstroData): number {\n return -2.0 * a.nupp.value;\n },\n\n // Schureman 202\n uM1(a: AstroData): number {\n const I = d2r * a.I.value;\n const P = d2r * a.P.value;\n const Q = r2d * Math.atan(((5 * Math.cos(I) - 1) / (7 * Math.cos(I) + 1)) * Math.tan(P));\n return a.xi.value - a.nu.value + Q;\n },\n\n uModd(a: AstroData, n: number): number {\n return (n / 2.0) * corrections.uM2(a);\n },\n};\n\nexport default corrections;\n","import nodeCorrections from \"../node-corrections/index.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\nimport type { NodeCorrectionFunction } from \"../node-corrections/index.js\";\n\n/**\n * Computes the dot notation of two arrays\n */\nconst dotArray = (a: number[], b: number[]): number => {\n const results: number[] = [];\n a.forEach((value, index) => {\n results.push(value * b[index]);\n });\n return results.reduce((total, value) => total + value);\n};\n\nconst astronimicDoodsonNumber = (astro: AstroData): AstroData[keyof AstroData][] => {\n return [astro[\"T+h-s\"], astro.s, astro.h, astro.p, astro.N, astro.pp, astro[\"90\"]];\n};\n\nconst astronomicSpeed = (astro: AstroData): number[] => {\n const results: number[] = [];\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.speed);\n });\n return results;\n};\n\nconst astronomicValues = (astro: AstroData): number[] => {\n const results: number[] = [];\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.value);\n });\n return results;\n};\n\nexport interface Constituent {\n name: string;\n coefficients: number[];\n value: (astro: AstroData) => number;\n speed: (astro: AstroData) => number;\n u: NodeCorrectionFunction;\n f: NodeCorrectionFunction;\n}\n\nconst constituentFactory = (\n name: string,\n coefficients: number[],\n u?: NodeCorrectionFunction,\n f?: NodeCorrectionFunction,\n): Constituent => {\n if (!coefficients) {\n throw new Error(\"Coefficient must be defined for a constituent\");\n }\n\n const constituent: Constituent = {\n name,\n coefficients,\n\n value: (astro: AstroData): number => {\n return dotArray(coefficients, astronomicValues(astro));\n },\n\n speed(astro: AstroData): number {\n return dotArray(coefficients, astronomicSpeed(astro));\n },\n\n u: typeof u !== \"undefined\" ? u : nodeCorrections.uZero,\n\n f: typeof f !== \"undefined\" ? f : nodeCorrections.fUnity,\n };\n\n return Object.freeze(constituent);\n};\n\nexport default constituentFactory;\nexport { astronimicDoodsonNumber, astronomicSpeed, astronomicValues };\n","import type { Constituent } from \"./constituent.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\n\nexport interface ConstituentMember {\n constituent: Constituent;\n factor: number;\n}\n\nexport interface CompoundConstituent {\n name: string;\n coefficients: number[];\n speed: (astro: AstroData) => number;\n value: (astro: AstroData) => number;\n u: (astro: AstroData) => number;\n f: (astro: AstroData) => number;\n}\n\nconst compoundConstituentFactory = (\n name: string,\n members: ConstituentMember[],\n): CompoundConstituent => {\n const coefficients: number[] = [];\n members.forEach(({ constituent, factor }) => {\n constituent.coefficients.forEach((coefficient, index) => {\n if (typeof coefficients[index] === \"undefined\") {\n coefficients[index] = 0;\n }\n coefficients[index] += coefficient * factor;\n });\n });\n\n const compoundConstituent: CompoundConstituent = {\n name,\n coefficients,\n\n speed: (astro: AstroData): number => {\n let speed = 0;\n members.forEach(({ constituent, factor }) => {\n speed += constituent.speed(astro) * factor;\n });\n return speed;\n },\n\n value: (astro: AstroData): number => {\n let value = 0;\n members.forEach(({ constituent, factor }) => {\n value += constituent.value(astro) * factor;\n });\n return value;\n },\n\n u: (astro: AstroData): number => {\n let u = 0;\n members.forEach(({ constituent, factor }) => {\n u += constituent.u(astro) * factor;\n });\n return u;\n },\n\n f: (astro: AstroData): number => {\n const f: number[] = [];\n members.forEach(({ constituent, factor }) => {\n f.push(Math.pow(constituent.f(astro), Math.abs(factor)));\n });\n return f.reduce((previous, value) => previous * value);\n },\n };\n\n return Object.freeze(compoundConstituent);\n};\n\nexport default compoundConstituentFactory;\n","import constituent from \"./constituent.js\";\nimport compoundConstituent from \"./compound-constituent.js\";\nimport nc from \"../node-corrections/index.js\";\nimport type { Constituent } from \"./constituent.js\";\nimport type { CompoundConstituent } from \"./compound-constituent.js\";\n\nexport interface Constituents {\n Z0: Constituent;\n SA: Constituent;\n SSA: Constituent;\n MM: Constituent;\n MF: Constituent;\n Q1: Constituent;\n O1: Constituent;\n K1: Constituent;\n J1: Constituent;\n M1: Constituent;\n P1: Constituent;\n S1: Constituent;\n OO1: Constituent;\n \"2N2\": Constituent;\n N2: Constituent;\n NU2: Constituent;\n M2: Constituent;\n LAM2: Constituent;\n L2: Constituent;\n T2: Constituent;\n S2: Constituent;\n R2: Constituent;\n K2: Constituent;\n M3: Constituent;\n MSF: CompoundConstituent;\n \"2Q1\": CompoundConstituent;\n RHO: CompoundConstituent;\n MU2: CompoundConstituent;\n \"2SM2\": CompoundConstituent;\n \"2MK3\": CompoundConstituent;\n MK3: CompoundConstituent;\n MN4: CompoundConstituent;\n M4: CompoundConstituent;\n MS4: CompoundConstituent;\n S4: CompoundConstituent;\n M6: CompoundConstituent;\n S6: CompoundConstituent;\n M8: CompoundConstituent;\n [key: string]: Constituent | CompoundConstituent;\n}\n\nconst constituents: Partial<Constituents> = {};\n\n// Long Term\nconstituents.Z0 = constituent(\"Z0\", [0, 0, 0, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.SA = constituent(\"Sa\", [0, 0, 1, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.SSA = constituent(\"Ssa\", [0, 0, 2, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.MM = constituent(\"MM\", [0, 1, 0, -1, 0, 0, 0], nc.uZero, nc.fMm);\nconstituents.MF = constituent(\"MF\", [0, 2, 0, 0, 0, 0, 0], nc.uMf, nc.fMf);\n// Diurnals\nconstituents.Q1 = constituent(\"Q1\", [1, -2, 0, 1, 0, 0, 1], nc.uO1, nc.fO1);\nconstituents.O1 = constituent(\"O1\", [1, -1, 0, 0, 0, 0, 1], nc.uO1, nc.fO1);\nconstituents.K1 = constituent(\"K1\", [1, 1, 0, 0, 0, 0, -1], nc.uK1, nc.fK1);\nconstituents.J1 = constituent(\"J1\", [1, 2, 0, -1, 0, 0, -1], nc.uJ1, nc.fJ1);\nconstituents.M1 = constituent(\"M1\", [1, 0, 0, 0, 0, 0, 1], nc.uM1, nc.fM1);\nconstituents.P1 = constituent(\"P1\", [1, 1, -2, 0, 0, 0, 1], nc.uZero, nc.fUnity);\nconstituents.S1 = constituent(\"S1\", [1, 1, -1, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.OO1 = constituent(\"OO1\", [1, 3, 0, 0, 0, 0, -1], nc.uOO1, nc.fOO1);\n// Semi diurnals\nconstituents[\"2N2\"] = constituent(\"2N2\", [2, -2, 0, 2, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.N2 = constituent(\"N2\", [2, -1, 0, 1, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.NU2 = constituent(\"NU2\", [2, -1, 2, -1, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.M2 = constituent(\"M2\", [2, 0, 0, 0, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.LAM2 = constituent(\"LAM2\", [2, 1, -2, 1, 0, 0, 2], nc.uM2, nc.fM2);\nconstituents.L2 = constituent(\"L2\", [2, 1, 0, -1, 0, 0, 2], nc.uL2, nc.fL2);\nconstituents.T2 = constituent(\"T2\", [2, 2, -3, 0, 0, 1, 0], nc.uZero, nc.fUnity);\nconstituents.S2 = constituent(\"S2\", [2, 2, -2, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.R2 = constituent(\"R2\", [2, 2, -1, 0, 0, -1, 2], nc.uZero, nc.fUnity);\nconstituents.K2 = constituent(\"K2\", [2, 2, 0, 0, 0, 0, 0], nc.uK2, nc.fK2);\n// Third diurnal\nconstituents.M3 = constituent(\n \"M3\",\n [3, 0, 0, 0, 0, 0, 0],\n (a) => {\n return nc.uModd(a, 3);\n },\n (a) => {\n return nc.fModd(a, 3);\n },\n);\n// Compound\nconstituents.MSF = compoundConstituent(\"MSF\", [\n { constituent: constituents.S2!, factor: 1 },\n { constituent: constituents.M2!, factor: -1 },\n]);\n\n// Diurnal\nconstituents[\"2Q1\"] = compoundConstituent(\"2Q1\", [\n { constituent: constituents.N2!, factor: 1 },\n { constituent: constituents.J1!, factor: -1 },\n]);\nconstituents.RHO = compoundConstituent(\"RHO\", [\n { constituent: constituents.NU2!, factor: 1 },\n { constituent: constituents.K1!, factor: -1 },\n]);\n\n// Semi-Diurnal\n\nconstituents.MU2 = compoundConstituent(\"MU2\", [\n { constituent: constituents.M2!, factor: 2 },\n { constituent: constituents.S2!, factor: -1 },\n]);\nconstituents[\"2SM2\"] = compoundConstituent(\"2SM2\", [\n { constituent: constituents.S2!, factor: 2 },\n { constituent: constituents.M2!, factor: -1 },\n]);\n\n// Third-Diurnal\nconstituents[\"2MK3\"] = compoundConstituent(\"2MK3\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.O1!, factor: 1 },\n]);\nconstituents.MK3 = compoundConstituent(\"MK3\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.K1!, factor: 1 },\n]);\n\n// Quarter-Diurnal\nconstituents.MN4 = compoundConstituent(\"MN4\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.N2!, factor: 1 },\n]);\nconstituents.M4 = compoundConstituent(\"M4\", [{ constituent: constituents.M2!, factor: 2 }]);\nconstituents.MS4 = compoundConstituent(\"MS4\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.S2!, factor: 1 },\n]);\nconstituents.S4 = compoundConstituent(\"S4\", [{ constituent: constituents.S2!, factor: 2 }]);\n\n// Sixth-Diurnal\nconstituents.M6 = compoundConstituent(\"M6\", [{ constituent: constituents.M2!, factor: 3 }]);\nconstituents.S6 = compoundConstituent(\"S6\", [{ constituent: constituents.S2!, factor: 3 }]);\n\n// Eighth-Diurnals\nconstituents.M8 = compoundConstituent(\"M8\", [{ constituent: constituents.M2!, factor: 4 }]);\n\nexport default constituents as Constituents;\n","import prediction from \"./prediction.js\";\nimport constituentModels from \"../constituents/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { HarmonicConstituent, InternalHarmonicConstituent, Prediction } from \"./prediction.js\";\n\nexport type * from \"./prediction.js\";\n\nexport interface HarmonicsOptions {\n harmonicConstituents: HarmonicConstituent[];\n offset: number | false;\n}\n\nexport interface PredictionOptions {\n timeFidelity?: number;\n}\n\nexport interface Harmonics {\n setTimeSpan: (startTime: Date | number, endTime: Date | number) => Harmonics;\n prediction: (options?: PredictionOptions) => Prediction;\n}\n\nconst getDate = (time: Date | number): Date => {\n if (time instanceof Date) {\n return time;\n }\n if (typeof time === \"number\") {\n return new Date(time * 1000);\n }\n throw new Error(\"Invalid date format, should be a Date object, or timestamp\");\n};\n\nconst getTimeline = (start: Date, end: Date, seconds: number = 10 * 60) => {\n const items: Date[] = [];\n const endTime = end.getTime() / 1000;\n let lastTime = start.getTime() / 1000;\n const startTime = lastTime;\n const hours: number[] = [];\n while (lastTime <= endTime) {\n items.push(new Date(lastTime * 1000));\n hours.push((lastTime - startTime) / (60 * 60));\n lastTime += seconds;\n }\n\n return {\n items,\n hours,\n };\n};\n\nconst harmonicsFactory = ({ harmonicConstituents, offset }: HarmonicsOptions): Harmonics => {\n if (!Array.isArray(harmonicConstituents)) {\n throw new Error(\"Harmonic constituents are not an array\");\n }\n const constituents: InternalHarmonicConstituent[] = [];\n harmonicConstituents.forEach((constituent) => {\n if (typeof constituent.name === \"undefined\") {\n throw new Error(\"Harmonic constituents must have a name property\");\n }\n if (constituentModels[constituent.name] !== undefined) {\n constituents.push({\n ...constituent,\n _model: constituentModels[constituent.name],\n phase: d2r * constituent.phase,\n });\n }\n });\n\n if (offset !== false) {\n constituents.push({\n name: \"Z0\",\n _model: constituentModels.Z0,\n phase: 0,\n amplitude: offset,\n });\n }\n\n let start = new Date();\n let end = new Date();\n\n const harmonics: Harmonics = {} as Harmonics;\n\n harmonics.setTimeSpan = (startTime: Date | number, endTime: Date | number): Harmonics => {\n start = getDate(startTime);\n end = getDate(endTime);\n if (start.getTime() >= end.getTime()) {\n throw new Error(\"Start time must be before end time\");\n }\n return harmonics;\n };\n\n harmonics.prediction = (options?: PredictionOptions): Prediction => {\n const opts = typeof options !== \"undefined\" ? options : { timeFidelity: 10 * 60 };\n return prediction({\n timeline: getTimeline(start, end, opts.timeFidelity),\n constituents,\n start,\n });\n };\n\n return Object.freeze(harmonics);\n};\n\nexport default harmonicsFactory;\nexport { getDate, getTimeline };\n","import harmonics from \"./harmonics/index.js\";\nimport { default as constituents } from \"./constituents/index.js\";\nimport type { HarmonicConstituent } from \"./harmonics/index.js\";\nimport type { TimelinePoint, Extreme, ExtremeOffsets } from \"./harmonics/prediction.js\";\n\nexport interface TidePredictionOptions {\n offset?: number | false;\n}\n\nexport interface TimeSpan {\n start: Date;\n end: Date;\n timeFidelity?: number;\n}\n\nexport interface ExtremesInput extends TimeSpan {\n labels?: {\n high?: string;\n low?: string;\n };\n offsets?: ExtremeOffsets;\n}\n\nexport interface TidePrediction {\n getTimelinePrediction: (params: TimeSpan) => TimelinePoint[];\n getExtremesPrediction: (params: ExtremesInput) => Extreme[];\n getWaterLevelAtTime: (params: { time: Date }) => TimelinePoint;\n}\n\nconst tidePredictionFactory = (\n constituents: HarmonicConstituent[],\n options: TidePredictionOptions = {},\n): TidePrediction => {\n const harmonicsOptions = {\n harmonicConstituents: constituents,\n offset: false as number | false,\n ...options,\n };\n\n const tidePrediction: TidePrediction = {\n getTimelinePrediction: ({ start, end, timeFidelity }: TimeSpan): TimelinePoint[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction({ timeFidelity })\n .getTimelinePrediction();\n },\n\n getExtremesPrediction: ({\n start,\n end,\n labels,\n offsets,\n timeFidelity,\n }: ExtremesInput): Extreme[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction({ timeFidelity })\n .getExtremesPrediction({ labels, offsets });\n },\n\n getWaterLevelAtTime: ({ time }: { time: Date }): TimelinePoint => {\n const endDate = new Date(time.getTime() + 10 * 60 * 1000);\n return harmonics(harmonicsOptions)\n .setTimeSpan(time, endDate)\n .prediction()\n .getTimelinePrediction()[0];\n },\n };\n\n return tidePrediction;\n};\n\n// Make constituents available on factory for reference\ntidePredictionFactory.constituents = constituents;\n\nexport default tidePredictionFactory;\nexport type { HarmonicConstituent, TimelinePoint, Extreme };\n"],"mappings":";;AAAA,MAAa,MAAM,KAAK,KAAK;AAC7B,MAAa,MAAM,MAAQ,KAAK;;;;ACAhC,MAAM,wBACJ,SACA,UAAkB,G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,YAAY,cAAc,UAAU,EAAE,cAAc,KAAS,EAExC,aAAa;GACpD;GACA;GACD,CAAC;;AAGJ,QAAO,OAAO,OAAO,UAAU;;AAGjC,wBAAe;;;;ACzEf,MAAM,yBACJ,gBACA,UAAiC,EAAE,KAChB;CACnB,MAAM,mBAAmB;EACvB,sBAAsBC;EACtB,QAAQ;EACR,GAAG;EACJ;AAgCD,QA9BuC;EACrC,wBAAwB,EAAE,OAAO,KAAK,mBAA8C;AAClF,UAAOC,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,uBAAuB;;EAG5B,wBAAwB,EACtB,OACA,KACA,QACA,SACA,mBAC8B;AAC9B,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,sBAAsB;IAAE;IAAQ;IAAS,CAAC;;EAG/C,sBAAsB,EAAE,WAA0C;GAChE,MAAM,UAAU,IAAI,KAAK,KAAK,SAAS,GAAG,MAAU,IAAK;AACzD,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,MAAM,QAAQ,CAC1B,YAAY,CACZ,uBAAuB,CAAC;;EAE9B;;AAMH,sBAAsB,eAAeD;AAErC,kBAAe"}
package/dist/index.d.cts CHANGED
@@ -9,7 +9,7 @@ interface AstroData {
9
9
  p: AstroValue;
10
10
  N: AstroValue;
11
11
  pp: AstroValue;
12
- '90': AstroValue;
12
+ "90": AstroValue;
13
13
  omega: AstroValue;
14
14
  i: AstroValue;
15
15
  I: AstroValue;
@@ -17,7 +17,7 @@ interface AstroData {
17
17
  nu: AstroValue;
18
18
  nup: AstroValue;
19
19
  nupp: AstroValue;
20
- 'T+h-s': AstroValue;
20
+ "T+h-s": AstroValue;
21
21
  P: AstroValue;
22
22
  }
23
23
  //#endregion
@@ -59,7 +59,7 @@ interface Constituents {
59
59
  P1: Constituent;
60
60
  S1: Constituent;
61
61
  OO1: Constituent;
62
- '2N2': Constituent;
62
+ "2N2": Constituent;
63
63
  N2: Constituent;
64
64
  NU2: Constituent;
65
65
  M2: Constituent;
@@ -71,11 +71,11 @@ interface Constituents {
71
71
  K2: Constituent;
72
72
  M3: Constituent;
73
73
  MSF: CompoundConstituent;
74
- '2Q1': CompoundConstituent;
74
+ "2Q1": CompoundConstituent;
75
75
  RHO: CompoundConstituent;
76
76
  MU2: CompoundConstituent;
77
- '2SM2': CompoundConstituent;
78
- '2MK3': CompoundConstituent;
77
+ "2SM2": CompoundConstituent;
78
+ "2MK3": CompoundConstituent;
79
79
  MK3: CompoundConstituent;
80
80
  MN4: CompoundConstituent;
81
81
  M4: CompoundConstituent;
@@ -91,7 +91,9 @@ interface Constituents {
91
91
  interface HarmonicConstituent {
92
92
  name: string;
93
93
  amplitude: number;
94
- [key: string]: any;
94
+ phase: number;
95
+ speed?: number;
96
+ description?: string;
95
97
  }
96
98
  interface TimelinePoint {
97
99
  time: Date;
@@ -109,7 +111,7 @@ interface ExtremeOffsets {
109
111
  height?: {
110
112
  high?: number;
111
113
  low?: number;
112
- type?: 'fixed' | 'ratio';
114
+ type?: "fixed" | "ratio";
113
115
  };
114
116
  time?: {
115
117
  high?: number;
@@ -119,12 +121,12 @@ interface ExtremeOffsets {
119
121
  //#endregion
120
122
  //#region src/index.d.ts
121
123
  interface TidePredictionOptions {
122
- phaseKey?: string;
123
124
  offset?: number | false;
124
125
  }
125
126
  interface TimeSpan {
126
127
  start: Date;
127
128
  end: Date;
129
+ timeFidelity?: number;
128
130
  }
129
131
  interface ExtremesInput extends TimeSpan {
130
132
  labels?: {
@@ -132,7 +134,6 @@ interface ExtremesInput extends TimeSpan {
132
134
  low?: string;
133
135
  };
134
136
  offsets?: ExtremeOffsets;
135
- timeFidelity?: number;
136
137
  }
137
138
  interface TidePrediction {
138
139
  getTimelinePrediction: (params: TimeSpan) => TimelinePoint[];
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ interface AstroData {
9
9
  p: AstroValue;
10
10
  N: AstroValue;
11
11
  pp: AstroValue;
12
- '90': AstroValue;
12
+ "90": AstroValue;
13
13
  omega: AstroValue;
14
14
  i: AstroValue;
15
15
  I: AstroValue;
@@ -17,7 +17,7 @@ interface AstroData {
17
17
  nu: AstroValue;
18
18
  nup: AstroValue;
19
19
  nupp: AstroValue;
20
- 'T+h-s': AstroValue;
20
+ "T+h-s": AstroValue;
21
21
  P: AstroValue;
22
22
  }
23
23
  //#endregion
@@ -59,7 +59,7 @@ interface Constituents {
59
59
  P1: Constituent;
60
60
  S1: Constituent;
61
61
  OO1: Constituent;
62
- '2N2': Constituent;
62
+ "2N2": Constituent;
63
63
  N2: Constituent;
64
64
  NU2: Constituent;
65
65
  M2: Constituent;
@@ -71,11 +71,11 @@ interface Constituents {
71
71
  K2: Constituent;
72
72
  M3: Constituent;
73
73
  MSF: CompoundConstituent;
74
- '2Q1': CompoundConstituent;
74
+ "2Q1": CompoundConstituent;
75
75
  RHO: CompoundConstituent;
76
76
  MU2: CompoundConstituent;
77
- '2SM2': CompoundConstituent;
78
- '2MK3': CompoundConstituent;
77
+ "2SM2": CompoundConstituent;
78
+ "2MK3": CompoundConstituent;
79
79
  MK3: CompoundConstituent;
80
80
  MN4: CompoundConstituent;
81
81
  M4: CompoundConstituent;
@@ -91,7 +91,9 @@ interface Constituents {
91
91
  interface HarmonicConstituent {
92
92
  name: string;
93
93
  amplitude: number;
94
- [key: string]: any;
94
+ phase: number;
95
+ speed?: number;
96
+ description?: string;
95
97
  }
96
98
  interface TimelinePoint {
97
99
  time: Date;
@@ -109,7 +111,7 @@ interface ExtremeOffsets {
109
111
  height?: {
110
112
  high?: number;
111
113
  low?: number;
112
- type?: 'fixed' | 'ratio';
114
+ type?: "fixed" | "ratio";
113
115
  };
114
116
  time?: {
115
117
  high?: number;
@@ -119,12 +121,12 @@ interface ExtremeOffsets {
119
121
  //#endregion
120
122
  //#region src/index.d.ts
121
123
  interface TidePredictionOptions {
122
- phaseKey?: string;
123
124
  offset?: number | false;
124
125
  }
125
126
  interface TimeSpan {
126
127
  start: Date;
127
128
  end: Date;
129
+ timeFidelity?: number;
128
130
  }
129
131
  interface ExtremesInput extends TimeSpan {
130
132
  labels?: {
@@ -132,7 +134,6 @@ interface ExtremesInput extends TimeSpan {
132
134
  low?: string;
133
135
  };
134
136
  offsets?: ExtremeOffsets;
135
- timeFidelity?: number;
136
137
  }
137
138
  interface TidePrediction {
138
139
  getTimelinePrediction: (params: TimeSpan) => TimelinePoint[];
package/dist/index.js CHANGED
@@ -78,9 +78,9 @@ const T = (t) => {
78
78
  return (JD(t) - 2451545) / 36525;
79
79
  };
80
80
  const JD = (t) => {
81
- let Y = t.getFullYear();
82
- let M = t.getMonth() + 1;
83
- const D = t.getDate() + t.getHours() / 24 + t.getMinutes() / 1440 + t.getSeconds() / (1440 * 60) + t.getMilliseconds() / (1440 * 60 * 1e6);
81
+ let Y = t.getUTCFullYear();
82
+ let M = t.getUTCMonth() + 1;
83
+ const D = t.getUTCDate() + t.getUTCHours() / 24 + t.getUTCMinutes() / 1440 + t.getUTCSeconds() / (1440 * 60) + t.getUTCMilliseconds() / (1440 * 60 * 1e6);
84
84
  if (M <= 2) {
85
85
  Y = Y - 1;
86
86
  M = M + 12;
@@ -209,7 +209,7 @@ const predictionFactory = ({ timeline, constituents: constituents$1, start }) =>
209
209
  let result = 0;
210
210
  constituents$1.forEach((constituent) => {
211
211
  const amplitude = constituent.amplitude;
212
- const phase = constituent._phase;
212
+ const phase = constituent.phase;
213
213
  const f = modelF[constituent.name];
214
214
  const speed = modelBaseSpeed[constituent.name];
215
215
  const u = modelU[constituent.name];
@@ -860,7 +860,7 @@ const getTimeline = (start, end, seconds = 600) => {
860
860
  hours
861
861
  };
862
862
  };
863
- const harmonicsFactory = ({ harmonicConstituents, phaseKey, offset }) => {
863
+ const harmonicsFactory = ({ harmonicConstituents, offset }) => {
864
864
  if (!Array.isArray(harmonicConstituents)) throw new Error("Harmonic constituents are not an array");
865
865
  const constituents$1 = [];
866
866
  harmonicConstituents.forEach((constituent) => {
@@ -868,13 +868,13 @@ const harmonicsFactory = ({ harmonicConstituents, phaseKey, offset }) => {
868
868
  if (constituents_default[constituent.name] !== void 0) constituents$1.push({
869
869
  ...constituent,
870
870
  _model: constituents_default[constituent.name],
871
- _phase: d2r * constituent[phaseKey]
871
+ phase: d2r * constituent.phase
872
872
  });
873
873
  });
874
874
  if (offset !== false) constituents$1.push({
875
875
  name: "Z0",
876
876
  _model: constituents_default.Z0,
877
- _phase: 0,
877
+ phase: 0,
878
878
  amplitude: offset
879
879
  });
880
880
  let start = /* @__PURE__ */ new Date();
@@ -902,13 +902,12 @@ var harmonics_default = harmonicsFactory;
902
902
  const tidePredictionFactory = (constituents$1, options = {}) => {
903
903
  const harmonicsOptions = {
904
904
  harmonicConstituents: constituents$1,
905
- phaseKey: "phase_GMT",
906
905
  offset: false,
907
906
  ...options
908
907
  };
909
908
  return {
910
- getTimelinePrediction: ({ start, end }) => {
911
- return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction().getTimelinePrediction();
909
+ getTimelinePrediction: ({ start, end, timeFidelity }) => {
910
+ return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction({ timeFidelity }).getTimelinePrediction();
912
911
  },
913
912
  getExtremesPrediction: ({ start, end, labels, offsets, timeFidelity }) => {
914
913
  return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction({ timeFidelity }).getExtremesPrediction({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["coefficients: Coefficients","result: number[]","modulus","result: any","polynomials: Record<string, number[]>","coefficients","functions: Record<\n string,\n (N: number, i: number, omega: number) => number\n >","amplitudes: number[]","prediction: Prediction","results: Extreme[]","results: TimelinePoint[]","prediction: TimelinePoint","prediction","astro","baseValue: Record<string, number>","baseSpeed: Record<string, number>","u: Record<string, number>[]","f: Record<string, number>[]","uItem: Record<string, number>","fItem: Record<string, number>","corrections: NodeCorrections","results: number[]","astro","coefficients","constituent: Constituent","nodeCorrections","coefficients: number[]","coefficients","compoundConstituent: CompoundConstituent","astro","f: number[]","constituents: Partial<Constituents>","constituent","nc","compoundConstituent","items: Date[]","hours: number[]","constituents: InternalHarmonicConstituent[]","constituentModels","harmonics: Harmonics","prediction","constituents","harmonics"],"sources":["../src/astronomy/constants.ts","../src/astronomy/coefficients.ts","../src/astronomy/index.ts","../src/harmonics/prediction.ts","../src/node-corrections/index.ts","../src/constituents/constituent.ts","../src/constituents/compound-constituent.ts","../src/constituents/index.ts","../src/harmonics/index.ts","../src/index.ts"],"sourcesContent":["export const d2r = Math.PI / 180.0\nexport const r2d = 180.0 / Math.PI\n","// Convert a sexagesimal angle into decimal degrees\nconst sexagesimalToDecimal = (\n degrees: number,\n arcmins: number = 0,\n arcsecs: number = 0,\n mas: number = 0,\n muas: number = 0\n): number => {\n return (\n degrees +\n arcmins / 60.0 +\n arcsecs / (60.0 * 60.0) +\n mas / (60.0 * 60.0 * 1e3) +\n muas / (60.0 * 60.0 * 1e6)\n )\n}\n\ninterface Coefficients {\n terrestrialObliquity: number[]\n solarPerigee: number[]\n solarLongitude: number[]\n lunarInclination: number[]\n lunarLongitude: number[]\n lunarNode: number[]\n lunarPerigee: number[]\n}\n\nconst coefficients: Coefficients = {\n // Meeus formula 21.3\n terrestrialObliquity: [\n sexagesimalToDecimal(23, 26, 21.448),\n -sexagesimalToDecimal(0, 0, 4680.93),\n -sexagesimalToDecimal(0, 0, 1.55),\n sexagesimalToDecimal(0, 0, 1999.25),\n -sexagesimalToDecimal(0, 0, 51.38),\n -sexagesimalToDecimal(0, 0, 249.67),\n -sexagesimalToDecimal(0, 0, 39.05),\n sexagesimalToDecimal(0, 0, 7.12),\n sexagesimalToDecimal(0, 0, 27.87),\n sexagesimalToDecimal(0, 0, 5.79),\n sexagesimalToDecimal(0, 0, 2.45)\n ].map((number, index) => {\n return number * Math.pow(1e-2, index)\n }),\n\n solarPerigee: [\n 280.46645 - 357.5291,\n 36000.76932 - 35999.0503,\n 0.0003032 + 0.0001559,\n 0.00000048\n ],\n\n solarLongitude: [280.46645, 36000.76983, 0.0003032],\n\n lunarInclination: [5.145],\n\n lunarLongitude: [\n 218.3164591,\n 481267.88134236,\n -0.0013268,\n 1 / 538841.0 - 1 / 65194000.0\n ],\n\n lunarNode: [\n 125.044555,\n -1934.1361849,\n 0.0020762,\n 1 / 467410.0,\n -1 / 60616000.0\n ],\n\n lunarPerigee: [\n 83.353243,\n 4069.0137111,\n -0.0103238,\n -1 / 80053.0,\n 1 / 18999000.0\n ]\n}\n\nexport default coefficients\nexport { sexagesimalToDecimal }\nexport type { Coefficients }\n","import { d2r, r2d } from './constants.js'\nimport coefficients from './coefficients.js'\n\nexport interface AstroValue {\n value: number\n speed: number\n}\n\nexport interface AstroData {\n s: AstroValue\n h: AstroValue\n p: AstroValue\n N: AstroValue\n pp: AstroValue\n '90': AstroValue\n omega: AstroValue\n i: AstroValue\n I: AstroValue\n xi: AstroValue\n nu: AstroValue\n nup: AstroValue\n nupp: AstroValue\n 'T+h-s': AstroValue\n P: AstroValue\n}\n\n// Evaluates a polynomial at argument\nconst polynomial = (coefficients: number[], argument: number): number => {\n const result: number[] = []\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * Math.pow(argument, index))\n })\n return result.reduce((a, b) => a + b)\n}\n\n// Evaluates a derivative polynomial at argument\nconst derivativePolynomial = (\n coefficients: number[],\n argument: number\n): number => {\n const result: number[] = []\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * index * Math.pow(argument, index - 1))\n })\n return result.reduce((a, b) => a + b)\n}\n\n// Meeus formula 11.1\nconst T = (t: Date): number => {\n return (JD(t) - 2451545.0) / 36525\n}\n\n// Meeus formula 7.1\nconst JD = (t: Date): number => {\n let Y = t.getFullYear()\n let M = t.getMonth() + 1\n const D =\n t.getDate() +\n t.getHours() / 24.0 +\n t.getMinutes() / (24.0 * 60.0) +\n t.getSeconds() / (24.0 * 60.0 * 60.0) +\n t.getMilliseconds() / (24.0 * 60.0 * 60.0 * 1e6)\n if (M <= 2) {\n Y = Y - 1\n M = M + 12\n }\n const A = Math.floor(Y / 100.0)\n const B = 2 - A + Math.floor(A / 4.0)\n return (\n Math.floor(365.25 * (Y + 4716)) +\n Math.floor(30.6001 * (M + 1)) +\n D +\n B -\n 1524.5\n )\n}\n\nconst _I = (N: number, i: number, omega: number): number => {\n N = d2r * N\n i = d2r * i\n omega = d2r * omega\n const cosI =\n Math.cos(i) * Math.cos(omega) - Math.sin(i) * Math.sin(omega) * Math.cos(N)\n return r2d * Math.acos(cosI)\n}\n\nconst _xi = (N: number, i: number, omega: number): number => {\n N = d2r * N\n i = d2r * i\n omega = d2r * omega\n let e1 =\n (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n let e2 =\n (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n e1 = Math.atan(e1)\n e2 = Math.atan(e2)\n e1 = e1 - 0.5 * N\n e2 = e2 - 0.5 * N\n return -(e1 + e2) * r2d\n}\n\nconst _nu = (N: number, i: number, omega: number): number => {\n N = d2r * N\n i = d2r * i\n omega = d2r * omega\n let e1 =\n (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n let e2 =\n (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) *\n Math.tan(0.5 * N)\n e1 = Math.atan(e1)\n e2 = Math.atan(e2)\n e1 = e1 - 0.5 * N\n e2 = e2 - 0.5 * N\n return (e1 - e2) * r2d\n}\n\n// Schureman equation 224\nconst _nup = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega)\n const nu = d2r * _nu(N, i, omega)\n return (\n r2d *\n Math.atan(\n (Math.sin(2 * I) * Math.sin(nu)) /\n (Math.sin(2 * I) * Math.cos(nu) + 0.3347)\n )\n )\n}\n\n// Schureman equation 232\nconst _nupp = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega)\n const nu = d2r * _nu(N, i, omega)\n const tan2nupp =\n (Math.sin(I) ** 2 * Math.sin(2 * nu)) /\n (Math.sin(I) ** 2 * Math.cos(2 * nu) + 0.0727)\n return r2d * 0.5 * Math.atan(tan2nupp)\n}\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b\n}\n\nconst astro = (time: Date): AstroData => {\n // This gets cast to `AstroData` later, but we build it up step by step here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: any = {}\n\n const polynomials: Record<string, number[]> = {\n s: coefficients.lunarLongitude,\n h: coefficients.solarLongitude,\n p: coefficients.lunarPerigee,\n N: coefficients.lunarNode,\n pp: coefficients.solarPerigee,\n '90': [90.0],\n omega: coefficients.terrestrialObliquity,\n i: coefficients.lunarInclination\n }\n\n // Polynomials are in T, that is Julian Centuries; we want our speeds to be\n // in the more convenient unit of degrees per hour.\n const dTdHour = 1 / (24 * 365.25 * 100)\n for (const name in polynomials) {\n result[name] = {\n value: modulus(polynomial(polynomials[name], T(time)), 360.0),\n speed: derivativePolynomial(polynomials[name], T(time)) * dTdHour\n }\n }\n\n // Some other parameters defined by Schureman which are dependent on the\n // parameters N, i, omega for use in node factor calculations. We don't need\n // their speeds.\n const functions: Record<\n string,\n (N: number, i: number, omega: number) => number\n > = {\n I: _I,\n xi: _xi,\n nu: _nu,\n nup: _nup,\n nupp: _nupp\n }\n Object.keys(functions).forEach((name) => {\n const functionCall = functions[name]\n result[name] = {\n value: modulus(\n functionCall(result.N.value, result.i.value, result.omega.value),\n 360.0\n ),\n speed: null\n }\n })\n\n // We don't work directly with the T (hours) parameter, instead our spanning\n // set for equilibrium arguments #is given by T+h-s, s, h, p, N, pp, 90.\n // This is in line with convention.\n const hour = {\n value: (JD(time) - Math.floor(JD(time))) * 360.0,\n speed: 15.0\n }\n\n result['T+h-s'] = {\n value: hour.value + result.h.value - result.s.value,\n speed: hour.speed + result.h.speed - result.s.speed\n }\n\n // It is convenient to calculate Schureman's P here since several node\n // factors need it, although it could be argued that these\n // (along with I, xi, nu etc) belong somewhere else.\n result.P = {\n value: result.p.value - (result.xi.value % 360.0),\n speed: null\n }\n\n return result as AstroData\n}\n\nexport default astro\nexport { polynomial, derivativePolynomial, T, JD, _I, _xi, _nu, _nup, _nupp }\n","import astro from '../astronomy/index.js'\nimport { d2r } from '../astronomy/constants.js'\nimport type { Constituent } from '../constituents/constituent.js'\nimport type { CompoundConstituent } from '../constituents/compound-constituent.js'\n\nexport interface Timeline {\n items: Date[]\n hours: number[]\n}\n\nexport interface HarmonicConstituent {\n name: string\n amplitude: number\n // This needs refactored to support generics with the `phaseKey` option\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nexport interface InternalHarmonicConstituent extends HarmonicConstituent {\n _phase: number\n _model: Constituent | CompoundConstituent\n}\n\nexport interface TimelinePoint {\n time: Date\n hour: number\n level: number\n}\n\nexport interface Extreme {\n time: Date\n level: number\n high: boolean\n low: boolean\n label: string\n}\n\nexport interface ExtremeOffsets {\n height?: {\n high?: number\n low?: number\n type?: 'fixed' | 'ratio'\n }\n time?: {\n high?: number\n low?: number\n }\n}\n\nexport interface ExtremeLabels {\n high?: string\n low?: string\n}\n\nexport interface ExtremesOptions {\n labels?: ExtremeLabels\n offsets?: ExtremeOffsets\n}\n\nexport interface Prediction {\n getExtremesPrediction: (options?: ExtremesOptions) => Extreme[]\n getTimelinePrediction: () => TimelinePoint[]\n}\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b\n}\n\nconst addExtremesOffsets = (\n extreme: Extreme,\n offsets?: ExtremeOffsets\n): Extreme => {\n if (typeof offsets === 'undefined' || !offsets) {\n return extreme\n }\n\n if (extreme.high && offsets.height?.high) {\n if (offsets.height.type === 'fixed') {\n extreme.level += offsets.height.high\n } else {\n extreme.level *= offsets.height.high\n }\n }\n if (extreme.low && offsets.height?.low) {\n if (offsets.height.type === 'fixed') {\n extreme.level += offsets.height.low\n } else {\n extreme.level *= offsets.height.low\n }\n }\n if (extreme.high && offsets.time?.high) {\n extreme.time = new Date(\n extreme.time.getTime() + offsets.time.high * 60 * 1000\n )\n }\n if (extreme.low && offsets.time?.low) {\n extreme.time = new Date(\n extreme.time.getTime() + offsets.time.low * 60 * 1000\n )\n }\n return extreme\n}\n\nconst getExtremeLabel = (\n label: 'high' | 'low',\n highLowLabels?: ExtremeLabels\n): string => {\n if (\n typeof highLowLabels !== 'undefined' &&\n typeof highLowLabels[label] !== 'undefined'\n ) {\n return highLowLabels[label]!\n }\n const labels = {\n high: 'High',\n low: 'Low'\n }\n return labels[label]\n}\n\ninterface PredictionFactoryParams {\n timeline: Timeline\n constituents: InternalHarmonicConstituent[]\n start: Date\n}\n\nconst predictionFactory = ({\n timeline,\n constituents,\n start\n}: PredictionFactoryParams): Prediction => {\n const getLevel = (\n hour: number,\n modelBaseSpeed: Record<string, number>,\n modelU: Record<string, number>,\n modelF: Record<string, number>,\n modelBaseValue: Record<string, number>\n ): number => {\n const amplitudes: number[] = []\n let result = 0\n\n constituents.forEach((constituent) => {\n const amplitude = constituent.amplitude\n const phase = constituent._phase\n const f = modelF[constituent.name]\n const speed = modelBaseSpeed[constituent.name]\n const u = modelU[constituent.name]\n const V0 = modelBaseValue[constituent.name]\n amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase))\n })\n // sum up each row\n amplitudes.forEach((item) => {\n result += item\n })\n return result\n }\n\n const prediction: Prediction = {} as Prediction\n\n prediction.getExtremesPrediction = (options?: ExtremesOptions): Extreme[] => {\n const { labels, offsets } = typeof options !== 'undefined' ? options : {}\n const results: Extreme[] = []\n const { baseSpeed, u, f, baseValue } = prepare()\n let goingUp = false\n let goingDown = false\n let lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue)\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index]\n const level = getLevel(hour, baseSpeed, u[index], f[index], baseValue)\n // Compare this level to the last one, if we\n // are changing angle, then the last one was high or low\n if (level > lastLevel && goingDown) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: false,\n low: true,\n label: getExtremeLabel('low', labels)\n },\n offsets\n )\n )\n }\n if (level < lastLevel && goingUp) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: true,\n low: false,\n label: getExtremeLabel('high', labels)\n },\n offsets\n )\n )\n }\n if (level > lastLevel) {\n goingUp = true\n goingDown = false\n }\n if (level < lastLevel) {\n goingUp = false\n goingDown = true\n }\n lastLevel = level\n })\n return results\n }\n\n prediction.getTimelinePrediction = (): TimelinePoint[] => {\n const results: TimelinePoint[] = []\n const { baseSpeed, u, f, baseValue } = prepare()\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index]\n const prediction: TimelinePoint = {\n time,\n hour,\n level: getLevel(hour, baseSpeed, u[index], f[index], baseValue)\n }\n\n results.push(prediction)\n })\n return results\n }\n\n const prepare = () => {\n const baseAstro = astro(start)\n\n const baseValue: Record<string, number> = {}\n const baseSpeed: Record<string, number> = {}\n const u: Record<string, number>[] = []\n const f: Record<string, number>[] = []\n constituents.forEach((constituent) => {\n const value = constituent._model.value(baseAstro)\n const speed = constituent._model.speed(baseAstro)\n baseValue[constituent.name] = d2r * value\n baseSpeed[constituent.name] = d2r * speed\n })\n timeline.items.forEach((time) => {\n const uItem: Record<string, number> = {}\n const fItem: Record<string, number> = {}\n const itemAstro = astro(time)\n constituents.forEach((constituent) => {\n const constituentU = modulus(constituent._model.u(itemAstro), 360)\n\n uItem[constituent.name] = d2r * constituentU\n fItem[constituent.name] = modulus(constituent._model.f(itemAstro), 360)\n })\n u.push(uItem)\n f.push(fItem)\n })\n\n return {\n baseValue,\n baseSpeed,\n u,\n f\n }\n }\n\n return Object.freeze(prediction)\n}\n\nexport default predictionFactory\n","import { d2r, r2d } from '../astronomy/constants.js'\nimport type { AstroData } from '../astronomy/index.js'\n\nexport type NodeCorrectionFunction = (\n a: AstroData,\n ...args: unknown[]\n) => number\n\nexport interface NodeCorrections {\n fUnity: () => number\n fMm: (a: AstroData) => number\n fMf: (a: AstroData) => number\n fO1: (a: AstroData) => number\n fJ1: (a: AstroData) => number\n fOO1: (a: AstroData) => number\n fM2: (a: AstroData) => number\n fK1: (a: AstroData) => number\n fL2: (a: AstroData) => number\n fK2: (a: AstroData) => number\n fM1: (a: AstroData) => number\n fModd: (a: AstroData, n: number) => number\n uZero: () => number\n uMf: (a: AstroData) => number\n uO1: (a: AstroData) => number\n uJ1: (a: AstroData) => number\n uOO1: (a: AstroData) => number\n uM2: (a: AstroData) => number\n uK1: (a: AstroData) => number\n uL2: (a: AstroData) => number\n uK2: (a: AstroData) => number\n uM1: (a: AstroData) => number\n uModd: (a: AstroData, n: number) => number\n}\n\nconst corrections: NodeCorrections = {\n fUnity(): number {\n return 1\n },\n\n // Schureman equations 73, 65\n fMm(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n (2 / 3.0 - Math.pow(Math.sin(omega), 2)) *\n (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2))\n return (2 / 3.0 - Math.pow(Math.sin(I), 2)) / mean\n },\n\n // Schureman equations 74, 66\n fMf(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean = Math.pow(Math.sin(omega), 2) * Math.pow(Math.cos(0.5 * i), 4)\n return Math.pow(Math.sin(I), 2) / mean\n },\n\n // Schureman equations 75, 67\n fO1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.sin(omega) *\n Math.pow(Math.cos(0.5 * omega), 2) *\n Math.pow(Math.cos(0.5 * i), 4)\n return (Math.sin(I) * Math.pow(Math.cos(0.5 * I), 2)) / mean\n },\n\n // Schureman equations 76, 68\n fJ1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2))\n return Math.sin(2 * I) / mean\n },\n\n // Schureman equations 77, 69\n fOO1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.sin(omega) *\n Math.pow(Math.sin(0.5 * omega), 2) *\n Math.pow(Math.cos(0.5 * i), 4)\n return (Math.sin(I) * Math.pow(Math.sin(0.5 * I), 2)) / mean\n },\n\n // Schureman equations 78, 70\n fM2(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const mean =\n Math.pow(Math.cos(0.5 * omega), 4) * Math.pow(Math.cos(0.5 * i), 4)\n return Math.pow(Math.cos(0.5 * I), 4) / mean\n },\n\n // Schureman equations 227, 226, 68\n // Should probably eventually include the derivations of the magic numbers (0.5023 etc).\n fK1(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const nu = d2r * a.nu.value\n const sin2IcosnuMean =\n Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2))\n const mean = 0.5023 * sin2IcosnuMean + 0.1681\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(2 * I), 2) +\n 0.1689 * Math.sin(2 * I) * Math.cos(nu) +\n 0.0283,\n 0.5\n ) / mean\n )\n },\n\n // Schureman equations 215, 213, 204\n // It can be (and has been) confirmed that the exponent for R_a reads 1/2 via Schureman Table 7\n fL2(a: AstroData): number {\n const P = d2r * a.P.value\n const I = d2r * a.I.value\n const rAInv = Math.pow(\n 1 -\n 12 * Math.pow(Math.tan(0.5 * I), 2) * Math.cos(2 * P) +\n 36 * Math.pow(Math.tan(0.5 * I), 4),\n 0.5\n )\n return corrections.fM2(a) * rAInv\n },\n\n // Schureman equations 235, 234, 71\n // Again, magic numbers\n fK2(a: AstroData): number {\n const omega = d2r * a.omega.value\n const i = d2r * a.i.value\n const I = d2r * a.I.value\n const nu = d2r * a.nu.value\n const sinsqIcos2nuMean =\n Math.sin(omega) ** 2 * (1 - (3 / 2.0) * Math.sin(i) ** 2)\n const mean = 0.5023 * sinsqIcos2nuMean + 0.0365\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(I), 4) +\n 0.0367 * Math.pow(Math.sin(I), 2) * Math.cos(2 * nu) +\n 0.0013,\n 0.5\n ) / mean\n )\n },\n\n // Schureman equations 206, 207, 195\n fM1(a: AstroData): number {\n const P = d2r * a.P.value\n const I = d2r * a.I.value\n const qAInv = Math.pow(\n 0.25 +\n 1.5 *\n Math.cos(I) *\n Math.cos(2 * P) *\n Math.pow(Math.cos(0.5 * I), -0.5) +\n 2.25 * Math.pow(Math.cos(I), 2) * Math.pow(Math.cos(0.5 * I), -4),\n 0.5\n )\n return corrections.fO1(a) * qAInv\n },\n\n // See e.g. Schureman equation 149\n fModd(a: AstroData, n: number): number {\n return Math.pow(corrections.fM2(a), n / 2.0)\n },\n\n // Node factors u, see Table 2 of Schureman.\n\n uZero(): number {\n return 0.0\n },\n\n uMf(a: AstroData): number {\n return -2.0 * a.xi.value\n },\n\n uO1(a: AstroData): number {\n return 2.0 * a.xi.value - a.nu.value\n },\n\n uJ1(a: AstroData): number {\n return -a.nu.value\n },\n\n uOO1(a: AstroData): number {\n return -2.0 * a.xi.value - a.nu.value\n },\n\n uM2(a: AstroData): number {\n return 2.0 * a.xi.value - 2.0 * a.nu.value\n },\n\n uK1(a: AstroData): number {\n return -a.nup.value\n },\n\n // Schureman 214\n uL2(a: AstroData): number {\n const I = d2r * a.I.value\n const P = d2r * a.P.value\n const R =\n r2d *\n Math.atan(\n Math.sin(2 * P) /\n ((1 / 6.0) * Math.pow(Math.tan(0.5 * I), -2) - Math.cos(2 * P))\n )\n return 2.0 * a.xi.value - 2.0 * a.nu.value - R\n },\n\n uK2(a: AstroData): number {\n return -2.0 * a.nupp.value\n },\n\n // Schureman 202\n uM1(a: AstroData): number {\n const I = d2r * a.I.value\n const P = d2r * a.P.value\n const Q =\n r2d *\n Math.atan(((5 * Math.cos(I) - 1) / (7 * Math.cos(I) + 1)) * Math.tan(P))\n return a.xi.value - a.nu.value + Q\n },\n\n uModd(a: AstroData, n: number): number {\n return (n / 2.0) * corrections.uM2(a)\n }\n}\n\nexport default corrections\n","import nodeCorrections from '../node-corrections/index.js'\nimport type { AstroData } from '../astronomy/index.js'\nimport type { NodeCorrectionFunction } from '../node-corrections/index.js'\n\n/**\n * Computes the dot notation of two arrays\n */\nconst dotArray = (a: number[], b: number[]): number => {\n const results: number[] = []\n a.forEach((value, index) => {\n results.push(value * b[index])\n })\n return results.reduce((total, value) => total + value)\n}\n\nconst astronimicDoodsonNumber = (\n astro: AstroData\n): AstroData[keyof AstroData][] => {\n return [\n astro['T+h-s'],\n astro.s,\n astro.h,\n astro.p,\n astro.N,\n astro.pp,\n astro['90']\n ]\n}\n\nconst astronomicSpeed = (astro: AstroData): number[] => {\n const results: number[] = []\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.speed)\n })\n return results\n}\n\nconst astronomicValues = (astro: AstroData): number[] => {\n const results: number[] = []\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.value)\n })\n return results\n}\n\nexport interface Constituent {\n name: string\n coefficients: number[]\n value: (astro: AstroData) => number\n speed: (astro: AstroData) => number\n u: NodeCorrectionFunction\n f: NodeCorrectionFunction\n}\n\nconst constituentFactory = (\n name: string,\n coefficients: number[],\n u?: NodeCorrectionFunction,\n f?: NodeCorrectionFunction\n): Constituent => {\n if (!coefficients) {\n throw new Error('Coefficient must be defined for a constituent')\n }\n\n const constituent: Constituent = {\n name,\n coefficients,\n\n value: (astro: AstroData): number => {\n return dotArray(coefficients, astronomicValues(astro))\n },\n\n speed(astro: AstroData): number {\n return dotArray(coefficients, astronomicSpeed(astro))\n },\n\n u: typeof u !== 'undefined' ? u : nodeCorrections.uZero,\n\n f: typeof f !== 'undefined' ? f : nodeCorrections.fUnity\n }\n\n return Object.freeze(constituent)\n}\n\nexport default constituentFactory\nexport { astronimicDoodsonNumber, astronomicSpeed, astronomicValues }\n","import type { Constituent } from './constituent.js'\nimport type { AstroData } from '../astronomy/index.js'\n\nexport interface ConstituentMember {\n constituent: Constituent\n factor: number\n}\n\nexport interface CompoundConstituent {\n name: string\n coefficients: number[]\n speed: (astro: AstroData) => number\n value: (astro: AstroData) => number\n u: (astro: AstroData) => number\n f: (astro: AstroData) => number\n}\n\nconst compoundConstituentFactory = (\n name: string,\n members: ConstituentMember[]\n): CompoundConstituent => {\n const coefficients: number[] = []\n members.forEach(({ constituent, factor }) => {\n constituent.coefficients.forEach((coefficient, index) => {\n if (typeof coefficients[index] === 'undefined') {\n coefficients[index] = 0\n }\n coefficients[index] += coefficient * factor\n })\n })\n\n const compoundConstituent: CompoundConstituent = {\n name,\n coefficients,\n\n speed: (astro: AstroData): number => {\n let speed = 0\n members.forEach(({ constituent, factor }) => {\n speed += constituent.speed(astro) * factor\n })\n return speed\n },\n\n value: (astro: AstroData): number => {\n let value = 0\n members.forEach(({ constituent, factor }) => {\n value += constituent.value(astro) * factor\n })\n return value\n },\n\n u: (astro: AstroData): number => {\n let u = 0\n members.forEach(({ constituent, factor }) => {\n u += constituent.u(astro) * factor\n })\n return u\n },\n\n f: (astro: AstroData): number => {\n const f: number[] = []\n members.forEach(({ constituent, factor }) => {\n f.push(Math.pow(constituent.f(astro), Math.abs(factor)))\n })\n return f.reduce((previous, value) => previous * value)\n }\n }\n\n return Object.freeze(compoundConstituent)\n}\n\nexport default compoundConstituentFactory\n","import constituent from './constituent.js'\nimport compoundConstituent from './compound-constituent.js'\nimport nc from '../node-corrections/index.js'\nimport type { Constituent } from './constituent.js'\nimport type { CompoundConstituent } from './compound-constituent.js'\n\nexport interface Constituents {\n Z0: Constituent\n SA: Constituent\n SSA: Constituent\n MM: Constituent\n MF: Constituent\n Q1: Constituent\n O1: Constituent\n K1: Constituent\n J1: Constituent\n M1: Constituent\n P1: Constituent\n S1: Constituent\n OO1: Constituent\n '2N2': Constituent\n N2: Constituent\n NU2: Constituent\n M2: Constituent\n LAM2: Constituent\n L2: Constituent\n T2: Constituent\n S2: Constituent\n R2: Constituent\n K2: Constituent\n M3: Constituent\n MSF: CompoundConstituent\n '2Q1': CompoundConstituent\n RHO: CompoundConstituent\n MU2: CompoundConstituent\n '2SM2': CompoundConstituent\n '2MK3': CompoundConstituent\n MK3: CompoundConstituent\n MN4: CompoundConstituent\n M4: CompoundConstituent\n MS4: CompoundConstituent\n S4: CompoundConstituent\n M6: CompoundConstituent\n S6: CompoundConstituent\n M8: CompoundConstituent\n [key: string]: Constituent | CompoundConstituent\n}\n\nconst constituents: Partial<Constituents> = {}\n\n// Long Term\nconstituents.Z0 = constituent('Z0', [0, 0, 0, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.SA = constituent('Sa', [0, 0, 1, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.SSA = constituent(\n 'Ssa',\n [0, 0, 2, 0, 0, 0, 0],\n nc.uZero,\n nc.fUnity\n)\nconstituents.MM = constituent('MM', [0, 1, 0, -1, 0, 0, 0], nc.uZero, nc.fMm)\nconstituents.MF = constituent('MF', [0, 2, 0, 0, 0, 0, 0], nc.uMf, nc.fMf)\n// Diurnals\nconstituents.Q1 = constituent('Q1', [1, -2, 0, 1, 0, 0, 1], nc.uO1, nc.fO1)\nconstituents.O1 = constituent('O1', [1, -1, 0, 0, 0, 0, 1], nc.uO1, nc.fO1)\nconstituents.K1 = constituent('K1', [1, 1, 0, 0, 0, 0, -1], nc.uK1, nc.fK1)\nconstituents.J1 = constituent('J1', [1, 2, 0, -1, 0, 0, -1], nc.uJ1, nc.fJ1)\nconstituents.M1 = constituent('M1', [1, 0, 0, 0, 0, 0, 1], nc.uM1, nc.fM1)\nconstituents.P1 = constituent('P1', [1, 1, -2, 0, 0, 0, 1], nc.uZero, nc.fUnity)\nconstituents.S1 = constituent('S1', [1, 1, -1, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.OO1 = constituent('OO1', [1, 3, 0, 0, 0, 0, -1], nc.uOO1, nc.fOO1)\n// Semi diurnals\nconstituents['2N2'] = constituent('2N2', [2, -2, 0, 2, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.N2 = constituent('N2', [2, -1, 0, 1, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.NU2 = constituent('NU2', [2, -1, 2, -1, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.M2 = constituent('M2', [2, 0, 0, 0, 0, 0, 0], nc.uM2, nc.fM2)\nconstituents.LAM2 = constituent('LAM2', [2, 1, -2, 1, 0, 0, 2], nc.uM2, nc.fM2)\nconstituents.L2 = constituent('L2', [2, 1, 0, -1, 0, 0, 2], nc.uL2, nc.fL2)\nconstituents.T2 = constituent('T2', [2, 2, -3, 0, 0, 1, 0], nc.uZero, nc.fUnity)\nconstituents.S2 = constituent('S2', [2, 2, -2, 0, 0, 0, 0], nc.uZero, nc.fUnity)\nconstituents.R2 = constituent(\n 'R2',\n [2, 2, -1, 0, 0, -1, 2],\n nc.uZero,\n nc.fUnity\n)\nconstituents.K2 = constituent('K2', [2, 2, 0, 0, 0, 0, 0], nc.uK2, nc.fK2)\n// Third diurnal\nconstituents.M3 = constituent(\n 'M3',\n [3, 0, 0, 0, 0, 0, 0],\n (a) => {\n return nc.uModd(a, 3)\n },\n (a) => {\n return nc.fModd(a, 3)\n }\n)\n// Compound\nconstituents.MSF = compoundConstituent('MSF', [\n { constituent: constituents.S2!, factor: 1 },\n { constituent: constituents.M2!, factor: -1 }\n])\n\n// Diurnal\nconstituents['2Q1'] = compoundConstituent('2Q1', [\n { constituent: constituents.N2!, factor: 1 },\n { constituent: constituents.J1!, factor: -1 }\n])\nconstituents.RHO = compoundConstituent('RHO', [\n { constituent: constituents.NU2!, factor: 1 },\n { constituent: constituents.K1!, factor: -1 }\n])\n\n// Semi-Diurnal\n\nconstituents.MU2 = compoundConstituent('MU2', [\n { constituent: constituents.M2!, factor: 2 },\n { constituent: constituents.S2!, factor: -1 }\n])\nconstituents['2SM2'] = compoundConstituent('2SM2', [\n { constituent: constituents.S2!, factor: 2 },\n { constituent: constituents.M2!, factor: -1 }\n])\n\n// Third-Diurnal\nconstituents['2MK3'] = compoundConstituent('2MK3', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.O1!, factor: 1 }\n])\nconstituents.MK3 = compoundConstituent('MK3', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.K1!, factor: 1 }\n])\n\n// Quarter-Diurnal\nconstituents.MN4 = compoundConstituent('MN4', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.N2!, factor: 1 }\n])\nconstituents.M4 = compoundConstituent('M4', [\n { constituent: constituents.M2!, factor: 2 }\n])\nconstituents.MS4 = compoundConstituent('MS4', [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.S2!, factor: 1 }\n])\nconstituents.S4 = compoundConstituent('S4', [\n { constituent: constituents.S2!, factor: 2 }\n])\n\n// Sixth-Diurnal\nconstituents.M6 = compoundConstituent('M6', [\n { constituent: constituents.M2!, factor: 3 }\n])\nconstituents.S6 = compoundConstituent('S6', [\n { constituent: constituents.S2!, factor: 3 }\n])\n\n// Eighth-Diurnals\nconstituents.M8 = compoundConstituent('M8', [\n { constituent: constituents.M2!, factor: 4 }\n])\n\nexport default constituents as Constituents\n","import prediction from './prediction.js'\nimport constituentModels from '../constituents/index.js'\nimport { d2r } from '../astronomy/constants.js'\nimport type {\n HarmonicConstituent,\n InternalHarmonicConstituent,\n Prediction\n} from './prediction.js'\n\nexport type * from './prediction.js'\n\nexport interface HarmonicsOptions {\n harmonicConstituents: HarmonicConstituent[]\n phaseKey: string\n offset: number | false\n}\n\nexport interface PredictionOptions {\n timeFidelity?: number\n}\n\nexport interface Harmonics {\n setTimeSpan: (startTime: Date | number, endTime: Date | number) => Harmonics\n prediction: (options?: PredictionOptions) => Prediction\n}\n\nconst getDate = (time: Date | number): Date => {\n if (time instanceof Date) {\n return time\n }\n if (typeof time === 'number') {\n return new Date(time * 1000)\n }\n throw new Error('Invalid date format, should be a Date object, or timestamp')\n}\n\nconst getTimeline = (start: Date, end: Date, seconds: number = 10 * 60) => {\n const items: Date[] = []\n const endTime = end.getTime() / 1000\n let lastTime = start.getTime() / 1000\n const startTime = lastTime\n const hours: number[] = []\n while (lastTime <= endTime) {\n items.push(new Date(lastTime * 1000))\n hours.push((lastTime - startTime) / (60 * 60))\n lastTime += seconds\n }\n\n return {\n items,\n hours\n }\n}\n\nconst harmonicsFactory = ({\n harmonicConstituents,\n phaseKey,\n offset\n}: HarmonicsOptions): Harmonics => {\n if (!Array.isArray(harmonicConstituents)) {\n throw new Error('Harmonic constituents are not an array')\n }\n const constituents: InternalHarmonicConstituent[] = []\n harmonicConstituents.forEach((constituent) => {\n if (typeof constituent.name === 'undefined') {\n throw new Error('Harmonic constituents must have a name property')\n }\n if (constituentModels[constituent.name] !== undefined) {\n constituents.push({\n ...constituent,\n _model: constituentModels[constituent.name],\n _phase: d2r * constituent[phaseKey]\n })\n }\n })\n\n if (offset !== false) {\n constituents.push({\n name: 'Z0',\n _model: constituentModels.Z0,\n _phase: 0,\n amplitude: offset\n })\n }\n\n let start = new Date()\n let end = new Date()\n\n const harmonics: Harmonics = {} as Harmonics\n\n harmonics.setTimeSpan = (\n startTime: Date | number,\n endTime: Date | number\n ): Harmonics => {\n start = getDate(startTime)\n end = getDate(endTime)\n if (start.getTime() >= end.getTime()) {\n throw new Error('Start time must be before end time')\n }\n return harmonics\n }\n\n harmonics.prediction = (options?: PredictionOptions): Prediction => {\n const opts =\n typeof options !== 'undefined' ? options : { timeFidelity: 10 * 60 }\n return prediction({\n timeline: getTimeline(start, end, opts.timeFidelity),\n constituents,\n start\n })\n }\n\n return Object.freeze(harmonics)\n}\n\nexport default harmonicsFactory\nexport { getDate, getTimeline }\n","import harmonics from './harmonics/index.js'\nimport { default as constituents } from './constituents/index.js'\nimport type { HarmonicConstituent } from './harmonics/index.js'\nimport type {\n TimelinePoint,\n Extreme,\n ExtremeOffsets\n} from './harmonics/prediction.js'\n\nexport interface TidePredictionOptions {\n phaseKey?: string\n offset?: number | false\n}\n\nexport interface TimeSpan {\n start: Date\n end: Date\n}\n\nexport interface ExtremesInput extends TimeSpan {\n labels?: {\n high?: string\n low?: string\n }\n offsets?: ExtremeOffsets\n timeFidelity?: number\n}\n\nexport interface TidePrediction {\n getTimelinePrediction: (params: TimeSpan) => TimelinePoint[]\n getExtremesPrediction: (params: ExtremesInput) => Extreme[]\n getWaterLevelAtTime: (params: { time: Date }) => TimelinePoint\n}\n\nconst tidePredictionFactory = (\n constituents: HarmonicConstituent[],\n options: TidePredictionOptions = {}\n): TidePrediction => {\n const harmonicsOptions = {\n harmonicConstituents: constituents,\n phaseKey: 'phase_GMT',\n offset: false as number | false,\n ...options\n }\n\n const tidePrediction: TidePrediction = {\n getTimelinePrediction: ({ start, end }: TimeSpan): TimelinePoint[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction()\n .getTimelinePrediction()\n },\n\n getExtremesPrediction: ({\n start,\n end,\n labels,\n offsets,\n timeFidelity\n }: ExtremesInput): Extreme[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction({ timeFidelity })\n .getExtremesPrediction({ labels, offsets })\n },\n\n getWaterLevelAtTime: ({ time }: { time: Date }): TimelinePoint => {\n const endDate = new Date(time.getTime() + 10 * 60 * 1000)\n return harmonics(harmonicsOptions)\n .setTimeSpan(time, endDate)\n .prediction()\n .getTimelinePrediction()[0]\n }\n }\n\n return tidePrediction\n}\n\n// Make constituents available on factory for reference\ntidePredictionFactory.constituents = constituents\n\nexport default tidePredictionFactory\nexport type { HarmonicConstituent, TimelinePoint, Extreme }\n"],"mappings":";AAAA,MAAa,MAAM,KAAK,KAAK;AAC7B,MAAa,MAAM,MAAQ,KAAK;;;;ACAhC,MAAM,wBACJ,SACA,UAAkB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AAGjC,wBAAe;;;;ACjFf,MAAM,yBACJ,gBACA,UAAiC,EAAE,KAChB;CACnB,MAAM,mBAAmB;EACvB,sBAAsBC;EACtB,UAAU;EACV,QAAQ;EACR,GAAG;EACJ;AAgCD,QA9BuC;EACrC,wBAAwB,EAAE,OAAO,UAAqC;AACpE,UAAOC,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,YAAY,CACZ,uBAAuB;;EAG5B,wBAAwB,EACtB,OACA,KACA,QACA,SACA,mBAC8B;AAC9B,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,sBAAsB;IAAE;IAAQ;IAAS,CAAC;;EAG/C,sBAAsB,EAAE,WAA0C;GAChE,MAAM,UAAU,IAAI,KAAK,KAAK,SAAS,GAAG,MAAU,IAAK;AACzD,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,MAAM,QAAQ,CAC1B,YAAY,CACZ,uBAAuB,CAAC;;EAE9B;;AAMH,sBAAsB,eAAeD;AAErC,kBAAe"}
1
+ {"version":3,"file":"index.js","names":["coefficients: Coefficients","result: number[]","modulus","result: any","polynomials: Record<string, number[]>","coefficients","functions: Record<string, (N: number, i: number, omega: number) => number>","amplitudes: number[]","prediction: Prediction","results: Extreme[]","results: TimelinePoint[]","prediction: TimelinePoint","prediction","astro","baseValue: Record<string, number>","baseSpeed: Record<string, number>","u: Record<string, number>[]","f: Record<string, number>[]","uItem: Record<string, number>","fItem: Record<string, number>","corrections: NodeCorrections","results: number[]","astro","coefficients","constituent: Constituent","nodeCorrections","coefficients: number[]","coefficients","compoundConstituent: CompoundConstituent","astro","f: number[]","constituents: Partial<Constituents>","constituent","nc","compoundConstituent","items: Date[]","hours: number[]","constituents: InternalHarmonicConstituent[]","constituentModels","harmonics: Harmonics","prediction","constituents","harmonics"],"sources":["../src/astronomy/constants.ts","../src/astronomy/coefficients.ts","../src/astronomy/index.ts","../src/harmonics/prediction.ts","../src/node-corrections/index.ts","../src/constituents/constituent.ts","../src/constituents/compound-constituent.ts","../src/constituents/index.ts","../src/harmonics/index.ts","../src/index.ts"],"sourcesContent":["export const d2r = Math.PI / 180.0;\nexport const r2d = 180.0 / Math.PI;\n","// Convert a sexagesimal angle into decimal degrees\nconst sexagesimalToDecimal = (\n degrees: number,\n arcmins: number = 0,\n arcsecs: number = 0,\n mas: number = 0,\n muas: number = 0,\n): number => {\n return (\n degrees +\n arcmins / 60.0 +\n arcsecs / (60.0 * 60.0) +\n mas / (60.0 * 60.0 * 1e3) +\n muas / (60.0 * 60.0 * 1e6)\n );\n};\n\ninterface Coefficients {\n terrestrialObliquity: number[];\n solarPerigee: number[];\n solarLongitude: number[];\n lunarInclination: number[];\n lunarLongitude: number[];\n lunarNode: number[];\n lunarPerigee: number[];\n}\n\nconst coefficients: Coefficients = {\n // Meeus formula 21.3\n terrestrialObliquity: [\n sexagesimalToDecimal(23, 26, 21.448),\n -sexagesimalToDecimal(0, 0, 4680.93),\n -sexagesimalToDecimal(0, 0, 1.55),\n sexagesimalToDecimal(0, 0, 1999.25),\n -sexagesimalToDecimal(0, 0, 51.38),\n -sexagesimalToDecimal(0, 0, 249.67),\n -sexagesimalToDecimal(0, 0, 39.05),\n sexagesimalToDecimal(0, 0, 7.12),\n sexagesimalToDecimal(0, 0, 27.87),\n sexagesimalToDecimal(0, 0, 5.79),\n sexagesimalToDecimal(0, 0, 2.45),\n ].map((number, index) => {\n return number * Math.pow(1e-2, index);\n }),\n\n solarPerigee: [280.46645 - 357.5291, 36000.76932 - 35999.0503, 0.0003032 + 0.0001559, 0.00000048],\n\n solarLongitude: [280.46645, 36000.76983, 0.0003032],\n\n lunarInclination: [5.145],\n\n lunarLongitude: [218.3164591, 481267.88134236, -0.0013268, 1 / 538841.0 - 1 / 65194000.0],\n\n lunarNode: [125.044555, -1934.1361849, 0.0020762, 1 / 467410.0, -1 / 60616000.0],\n\n lunarPerigee: [83.353243, 4069.0137111, -0.0103238, -1 / 80053.0, 1 / 18999000.0],\n};\n\nexport default coefficients;\nexport { sexagesimalToDecimal };\nexport type { Coefficients };\n","import { d2r, r2d } from \"./constants.js\";\nimport coefficients from \"./coefficients.js\";\n\nexport interface AstroValue {\n value: number;\n speed: number;\n}\n\nexport interface AstroData {\n s: AstroValue;\n h: AstroValue;\n p: AstroValue;\n N: AstroValue;\n pp: AstroValue;\n \"90\": AstroValue;\n omega: AstroValue;\n i: AstroValue;\n I: AstroValue;\n xi: AstroValue;\n nu: AstroValue;\n nup: AstroValue;\n nupp: AstroValue;\n \"T+h-s\": AstroValue;\n P: AstroValue;\n}\n\n// Evaluates a polynomial at argument\nconst polynomial = (coefficients: number[], argument: number): number => {\n const result: number[] = [];\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * Math.pow(argument, index));\n });\n return result.reduce((a, b) => a + b);\n};\n\n// Evaluates a derivative polynomial at argument\nconst derivativePolynomial = (coefficients: number[], argument: number): number => {\n const result: number[] = [];\n coefficients.forEach((coefficient, index) => {\n result.push(coefficient * index * Math.pow(argument, index - 1));\n });\n return result.reduce((a, b) => a + b);\n};\n\n// Meeus formula 11.1\nconst T = (t: Date): number => {\n return (JD(t) - 2451545.0) / 36525;\n};\n\n// Meeus formula 7.1\nconst JD = (t: Date): number => {\n let Y = t.getUTCFullYear();\n let M = t.getUTCMonth() + 1;\n const D =\n t.getUTCDate() +\n t.getUTCHours() / 24.0 +\n t.getUTCMinutes() / (24.0 * 60.0) +\n t.getUTCSeconds() / (24.0 * 60.0 * 60.0) +\n t.getUTCMilliseconds() / (24.0 * 60.0 * 60.0 * 1e6);\n if (M <= 2) {\n Y = Y - 1;\n M = M + 12;\n }\n const A = Math.floor(Y / 100.0);\n const B = 2 - A + Math.floor(A / 4.0);\n return Math.floor(365.25 * (Y + 4716)) + Math.floor(30.6001 * (M + 1)) + D + B - 1524.5;\n};\n\nconst _I = (N: number, i: number, omega: number): number => {\n N = d2r * N;\n i = d2r * i;\n omega = d2r * omega;\n const cosI = Math.cos(i) * Math.cos(omega) - Math.sin(i) * Math.sin(omega) * Math.cos(N);\n return r2d * Math.acos(cosI);\n};\n\nconst _xi = (N: number, i: number, omega: number): number => {\n N = d2r * N;\n i = d2r * i;\n omega = d2r * omega;\n let e1 = (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) * Math.tan(0.5 * N);\n let e2 = (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) * Math.tan(0.5 * N);\n e1 = Math.atan(e1);\n e2 = Math.atan(e2);\n e1 = e1 - 0.5 * N;\n e2 = e2 - 0.5 * N;\n return -(e1 + e2) * r2d;\n};\n\nconst _nu = (N: number, i: number, omega: number): number => {\n N = d2r * N;\n i = d2r * i;\n omega = d2r * omega;\n let e1 = (Math.cos(0.5 * (omega - i)) / Math.cos(0.5 * (omega + i))) * Math.tan(0.5 * N);\n let e2 = (Math.sin(0.5 * (omega - i)) / Math.sin(0.5 * (omega + i))) * Math.tan(0.5 * N);\n e1 = Math.atan(e1);\n e2 = Math.atan(e2);\n e1 = e1 - 0.5 * N;\n e2 = e2 - 0.5 * N;\n return (e1 - e2) * r2d;\n};\n\n// Schureman equation 224\nconst _nup = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega);\n const nu = d2r * _nu(N, i, omega);\n return (\n r2d * Math.atan((Math.sin(2 * I) * Math.sin(nu)) / (Math.sin(2 * I) * Math.cos(nu) + 0.3347))\n );\n};\n\n// Schureman equation 232\nconst _nupp = (N: number, i: number, omega: number): number => {\n const I = d2r * _I(N, i, omega);\n const nu = d2r * _nu(N, i, omega);\n const tan2nupp =\n (Math.sin(I) ** 2 * Math.sin(2 * nu)) / (Math.sin(I) ** 2 * Math.cos(2 * nu) + 0.0727);\n return r2d * 0.5 * Math.atan(tan2nupp);\n};\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b;\n};\n\nconst astro = (time: Date): AstroData => {\n // This gets cast to `AstroData` later, but we build it up step by step here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: any = {};\n\n const polynomials: Record<string, number[]> = {\n s: coefficients.lunarLongitude,\n h: coefficients.solarLongitude,\n p: coefficients.lunarPerigee,\n N: coefficients.lunarNode,\n pp: coefficients.solarPerigee,\n \"90\": [90.0],\n omega: coefficients.terrestrialObliquity,\n i: coefficients.lunarInclination,\n };\n\n // Polynomials are in T, that is Julian Centuries; we want our speeds to be\n // in the more convenient unit of degrees per hour.\n const dTdHour = 1 / (24 * 365.25 * 100);\n for (const name in polynomials) {\n result[name] = {\n value: modulus(polynomial(polynomials[name], T(time)), 360.0),\n speed: derivativePolynomial(polynomials[name], T(time)) * dTdHour,\n };\n }\n\n // Some other parameters defined by Schureman which are dependent on the\n // parameters N, i, omega for use in node factor calculations. We don't need\n // their speeds.\n const functions: Record<string, (N: number, i: number, omega: number) => number> = {\n I: _I,\n xi: _xi,\n nu: _nu,\n nup: _nup,\n nupp: _nupp,\n };\n Object.keys(functions).forEach((name) => {\n const functionCall = functions[name];\n result[name] = {\n value: modulus(functionCall(result.N.value, result.i.value, result.omega.value), 360.0),\n speed: null,\n };\n });\n\n // We don't work directly with the T (hours) parameter, instead our spanning\n // set for equilibrium arguments #is given by T+h-s, s, h, p, N, pp, 90.\n // This is in line with convention.\n const hour = {\n value: (JD(time) - Math.floor(JD(time))) * 360.0,\n speed: 15.0,\n };\n\n result[\"T+h-s\"] = {\n value: hour.value + result.h.value - result.s.value,\n speed: hour.speed + result.h.speed - result.s.speed,\n };\n\n // It is convenient to calculate Schureman's P here since several node\n // factors need it, although it could be argued that these\n // (along with I, xi, nu etc) belong somewhere else.\n result.P = {\n value: result.p.value - (result.xi.value % 360.0),\n speed: null,\n };\n\n return result as AstroData;\n};\n\nexport default astro;\nexport { polynomial, derivativePolynomial, T, JD, _I, _xi, _nu, _nup, _nupp };\n","import astro from \"../astronomy/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { Constituent } from \"../constituents/constituent.js\";\nimport type { CompoundConstituent } from \"../constituents/compound-constituent.js\";\n\nexport interface Timeline {\n items: Date[];\n hours: number[];\n}\n\nexport interface HarmonicConstituent {\n name: string;\n amplitude: number;\n phase: number;\n speed?: number;\n description?: string;\n}\n\nexport interface InternalHarmonicConstituent extends HarmonicConstituent {\n _model: Constituent | CompoundConstituent;\n}\n\nexport interface TimelinePoint {\n time: Date;\n hour: number;\n level: number;\n}\n\nexport interface Extreme {\n time: Date;\n level: number;\n high: boolean;\n low: boolean;\n label: string;\n}\n\nexport interface ExtremeOffsets {\n height?: {\n high?: number;\n low?: number;\n type?: \"fixed\" | \"ratio\";\n };\n time?: {\n high?: number;\n low?: number;\n };\n}\n\nexport interface ExtremeLabels {\n high?: string;\n low?: string;\n}\n\nexport interface ExtremesOptions {\n labels?: ExtremeLabels;\n offsets?: ExtremeOffsets;\n}\n\nexport interface Prediction {\n getExtremesPrediction: (options?: ExtremesOptions) => Extreme[];\n getTimelinePrediction: () => TimelinePoint[];\n}\n\nconst modulus = (a: number, b: number): number => {\n return ((a % b) + b) % b;\n};\n\nconst addExtremesOffsets = (extreme: Extreme, offsets?: ExtremeOffsets): Extreme => {\n if (typeof offsets === \"undefined\" || !offsets) {\n return extreme;\n }\n\n if (extreme.high && offsets.height?.high) {\n if (offsets.height.type === \"fixed\") {\n extreme.level += offsets.height.high;\n } else {\n extreme.level *= offsets.height.high;\n }\n }\n if (extreme.low && offsets.height?.low) {\n if (offsets.height.type === \"fixed\") {\n extreme.level += offsets.height.low;\n } else {\n extreme.level *= offsets.height.low;\n }\n }\n if (extreme.high && offsets.time?.high) {\n extreme.time = new Date(extreme.time.getTime() + offsets.time.high * 60 * 1000);\n }\n if (extreme.low && offsets.time?.low) {\n extreme.time = new Date(extreme.time.getTime() + offsets.time.low * 60 * 1000);\n }\n return extreme;\n};\n\nconst getExtremeLabel = (label: \"high\" | \"low\", highLowLabels?: ExtremeLabels): string => {\n if (typeof highLowLabels !== \"undefined\" && typeof highLowLabels[label] !== \"undefined\") {\n return highLowLabels[label]!;\n }\n const labels = {\n high: \"High\",\n low: \"Low\",\n };\n return labels[label];\n};\n\ninterface PredictionFactoryParams {\n timeline: Timeline;\n constituents: InternalHarmonicConstituent[];\n start: Date;\n}\n\nconst predictionFactory = ({\n timeline,\n constituents,\n start,\n}: PredictionFactoryParams): Prediction => {\n const getLevel = (\n hour: number,\n modelBaseSpeed: Record<string, number>,\n modelU: Record<string, number>,\n modelF: Record<string, number>,\n modelBaseValue: Record<string, number>,\n ): number => {\n const amplitudes: number[] = [];\n let result = 0;\n\n constituents.forEach((constituent) => {\n const amplitude = constituent.amplitude;\n const phase = constituent.phase;\n const f = modelF[constituent.name];\n const speed = modelBaseSpeed[constituent.name];\n const u = modelU[constituent.name];\n const V0 = modelBaseValue[constituent.name];\n amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase));\n });\n // sum up each row\n amplitudes.forEach((item) => {\n result += item;\n });\n return result;\n };\n\n const prediction: Prediction = {} as Prediction;\n\n prediction.getExtremesPrediction = (options?: ExtremesOptions): Extreme[] => {\n const { labels, offsets } = typeof options !== \"undefined\" ? options : {};\n const results: Extreme[] = [];\n const { baseSpeed, u, f, baseValue } = prepare();\n let goingUp = false;\n let goingDown = false;\n let lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue);\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index];\n const level = getLevel(hour, baseSpeed, u[index], f[index], baseValue);\n // Compare this level to the last one, if we\n // are changing angle, then the last one was high or low\n if (level > lastLevel && goingDown) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: false,\n low: true,\n label: getExtremeLabel(\"low\", labels),\n },\n offsets,\n ),\n );\n }\n if (level < lastLevel && goingUp) {\n results.push(\n addExtremesOffsets(\n {\n time: timeline.items[index - 1],\n level: lastLevel,\n high: true,\n low: false,\n label: getExtremeLabel(\"high\", labels),\n },\n offsets,\n ),\n );\n }\n if (level > lastLevel) {\n goingUp = true;\n goingDown = false;\n }\n if (level < lastLevel) {\n goingUp = false;\n goingDown = true;\n }\n lastLevel = level;\n });\n return results;\n };\n\n prediction.getTimelinePrediction = (): TimelinePoint[] => {\n const results: TimelinePoint[] = [];\n const { baseSpeed, u, f, baseValue } = prepare();\n timeline.items.forEach((time, index) => {\n const hour = timeline.hours[index];\n const prediction: TimelinePoint = {\n time,\n hour,\n level: getLevel(hour, baseSpeed, u[index], f[index], baseValue),\n };\n\n results.push(prediction);\n });\n return results;\n };\n\n const prepare = () => {\n const baseAstro = astro(start);\n\n const baseValue: Record<string, number> = {};\n const baseSpeed: Record<string, number> = {};\n const u: Record<string, number>[] = [];\n const f: Record<string, number>[] = [];\n constituents.forEach((constituent) => {\n const value = constituent._model.value(baseAstro);\n const speed = constituent._model.speed(baseAstro);\n baseValue[constituent.name] = d2r * value;\n baseSpeed[constituent.name] = d2r * speed;\n });\n timeline.items.forEach((time) => {\n const uItem: Record<string, number> = {};\n const fItem: Record<string, number> = {};\n const itemAstro = astro(time);\n constituents.forEach((constituent) => {\n const constituentU = modulus(constituent._model.u(itemAstro), 360);\n\n uItem[constituent.name] = d2r * constituentU;\n fItem[constituent.name] = modulus(constituent._model.f(itemAstro), 360);\n });\n u.push(uItem);\n f.push(fItem);\n });\n\n return {\n baseValue,\n baseSpeed,\n u,\n f,\n };\n };\n\n return Object.freeze(prediction);\n};\n\nexport default predictionFactory;\n","import { d2r, r2d } from \"../astronomy/constants.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\n\nexport type NodeCorrectionFunction = (a: AstroData, ...args: unknown[]) => number;\n\nexport interface NodeCorrections {\n fUnity: () => number;\n fMm: (a: AstroData) => number;\n fMf: (a: AstroData) => number;\n fO1: (a: AstroData) => number;\n fJ1: (a: AstroData) => number;\n fOO1: (a: AstroData) => number;\n fM2: (a: AstroData) => number;\n fK1: (a: AstroData) => number;\n fL2: (a: AstroData) => number;\n fK2: (a: AstroData) => number;\n fM1: (a: AstroData) => number;\n fModd: (a: AstroData, n: number) => number;\n uZero: () => number;\n uMf: (a: AstroData) => number;\n uO1: (a: AstroData) => number;\n uJ1: (a: AstroData) => number;\n uOO1: (a: AstroData) => number;\n uM2: (a: AstroData) => number;\n uK1: (a: AstroData) => number;\n uL2: (a: AstroData) => number;\n uK2: (a: AstroData) => number;\n uM1: (a: AstroData) => number;\n uModd: (a: AstroData, n: number) => number;\n}\n\nconst corrections: NodeCorrections = {\n fUnity(): number {\n return 1;\n },\n\n // Schureman equations 73, 65\n fMm(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean =\n (2 / 3.0 - Math.pow(Math.sin(omega), 2)) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2));\n return (2 / 3.0 - Math.pow(Math.sin(I), 2)) / mean;\n },\n\n // Schureman equations 74, 66\n fMf(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean = Math.pow(Math.sin(omega), 2) * Math.pow(Math.cos(0.5 * i), 4);\n return Math.pow(Math.sin(I), 2) / mean;\n },\n\n // Schureman equations 75, 67\n fO1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean =\n Math.sin(omega) * Math.pow(Math.cos(0.5 * omega), 2) * Math.pow(Math.cos(0.5 * i), 4);\n return (Math.sin(I) * Math.pow(Math.cos(0.5 * I), 2)) / mean;\n },\n\n // Schureman equations 76, 68\n fJ1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean = Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2));\n return Math.sin(2 * I) / mean;\n },\n\n // Schureman equations 77, 69\n fOO1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean =\n Math.sin(omega) * Math.pow(Math.sin(0.5 * omega), 2) * Math.pow(Math.cos(0.5 * i), 4);\n return (Math.sin(I) * Math.pow(Math.sin(0.5 * I), 2)) / mean;\n },\n\n // Schureman equations 78, 70\n fM2(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const mean = Math.pow(Math.cos(0.5 * omega), 4) * Math.pow(Math.cos(0.5 * i), 4);\n return Math.pow(Math.cos(0.5 * I), 4) / mean;\n },\n\n // Schureman equations 227, 226, 68\n // Should probably eventually include the derivations of the magic numbers (0.5023 etc).\n fK1(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const nu = d2r * a.nu.value;\n const sin2IcosnuMean = Math.sin(2 * omega) * (1 - (3 / 2.0) * Math.pow(Math.sin(i), 2));\n const mean = 0.5023 * sin2IcosnuMean + 0.1681;\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(2 * I), 2) + 0.1689 * Math.sin(2 * I) * Math.cos(nu) + 0.0283,\n 0.5,\n ) / mean\n );\n },\n\n // Schureman equations 215, 213, 204\n // It can be (and has been) confirmed that the exponent for R_a reads 1/2 via Schureman Table 7\n fL2(a: AstroData): number {\n const P = d2r * a.P.value;\n const I = d2r * a.I.value;\n const rAInv = Math.pow(\n 1 -\n 12 * Math.pow(Math.tan(0.5 * I), 2) * Math.cos(2 * P) +\n 36 * Math.pow(Math.tan(0.5 * I), 4),\n 0.5,\n );\n return corrections.fM2(a) * rAInv;\n },\n\n // Schureman equations 235, 234, 71\n // Again, magic numbers\n fK2(a: AstroData): number {\n const omega = d2r * a.omega.value;\n const i = d2r * a.i.value;\n const I = d2r * a.I.value;\n const nu = d2r * a.nu.value;\n const sinsqIcos2nuMean = Math.sin(omega) ** 2 * (1 - (3 / 2.0) * Math.sin(i) ** 2);\n const mean = 0.5023 * sinsqIcos2nuMean + 0.0365;\n return (\n Math.pow(\n 0.2523 * Math.pow(Math.sin(I), 4) +\n 0.0367 * Math.pow(Math.sin(I), 2) * Math.cos(2 * nu) +\n 0.0013,\n 0.5,\n ) / mean\n );\n },\n\n // Schureman equations 206, 207, 195\n fM1(a: AstroData): number {\n const P = d2r * a.P.value;\n const I = d2r * a.I.value;\n const qAInv = Math.pow(\n 0.25 +\n 1.5 * Math.cos(I) * Math.cos(2 * P) * Math.pow(Math.cos(0.5 * I), -0.5) +\n 2.25 * Math.pow(Math.cos(I), 2) * Math.pow(Math.cos(0.5 * I), -4),\n 0.5,\n );\n return corrections.fO1(a) * qAInv;\n },\n\n // See e.g. Schureman equation 149\n fModd(a: AstroData, n: number): number {\n return Math.pow(corrections.fM2(a), n / 2.0);\n },\n\n // Node factors u, see Table 2 of Schureman.\n\n uZero(): number {\n return 0.0;\n },\n\n uMf(a: AstroData): number {\n return -2.0 * a.xi.value;\n },\n\n uO1(a: AstroData): number {\n return 2.0 * a.xi.value - a.nu.value;\n },\n\n uJ1(a: AstroData): number {\n return -a.nu.value;\n },\n\n uOO1(a: AstroData): number {\n return -2.0 * a.xi.value - a.nu.value;\n },\n\n uM2(a: AstroData): number {\n return 2.0 * a.xi.value - 2.0 * a.nu.value;\n },\n\n uK1(a: AstroData): number {\n return -a.nup.value;\n },\n\n // Schureman 214\n uL2(a: AstroData): number {\n const I = d2r * a.I.value;\n const P = d2r * a.P.value;\n const R =\n r2d *\n Math.atan(Math.sin(2 * P) / ((1 / 6.0) * Math.pow(Math.tan(0.5 * I), -2) - Math.cos(2 * P)));\n return 2.0 * a.xi.value - 2.0 * a.nu.value - R;\n },\n\n uK2(a: AstroData): number {\n return -2.0 * a.nupp.value;\n },\n\n // Schureman 202\n uM1(a: AstroData): number {\n const I = d2r * a.I.value;\n const P = d2r * a.P.value;\n const Q = r2d * Math.atan(((5 * Math.cos(I) - 1) / (7 * Math.cos(I) + 1)) * Math.tan(P));\n return a.xi.value - a.nu.value + Q;\n },\n\n uModd(a: AstroData, n: number): number {\n return (n / 2.0) * corrections.uM2(a);\n },\n};\n\nexport default corrections;\n","import nodeCorrections from \"../node-corrections/index.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\nimport type { NodeCorrectionFunction } from \"../node-corrections/index.js\";\n\n/**\n * Computes the dot notation of two arrays\n */\nconst dotArray = (a: number[], b: number[]): number => {\n const results: number[] = [];\n a.forEach((value, index) => {\n results.push(value * b[index]);\n });\n return results.reduce((total, value) => total + value);\n};\n\nconst astronimicDoodsonNumber = (astro: AstroData): AstroData[keyof AstroData][] => {\n return [astro[\"T+h-s\"], astro.s, astro.h, astro.p, astro.N, astro.pp, astro[\"90\"]];\n};\n\nconst astronomicSpeed = (astro: AstroData): number[] => {\n const results: number[] = [];\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.speed);\n });\n return results;\n};\n\nconst astronomicValues = (astro: AstroData): number[] => {\n const results: number[] = [];\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.value);\n });\n return results;\n};\n\nexport interface Constituent {\n name: string;\n coefficients: number[];\n value: (astro: AstroData) => number;\n speed: (astro: AstroData) => number;\n u: NodeCorrectionFunction;\n f: NodeCorrectionFunction;\n}\n\nconst constituentFactory = (\n name: string,\n coefficients: number[],\n u?: NodeCorrectionFunction,\n f?: NodeCorrectionFunction,\n): Constituent => {\n if (!coefficients) {\n throw new Error(\"Coefficient must be defined for a constituent\");\n }\n\n const constituent: Constituent = {\n name,\n coefficients,\n\n value: (astro: AstroData): number => {\n return dotArray(coefficients, astronomicValues(astro));\n },\n\n speed(astro: AstroData): number {\n return dotArray(coefficients, astronomicSpeed(astro));\n },\n\n u: typeof u !== \"undefined\" ? u : nodeCorrections.uZero,\n\n f: typeof f !== \"undefined\" ? f : nodeCorrections.fUnity,\n };\n\n return Object.freeze(constituent);\n};\n\nexport default constituentFactory;\nexport { astronimicDoodsonNumber, astronomicSpeed, astronomicValues };\n","import type { Constituent } from \"./constituent.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\n\nexport interface ConstituentMember {\n constituent: Constituent;\n factor: number;\n}\n\nexport interface CompoundConstituent {\n name: string;\n coefficients: number[];\n speed: (astro: AstroData) => number;\n value: (astro: AstroData) => number;\n u: (astro: AstroData) => number;\n f: (astro: AstroData) => number;\n}\n\nconst compoundConstituentFactory = (\n name: string,\n members: ConstituentMember[],\n): CompoundConstituent => {\n const coefficients: number[] = [];\n members.forEach(({ constituent, factor }) => {\n constituent.coefficients.forEach((coefficient, index) => {\n if (typeof coefficients[index] === \"undefined\") {\n coefficients[index] = 0;\n }\n coefficients[index] += coefficient * factor;\n });\n });\n\n const compoundConstituent: CompoundConstituent = {\n name,\n coefficients,\n\n speed: (astro: AstroData): number => {\n let speed = 0;\n members.forEach(({ constituent, factor }) => {\n speed += constituent.speed(astro) * factor;\n });\n return speed;\n },\n\n value: (astro: AstroData): number => {\n let value = 0;\n members.forEach(({ constituent, factor }) => {\n value += constituent.value(astro) * factor;\n });\n return value;\n },\n\n u: (astro: AstroData): number => {\n let u = 0;\n members.forEach(({ constituent, factor }) => {\n u += constituent.u(astro) * factor;\n });\n return u;\n },\n\n f: (astro: AstroData): number => {\n const f: number[] = [];\n members.forEach(({ constituent, factor }) => {\n f.push(Math.pow(constituent.f(astro), Math.abs(factor)));\n });\n return f.reduce((previous, value) => previous * value);\n },\n };\n\n return Object.freeze(compoundConstituent);\n};\n\nexport default compoundConstituentFactory;\n","import constituent from \"./constituent.js\";\nimport compoundConstituent from \"./compound-constituent.js\";\nimport nc from \"../node-corrections/index.js\";\nimport type { Constituent } from \"./constituent.js\";\nimport type { CompoundConstituent } from \"./compound-constituent.js\";\n\nexport interface Constituents {\n Z0: Constituent;\n SA: Constituent;\n SSA: Constituent;\n MM: Constituent;\n MF: Constituent;\n Q1: Constituent;\n O1: Constituent;\n K1: Constituent;\n J1: Constituent;\n M1: Constituent;\n P1: Constituent;\n S1: Constituent;\n OO1: Constituent;\n \"2N2\": Constituent;\n N2: Constituent;\n NU2: Constituent;\n M2: Constituent;\n LAM2: Constituent;\n L2: Constituent;\n T2: Constituent;\n S2: Constituent;\n R2: Constituent;\n K2: Constituent;\n M3: Constituent;\n MSF: CompoundConstituent;\n \"2Q1\": CompoundConstituent;\n RHO: CompoundConstituent;\n MU2: CompoundConstituent;\n \"2SM2\": CompoundConstituent;\n \"2MK3\": CompoundConstituent;\n MK3: CompoundConstituent;\n MN4: CompoundConstituent;\n M4: CompoundConstituent;\n MS4: CompoundConstituent;\n S4: CompoundConstituent;\n M6: CompoundConstituent;\n S6: CompoundConstituent;\n M8: CompoundConstituent;\n [key: string]: Constituent | CompoundConstituent;\n}\n\nconst constituents: Partial<Constituents> = {};\n\n// Long Term\nconstituents.Z0 = constituent(\"Z0\", [0, 0, 0, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.SA = constituent(\"Sa\", [0, 0, 1, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.SSA = constituent(\"Ssa\", [0, 0, 2, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.MM = constituent(\"MM\", [0, 1, 0, -1, 0, 0, 0], nc.uZero, nc.fMm);\nconstituents.MF = constituent(\"MF\", [0, 2, 0, 0, 0, 0, 0], nc.uMf, nc.fMf);\n// Diurnals\nconstituents.Q1 = constituent(\"Q1\", [1, -2, 0, 1, 0, 0, 1], nc.uO1, nc.fO1);\nconstituents.O1 = constituent(\"O1\", [1, -1, 0, 0, 0, 0, 1], nc.uO1, nc.fO1);\nconstituents.K1 = constituent(\"K1\", [1, 1, 0, 0, 0, 0, -1], nc.uK1, nc.fK1);\nconstituents.J1 = constituent(\"J1\", [1, 2, 0, -1, 0, 0, -1], nc.uJ1, nc.fJ1);\nconstituents.M1 = constituent(\"M1\", [1, 0, 0, 0, 0, 0, 1], nc.uM1, nc.fM1);\nconstituents.P1 = constituent(\"P1\", [1, 1, -2, 0, 0, 0, 1], nc.uZero, nc.fUnity);\nconstituents.S1 = constituent(\"S1\", [1, 1, -1, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.OO1 = constituent(\"OO1\", [1, 3, 0, 0, 0, 0, -1], nc.uOO1, nc.fOO1);\n// Semi diurnals\nconstituents[\"2N2\"] = constituent(\"2N2\", [2, -2, 0, 2, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.N2 = constituent(\"N2\", [2, -1, 0, 1, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.NU2 = constituent(\"NU2\", [2, -1, 2, -1, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.M2 = constituent(\"M2\", [2, 0, 0, 0, 0, 0, 0], nc.uM2, nc.fM2);\nconstituents.LAM2 = constituent(\"LAM2\", [2, 1, -2, 1, 0, 0, 2], nc.uM2, nc.fM2);\nconstituents.L2 = constituent(\"L2\", [2, 1, 0, -1, 0, 0, 2], nc.uL2, nc.fL2);\nconstituents.T2 = constituent(\"T2\", [2, 2, -3, 0, 0, 1, 0], nc.uZero, nc.fUnity);\nconstituents.S2 = constituent(\"S2\", [2, 2, -2, 0, 0, 0, 0], nc.uZero, nc.fUnity);\nconstituents.R2 = constituent(\"R2\", [2, 2, -1, 0, 0, -1, 2], nc.uZero, nc.fUnity);\nconstituents.K2 = constituent(\"K2\", [2, 2, 0, 0, 0, 0, 0], nc.uK2, nc.fK2);\n// Third diurnal\nconstituents.M3 = constituent(\n \"M3\",\n [3, 0, 0, 0, 0, 0, 0],\n (a) => {\n return nc.uModd(a, 3);\n },\n (a) => {\n return nc.fModd(a, 3);\n },\n);\n// Compound\nconstituents.MSF = compoundConstituent(\"MSF\", [\n { constituent: constituents.S2!, factor: 1 },\n { constituent: constituents.M2!, factor: -1 },\n]);\n\n// Diurnal\nconstituents[\"2Q1\"] = compoundConstituent(\"2Q1\", [\n { constituent: constituents.N2!, factor: 1 },\n { constituent: constituents.J1!, factor: -1 },\n]);\nconstituents.RHO = compoundConstituent(\"RHO\", [\n { constituent: constituents.NU2!, factor: 1 },\n { constituent: constituents.K1!, factor: -1 },\n]);\n\n// Semi-Diurnal\n\nconstituents.MU2 = compoundConstituent(\"MU2\", [\n { constituent: constituents.M2!, factor: 2 },\n { constituent: constituents.S2!, factor: -1 },\n]);\nconstituents[\"2SM2\"] = compoundConstituent(\"2SM2\", [\n { constituent: constituents.S2!, factor: 2 },\n { constituent: constituents.M2!, factor: -1 },\n]);\n\n// Third-Diurnal\nconstituents[\"2MK3\"] = compoundConstituent(\"2MK3\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.O1!, factor: 1 },\n]);\nconstituents.MK3 = compoundConstituent(\"MK3\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.K1!, factor: 1 },\n]);\n\n// Quarter-Diurnal\nconstituents.MN4 = compoundConstituent(\"MN4\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.N2!, factor: 1 },\n]);\nconstituents.M4 = compoundConstituent(\"M4\", [{ constituent: constituents.M2!, factor: 2 }]);\nconstituents.MS4 = compoundConstituent(\"MS4\", [\n { constituent: constituents.M2!, factor: 1 },\n { constituent: constituents.S2!, factor: 1 },\n]);\nconstituents.S4 = compoundConstituent(\"S4\", [{ constituent: constituents.S2!, factor: 2 }]);\n\n// Sixth-Diurnal\nconstituents.M6 = compoundConstituent(\"M6\", [{ constituent: constituents.M2!, factor: 3 }]);\nconstituents.S6 = compoundConstituent(\"S6\", [{ constituent: constituents.S2!, factor: 3 }]);\n\n// Eighth-Diurnals\nconstituents.M8 = compoundConstituent(\"M8\", [{ constituent: constituents.M2!, factor: 4 }]);\n\nexport default constituents as Constituents;\n","import prediction from \"./prediction.js\";\nimport constituentModels from \"../constituents/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { HarmonicConstituent, InternalHarmonicConstituent, Prediction } from \"./prediction.js\";\n\nexport type * from \"./prediction.js\";\n\nexport interface HarmonicsOptions {\n harmonicConstituents: HarmonicConstituent[];\n offset: number | false;\n}\n\nexport interface PredictionOptions {\n timeFidelity?: number;\n}\n\nexport interface Harmonics {\n setTimeSpan: (startTime: Date | number, endTime: Date | number) => Harmonics;\n prediction: (options?: PredictionOptions) => Prediction;\n}\n\nconst getDate = (time: Date | number): Date => {\n if (time instanceof Date) {\n return time;\n }\n if (typeof time === \"number\") {\n return new Date(time * 1000);\n }\n throw new Error(\"Invalid date format, should be a Date object, or timestamp\");\n};\n\nconst getTimeline = (start: Date, end: Date, seconds: number = 10 * 60) => {\n const items: Date[] = [];\n const endTime = end.getTime() / 1000;\n let lastTime = start.getTime() / 1000;\n const startTime = lastTime;\n const hours: number[] = [];\n while (lastTime <= endTime) {\n items.push(new Date(lastTime * 1000));\n hours.push((lastTime - startTime) / (60 * 60));\n lastTime += seconds;\n }\n\n return {\n items,\n hours,\n };\n};\n\nconst harmonicsFactory = ({ harmonicConstituents, offset }: HarmonicsOptions): Harmonics => {\n if (!Array.isArray(harmonicConstituents)) {\n throw new Error(\"Harmonic constituents are not an array\");\n }\n const constituents: InternalHarmonicConstituent[] = [];\n harmonicConstituents.forEach((constituent) => {\n if (typeof constituent.name === \"undefined\") {\n throw new Error(\"Harmonic constituents must have a name property\");\n }\n if (constituentModels[constituent.name] !== undefined) {\n constituents.push({\n ...constituent,\n _model: constituentModels[constituent.name],\n phase: d2r * constituent.phase,\n });\n }\n });\n\n if (offset !== false) {\n constituents.push({\n name: \"Z0\",\n _model: constituentModels.Z0,\n phase: 0,\n amplitude: offset,\n });\n }\n\n let start = new Date();\n let end = new Date();\n\n const harmonics: Harmonics = {} as Harmonics;\n\n harmonics.setTimeSpan = (startTime: Date | number, endTime: Date | number): Harmonics => {\n start = getDate(startTime);\n end = getDate(endTime);\n if (start.getTime() >= end.getTime()) {\n throw new Error(\"Start time must be before end time\");\n }\n return harmonics;\n };\n\n harmonics.prediction = (options?: PredictionOptions): Prediction => {\n const opts = typeof options !== \"undefined\" ? options : { timeFidelity: 10 * 60 };\n return prediction({\n timeline: getTimeline(start, end, opts.timeFidelity),\n constituents,\n start,\n });\n };\n\n return Object.freeze(harmonics);\n};\n\nexport default harmonicsFactory;\nexport { getDate, getTimeline };\n","import harmonics from \"./harmonics/index.js\";\nimport { default as constituents } from \"./constituents/index.js\";\nimport type { HarmonicConstituent } from \"./harmonics/index.js\";\nimport type { TimelinePoint, Extreme, ExtremeOffsets } from \"./harmonics/prediction.js\";\n\nexport interface TidePredictionOptions {\n offset?: number | false;\n}\n\nexport interface TimeSpan {\n start: Date;\n end: Date;\n timeFidelity?: number;\n}\n\nexport interface ExtremesInput extends TimeSpan {\n labels?: {\n high?: string;\n low?: string;\n };\n offsets?: ExtremeOffsets;\n}\n\nexport interface TidePrediction {\n getTimelinePrediction: (params: TimeSpan) => TimelinePoint[];\n getExtremesPrediction: (params: ExtremesInput) => Extreme[];\n getWaterLevelAtTime: (params: { time: Date }) => TimelinePoint;\n}\n\nconst tidePredictionFactory = (\n constituents: HarmonicConstituent[],\n options: TidePredictionOptions = {},\n): TidePrediction => {\n const harmonicsOptions = {\n harmonicConstituents: constituents,\n offset: false as number | false,\n ...options,\n };\n\n const tidePrediction: TidePrediction = {\n getTimelinePrediction: ({ start, end, timeFidelity }: TimeSpan): TimelinePoint[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction({ timeFidelity })\n .getTimelinePrediction();\n },\n\n getExtremesPrediction: ({\n start,\n end,\n labels,\n offsets,\n timeFidelity,\n }: ExtremesInput): Extreme[] => {\n return harmonics(harmonicsOptions)\n .setTimeSpan(start, end)\n .prediction({ timeFidelity })\n .getExtremesPrediction({ labels, offsets });\n },\n\n getWaterLevelAtTime: ({ time }: { time: Date }): TimelinePoint => {\n const endDate = new Date(time.getTime() + 10 * 60 * 1000);\n return harmonics(harmonicsOptions)\n .setTimeSpan(time, endDate)\n .prediction()\n .getTimelinePrediction()[0];\n },\n };\n\n return tidePrediction;\n};\n\n// Make constituents available on factory for reference\ntidePredictionFactory.constituents = constituents;\n\nexport default tidePredictionFactory;\nexport type { HarmonicConstituent, TimelinePoint, Extreme };\n"],"mappings":";AAAA,MAAa,MAAM,KAAK,KAAK;AAC7B,MAAa,MAAM,MAAQ,KAAK;;;;ACA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UAAU,YAAY,OAAO,MAFlB,OAAO,YAAY,cAAc,UAAU,EAAE,cAAc,KAAS,EAExC,aAAa;GACpD;GACA;GACD,CAAC;;AAGJ,QAAO,OAAO,OAAO,UAAU;;AAGjC,wBAAe;;;;ACzEf,MAAM,yBACJ,gBACA,UAAiC,EAAE,KAChB;CACnB,MAAM,mBAAmB;EACvB,sBAAsBC;EACtB,QAAQ;EACR,GAAG;EACJ;AAgCD,QA9BuC;EACrC,wBAAwB,EAAE,OAAO,KAAK,mBAA8C;AAClF,UAAOC,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,uBAAuB;;EAG5B,wBAAwB,EACtB,OACA,KACA,QACA,SACA,mBAC8B;AAC9B,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,sBAAsB;IAAE;IAAQ;IAAS,CAAC;;EAG/C,sBAAsB,EAAE,WAA0C;GAChE,MAAM,UAAU,IAAI,KAAK,KAAK,SAAS,GAAG,MAAU,IAAK;AACzD,UAAOA,kBAAU,iBAAiB,CAC/B,YAAY,MAAM,QAAQ,CAC1B,YAAY,CACZ,uBAAuB,CAAC;;EAE9B;;AAMH,sBAAsB,eAAeD;AAErC,kBAAe"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@neaps/tide-predictor",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Tide predictor",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/neaps/neaps",
7
+ "url": "git+https://github.com/neaps/neaps.git",
8
8
  "directory": "packages/tide-predictor"
9
9
  },
10
10
  "author": "Kevin Miller <keveemiller@gmail.com>",
11
11
  "license": "MIT",
12
12
  "type": "module",
13
- "main": "dist/index.umd.cjs",
13
+ "main": "dist/index.cjs",
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",