@neaps/tide-predictor 0.5.0 → 0.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["modulus","coefficients","nodeCorrections","nc","nc","M2","O1","nc","M2","K1","M2","O1","nc","M2","S2","nc","nc","nc","N2","J1","S2","M2","nc","L2","N2","nc","nc","nc","nc","nc","M2","M2","M2","nc","nc","nc","M2","K1","M2","K1","S2","nc","M2","N2","nc","M2","P1","M2","S2","S2","M2","M2","S2","K1","nc","M2","T2","M2","S2","N2","nc","nc","nc","nc","R2","NU2","K1","nc","S2","S2","S2","nc","nc","nc","T2","nc","astro","constituentModels","constituentModels","prediction","harmonics","constituents"],"sources":["../src/astronomy/constants.ts","../src/astronomy/coefficients.ts","../src/astronomy/index.ts","../src/node-corrections/index.ts","../src/constituents/definition.ts","../src/constituents/M2.ts","../src/constituents/O1.ts","../src/constituents/2MK3.ts","../src/constituents/K1.ts","../src/constituents/2MK5.ts","../src/constituents/2MO5.ts","../src/constituents/S2.ts","../src/constituents/2MS6.ts","../src/constituents/2N2.ts","../src/constituents/N2.ts","../src/constituents/J1.ts","../src/constituents/2Q1.ts","../src/constituents/2SM2.ts","../src/constituents/L2.ts","../src/constituents/3L2.ts","../src/constituents/3N2.ts","../src/constituents/EP2.ts","../src/constituents/K2.ts","../src/constituents/LAMBDA2.ts","../src/constituents/M1.ts","../src/constituents/M3.ts","../src/constituents/M4.ts","../src/constituents/M6.ts","../src/constituents/M8.ts","../src/constituents/MA2.ts","../src/constituents/MB2.ts","../src/constituents/MF.ts","../src/constituents/MK3.ts","../src/constituents/MKS2.ts","../src/constituents/MM.ts","../src/constituents/MN4.ts","../src/constituents/P1.ts","../src/constituents/MP1.ts","../src/constituents/MS4.ts","../src/constituents/MSF.ts","../src/constituents/MSQM.ts","../src/constituents/T2.ts","../src/constituents/MTM.ts","../src/constituents/MU2.ts","../src/constituents/N4.ts","../src/constituents/NU2.ts","../src/constituents/OO1.ts","../src/constituents/Q1.ts","../src/constituents/R2.ts","../src/constituents/R3.ts","../src/constituents/RHO1.ts","../src/constituents/S1.ts","../src/constituents/S3.ts","../src/constituents/S4.ts","../src/constituents/S6.ts","../src/constituents/SA.ts","../src/constituents/SGM.ts","../src/constituents/SSA.ts","../src/constituents/T3.ts","../src/constituents/Z0.ts","../src/constituents/index.ts","../src/harmonics/prediction.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 { d2r, r2d } from \"../astronomy/constants.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\n\nexport type NodeCorrectionFunction = (a: AstroData, ...args: unknown[]) => number;\n\nconst corrections = {\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 type { AstroData } from \"../astronomy/index.js\";\nimport nodeCorrections, { type NodeCorrectionFunction } from \"../node-corrections/index.js\";\n\nexport interface Constituent {\n names: string[];\n coefficients: number[];\n value: (astro: AstroData) => number;\n speed: (astro: AstroData) => number;\n u: NodeCorrectionFunction;\n f: NodeCorrectionFunction;\n}\n\nexport function defineConstituent(\n names: string | 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 return Object.freeze({\n names: Array.isArray(names) ? names : [names],\n\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\nexport interface ConstituentMember {\n constituent: Constituent;\n factor: number;\n}\n\nexport function defineCompoundConstituent(\n names: string | string[],\n members: ConstituentMember[],\n): Constituent {\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 return Object.freeze({\n names: Array.isArray(names) ? names : [names],\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\n/**\n * Computes the dot notation of two arrays\n */\nfunction 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\nexport function 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\nexport function astronomicSpeed(astro: AstroData): number[] {\n const results: number[] = [];\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.speed);\n });\n return results;\n}\n\nexport function astronomicValues(astro: AstroData): number[] {\n const results: number[] = [];\n astronimicDoodsonNumber(astro).forEach((number) => {\n results.push(number.value);\n });\n return results;\n}\n\n// Silence TS warning for empty module\nexport default {};\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar semi-diurnal (M2).\n * Primary principal lunar constituent; largest semi-diurnal tidal component globally.\n * Amplitude varies 10-20% over lunar node cycle; typically 0.2-0.5m in coastal areas.\n * Base constituent for many compound shallow-water constituents.\n */\nexport default defineConstituent(\"M2\", [2, 0, 0, 0, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar diurnal (O1).\n * Primary lunar diurnal constituent; one-per-lunar-day oscillation.\n * Amplitude varies 10-20% due to lunar node effects.\n */\nexport default defineConstituent(\"O1\", [1, -1, 0, 0, 0, 0, 1], nc.uO1, nc.fO1);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport O1 from \"./O1.js\";\n\n/**\n * Shallow-water terdiurnal (2MK3 = M2 + O1).\n * Lunar-lunar interaction from M2 semi-diurnal and O1 diurnal components.\n * Generated in shallow-water environments; typical amplitude <1 cm.\n */\nexport default defineCompoundConstituent(\"2MK3\", [\n { constituent: M2, factor: 1 },\n { constituent: O1, factor: 1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunisolar diurnal (K1).\n * Combined lunar and solar diurnal constituent; strongest diurnal tide in many regions.\n * Often comparable in amplitude to O1; amplitude ratio K1/O1 varies with latitude.\n */\nexport default defineConstituent(\"K1\", [1, 1, 0, 0, 0, 0, -1], nc.uK1, nc.fK1);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport K1 from \"./K1.js\";\n\n/**\n * Shallow-water fifth-diurnal from M2-K1 interaction.\n *\n * Note: Found in coastal tide predictions, especially in enclosed bays and harbors.\n * Amplitude typically 0.1-0.5 cm depending on location and water depth.\n * Shallow-water constituent only; not present in deep ocean.\n *\n * @see NOAA CO-OPS\n */\nexport default defineCompoundConstituent(\"2MK5\", [\n { constituent: M2, factor: 2 },\n { constituent: K1, factor: 1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport O1 from \"./O1.js\";\n\n/**\n * Shallow-water fifth-diurnal from M2-O1 interaction.\n *\n * Note: Primarily shallow-water coastal phenomenon, not present in deep ocean.\n * Amplitude typically <0.5 cm except in extreme shallow-water or enclosed basins.\n * Found in coastal tide predictions alongside other shallow-water constituents.\n *\n * @see NOAA CO-OPS\n */\nexport default defineCompoundConstituent(\"2MO5\", [\n { constituent: M2, factor: 2 },\n { constituent: O1, factor: 1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar semi-diurnal (S2).\n * Principal solar semi-diurnal constituent; largest solar tide component.\n * Amplitude typically 20-50% of M2; varies with geographic location and latitude.\n * Ratio M2/S2 determines tidal form factor (diurnal vs semi-diurnal regimes).\n * Base constituent for many compound shallow-water constituents.\n */\nexport default defineConstituent(\"S2\", [2, 2, -2, 0, 0, 0, 0], nc.uZero, nc.fUnity);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Sixth-diurnal shallow-water interaction: 2×M2 + S2.\n *\n * Generated only in shallow water; typical amplitude 0.01-0.2 meters depending on depth.\n * Included in IHO shallow-water constituent tables and NOAA analysis (order #37).\n */\nexport default defineCompoundConstituent(\"2MS6\", [\n { constituent: M2, factor: 2 },\n { constituent: S2, factor: 1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar semi-diurnal (2N2).\n * Second-order lunar semi-diurnal from Moon's orbital ellipticity.\n * Amplitude typically 5-10% of M2; significant in semi-diurnal analysis.\n */\nexport default defineConstituent(\"2N2\", [2, -2, 0, 2, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar elliptic semi-diurnal (N2).\n * Primary lunar elliptic semi-diurnal constituent from Moon's orbital variations.\n * Amplitude typically 5-15% of M2; third-largest semi-diurnal constituent.\n */\nexport default defineConstituent(\"N2\", [2, -1, 0, 1, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar diurnal (J1).\n * Shallow-water lunar diurnal constituent; generally much smaller than O1 and K1.\n * Typically important only in shallow-water systems and enclosed basins.\n * Amplitude usually <5% of O1; rarely significant in routine predictions.\n */\nexport default defineConstituent(\"J1\", [1, 2, 0, -1, 0, 0, -1], nc.uJ1, nc.fJ1);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport N2 from \"./N2.js\";\nimport J1 from \"./J1.js\";\n\n/**\n * Shallow-water diurnal (2Q1 = N2-J1).\n * Derived from interaction of semi-diurnal N2 and diurnal J1 constituents.\n * Amplitude typically very small; rarely significant.\n * Found only in shallow-water regions with strong tidal distortion.\n */\nexport default defineCompoundConstituent(\"2Q1\", [\n { constituent: N2, factor: 1 },\n { constituent: J1, factor: -1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport S2 from \"./S2.js\";\nimport M2 from \"./M2.js\";\n\n/**\n * Shallow-water semi-diurnal (2SM2).\n * Compound constituent: 2×S2 - M2\n * Solar-lunar interaction constituent generated in shallow-water environments.\n * Amplitude typically <2% of M2; complementary to MU2.\n */\nexport default defineCompoundConstituent(\"2SM2\", [\n { constituent: S2, factor: 2 },\n { constituent: M2, factor: -1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar elliptic semi-diurnal (L2).\n * Secondary lunar elliptic semi-diurnal from Moon's orbital variations and perigee effects.\n * Amplitude typically 1-3% of M2; often grouped with other lunar elliptic constituents.\n * Important in detailed harmonic analyses of semi-diurnal tides.\n */\nexport default defineConstituent(\"L2\", [2, 1, 0, -1, 0, 0, 2], nc.uL2, nc.fL2);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport L2 from \"./L2.js\";\n\n/**\n * Triple lunar elliptic; 3 times L2 interaction.\n *\n * Warning: Not in standard IHO constituent bank. Mainly historical/theoretical interest.\n * Very small amplitude (<0.1 cm); found only in extreme shallow water or enclosed basins.\n * Often ignored in routine tide predictions.\n *\n * @see Schureman, P. (1958). Manual of Harmonic Analysis and Prediction of Tides\n */\nexport default defineCompoundConstituent(\"3L2\", [{ constituent: L2, factor: 3 }]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport N2 from \"./N2.js\";\n\n/**\n * Triple N2 shallow-water harmonic (3 × N2).\n *\n * Note: Shallow-water constituent with definition based on compound frequency estimates.\n * Typical amplitude <0.5 cm; often <0.1 cm except in extreme shallow-water or enclosed basins.\n * Rarely significant in routine tide predictions.\n *\n * @see NOAA CO-OPS shallow-water constituents\n */\nexport default defineCompoundConstituent(\"3N2\", [{ constituent: N2, factor: 3 }]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar elliptic semi-diurnal constituent (ε2).\n */\nexport default defineConstituent(\"EP2\", [2, -3, 2, 1, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunisolar semi-diurnal (K2).\n * Combined lunar and solar semi-diurnal constituent from declination effects.\n * Amplitude typically 10-30% of S2; second-largest solar-related semi-diurnal component.\n * Important in semi-diurnal tidal analysis, especially at mid-latitudes.\n */\nexport default defineConstituent(\"K2\", [2, 2, 0, 0, 0, 0, 0], nc.uK2, nc.fK2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar semi-diurnal (λ2, lambda2).\n * Lunar semi-diurnal constituent from Moon's perigee effects.\n * Amplitude typically <5% of M2; important in detailed constituent analysis.\n * IHO standard designation (previously abbreviated as LAM2).\n */\nexport default defineConstituent([\"LAM2\", \"LAMBDA2\"], [2, 1, -2, 1, 0, 0, 2], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar diurnal elliptic (M1).\n * Secondary lunar diurnal constituent from Moon's elliptical orbit.\n * Typically very small amplitude; usually <1% of O1.\n * Rarely significant except in detailed harmonic analyses.\n */\nexport default defineConstituent(\"M1\", [1, 0, 0, 0, 0, 0, 1], nc.uM1, nc.fM1);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar terdiurnal (M3).\n * Third-diurnal lunar constituent from Moon's orbital motion.\n * Typically found in shallow water and resonant systems.\n * Amplitude usually <2% of M2; important in some shallow-water analyses.\n */\n// Third diurnal\nexport default defineConstituent(\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","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\n\n/**\n * Shallow-water quarter-diurnal (M4 = 2×M2).\n * First overtide of M2; generated in shallow-water environments.\n * Amplitude typically 2-10% of M2; largest of the quarter-diurnal constituents.\n * Important indicator of shallow-water tidal distortion.\n */\nexport default defineCompoundConstituent(\"M4\", [{ constituent: M2, factor: 2 }]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\n\n/**\n * Shallow-water sixth-diurnal (M6 = 3×M2).\n * Second overtide of M2; generated in shallow-water environments.\n * Amplitude typically 0.5-3% of M2; important in extreme shallow water.\n * Indicator of significant tidal distortion and non-linear effects.\n */\nexport default defineCompoundConstituent(\"M6\", [{ constituent: M2, factor: 3 }]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\n\n/**\n * Shallow-water eighth-diurnal (M8 = 4×M2).\n * Third overtide of M2; generated in extreme shallow-water environments.\n * Amplitude typically <0.5% of M2; very rarely significant.\n * Found only in highly distorted tidal regimes (extreme shallow water, enclosed basins).\n */\nexport default defineCompoundConstituent(\"M8\", [{ constituent: M2, factor: 4 }]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar variational semi-diurnal constituent (μ2, mu2).\n * Derived from Moon's orbital parameter variations.\n *\n * Note: Often included with M2 family in modern analysis. Minor constituent with\n * location-dependent amplitude.\n */\nexport default defineConstituent(\"MA2\", [2, 0, -1, 0, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar elliptic constituent from parameter variations.\n *\n * From https://iho.int/mtg_docs/com_wg/IHOTC/IHOTC_Misc/TWCWG_Constituent_list.pdf:\n *\n * > MB2 was originally called Ma2 but this became ambiguous when spoken, or typed on\n * > computers without lower case, and so it was initially changed to MA2*. However, this\n * > in turn was thought to be clumsy and hence MB2 was finally adopted. Although\n * > theoretically they should have the same values of u and f as M2, they are so small\n * > that they are commonly treated as having values of u = 0 and f = 1.\n *\n * @see Schureman, P. (1958). Manual of Harmonic Analysis and Prediction of Tides\n */\nexport default defineConstituent(\"MB2\", [2, 0, 1, 0, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar fortnightly (MF).\n * Long-period constituent from lunar inequality interactions.\n * Significant in long-term water level records and coastal resonances.\n */\nexport default defineConstituent(\"MF\", [0, 2, 0, 0, 0, 0, 0], nc.uMf, nc.fMf);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport K1 from \"./K1.js\";\n\n/**\n * Shallow-water terdiurnal (MK3).\n * Compound constituent: M2 + K1\n * Lunisolar interaction from M2 semi-diurnal and K1 diurnal components.\n * Generated in shallow-water environments; typical amplitude 0.5-2 cm.\n * Often paired with 2MK3 in terdiurnal tide analysis.\n */\nexport default defineCompoundConstituent(\"MK3\", [\n { constituent: M2, factor: 1 },\n { constituent: K1, factor: 1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport K1 from \"./K1.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Three-way shallow-water interaction of M2, K1, and S2.\n *\n * Warning: Not in standard IHO constituent bank. Shallow-water specific constituent\n * with definition varying by application and water depth. Use with caution and document\n * the specific convention used in your analysis.\n *\n * @see NOAA CO-OPS shallow-water constituents\n */\nexport default defineCompoundConstituent(\"MKS2\", [\n { constituent: M2, factor: 1 },\n { constituent: K1, factor: 1 },\n { constituent: S2, factor: -1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar monthly (MM).\n * Long-period constituent from lunar declination variations.\n * Important for long-term water level studies.\n */\nexport default defineConstituent(\"MM\", [0, 1, 0, -1, 0, 0, 0], nc.uZero, nc.fMm);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport N2 from \"./N2.js\";\n\n/**\n * Shallow-water quarter-diurnal (MN4).\n * Compound constituent: M2 + N2\n * Lunar-lunar elliptic interaction from M2 and N2 semi-diurnal components.\n * Generated in shallow-water environments; typical amplitude 1-5 cm.\n * Often significant in shallow seas and estuaries.\n */\nexport default defineCompoundConstituent(\"MN4\", [\n { constituent: M2, factor: 1 },\n { constituent: N2, factor: 1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar diurnal (P1).\n * Principal solar diurnal constituent; one-per-solar-day oscillation.\n * Amplitude typically 1/3 of K1; varies with latitude.\n * Forms key component of diurnal tidal analysis alongside K1 and O1.\n */\nexport default defineConstituent(\"P1\", [1, 1, -2, 0, 0, 0, 1], nc.uZero, nc.fUnity);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport P1 from \"./P1.js\";\n\n/**\n * Solar-lunar diurnal (MP1 = M2 - P1).\n * Combined solar and lunar diurnal constituent from solar-lunar interaction.\n * Amplitude typically small; usually <5% of K1.\n * Rarely significant except in specialized harmonic analyses.\n */\nexport default defineCompoundConstituent(\"MP1\", [\n { constituent: M2, factor: 1 },\n { constituent: P1, factor: -1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Shallow-water quarter-diurnal (MS4).\n * Compound constituent: M2 + S2\n * Lunar-solar interaction from M2 and S2 semi-diurnal components.\n * Generated in shallow-water environments; typical amplitude 1-5 cm.\n * Often second-largest quarter-diurnal component after M4.\n */\nexport default defineCompoundConstituent(\"MS4\", [\n { constituent: M2, factor: 1 },\n { constituent: S2, factor: 1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport S2 from \"./S2.js\";\nimport M2 from \"./M2.js\";\n\n/**\n * Lunisolar synodic fortnightly (MSF = S2-M2).\n * Long-period constituent representing beat frequency between solar S2 and lunar M2.\n * Manifests as fortnightly modulation of tidal range (spring-neap cycle).\n * Amplitude typically 5-15% of M2; represents the primary spring-neap variation.\n * Important for tidal range predictions and coastal flooding assessments.\n */\nexport default defineCompoundConstituent(\"MSF\", [\n { constituent: S2, factor: 1 },\n { constituent: M2, factor: -1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport S2 from \"./S2.js\";\nimport K1 from \"./K1.js\";\n\n/**\n * Lunar-solar interaction compound constituent.\n *\n * Warning: Non-standard constituent not in IHO or modern NOAA standard tables.\n * Definition varies significantly across sources. Rarely used in modern tide prediction.\n * Appears in Schureman's tables as variant shallow-water interaction.\n *\n * @see NOAA CO-OPS shallow-water constituents\n * @see Schureman shallow-water analysis tables\n */\nexport default defineCompoundConstituent(\"MSQM\", [\n { constituent: M2, factor: 1 },\n { constituent: S2, factor: 1 },\n { constituent: K1, factor: 1 },\n]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar elliptic semi-diurnal (T2).\n * Larger solar elliptic semi-diurnal constituent from solar declination effects.\n * Amplitude typically <5% of S2; increases at higher latitudes.\n * Forms part of solar semi-diurnal analysis alongside S2 and R2.\n */\nexport default defineConstituent(\"T2\", [2, 2, -3, 0, 0, 1, 0], nc.uZero, nc.fUnity);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport T2 from \"./T2.js\";\n\n/**\n * Lunar-solar shallow-water interaction (M2 modulated by lunar orbit).\n *\n * Warning: Not in modern IHO standard constituents; mostly historical interest.\n * Often replaced by specific ν2, λ2, or other lunar elliptic terms in modern analysis.\n * Amplitude is location and depth-dependent.\n *\n * @see NOAA CO-OPS shallow-water variants\n * @see Schureman Manual\n */\nexport default defineCompoundConstituent(\"MTM\", [\n { constituent: M2, factor: 1 },\n { constituent: T2, factor: 1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport M2 from \"./M2.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Shallow-water semi-diurnal (MU2 or μ2).\n * Compound constituent: 2×M2 - S2\n * Lunar variational constituent generated in shallow-water environments.\n * Amplitude typically <2% of M2; found in coastal shallow-water predictions.\n */\nexport default defineCompoundConstituent(\"MU2\", [\n { constituent: M2, factor: 2 },\n { constituent: S2, factor: -1 },\n]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport N2 from \"./N2.js\";\n\n/**\n * Second overtide of N2; shallow-water quarter-diurnal harmonic.\n * Amplitude ranges 0.25 to 2.25 times mean due to 18.613-year lunar node cycle.\n *\n * Note: Shallow-water constituent, typically found in tide predictions for coastal areas.\n */\nexport default defineCompoundConstituent(\"N4\", [{ constituent: N2, factor: 2 }]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar elliptic semi-diurnal (NU2).\n * Secondary lunar elliptic semi-diurnal from Moon's orbital variations.\n * Amplitude typically 2-5% of M2; smaller than N2.\n * Important in detailed semi-diurnal constituent analysis.\n */\nexport default defineConstituent(\"NU2\", [2, -1, 2, -1, 0, 0, 0], nc.uM2, nc.fM2);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar diurnal (OO1).\n * Second-order lunar diurnal constituent from Moon's orbital eccentricity.\n * Typically very small amplitude; <2% of O1 in most locations.\n * Important for detailed harmonic analysis in some regions.\n */\nexport default defineConstituent(\"OO1\", [1, 3, 0, 0, 0, 0, -1], nc.uOO1, nc.fOO1);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Elliptic lunar diurnal (Q1).\n * One solar day and one lunar day modulation interaction.\n * Amplitude typically 2-5% of O1; important in diurnal constituent analysis.\n */\nexport default defineConstituent(\"Q1\", [1, -2, 0, 1, 0, 0, 1], nc.uO1, nc.fO1);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar elliptic semi-diurnal (R2).\n * Smaller solar elliptic semi-diurnal constituent from solar declination effects.\n * Amplitude typically <2% of S2; smallest of the solar semi-diurnal group.\n * Rarely significant except in very detailed analyses.\n */\nexport default defineConstituent(\"R2\", [2, 2, -1, 0, 0, -1, 2], nc.uZero, nc.fUnity);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport R2 from \"./R2.js\";\n\n/**\n * Solar elliptic terdiurnal; 1.5 times R2 (smaller solar elliptic semi-diurnal).\n *\n * Note: Generated only in shallow water; very small amplitude (<0.05 cm typical).\n * Usually negligible except in extreme shallow-water environments.\n *\n * @see NOAA CO-OPS\n */\nexport default defineCompoundConstituent(\"R3\", [{ constituent: R2, factor: 1.5 }]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport NU2 from \"./NU2.js\";\nimport K1 from \"./K1.js\";\n\n/**\n * Shallow-water diurnal (RHO1, ρ1).\n * Compound constituent: NU2-K1 (ν2-K1)\n * Derived from interaction of semi-diurnal NU2 and diurnal K1 constituents.\n * Amplitude typically very small; rarely significant.\n * Found only in shallow-water regions with strong tidal distortion.\n */\nexport default defineCompoundConstituent(\n [\"RHO\", \"RHO1\"],\n [\n { constituent: NU2, factor: 1 },\n { constituent: K1, factor: -1 },\n ],\n);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar diurnal (S1).\n * Secondary solar diurnal constituent related to solar declination inequality.\n * Usually very small amplitude; typically dominated by K1 and P1 in diurnal analysis.\n * Rarely included in routine harmonic analyses.\n */\nexport default defineConstituent(\"S1\", [1, 1, -1, 0, 0, 0, 0], nc.uZero, nc.fUnity);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Solar terdiurnal overtide; shallow-water only.\n *\n * Note: Generated only in shallow water; not found in deep ocean.\n * Typical amplitude <1 cm except in extreme shallow-water environments.\n *\n * @see NOAA CO-OPS\n */\nexport default defineCompoundConstituent(\"S3\", [{ constituent: S2, factor: 1.5 }]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Shallow-water quarter-diurnal (S4).\n * Compound constituent: 2×S2\n * First overtide of S2; generated in shallow-water environments.\n * Amplitude typically 1-3% of S2; smallest of the common quarter-diurnal constituents.\n * Purely solar, so has fixed amplitude and phase at any location.\n */\nexport default defineCompoundConstituent(\"S4\", [{ constituent: S2, factor: 2 }]);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport S2 from \"./S2.js\";\n\n/**\n * Shallow-water sixth-diurnal (S6).\n * Compound constituent: 3×S2\n * Second overtide of S2; generated in shallow-water environments.\n * Amplitude typically 0.5-1% of S2; smallest of the common overtides.\n * Rarely significant except in extreme shallow water or resonant systems.\n */\nexport default defineCompoundConstituent(\"S6\", [{ constituent: S2, factor: 3 }]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar annual (Sa).\n * Long-term constituent driven by solar declination variations over the year.\n */\nexport default defineConstituent([\"SA\", \"Sa\"], [0, 0, 1, 0, 0, 0, 0], nc.uZero, nc.fUnity);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Lunar diurnal variational constituent (σ1, sigma1).\n * Derived from Moon's declination variations.\n *\n * Note: Often has small amplitude; closely related to K1 and O1 variations.\n */\nexport default defineConstituent([\"SGM\", \"SIGMA1\"], [1, -3, 2, 0, 0, 0, -1], nc.uO1, nc.fO1);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Solar semi-annual (Ssa).\n * Semi-annual constituent from solar declination with twice-yearly periodicity.\n */\nexport default defineConstituent([\"Ssa\", \"SSA\"], [0, 0, 2, 0, 0, 0, 0], nc.uZero, nc.fUnity);\n","import { defineCompoundConstituent } from \"./definition.js\";\nimport T2 from \"./T2.js\";\n\n/**\n * Solar elliptic terdiurnal; 1.5 times T2 (larger solar elliptic semi-diurnal).\n *\n * Note: Generated only in shallow water; minimal amplitude (<0.1 cm typical).\n * Rarely significant except in extreme shallow-water or enclosed basins.\n *\n * @see NOAA CO-OPS\n */\nexport default defineCompoundConstituent(\"T3\", [{ constituent: T2, factor: 1.5 }]);\n","import { defineConstituent } from \"./definition.js\";\nimport nc from \"../node-corrections/index.js\";\n\n/**\n * Mean sea level (Z0).\n * Not a tidal constituent in the strict sense, but represents the mean sea level offset\n * or the \"zero\" reference level used in tidal predictions.\n * No astronomical forcing; typically determined from harmonic analysis of observed data.\n */\nexport default defineConstituent(\"Z0\", [0, 0, 0, 0, 0, 0, 0], nc.uZero, nc.fUnity);\n","import { type Constituent } from \"./definition\";\n\n// Dynamically import all constituent files\nconst constituentModules = import.meta.glob<Constituent>(\"./*.ts\", {\n eager: true,\n import: \"default\",\n});\n\nconst constituents: Record<string, Constituent> = {};\n\n// Extract constituent name from file path and populate the constituents object\nfor (const [path, module] of Object.entries(constituentModules)) {\n // Skip the index and definition files\n if (path.match(/index|definition/)) continue;\n\n module.names.forEach((name) => {\n constituents[name] = module;\n });\n}\n\nexport default constituents;\n","import astro from \"../astronomy/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport constituentModels from \"../constituents/index.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 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: HarmonicConstituent[];\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 model = constituentModels[constituent.name];\n if (!model) return;\n\n const value = model.value(baseAstro);\n const speed = 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 model = constituentModels[constituent.name];\n if (!model) return;\n\n const constituentU = modulus(model.u(itemAstro), 360);\n uItem[constituent.name] = d2r * constituentU;\n fItem[constituent.name] = modulus(model.f(itemAstro), 360);\n });\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 prediction from \"./prediction.js\";\nimport constituentModels from \"../constituents/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { HarmonicConstituent, 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: HarmonicConstituent[] = [];\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 phase: d2r * constituent.phase,\n });\n }\n });\n\n if (offset !== false) {\n constituents.push({\n name: \"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,GAClB,UAAkB,GAClB,MAAc,GACd,OAAe,MACJ;AACX,QACE,UACA,UAAU,KACV,UAAW,OACX,OAAO,OAAc,OACrB,QAAQ,OAAc;;AAc1B,MAAM,eAA6B;CAEjC,sBAAsB;EACpB,qBAAqB,IAAI,IAAI,OAAO;EACpC,CAAC,qBAAqB,GAAG,GAAG,QAAQ;EACpC,CAAC,qBAAqB,GAAG,GAAG,KAAK;EACjC,qBAAqB,GAAG,GAAG,QAAQ;EACnC,CAAC,qBAAqB,GAAG,GAAG,MAAM;EAClC,CAAC,qBAAqB,GAAG,GAAG,OAAO;EACnC,CAAC,qBAAqB,GAAG,GAAG,MAAM;EAClC,qBAAqB,GAAG,GAAG,KAAK;EAChC,qBAAqB,GAAG,GAAG,MAAM;EACjC,qBAAqB,GAAG,GAAG,KAAK;EAChC,qBAAqB,GAAG,GAAG,KAAK;EACjC,CAAC,KAAK,QAAQ,UAAU;AACvB,SAAO,SAAS,KAAK,IAAI,KAAM,MAAM;GACrC;CAEF,cAAc;EA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AAE;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,eAAeC;AAErC,kBAAe"}
1
+ {"version":3,"file":"index.cjs","names":["fundamentals","fundamentals","iho","iho","iho","data","defaultConstituentModels","iho","prediction","harmonics","constituents"],"sources":["../src/astronomy/constants.ts","../src/astronomy/coefficients.ts","../src/astronomy/index.ts","../src/node-corrections/iho.ts","../src/node-corrections/schureman.ts","../src/node-corrections/index.ts","../src/harmonics/prediction.ts","../src/constituents/compound.ts","../src/constituents/definition.ts","../src/constituents/data.json","../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 { d2r, r2d } from \"../astronomy/constants.js\";\nimport type { Fundamentals } from \"./types.js\";\n\nconst fundamentals: Fundamentals = {\n Mm: (a) => corrMm(d2r * a.N.value, d2r * a.p.value),\n Mf: (a) => corrMf(d2r * a.N.value),\n O1: (a) => corrO1(d2r * a.N.value),\n K1: (a) => corrK1(d2r * a.N.value),\n J1: (a) => corrJ1(d2r * a.N.value),\n M1B: (a) => corrM1B(d2r * a.N.value, d2r * a.p.value),\n M1C: (a) => corrM1(d2r * a.N.value, d2r * a.p.value),\n M1: (a) => corrM1(d2r * a.N.value, d2r * a.p.value),\n M1A: (a) => corrM1A(d2r * a.N.value, d2r * a.p.value),\n M2: (a) => corrM2(d2r * a.N.value),\n K2: (a) => corrK2(d2r * a.N.value),\n M3: (a) => corrM3(d2r * a.N.value),\n L2: (a) => corrL2(d2r * a.N.value, d2r * a.p.value),\n gamma2: (a) => corrGamma2(d2r * a.N.value, d2r * a.p.value),\n alpha2: (a) => corrAlpha2(d2r * a.p.value, d2r * a.pp.value),\n delta2: (a) => corrDelta2(d2r * a.N.value),\n xi2: (a) => corrXiEta2(d2r * a.N.value),\n eta2: (a) => corrXiEta2(d2r * a.N.value),\n};\n\nexport default fundamentals;\n\n// ─── Fundamental constituent formulas (IHO TWCWG Annex A) ────────────────────\n\nfunction corrMm(N: number, p: number) {\n return {\n f: 1 - 0.1311 * Math.cos(N) + 0.0538 * Math.cos(2 * p) + 0.0205 * Math.cos(2 * p - N),\n u: 0,\n };\n}\n\nfunction corrMf(N: number) {\n return {\n f: 1.084 + 0.415 * Math.cos(N) + 0.039 * Math.cos(2 * N),\n u: -23.7 * Math.sin(N) + 2.7 * Math.sin(2 * N) - 0.4 * Math.sin(3 * N),\n };\n}\n\nfunction corrO1(N: number) {\n return {\n f: 1.0176 + 0.1871 * Math.cos(N) - 0.0147 * Math.cos(2 * N),\n u: 10.8 * Math.sin(N) - 1.34 * Math.sin(2 * N) + 0.19 * Math.sin(3 * N),\n };\n}\n\nfunction corrK1(N: number) {\n return {\n f: 1.006 + 0.115 * Math.cos(N) - 0.0088 * Math.cos(2 * N) + 0.0006 * Math.cos(3 * N),\n u: -8.86 * Math.sin(N) + 0.68 * Math.sin(2 * N) - 0.07 * Math.sin(3 * N),\n };\n}\n\nfunction corrJ1(N: number) {\n return {\n f: 1.1029 + 0.1676 * Math.cos(N) - 0.017 * Math.cos(2 * N) + 0.0016 * Math.cos(3 * N),\n u: -12.94 * Math.sin(N) + 1.34 * Math.sin(2 * N) - 0.19 * Math.sin(3 * N),\n };\n}\n\nfunction corrM2(N: number) {\n return {\n f: 1.0007 - 0.0373 * Math.cos(N) + 0.0002 * Math.cos(2 * N),\n u: -2.14 * Math.sin(N),\n };\n}\n\nfunction corrK2(N: number) {\n return {\n f: 1.0246 + 0.2863 * Math.cos(N) + 0.0083 * Math.cos(2 * N) - 0.0015 * Math.cos(3 * N),\n u: -17.74 * Math.sin(N) + 0.68 * Math.sin(2 * N) - 0.04 * Math.sin(3 * N),\n };\n}\n\nfunction corrM3(N: number) {\n const m2 = corrM2(N);\n return {\n f: Math.pow(Math.sqrt(m2.f), 3),\n u: -3.21 * Math.sin(N),\n };\n}\n\n// ─── Special constituents (f·sinU / f·cosU form) ─────────────────────────────\n\nfunction corrM1B(N: number, p: number) {\n const fsinU = 2.783 * Math.sin(2 * p) + 0.558 * Math.sin(2 * p - N) + 0.184 * Math.sin(N);\n const fcosU = 1 + 2.783 * Math.cos(2 * p) + 0.558 * Math.cos(2 * p - N) + 0.184 * Math.cos(N);\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrM1(N: number, p: number) {\n const fsinU = Math.sin(p) + 0.2 * Math.sin(p - N);\n const fcosU = 2 * (Math.cos(p) + 0.2 * Math.cos(p - N));\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrM1A(N: number, p: number) {\n const fsinU = -0.3593 * Math.sin(2 * p) - 0.2 * Math.sin(N) - 0.066 * Math.sin(2 * p - N);\n const fcosU = 1 + 0.3593 * Math.cos(2 * p) + 0.2 * Math.cos(N) + 0.066 * Math.cos(2 * p - N);\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrGamma2(N: number, p: number) {\n const fsinU = 0.147 * Math.sin(2 * (N - p));\n const fcosU = 1 + 0.147 * Math.cos(2 * (N - p));\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrAlpha2(p: number, pp: number) {\n const fsinU = -0.0446 * Math.sin(p - pp);\n const fcosU = 1 - 0.0446 * Math.cos(p - pp);\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrDelta2(N: number) {\n const fsinU = 0.477 * Math.sin(N);\n const fcosU = 1 - 0.477 * Math.cos(N);\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrXiEta2(N: number) {\n const fsinU = -0.439 * Math.sin(N);\n const fcosU = 1 + 0.439 * Math.cos(N);\n return fromSinCos(fsinU, fcosU);\n}\n\nfunction corrL2(N: number, p: number) {\n const fsinU =\n -0.2505 * Math.sin(2 * p) -\n 0.1102 * Math.sin(2 * p - N) -\n 0.0156 * Math.sin(2 * p - 2 * N) -\n 0.037 * Math.sin(N);\n const fcosU =\n 1 -\n 0.2505 * Math.cos(2 * p) -\n 0.1102 * Math.cos(2 * p - N) -\n 0.0156 * Math.cos(2 * p - 2 * N) -\n 0.037 * Math.cos(N);\n return fromSinCos(fsinU, fcosU);\n}\n\n/**\n * Compute f and u from f·sinU / f·cosU form.\n */\nfunction fromSinCos(fsinU: number, fcosU: number) {\n const f = Math.sqrt(fsinU * fsinU + fcosU * fcosU);\n const u = r2d * Math.atan2(fsinU, fcosU);\n return { f, u };\n}\n","import { d2r, r2d } from \"../astronomy/constants.js\";\nimport type { AstroData } from \"../astronomy/index.js\";\nimport type { Fundamentals } from \"./types.js\";\n\nconst fundamentals: Fundamentals = {\n Mm: (a) => ({ f: fMm(a), u: 0 }),\n Mf: (a) => ({ f: fMf(a), u: uMf(a) }),\n O1: (a) => ({ f: fO1(a), u: uO1(a) }),\n K1: (a) => ({ f: fK1(a), u: uK1(a) }),\n J1: (a) => ({ f: fJ1(a), u: uJ1(a) }),\n OO1: (a) => ({ f: fOO1(a), u: uOO1(a) }),\n M2: (a) => ({ f: fM2(a), u: uM2(a) }),\n K2: (a) => ({ f: fK2(a), u: uK2(a) }),\n L2: (a) => ({ f: fL2(a), u: uL2(a) }),\n M1: (a) => ({ f: fM1(a), u: uM1(a) }),\n M3: (a) => ({ f: fModd(a, 3), u: uModd(a, 3) }),\n};\n\nexport default fundamentals;\n\n// ─── Schureman f (amplitude) functions ────────────────────────────────────────\n\n// Schureman equations 73, 65\nfunction 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\nfunction 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\nfunction 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\nfunction 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\nfunction 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\nfunction 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\nfunction 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\nfunction 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 - 12 * Math.pow(Math.tan(0.5 * I), 2) * Math.cos(2 * P) + 36 * Math.pow(Math.tan(0.5 * I), 4),\n 0.5,\n );\n return fM2(a) * rAInv;\n}\n\n// Schureman equations 235, 234, 71\nfunction 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\nfunction 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 fO1(a) * qAInv;\n}\n\n// Schureman equation 149\nfunction fModd(a: AstroData, n: number): number {\n return Math.pow(fM2(a), n / 2.0);\n}\n\n// ─── Schureman u (phase) functions ────────────────────────────────────────────\n\nfunction uMf(a: AstroData): number {\n return -2.0 * a.xi.value;\n}\n\nfunction uO1(a: AstroData): number {\n return 2.0 * a.xi.value - a.nu.value;\n}\n\nfunction uJ1(a: AstroData): number {\n return -a.nu.value;\n}\n\nfunction uOO1(a: AstroData): number {\n return -2.0 * a.xi.value - a.nu.value;\n}\n\nfunction uM2(a: AstroData): number {\n return 2.0 * a.xi.value - 2.0 * a.nu.value;\n}\n\nfunction uK1(a: AstroData): number {\n return -a.nup.value;\n}\n\n// Schureman 214\nfunction 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\nfunction uK2(a: AstroData): number {\n return -2.0 * a.nupp.value;\n}\n\n// Schureman 202\nfunction 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\nfunction uModd(a: AstroData, n: number): number {\n return (n / 2.0) * uM2(a);\n}\n","import iho from \"./iho.js\";\nimport schureman from \"./schureman.js\";\nimport type { Fundamentals } from \"./types.js\";\n\nexport type * from \"./types.js\";\n\nexport { iho, schureman };\n\nexport const fundamentals: Record<string, Fundamentals> = {\n iho,\n schureman,\n};\n\nexport function resolveFundamentals(name?: string): Fundamentals {\n if (!name) return iho;\n const fundamental = fundamentals[name];\n if (!fundamental) throw new Error(`Unknown fundamentals: ${name}`);\n return fundamental;\n}\n","import astro from \"../astronomy/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { Constituent } from \"../constituents/types.js\";\nimport { iho, type Fundamentals } from \"../node-corrections/index.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 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 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: HarmonicConstituent[];\n constituentModels: Record<string, Constituent>;\n fundamentals?: Fundamentals;\n start: Date;\n}\n\nconst predictionFactory = ({\n timeline,\n constituents,\n constituentModels,\n start,\n fundamentals = iho,\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 model = constituentModels[constituent.name];\n if (!model) return;\n\n const value = model.value(baseAstro);\n const speed = model.speed;\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 model = constituentModels[constituent.name];\n if (!model) return;\n\n const correction = model.correction(itemAstro, fundamentals);\n uItem[constituent.name] = d2r * correction.u;\n fItem[constituent.name] = correction.f;\n });\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 type { Constituent, ConstituentMember } from \"./types.js\";\n\n/**\n * Compound constituent decomposition per IHO TWCWG Annex B.\n *\n * Parses compound constituent names (e.g. \"MS4\", \"2MK3\", \"2(MN)S6\") to\n * determine which fundamental constituents they are composed of. Each\n * component is resolved to a ConstituentMember with a signed factor.\n */\n\ninterface LetterInfo {\n species: number;\n}\n\ninterface ParsedToken {\n letter: string;\n multiplier: number;\n}\n\n/** Intermediate result before resolving to ConstituentMember. */\ninterface ResolvedComponent {\n /** Constituent name derived from letter + species (e.g. \"N2\", \"S2\", \"K1\") */\n constituentKey: string;\n factor: number;\n}\n\n// ─── Letter-to-species mapping ───────────────────────────────────────────────\n\n/**\n * Maps constituent letters to their species. K is omitted because it's\n * ambiguous (K1 or K2) and resolved during sign resolution.\n */\nconst LETTER_MAP: Record<string, LetterInfo> = {\n M: { species: 2 },\n S: { species: 2 },\n N: { species: 2 },\n O: { species: 1 },\n P: { species: 1 },\n Q: { species: 1 },\n J: { species: 1 },\n T: { species: 2 },\n R: { species: 2 },\n L: { species: 2 },\n nu: { species: 2 },\n lambda: { species: 2 },\n};\n\nconst K1_INFO: LetterInfo = { species: 1 };\nconst K2_INFO: LetterInfo = { species: 2 };\n\n// ─── Name parser ─────────────────────────────────────────────────────────────\n\n/**\n * Parse a compound constituent name into component tokens and target species.\n *\n * Format: `[multiplier]Letter[multiplier]Letter...species`\n *\n * Throws for names that cannot be decomposed — any constituent with nodal\n * correction code \"x\" must have a parseable compound name.\n *\n * IHO Annex B exception: MA and MB constituents are annual variants that\n * follow the same decomposition as their base M constituent.\n */\nexport function parseName(name: string): { tokens: ParsedToken[]; targetSpecies: number } {\n const fail = (reason: string): Error =>\n new Error(`Unable to parse compound constituent \"${name}\": ${reason}`);\n\n // IHO Annex B exception: Normalize MA/MB annual variants to M\n let normalizedName = name;\n if ((name.startsWith(\"MA\") || name.startsWith(\"MB\")) && name.length > 2) {\n normalizedName = \"M\" + name.substring(2);\n }\n\n // Extract trailing species number\n const m = normalizedName.match(/^(.+?)(\\d+)$/);\n if (!m) throw fail(\"no trailing species digits\");\n\n const body = m[1];\n const targetSpecies = parseInt(m[2], 10);\n if (targetSpecies === 0) throw fail(\"species is 0\");\n\n const tokens: ParsedToken[] = [];\n let i = 0;\n\n while (i < body.length) {\n // Read optional multiplier\n let multiplier = 0;\n while (i < body.length && body[i] >= \"0\" && body[i] <= \"9\") {\n multiplier = multiplier * 10 + (body.charCodeAt(i) - 48);\n i++;\n }\n if (multiplier === 0) multiplier = 1;\n\n if (i >= body.length) throw fail(\"trailing digits with no letter\");\n\n // Parenthesized group: multiplier distributes to all letters inside\n if (body[i] === \"(\") {\n i++; // skip (\n const groupLetters: string[] = [];\n while (i < body.length && body[i] !== \")\") {\n const letter = readLetter(body, i);\n if (!letter) throw fail(`unrecognized character at position ${i}`);\n groupLetters.push(letter);\n i += letter.length;\n }\n if (i >= body.length || body[i] !== \")\") throw fail(\"unclosed parenthesized group\");\n i++; // skip )\n if (groupLetters.length === 0) throw fail(\"empty parenthesized group\");\n\n for (const letter of groupLetters) {\n if (!isKnownLetter(letter)) throw fail(`unknown letter \"${letter}\"`);\n tokens.push({ letter, multiplier });\n }\n continue;\n }\n\n // Read a letter\n const letter = readLetter(body, i);\n if (!letter) throw fail(`unrecognized character at position ${i}`);\n if (!isKnownLetter(letter)) throw fail(`unknown letter \"${letter}\"`);\n i += letter.length;\n tokens.push({ letter, multiplier });\n }\n\n return { tokens, targetSpecies };\n}\n\n/** Read a single letter or multi-char token (nu, lambda) at position i. */\nfunction readLetter(body: string, i: number): string | null {\n // Multi-char tokens (must check before single uppercase)\n if (body.startsWith(\"nu\", i) && (i + 2 >= body.length || !isLower(body[i + 2]))) {\n return \"nu\";\n }\n if (body.startsWith(\"lambda\", i)) {\n return \"lambda\";\n }\n\n const ch = body[i];\n // Uppercase letter\n if (ch >= \"A\" && ch <= \"Z\") return ch;\n\n // Unrecognized (lowercase suffix, etc.)\n return null;\n}\n\nfunction isLower(ch: string): boolean {\n return ch >= \"a\" && ch <= \"z\";\n}\n\nfunction isKnownLetter(letter: string): boolean {\n // A and B are not compound letters per Annex B exceptions\n if (letter === \"A\" || letter === \"B\") return false;\n return letter === \"K\" || letter in LETTER_MAP;\n}\n\n// ─── Sign resolution ─────────────────────────────────────────────────────────\n\n/**\n * Resolve component signs using the IHO Annex B progressive right-to-left\n * sign-flipping algorithm.\n *\n * For K (ambiguous between K1 and K2), tries K2 first then K1.\n */\nexport function resolveSigns(\n tokens: ParsedToken[],\n targetSpecies: number,\n): ResolvedComponent[] | null {\n const hasK = tokens.some((t) => t.letter === \"K\");\n\n if (hasK) {\n // Try K2 first (more common in even-species compounds)\n const result = tryResolve(tokens, targetSpecies, K2_INFO);\n if (result) return result;\n // Fall back to K1\n return tryResolve(tokens, targetSpecies, K1_INFO);\n }\n\n return tryResolve(tokens, targetSpecies, K2_INFO);\n}\n\nfunction tryResolve(\n tokens: ParsedToken[],\n targetSpecies: number,\n kInfo: LetterInfo,\n): ResolvedComponent[] | null {\n const infos = tokens.map((t) => (t.letter === \"K\" ? kInfo : LETTER_MAP[t.letter]));\n\n /** Derive constituent key: letter + species (e.g. \"M2\", \"S2\", \"K1\") */\n const keyOf = (j: number) => tokens[j].letter + infos[j].species;\n\n // Single-letter overtide: e.g. M4 = M2 × M2\n if (tokens.length === 1) {\n const info = infos[0];\n const letterSpecies = info.species;\n if (letterSpecies > 0 && targetSpecies > letterSpecies) {\n return [\n {\n constituentKey: keyOf(0),\n factor: targetSpecies / letterSpecies,\n },\n ];\n }\n // Single letter, species matches directly (shouldn't normally be \"x\" code)\n if (letterSpecies === targetSpecies) {\n return [\n {\n constituentKey: keyOf(0),\n factor: 1,\n },\n ];\n }\n }\n\n // Progressive right-to-left sign flip (IHO Annex B)\n const signs: (1 | -1)[] = new Array(tokens.length).fill(1);\n let total = 0;\n for (let j = 0; j < tokens.length; j++) {\n total += tokens[j].multiplier * infos[j].species;\n }\n\n for (let j = tokens.length - 1; j >= 0; j--) {\n if (total === targetSpecies) break;\n signs[j] = -1;\n total -= 2 * tokens[j].multiplier * infos[j].species;\n }\n\n if (total !== targetSpecies) return null;\n\n return tokens.map((t, j) => ({\n constituentKey: keyOf(j),\n factor: signs[j] * t.multiplier,\n }));\n}\n\n// ─── Decomposition ───────────────────────────────────────────────────────────\n\n/**\n * Decompose a compound constituent name into its structural members.\n * Each letter is mapped to its own constituent (e.g. N→N2, S→S2) with\n * signed factors from the IHO Annex B sign-resolution algorithm.\n *\n * Returns null if the name cannot be parsed or sign resolution fails.\n * Long-period constituents with non-standard naming conventions (e.g.\n * \"MSm\", \"KOo\") use explicit members in data.json instead.\n *\n * @param name - Constituent name (e.g. \"MS4\", \"2MK3\", \"2(MN)S6\")\n * @param species - Species from coefficients[0], or 0 if XDO is null\n * @param constituents - Map of all constituents for resolving keys\n */\nexport function decomposeCompound(\n name: string,\n species: number,\n constituents: Record<string, Constituent>,\n): ConstituentMember[] | null {\n let parsed: ReturnType<typeof parseName>;\n try {\n parsed = parseName(name);\n } catch {\n return null;\n }\n\n // If species was provided and doesn't match trailing digits, prefer\n // the one from coefficients (it's authoritative when XDO is present).\n // parsed.targetSpecies is always > 0 (parseName rejects species=0).\n const targetSpecies = species > 0 ? species : parsed.targetSpecies;\n\n const resolved = resolveSigns(parsed.tokens, targetSpecies);\n if (!resolved) return null;\n\n const members: ConstituentMember[] = [];\n for (const { constituentKey, factor } of resolved) {\n const constituent = constituents[constituentKey];\n if (!constituent) return null;\n members.push({ constituent, factor });\n }\n\n return members.length > 0 ? members : null;\n}\n","import type { AstroData } from \"../astronomy/index.js\";\nimport { iho, type Fundamentals, type NodalCorrection } from \"../node-corrections/index.js\";\nimport { decomposeCompound } from \"./compound.js\";\nimport {\n Constituent,\n DefineConstituentOptions,\n ConstituentMember,\n NodalCorrectionCode,\n Coefficients,\n XDO,\n} from \"./types.js\";\n\nexport const constituents: Record<string, Constituent> = {};\n\n/**\n * Create a constituent\n *\n * For null-XDO compounds, V₀ is derived lazily from members once they\n * are resolved (V₀ = Σ factor × V₀(member)).\n */\nexport function defineConstituent({\n name,\n speed,\n xdo,\n aliases = [],\n members: memberRefs,\n nodalCorrection,\n}: DefineConstituentOptions): Constituent {\n const coefficients = xdo ? xdoToCoefficients(xdo) : null;\n let resolvedMembers: ConstituentMember[] | null = null;\n\n const constituent: Constituent = {\n name,\n speed,\n aliases,\n coefficients,\n\n get members() {\n if (!resolvedMembers) {\n if (memberRefs) {\n // Explicit members take precedence over nodal correction codes\n resolvedMembers = memberRefs.map(([name, factor]) => {\n const constituent = constituents[name];\n return { constituent, factor };\n });\n } else {\n resolvedMembers = resolveMembers(nodalCorrection, name, xdo?.[0] ?? 0) ?? [];\n }\n }\n\n return resolvedMembers;\n },\n\n value(astro: AstroData): number {\n if (coefficients) return computeV0(coefficients, astro);\n\n // Null-XDO compound: derive V₀ from structural members\n let v = 0;\n for (const { constituent: c, factor } of constituent.members) {\n v += c.value(astro) * factor;\n }\n return v;\n },\n\n correction(astro: AstroData, fundamentals: Fundamentals = iho): NodalCorrection {\n // Fundamentals have their own correction formula\n const fundamental = fundamentals[name];\n if (fundamental) return fundamental(astro);\n\n // Start with UNITY\n let f = 1;\n let u = 0;\n\n // Compound: recurse through members\n // u = Σ factor × u(member), f = Π f(member)^|factor|\n for (const { constituent: member, factor } of constituent.members) {\n const corr = member.correction(astro, fundamentals);\n u += factor * corr.u;\n f *= Math.pow(corr.f, Math.abs(factor));\n }\n\n return { u, f };\n },\n };\n\n [constituent.name, ...aliases].forEach((alias) => {\n constituents[alias] = constituent;\n });\n\n return constituent;\n}\n\n/**\n * Convert XDO digit array to Doodson coefficients.\n * D₁ is the τ coefficient (NOT offset). D₂–D₆ are each offset by 5.\n * D₇ (90° phase) is negated to convert from IHO XDO convention to the\n * Schureman/NOAA convention used by published harmonic constants.\n */\nexport function xdoToCoefficients(xdo: XDO): Coefficients {\n return [\n xdo[0], // D₁: τ coefficient (NOT offset by 5)\n xdo[1] - 5, // D₂: s\n xdo[2] - 5, // D₃: h\n xdo[3] - 5, // D₄: p\n xdo[4] - 5, // D₅: N' (used directly, NOT negated)\n xdo[5] - 5, // D₆: p' (solar perigee)\n 5 - xdo[6], // D₇: 90° phase (negated: IHO → Schureman convention)\n ];\n}\n\n/**\n * Compute V₀ using Doodson coefficients and standard astronomical arguments.\n * Uses N' = −N from the existing astronomy module's N value.\n */\nexport function computeV0(coefficients: Coefficients, astro: AstroData): number {\n const values = [\n astro[\"T+h-s\"].value, // τ\n astro.s.value, // s\n astro.h.value, // h\n astro.p.value, // p\n -astro.N.value, // N' = −N\n astro.pp.value, // p'\n 90.0, // constant phase\n ];\n let sum = 0;\n for (let i = 0; i < 7; i++) {\n sum += coefficients[i] * values[i];\n }\n return sum;\n}\n\n/**\n * Resolve the IHO nodal correction code into pre-computed ConstituentMember[].\n * This maps every code to the constituent members needed to compute\n * f and u at prediction time, eliminating the code dispatch at runtime.\n *\n * Members reference structural constituents (e.g. N→N2 not M2). Each\n * constituent's correction method recursively resolves each member's\n * correction through its own members chain (N2.members → [{M2,1}] → M2 fundamental).\n */\nfunction resolveMembers(\n code: NodalCorrectionCode,\n name: string,\n species: number,\n): ConstituentMember[] | null {\n switch (code) {\n // UNITY — no nodal correction\n case \"z\":\n case \"f\":\n return null;\n\n // Fundamentals — correction looked up by name in the fundamentals,\n // so no members needed for indirection.\n case \"y\":\n return null;\n\n // Direct constituent references\n case \"a\":\n return [{ constituent: constituents[\"Mm\"], factor: 1 }];\n case \"m\":\n return [{ constituent: constituents[\"M2\"], factor: 1 }];\n case \"o\":\n return [{ constituent: constituents[\"O1\"], factor: 1 }];\n case \"k\":\n return [{ constituent: constituents[\"K1\"], factor: 1 }];\n case \"j\":\n return [{ constituent: constituents[\"J1\"], factor: 1 }];\n\n // M2-derived\n case \"b\":\n return [{ constituent: constituents[\"M2\"], factor: -1 }];\n case \"c\":\n return [{ constituent: constituents[\"M2\"], factor: -2 }];\n case \"g\":\n return [{ constituent: constituents[\"M2\"], factor: species / 2 }];\n\n // Compound decomposition — returns structural members\n case \"p\":\n return decomposeCompound(\"2MN2\", species, constituents);\n case \"d\":\n return decomposeCompound(\"KQ1\", species, constituents);\n case \"q\":\n return decomposeCompound(\"NKM2\", species, constituents);\n case \"x\":\n return decomposeCompound(name, species, constituents);\n }\n}\n","","import { constituents, defineConstituent } from \"./definition.js\";\nimport { DefineConstituentOptions } from \"./types.js\";\nimport data from \"./data.json\" with { type: \"json\" };\n\nexport type * from \"./types.js\";\n\n// Define constituents from data file\nfor (const entry of data) {\n defineConstituent(entry as DefineConstituentOptions);\n}\n\nexport default constituents;\n","import prediction from \"./prediction.js\";\nimport defaultConstituentModels from \"../constituents/index.js\";\nimport type { Constituent } from \"../constituents/types.js\";\nimport { iho, Fundamentals } from \"../node-corrections/index.js\";\nimport { d2r } from \"../astronomy/constants.js\";\nimport type { HarmonicConstituent, Prediction } from \"./prediction.js\";\n\nexport type * from \"./prediction.js\";\n\nexport interface HarmonicsOptions {\n harmonicConstituents: HarmonicConstituent[];\n constituentModels?: Record<string, Constituent>;\n offset: number | false;\n fundamentals?: Fundamentals;\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 constituentModels = defaultConstituentModels,\n offset,\n fundamentals = iho,\n}: HarmonicsOptions): Harmonics => {\n if (!Array.isArray(harmonicConstituents)) {\n throw new Error(\"Harmonic constituents are not an array\");\n }\n const constituents: HarmonicConstituent[] = [];\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 phase: d2r * constituent.phase,\n });\n }\n });\n\n if (offset !== false) {\n constituents.push({\n name: \"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 constituentModels,\n start,\n fundamentals,\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 { resolveFundamentals } from \"./node-corrections/index.js\";\nimport type { HarmonicConstituent } from \"./harmonics/index.js\";\nimport type { TimelinePoint, Extreme, ExtremeOffsets } from \"./harmonics/prediction.js\";\n\nexport { default as astro } from \"./astronomy/index.js\";\nexport { default as constituents } from \"./constituents/index.js\";\nexport type * from \"./astronomy/index.js\";\nexport type * from \"./constituents/index.js\";\nexport type * from \"./harmonics/index.js\";\nexport type * from \"./node-corrections/index.js\";\n\nexport interface TidePredictionOptions {\n offset?: number | false;\n nodeCorrections?: \"iho\" | \"schureman\";\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\nexport function createTidePredictor(\n constituents: HarmonicConstituent[],\n options: TidePredictionOptions = {},\n): TidePrediction {\n const { nodeCorrections, ...harmonicsOpts } = options;\n const harmonicsOptions = {\n harmonicConstituents: constituents,\n fundamentals: resolveFundamentals(nodeCorrections),\n offset: false as number | false,\n ...harmonicsOpts,\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\n/** @deprecated Use `import { constituents } from \"@neaps/tide-predictor\"; */\ncreateTidePredictor.constituents = constituents;\n\n/** @deprecated Use `import { createTidePredictor } from \"@neaps/tide-predictor\";` */\nexport default createTidePredictor;\n"],"mappings":";;;AAAA,MAAa,MAAM,KAAK,KAAK;AAC7B,MAAa,MAAM,MAAQ,KAAK;;;;ACAhC,MAAM,wBACJ,SACA,UAAkB,GAClB,UAAkB,GAClB,MAAc,GACd,OAAe,MACJ;AACX,QACE,UACA,UAAU,KACV,UAAW,OACX,OAAO,OAAc,OACrB,QAAQ,OAAc;;AAc1B,MAAM,eAA6B;CAEjC,sBAAsB;EACpB,qBAAqB,IAAI,IAAI,OAAO;EACpC,CAAC,qBAAqB,GAAG,GAAG,QAAQ;EACpC,CAAC,qBAAqB,GAAG,GAAG,KAAK;EACjC,qBAAqB,GAAG,GAAG,QAAQ;EACnC,CAAC,qBAAqB,GAAG,GAAG,MAAM;EAClC,CAAC,qBAAqB,GAAG,GAAG,OAAO;EACnC,CAAC,qBAAqB,GAAG,GAAG,MAAM;EAClC,qBAAqB,GAAG,GAAG,KAAK;EAChC,qBAAqB,GAAG,GAAG,MAAM;EACjC,qBAAqB,GAAG,GAAG,KAAK;EAChC,qBAAqB,GAAG,GAAG,KAAK;EACjC,CAAC,KAAK,QAAQ,UAAU;AACvB,SAAO,SAAS,KAAK,IAAI,KAAM,MAAM;GACrC;CAEF,cAAc;EAAC;EAAsB;EAA0B;EAAuB;EAAW;CAEjG,gBAAgB;EAAC;EAAW;EAAa;EAAU;CAEnD,kBAAkB,CAAC,MAAM;CAEzB,gBAAgB;EAAC;EAAa;EAAiB;EAAY,IAAI,SAAW,IAAI;EAAW;CAEzF,WAAW;EAAC;EAAY;EAAe;EAAW,IAAI;EAAU,KAAK;EAAW;CAEhF,cAAc;EAAC;EAAW;EAAc;EAAY,KAAK;EAAS,IAAI;EAAW;CAClF;;;;AC7BD,MAAM,cAAc,cAAwB,aAA6B;CACvE,MAAM,SAAmB,EAAE;AA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ACtB,cAAc,oBAAoB,gBAAgB;EAClD,QAAQ;EACR,GAAG;EACJ;AAgCD,QA9BuC;EACrC,wBAAwB,EAAE,OAAO,KAAK,mBAA8C;AAClF,UAAOC,iBAAU,iBAAiB,CAC/B,YAAY,OAAO,IAAI,CACvB,WAAW,EAAE,cAAc,CAAC,CAC5B,uBAAuB;;EAG5B,wBAAwB,EACtB,OACA,KACA,QACA,SACA,mBAC8B;AAC9B,UAAOA,iBAAU,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,iBAAU,iBAAiB,CAC/B,YAAY,MAAM,QAAQ,CAC1B,YAAY,CACZ,uBAAuB,CAAC;;EAE9B;;;AAOH,oBAAoB,eAAeC"}
package/dist/index.d.cts CHANGED
@@ -20,21 +20,70 @@ interface AstroData {
20
20
  "T+h-s": AstroValue;
21
21
  P: AstroValue;
22
22
  }
23
+ declare const polynomial: (coefficients: number[], argument: number) => number;
24
+ declare const derivativePolynomial: (coefficients: number[], argument: number) => number;
25
+ declare const T: (t: Date) => number;
26
+ declare const JD: (t: Date) => number;
27
+ declare const _I: (N: number, i: number, omega: number) => number;
28
+ declare const _xi: (N: number, i: number, omega: number) => number;
29
+ declare const _nu: (N: number, i: number, omega: number) => number;
30
+ declare const _nup: (N: number, i: number, omega: number) => number;
31
+ declare const _nupp: (N: number, i: number, omega: number) => number;
32
+ declare const astro: (time: Date) => AstroData;
23
33
  //#endregion
24
- //#region src/node-corrections/index.d.ts
25
- type NodeCorrectionFunction = (a: AstroData, ...args: unknown[]) => number;
34
+ //#region src/node-corrections/types.d.ts
35
+ interface NodalCorrection {
36
+ f: number;
37
+ u: number;
38
+ }
39
+ type CorrectionFn = (astro: AstroData) => NodalCorrection;
40
+ type Fundamentals = Record<string, CorrectionFn>;
26
41
  //#endregion
27
- //#region src/constituents/definition.d.ts
42
+ //#region src/constituents/types.d.ts
43
+ interface DefineConstituentOptions {
44
+ name: string;
45
+ speed: number;
46
+ xdo: XDO | null;
47
+ nodalCorrection: NodalCorrectionCode;
48
+ aliases?: string[];
49
+ members?: [string, number][];
50
+ }
28
51
  interface Constituent {
29
- names: string[];
30
- coefficients: number[];
52
+ name: string;
53
+ aliases: string[];
54
+ coefficients: Coefficients | null;
55
+ members: ConstituentMember[];
56
+ speed: number;
31
57
  value: (astro: AstroData) => number;
32
- speed: (astro: AstroData) => number;
33
- u: NodeCorrectionFunction;
34
- f: NodeCorrectionFunction;
58
+ correction: (astro: AstroData, fundamentals?: Fundamentals) => NodalCorrection;
59
+ }
60
+ interface ConstituentMember {
61
+ constituent: Constituent;
62
+ factor: number;
35
63
  }
64
+ type Coefficients = [number, number, number, number, number, number, number];
65
+ type XDO = [number, number, number, number, number, number, number];
66
+ /**
67
+ * IHO letter codes from data.json that encode how to derive nodal corrections.
68
+ * See the "Nodal Corrections — Application" section in docs/TWCWG_Constituent_list.md
69
+ */
70
+ type NodalCorrectionCode = "z" | "f" | "y" | "a" | "m" | "o" | "k" | "j" | "b" | "c" | "g" | "p" | "d" | "q" | "x";
71
+ //#endregion
72
+ //#region src/node-corrections/iho.d.ts
73
+ declare const fundamentals$2: Fundamentals;
74
+ //#endregion
75
+ //#region src/node-corrections/schureman.d.ts
76
+ declare const fundamentals$3: Fundamentals;
77
+ //#endregion
78
+ //#region src/node-corrections/index.d.ts
79
+ declare const fundamentals$1: Record<string, Fundamentals>;
80
+ declare function resolveFundamentals(name?: string): Fundamentals;
36
81
  //#endregion
37
82
  //#region src/harmonics/prediction.d.ts
83
+ interface Timeline {
84
+ items: Date[];
85
+ hours: number[];
86
+ }
38
87
  interface HarmonicConstituent {
39
88
  name: string;
40
89
  amplitude: number;
@@ -65,10 +114,46 @@ interface ExtremeOffsets {
65
114
  low?: number;
66
115
  };
67
116
  }
117
+ interface ExtremeLabels {
118
+ high?: string;
119
+ low?: string;
120
+ }
121
+ interface ExtremesOptions {
122
+ labels?: ExtremeLabels;
123
+ offsets?: ExtremeOffsets;
124
+ }
125
+ interface Prediction {
126
+ getExtremesPrediction: (options?: ExtremesOptions) => Extreme[];
127
+ getTimelinePrediction: () => TimelinePoint[];
128
+ }
129
+ //#endregion
130
+ //#region src/harmonics/index.d.ts
131
+ interface HarmonicsOptions {
132
+ harmonicConstituents: HarmonicConstituent[];
133
+ constituentModels?: Record<string, Constituent>;
134
+ offset: number | false;
135
+ fundamentals?: Fundamentals;
136
+ }
137
+ interface PredictionOptions {
138
+ timeFidelity?: number;
139
+ }
140
+ interface Harmonics {
141
+ setTimeSpan: (startTime: Date | number, endTime: Date | number) => Harmonics;
142
+ prediction: (options?: PredictionOptions) => Prediction;
143
+ }
144
+ declare const getDate: (time: Date | number) => Date;
145
+ declare const getTimeline: (start: Date, end: Date, seconds?: number) => {
146
+ items: Date[];
147
+ hours: number[];
148
+ };
149
+ //#endregion
150
+ //#region src/constituents/definition.d.ts
151
+ declare const constituents$1: Record<string, Constituent>;
68
152
  //#endregion
69
153
  //#region src/index.d.ts
70
154
  interface TidePredictionOptions {
71
155
  offset?: number | false;
156
+ nodeCorrections?: "iho" | "schureman";
72
157
  }
73
158
  interface TimeSpan {
74
159
  start: Date;
@@ -89,10 +174,10 @@ interface TidePrediction {
89
174
  time: Date;
90
175
  }) => TimelinePoint;
91
176
  }
92
- declare const tidePredictionFactory: {
93
- (constituents: HarmonicConstituent[], options?: TidePredictionOptions): TidePrediction;
94
- constituents: Record<string, Constituent>;
95
- };
177
+ declare function createTidePredictor(constituents: HarmonicConstituent[], options?: TidePredictionOptions): TidePrediction;
178
+ declare namespace createTidePredictor {
179
+ var constituents: Record<string, Constituent>;
180
+ }
96
181
  //#endregion
97
- export { type Extreme, ExtremesInput, type HarmonicConstituent, TidePrediction, TidePredictionOptions, TimeSpan, type TimelinePoint, tidePredictionFactory as default };
182
+ export { AstroData, AstroValue, Coefficients, Constituent, ConstituentMember, CorrectionFn, DefineConstituentOptions, Extreme, ExtremeLabels, ExtremeOffsets, ExtremesInput, ExtremesOptions, Fundamentals, HarmonicConstituent, Harmonics, HarmonicsOptions, JD, NodalCorrection, NodalCorrectionCode, Prediction, PredictionOptions, T, TidePrediction, TidePredictionOptions, TimeSpan, Timeline, TimelinePoint, XDO, _I, _nu, _nup, _nupp, _xi, astro, constituents$1 as constituents, createTidePredictor, createTidePredictor as default, derivativePolynomial, fundamentals$1 as fundamentals, getDate, getTimeline, fundamentals$2 as iho, polynomial, resolveFundamentals, fundamentals$3 as schureman };
98
183
  //# sourceMappingURL=index.d.cts.map