@neaps/tide-predictor 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -78,9 +78,9 @@ const T = (t) => {
78
78
  return (JD(t) - 2451545) / 36525;
79
79
  };
80
80
  const JD = (t) => {
81
- let Y = t.getFullYear();
82
- let M = t.getMonth() + 1;
83
- const D = t.getDate() + t.getHours() / 24 + t.getMinutes() / 1440 + t.getSeconds() / (1440 * 60) + t.getMilliseconds() / (1440 * 60 * 1e6);
81
+ let Y = t.getUTCFullYear();
82
+ let M = t.getUTCMonth() + 1;
83
+ const D = t.getUTCDate() + t.getUTCHours() / 24 + t.getUTCMinutes() / 1440 + t.getUTCSeconds() / (1440 * 60) + t.getUTCMilliseconds() / (1440 * 60 * 1e6);
84
84
  if (M <= 2) {
85
85
  Y = Y - 1;
86
86
  M = M + 12;
@@ -181,132 +181,6 @@ const astro = (time) => {
181
181
  };
182
182
  var astronomy_default = astro;
183
183
 
184
- //#endregion
185
- //#region src/harmonics/prediction.ts
186
- const modulus = (a, b) => {
187
- return (a % b + b) % b;
188
- };
189
- const addExtremesOffsets = (extreme, offsets) => {
190
- if (typeof offsets === "undefined" || !offsets) return extreme;
191
- if (extreme.high && offsets.height?.high) if (offsets.height.type === "fixed") extreme.level += offsets.height.high;
192
- else extreme.level *= offsets.height.high;
193
- if (extreme.low && offsets.height?.low) if (offsets.height.type === "fixed") extreme.level += offsets.height.low;
194
- else extreme.level *= offsets.height.low;
195
- if (extreme.high && offsets.time?.high) extreme.time = new Date(extreme.time.getTime() + offsets.time.high * 60 * 1e3);
196
- if (extreme.low && offsets.time?.low) extreme.time = new Date(extreme.time.getTime() + offsets.time.low * 60 * 1e3);
197
- return extreme;
198
- };
199
- const getExtremeLabel = (label, highLowLabels) => {
200
- if (typeof highLowLabels !== "undefined" && typeof highLowLabels[label] !== "undefined") return highLowLabels[label];
201
- return {
202
- high: "High",
203
- low: "Low"
204
- }[label];
205
- };
206
- const predictionFactory = ({ timeline, constituents: constituents$1, start }) => {
207
- const getLevel = (hour, modelBaseSpeed, modelU, modelF, modelBaseValue) => {
208
- const amplitudes = [];
209
- let result = 0;
210
- constituents$1.forEach((constituent) => {
211
- const amplitude = constituent.amplitude;
212
- const phase = constituent._phase;
213
- const f = modelF[constituent.name];
214
- const speed = modelBaseSpeed[constituent.name];
215
- const u = modelU[constituent.name];
216
- const V0 = modelBaseValue[constituent.name];
217
- amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase));
218
- });
219
- amplitudes.forEach((item) => {
220
- result += item;
221
- });
222
- return result;
223
- };
224
- const prediction = {};
225
- prediction.getExtremesPrediction = (options) => {
226
- const { labels, offsets } = typeof options !== "undefined" ? options : {};
227
- const results = [];
228
- const { baseSpeed, u, f, baseValue } = prepare();
229
- let goingUp = false;
230
- let goingDown = false;
231
- let lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue);
232
- timeline.items.forEach((time, index) => {
233
- const hour = timeline.hours[index];
234
- const level = getLevel(hour, baseSpeed, u[index], f[index], baseValue);
235
- if (level > lastLevel && goingDown) results.push(addExtremesOffsets({
236
- time: timeline.items[index - 1],
237
- level: lastLevel,
238
- high: false,
239
- low: true,
240
- label: getExtremeLabel("low", labels)
241
- }, offsets));
242
- if (level < lastLevel && goingUp) results.push(addExtremesOffsets({
243
- time: timeline.items[index - 1],
244
- level: lastLevel,
245
- high: true,
246
- low: false,
247
- label: getExtremeLabel("high", labels)
248
- }, offsets));
249
- if (level > lastLevel) {
250
- goingUp = true;
251
- goingDown = false;
252
- }
253
- if (level < lastLevel) {
254
- goingUp = false;
255
- goingDown = true;
256
- }
257
- lastLevel = level;
258
- });
259
- return results;
260
- };
261
- prediction.getTimelinePrediction = () => {
262
- const results = [];
263
- const { baseSpeed, u, f, baseValue } = prepare();
264
- timeline.items.forEach((time, index) => {
265
- const hour = timeline.hours[index];
266
- const prediction$1 = {
267
- time,
268
- hour,
269
- level: getLevel(hour, baseSpeed, u[index], f[index], baseValue)
270
- };
271
- results.push(prediction$1);
272
- });
273
- return results;
274
- };
275
- const prepare = () => {
276
- const baseAstro = astronomy_default(start);
277
- const baseValue = {};
278
- const baseSpeed = {};
279
- const u = [];
280
- const f = [];
281
- constituents$1.forEach((constituent) => {
282
- const value = constituent._model.value(baseAstro);
283
- const speed = constituent._model.speed(baseAstro);
284
- baseValue[constituent.name] = d2r * value;
285
- baseSpeed[constituent.name] = d2r * speed;
286
- });
287
- timeline.items.forEach((time) => {
288
- const uItem = {};
289
- const fItem = {};
290
- const itemAstro = astronomy_default(time);
291
- constituents$1.forEach((constituent) => {
292
- const constituentU = modulus(constituent._model.u(itemAstro), 360);
293
- uItem[constituent.name] = d2r * constituentU;
294
- fItem[constituent.name] = modulus(constituent._model.f(itemAstro), 360);
295
- });
296
- u.push(uItem);
297
- f.push(fItem);
298
- });
299
- return {
300
- baseValue,
301
- baseSpeed,
302
- u,
303
- f
304
- };
305
- };
306
- return Object.freeze(prediction);
307
- };
308
- var prediction_default = predictionFactory;
309
-
310
184
  //#endregion
311
185
  //#region src/node-corrections/index.ts
312
186
  const corrections = {
@@ -429,45 +303,10 @@ const corrections = {
429
303
  var node_corrections_default = corrections;
430
304
 
431
305
  //#endregion
432
- //#region src/constituents/constituent.ts
433
- /**
434
- * Computes the dot notation of two arrays
435
- */
436
- const dotArray = (a, b) => {
437
- const results = [];
438
- a.forEach((value, index) => {
439
- results.push(value * b[index]);
440
- });
441
- return results.reduce((total, value) => total + value);
442
- };
443
- const astronimicDoodsonNumber = (astro$1) => {
444
- return [
445
- astro$1["T+h-s"],
446
- astro$1.s,
447
- astro$1.h,
448
- astro$1.p,
449
- astro$1.N,
450
- astro$1.pp,
451
- astro$1["90"]
452
- ];
453
- };
454
- const astronomicSpeed = (astro$1) => {
455
- const results = [];
456
- astronimicDoodsonNumber(astro$1).forEach((number) => {
457
- results.push(number.speed);
458
- });
459
- return results;
460
- };
461
- const astronomicValues = (astro$1) => {
462
- const results = [];
463
- astronimicDoodsonNumber(astro$1).forEach((number) => {
464
- results.push(number.value);
465
- });
466
- return results;
467
- };
468
- const constituentFactory = (name, coefficients$1, u, f) => {
306
+ //#region src/constituents/definition.ts
307
+ function defineConstituent(name, coefficients$1, u, f) {
469
308
  if (!coefficients$1) throw new Error("Coefficient must be defined for a constituent");
470
- const constituent = {
309
+ return Object.freeze({
471
310
  name,
472
311
  coefficients: coefficients$1,
473
312
  value: (astro$1) => {
@@ -478,14 +317,9 @@ const constituentFactory = (name, coefficients$1, u, f) => {
478
317
  },
479
318
  u: typeof u !== "undefined" ? u : node_corrections_default.uZero,
480
319
  f: typeof f !== "undefined" ? f : node_corrections_default.fUnity
481
- };
482
- return Object.freeze(constituent);
483
- };
484
- var constituent_default = constituentFactory;
485
-
486
- //#endregion
487
- //#region src/constituents/compound-constituent.ts
488
- const compoundConstituentFactory = (name, members) => {
320
+ });
321
+ }
322
+ function defineCompoundConstituent(name, members) {
489
323
  const coefficients$1 = [];
490
324
  members.forEach(({ constituent, factor }) => {
491
325
  constituent.coefficients.forEach((coefficient, index) => {
@@ -493,7 +327,7 @@ const compoundConstituentFactory = (name, members) => {
493
327
  coefficients$1[index] += coefficient * factor;
494
328
  });
495
329
  });
496
- const compoundConstituent = {
330
+ return Object.freeze({
497
331
  name,
498
332
  coefficients: coefficients$1,
499
333
  speed: (astro$1) => {
@@ -524,69 +358,71 @@ const compoundConstituentFactory = (name, members) => {
524
358
  });
525
359
  return f.reduce((previous, value) => previous * value);
526
360
  }
527
- };
528
- return Object.freeze(compoundConstituent);
529
- };
530
- var compound_constituent_default = compoundConstituentFactory;
361
+ });
362
+ }
363
+ /**
364
+ * Computes the dot notation of two arrays
365
+ */
366
+ function dotArray(a, b) {
367
+ const results = [];
368
+ a.forEach((value, index) => {
369
+ results.push(value * b[index]);
370
+ });
371
+ return results.reduce((total, value) => total + value);
372
+ }
373
+ function astronimicDoodsonNumber(astro$1) {
374
+ return [
375
+ astro$1["T+h-s"],
376
+ astro$1.s,
377
+ astro$1.h,
378
+ astro$1.p,
379
+ astro$1.N,
380
+ astro$1.pp,
381
+ astro$1["90"]
382
+ ];
383
+ }
384
+ function astronomicSpeed(astro$1) {
385
+ const results = [];
386
+ astronimicDoodsonNumber(astro$1).forEach((number) => {
387
+ results.push(number.speed);
388
+ });
389
+ return results;
390
+ }
391
+ function astronomicValues(astro$1) {
392
+ const results = [];
393
+ astronimicDoodsonNumber(astro$1).forEach((number) => {
394
+ results.push(number.value);
395
+ });
396
+ return results;
397
+ }
398
+ var definition_default = {};
531
399
 
532
400
  //#endregion
533
- //#region src/constituents/index.ts
534
- const constituents = {};
535
- constituents.Z0 = constituent_default("Z0", [
536
- 0,
537
- 0,
538
- 0,
539
- 0,
540
- 0,
541
- 0,
542
- 0
543
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
544
- constituents.SA = constituent_default("Sa", [
545
- 0,
546
- 0,
547
- 1,
548
- 0,
549
- 0,
550
- 0,
551
- 0
552
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
553
- constituents.SSA = constituent_default("Ssa", [
554
- 0,
555
- 0,
401
+ //#region src/constituents/M2.ts
402
+ /**
403
+ * Lunar semi-diurnal (M2).
404
+ * Primary principal lunar constituent; largest semi-diurnal tidal component globally.
405
+ * Amplitude varies 10-20% over lunar node cycle; typically 0.2-0.5m in coastal areas.
406
+ * Base constituent for many compound shallow-water constituents.
407
+ */
408
+ var M2_default = defineConstituent("M2", [
556
409
  2,
557
410
  0,
558
411
  0,
559
412
  0,
560
- 0
561
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
562
- constituents.MM = constituent_default("MM", [
563
- 0,
564
- 1,
565
- 0,
566
- -1,
567
- 0,
568
- 0,
569
- 0
570
- ], node_corrections_default.uZero, node_corrections_default.fMm);
571
- constituents.MF = constituent_default("MF", [
572
- 0,
573
- 2,
574
- 0,
575
- 0,
576
413
  0,
577
414
  0,
578
415
  0
579
- ], node_corrections_default.uMf, node_corrections_default.fMf);
580
- constituents.Q1 = constituent_default("Q1", [
581
- 1,
582
- -2,
583
- 0,
584
- 1,
585
- 0,
586
- 0,
587
- 1
588
- ], node_corrections_default.uO1, node_corrections_default.fO1);
589
- constituents.O1 = constituent_default("O1", [
416
+ ], node_corrections_default.uM2, node_corrections_default.fM2);
417
+
418
+ //#endregion
419
+ //#region src/constituents/O1.ts
420
+ /**
421
+ * Lunar diurnal (O1).
422
+ * Primary lunar diurnal constituent; one-per-lunar-day oscillation.
423
+ * Amplitude varies 10-20% due to lunar node effects.
424
+ */
425
+ var O1_default = defineConstituent("O1", [
590
426
  1,
591
427
  -1,
592
428
  0,
@@ -595,7 +431,30 @@ constituents.O1 = constituent_default("O1", [
595
431
  0,
596
432
  1
597
433
  ], node_corrections_default.uO1, node_corrections_default.fO1);
598
- constituents.K1 = constituent_default("K1", [
434
+
435
+ //#endregion
436
+ //#region src/constituents/2MK3.ts
437
+ /**
438
+ * Shallow-water terdiurnal (2MK3 = M2 + O1).
439
+ * Lunar-lunar interaction from M2 semi-diurnal and O1 diurnal components.
440
+ * Generated in shallow-water environments; typical amplitude <1 cm.
441
+ */
442
+ var _2MK3_default = defineCompoundConstituent("2MK3", [{
443
+ constituent: M2_default,
444
+ factor: 1
445
+ }, {
446
+ constituent: O1_default,
447
+ factor: 1
448
+ }]);
449
+
450
+ //#endregion
451
+ //#region src/constituents/K1.ts
452
+ /**
453
+ * Lunisolar diurnal (K1).
454
+ * Combined lunar and solar diurnal constituent; strongest diurnal tide in many regions.
455
+ * Often comparable in amplitude to O1; amplitude ratio K1/O1 varies with latitude.
456
+ */
457
+ var K1_default = defineConstituent("K1", [
599
458
  1,
600
459
  1,
601
460
  0,
@@ -604,52 +463,88 @@ constituents.K1 = constituent_default("K1", [
604
463
  0,
605
464
  -1
606
465
  ], node_corrections_default.uK1, node_corrections_default.fK1);
607
- constituents.J1 = constituent_default("J1", [
608
- 1,
609
- 2,
610
- 0,
611
- -1,
612
- 0,
613
- 0,
614
- -1
615
- ], node_corrections_default.uJ1, node_corrections_default.fJ1);
616
- constituents.M1 = constituent_default("M1", [
617
- 1,
618
- 0,
619
- 0,
620
- 0,
621
- 0,
622
- 0,
623
- 1
624
- ], node_corrections_default.uM1, node_corrections_default.fM1);
625
- constituents.P1 = constituent_default("P1", [
626
- 1,
627
- 1,
466
+
467
+ //#endregion
468
+ //#region src/constituents/2MK5.ts
469
+ /**
470
+ * Shallow-water fifth-diurnal from M2-K1 interaction.
471
+ *
472
+ * Note: Found in coastal tide predictions, especially in enclosed bays and harbors.
473
+ * Amplitude typically 0.1-0.5 cm depending on location and water depth.
474
+ * Shallow-water constituent only; not present in deep ocean.
475
+ *
476
+ * @see NOAA CO-OPS
477
+ */
478
+ var _2MK5_default = defineCompoundConstituent("2MK5", [{
479
+ constituent: M2_default,
480
+ factor: 2
481
+ }, {
482
+ constituent: K1_default,
483
+ factor: 1
484
+ }]);
485
+
486
+ //#endregion
487
+ //#region src/constituents/2MO5.ts
488
+ /**
489
+ * Shallow-water fifth-diurnal from M2-O1 interaction.
490
+ *
491
+ * Note: Primarily shallow-water coastal phenomenon, not present in deep ocean.
492
+ * Amplitude typically <0.5 cm except in extreme shallow-water or enclosed basins.
493
+ * Found in coastal tide predictions alongside other shallow-water constituents.
494
+ *
495
+ * @see NOAA CO-OPS
496
+ */
497
+ var _2MO5_default = defineCompoundConstituent("2MO5", [{
498
+ constituent: M2_default,
499
+ factor: 2
500
+ }, {
501
+ constituent: O1_default,
502
+ factor: 1
503
+ }]);
504
+
505
+ //#endregion
506
+ //#region src/constituents/S2.ts
507
+ /**
508
+ * Solar semi-diurnal (S2).
509
+ * Principal solar semi-diurnal constituent; largest solar tide component.
510
+ * Amplitude typically 20-50% of M2; varies with geographic location and latitude.
511
+ * Ratio M2/S2 determines tidal form factor (diurnal vs semi-diurnal regimes).
512
+ * Base constituent for many compound shallow-water constituents.
513
+ */
514
+ var S2_default = defineConstituent("S2", [
515
+ 2,
516
+ 2,
628
517
  -2,
629
518
  0,
630
519
  0,
631
520
  0,
632
- 1
633
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
634
- constituents.S1 = constituent_default("S1", [
635
- 1,
636
- 1,
637
- -1,
638
- 0,
639
- 0,
640
- 0,
641
521
  0
642
522
  ], node_corrections_default.uZero, node_corrections_default.fUnity);
643
- constituents.OO1 = constituent_default("OO1", [
644
- 1,
645
- 3,
646
- 0,
647
- 0,
648
- 0,
649
- 0,
650
- -1
651
- ], node_corrections_default.uOO1, node_corrections_default.fOO1);
652
- constituents["2N2"] = constituent_default("2N2", [
523
+
524
+ //#endregion
525
+ //#region src/constituents/2MS6.ts
526
+ /**
527
+ * Sixth-diurnal shallow-water interaction: 2×M2 + S2.
528
+ *
529
+ * Generated only in shallow water; typical amplitude 0.01-0.2 meters depending on depth.
530
+ * Included in IHO shallow-water constituent tables and NOAA analysis (order #37).
531
+ */
532
+ var _2MS6_default = defineCompoundConstituent("2MS6", [{
533
+ constituent: M2_default,
534
+ factor: 2
535
+ }, {
536
+ constituent: S2_default,
537
+ factor: 1
538
+ }]);
539
+
540
+ //#endregion
541
+ //#region src/constituents/2N2.ts
542
+ /**
543
+ * Lunar semi-diurnal (2N2).
544
+ * Second-order lunar semi-diurnal from Moon's orbital ellipticity.
545
+ * Amplitude typically 5-10% of M2; significant in semi-diurnal analysis.
546
+ */
547
+ var _2N2_default = defineConstituent("2N2", [
653
548
  2,
654
549
  -2,
655
550
  0,
@@ -658,7 +553,15 @@ constituents["2N2"] = constituent_default("2N2", [
658
553
  0,
659
554
  0
660
555
  ], node_corrections_default.uM2, node_corrections_default.fM2);
661
- constituents.N2 = constituent_default("N2", [
556
+
557
+ //#endregion
558
+ //#region src/constituents/N2.ts
559
+ /**
560
+ * Lunar elliptic semi-diurnal (N2).
561
+ * Primary lunar elliptic semi-diurnal constituent from Moon's orbital variations.
562
+ * Amplitude typically 5-15% of M2; third-largest semi-diurnal constituent.
563
+ */
564
+ var N2_default = defineConstituent("N2", [
662
565
  2,
663
566
  -1,
664
567
  0,
@@ -667,25 +570,149 @@ constituents.N2 = constituent_default("N2", [
667
570
  0,
668
571
  0
669
572
  ], node_corrections_default.uM2, node_corrections_default.fM2);
670
- constituents.NU2 = constituent_default("NU2", [
573
+
574
+ //#endregion
575
+ //#region src/constituents/J1.ts
576
+ /**
577
+ * Lunar diurnal (J1).
578
+ * Shallow-water lunar diurnal constituent; generally much smaller than O1 and K1.
579
+ * Typically important only in shallow-water systems and enclosed basins.
580
+ * Amplitude usually <5% of O1; rarely significant in routine predictions.
581
+ */
582
+ var J1_default = defineConstituent("J1", [
583
+ 1,
671
584
  2,
585
+ 0,
672
586
  -1,
587
+ 0,
588
+ 0,
589
+ -1
590
+ ], node_corrections_default.uJ1, node_corrections_default.fJ1);
591
+
592
+ //#endregion
593
+ //#region src/constituents/2Q1.ts
594
+ /**
595
+ * Shallow-water diurnal (2Q1 = N2-J1).
596
+ * Derived from interaction of semi-diurnal N2 and diurnal J1 constituents.
597
+ * Amplitude typically very small; rarely significant.
598
+ * Found only in shallow-water regions with strong tidal distortion.
599
+ */
600
+ var _2Q1_default = defineCompoundConstituent("2Q1", [{
601
+ constituent: N2_default,
602
+ factor: 1
603
+ }, {
604
+ constituent: J1_default,
605
+ factor: -1
606
+ }]);
607
+
608
+ //#endregion
609
+ //#region src/constituents/2SM2.ts
610
+ /**
611
+ * Shallow-water semi-diurnal (2SM2).
612
+ * Compound constituent: 2×S2 - M2
613
+ * Solar-lunar interaction constituent generated in shallow-water environments.
614
+ * Amplitude typically <2% of M2; complementary to MU2.
615
+ */
616
+ var _2SM2_default = defineCompoundConstituent("2SM2", [{
617
+ constituent: S2_default,
618
+ factor: 2
619
+ }, {
620
+ constituent: M2_default,
621
+ factor: -1
622
+ }]);
623
+
624
+ //#endregion
625
+ //#region src/constituents/L2.ts
626
+ /**
627
+ * Lunar elliptic semi-diurnal (L2).
628
+ * Secondary lunar elliptic semi-diurnal from Moon's orbital variations and perigee effects.
629
+ * Amplitude typically 1-3% of M2; often grouped with other lunar elliptic constituents.
630
+ * Important in detailed harmonic analyses of semi-diurnal tides.
631
+ */
632
+ var L2_default = defineConstituent("L2", [
673
633
  2,
634
+ 1,
635
+ 0,
674
636
  -1,
675
637
  0,
676
638
  0,
639
+ 2
640
+ ], node_corrections_default.uL2, node_corrections_default.fL2);
641
+
642
+ //#endregion
643
+ //#region src/constituents/3L2.ts
644
+ /**
645
+ * Triple lunar elliptic; 3 times L2 interaction.
646
+ *
647
+ * Warning: Not in standard IHO constituent bank. Mainly historical/theoretical interest.
648
+ * Very small amplitude (<0.1 cm); found only in extreme shallow water or enclosed basins.
649
+ * Often ignored in routine tide predictions.
650
+ *
651
+ * @see Schureman, P. (1958). Manual of Harmonic Analysis and Prediction of Tides
652
+ */
653
+ var _3L2_default = defineCompoundConstituent("3L2", [{
654
+ constituent: L2_default,
655
+ factor: 3
656
+ }]);
657
+
658
+ //#endregion
659
+ //#region src/constituents/3N2.ts
660
+ /**
661
+ * Triple N2 shallow-water harmonic (3 × N2).
662
+ *
663
+ * Note: Shallow-water constituent with definition based on compound frequency estimates.
664
+ * Typical amplitude <0.5 cm; often <0.1 cm except in extreme shallow-water or enclosed basins.
665
+ * Rarely significant in routine tide predictions.
666
+ *
667
+ * @see NOAA CO-OPS shallow-water constituents
668
+ */
669
+ var _3N2_default = defineCompoundConstituent("3N2", [{
670
+ constituent: N2_default,
671
+ factor: 3
672
+ }]);
673
+
674
+ //#endregion
675
+ //#region src/constituents/EP2.ts
676
+ /**
677
+ * Lunar elliptic semi-diurnal constituent (ε2).
678
+ */
679
+ var EP2_default = defineConstituent("EP2", [
680
+ 2,
681
+ -3,
682
+ 2,
683
+ 1,
684
+ 0,
685
+ 0,
677
686
  0
678
687
  ], node_corrections_default.uM2, node_corrections_default.fM2);
679
- constituents.M2 = constituent_default("M2", [
688
+
689
+ //#endregion
690
+ //#region src/constituents/K2.ts
691
+ /**
692
+ * Lunisolar semi-diurnal (K2).
693
+ * Combined lunar and solar semi-diurnal constituent from declination effects.
694
+ * Amplitude typically 10-30% of S2; second-largest solar-related semi-diurnal component.
695
+ * Important in semi-diurnal tidal analysis, especially at mid-latitudes.
696
+ */
697
+ var K2_default = defineConstituent("K2", [
698
+ 2,
680
699
  2,
681
- 0,
682
700
  0,
683
701
  0,
684
702
  0,
685
703
  0,
686
704
  0
687
- ], node_corrections_default.uM2, node_corrections_default.fM2);
688
- constituents.LAM2 = constituent_default("LAM2", [
705
+ ], node_corrections_default.uK2, node_corrections_default.fK2);
706
+
707
+ //#endregion
708
+ //#region src/constituents/LAMBDA2.ts
709
+ /**
710
+ * Lunar semi-diurnal (λ2, lambda2).
711
+ * Lunar semi-diurnal constituent from Moon's perigee effects.
712
+ * Amplitude typically <5% of M2; important in detailed constituent analysis.
713
+ * IHO standard designation (previously abbreviated as LAM2).
714
+ */
715
+ var LAMBDA2_default = defineConstituent("LAMBDA2", [
689
716
  2,
690
717
  1,
691
718
  -2,
@@ -694,149 +721,835 @@ constituents.LAM2 = constituent_default("LAM2", [
694
721
  0,
695
722
  2
696
723
  ], node_corrections_default.uM2, node_corrections_default.fM2);
697
- constituents.L2 = constituent_default("L2", [
698
- 2,
724
+
725
+ //#endregion
726
+ //#region src/constituents/LAM2.ts
727
+ /**
728
+ * Alias for compatibility between NOAA and IHO
729
+ *
730
+ * @see LAMBDA2
731
+ */
732
+ var LAM2_default = LAMBDA2_default;
733
+
734
+ //#endregion
735
+ //#region src/constituents/M1.ts
736
+ /**
737
+ * Lunar diurnal elliptic (M1).
738
+ * Secondary lunar diurnal constituent from Moon's elliptical orbit.
739
+ * Typically very small amplitude; usually <1% of O1.
740
+ * Rarely significant except in detailed harmonic analyses.
741
+ */
742
+ var M1_default = defineConstituent("M1", [
699
743
  1,
700
744
  0,
701
- -1,
702
745
  0,
703
746
  0,
704
- 2
705
- ], node_corrections_default.uL2, node_corrections_default.fL2);
706
- constituents.T2 = constituent_default("T2", [
707
- 2,
708
- 2,
709
- -3,
710
747
  0,
711
748
  0,
712
- 1,
713
- 0
714
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
715
- constituents.S2 = constituent_default("S2", [
716
- 2,
717
- 2,
718
- -2,
749
+ 1
750
+ ], node_corrections_default.uM1, node_corrections_default.fM1);
751
+
752
+ //#endregion
753
+ //#region src/constituents/M3.ts
754
+ /**
755
+ * Lunar terdiurnal (M3).
756
+ * Third-diurnal lunar constituent from Moon's orbital motion.
757
+ * Typically found in shallow water and resonant systems.
758
+ * Amplitude usually <2% of M2; important in some shallow-water analyses.
759
+ */
760
+ var M3_default = defineConstituent("M3", [
761
+ 3,
762
+ 0,
763
+ 0,
719
764
  0,
720
765
  0,
721
766
  0,
722
767
  0
723
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
724
- constituents.R2 = constituent_default("R2", [
725
- 2,
768
+ ], (a) => {
769
+ return node_corrections_default.uModd(a, 3);
770
+ }, (a) => {
771
+ return node_corrections_default.fModd(a, 3);
772
+ });
773
+
774
+ //#endregion
775
+ //#region src/constituents/M4.ts
776
+ /**
777
+ * Shallow-water quarter-diurnal (M4 = 2×M2).
778
+ * First overtide of M2; generated in shallow-water environments.
779
+ * Amplitude typically 2-10% of M2; largest of the quarter-diurnal constituents.
780
+ * Important indicator of shallow-water tidal distortion.
781
+ */
782
+ var M4_default = defineCompoundConstituent("M4", [{
783
+ constituent: M2_default,
784
+ factor: 2
785
+ }]);
786
+
787
+ //#endregion
788
+ //#region src/constituents/M6.ts
789
+ /**
790
+ * Shallow-water sixth-diurnal (M6 = 3×M2).
791
+ * Second overtide of M2; generated in shallow-water environments.
792
+ * Amplitude typically 0.5-3% of M2; important in extreme shallow water.
793
+ * Indicator of significant tidal distortion and non-linear effects.
794
+ */
795
+ var M6_default = defineCompoundConstituent("M6", [{
796
+ constituent: M2_default,
797
+ factor: 3
798
+ }]);
799
+
800
+ //#endregion
801
+ //#region src/constituents/M8.ts
802
+ /**
803
+ * Shallow-water eighth-diurnal (M8 = 4×M2).
804
+ * Third overtide of M2; generated in extreme shallow-water environments.
805
+ * Amplitude typically <0.5% of M2; very rarely significant.
806
+ * Found only in highly distorted tidal regimes (extreme shallow water, enclosed basins).
807
+ */
808
+ var M8_default = defineCompoundConstituent("M8", [{
809
+ constituent: M2_default,
810
+ factor: 4
811
+ }]);
812
+
813
+ //#endregion
814
+ //#region src/constituents/MA2.ts
815
+ /**
816
+ * Lunar variational semi-diurnal constituent (μ2, mu2).
817
+ * Derived from Moon's orbital parameter variations.
818
+ *
819
+ * Note: Often included with M2 family in modern analysis. Minor constituent with
820
+ * location-dependent amplitude.
821
+ */
822
+ var MA2_default = defineConstituent("MA2", [
726
823
  2,
824
+ 0,
727
825
  -1,
728
826
  0,
729
827
  0,
730
- -1,
731
- 2
732
- ], node_corrections_default.uZero, node_corrections_default.fUnity);
733
- constituents.K2 = constituent_default("K2", [
734
- 2,
828
+ 0,
829
+ 0
830
+ ], node_corrections_default.uM2, node_corrections_default.fM2);
831
+
832
+ //#endregion
833
+ //#region src/constituents/MB2.ts
834
+ /**
835
+ * Lunar elliptic constituent from parameter variations.
836
+ *
837
+ * From https://iho.int/mtg_docs/com_wg/IHOTC/IHOTC_Misc/TWCWG_Constituent_list.pdf:
838
+ *
839
+ * > MB2 was originally called Ma2 but this became ambiguous when spoken, or typed on
840
+ * > computers without lower case, and so it was initially changed to MA2*. However, this
841
+ * > in turn was thought to be clumsy and hence MB2 was finally adopted. Although
842
+ * > theoretically they should have the same values of u and f as M2, they are so small
843
+ * > that they are commonly treated as having values of u = 0 and f = 1.
844
+ *
845
+ * @see Schureman, P. (1958). Manual of Harmonic Analysis and Prediction of Tides
846
+ */
847
+ var MB2_default = defineConstituent("MB2", [
735
848
  2,
736
849
  0,
850
+ 1,
737
851
  0,
738
852
  0,
739
853
  0,
740
854
  0
741
- ], node_corrections_default.uK2, node_corrections_default.fK2);
742
- constituents.M3 = constituent_default("M3", [
743
- 3,
855
+ ], node_corrections_default.uM2, node_corrections_default.fM2);
856
+
857
+ //#endregion
858
+ //#region src/constituents/MF.ts
859
+ /**
860
+ * Lunar fortnightly (MF).
861
+ * Long-period constituent from lunar inequality interactions.
862
+ * Significant in long-term water level records and coastal resonances.
863
+ */
864
+ var MF_default = defineConstituent("MF", [
744
865
  0,
866
+ 2,
745
867
  0,
746
868
  0,
747
869
  0,
748
870
  0,
749
871
  0
750
- ], (a) => {
751
- return node_corrections_default.uModd(a, 3);
752
- }, (a) => {
753
- return node_corrections_default.fModd(a, 3);
754
- });
755
- constituents.MSF = compound_constituent_default("MSF", [{
756
- constituent: constituents.S2,
872
+ ], node_corrections_default.uMf, node_corrections_default.fMf);
873
+
874
+ //#endregion
875
+ //#region src/constituents/MK3.ts
876
+ /**
877
+ * Shallow-water terdiurnal (MK3).
878
+ * Compound constituent: M2 + K1
879
+ * Lunisolar interaction from M2 semi-diurnal and K1 diurnal components.
880
+ * Generated in shallow-water environments; typical amplitude 0.5-2 cm.
881
+ * Often paired with 2MK3 in terdiurnal tide analysis.
882
+ */
883
+ var MK3_default = defineCompoundConstituent("MK3", [{
884
+ constituent: M2_default,
757
885
  factor: 1
758
886
  }, {
759
- constituent: constituents.M2,
760
- factor: -1
887
+ constituent: K1_default,
888
+ factor: 1
761
889
  }]);
762
- constituents["2Q1"] = compound_constituent_default("2Q1", [{
763
- constituent: constituents.N2,
890
+
891
+ //#endregion
892
+ //#region src/constituents/MKS2.ts
893
+ /**
894
+ * Three-way shallow-water interaction of M2, K1, and S2.
895
+ *
896
+ * Warning: Not in standard IHO constituent bank. Shallow-water specific constituent
897
+ * with definition varying by application and water depth. Use with caution and document
898
+ * the specific convention used in your analysis.
899
+ *
900
+ * @see NOAA CO-OPS shallow-water constituents
901
+ */
902
+ var MKS2_default = defineCompoundConstituent("MKS2", [
903
+ {
904
+ constituent: M2_default,
905
+ factor: 1
906
+ },
907
+ {
908
+ constituent: K1_default,
909
+ factor: 1
910
+ },
911
+ {
912
+ constituent: S2_default,
913
+ factor: -1
914
+ }
915
+ ]);
916
+
917
+ //#endregion
918
+ //#region src/constituents/MM.ts
919
+ /**
920
+ * Lunar monthly (MM).
921
+ * Long-period constituent from lunar declination variations.
922
+ * Important for long-term water level studies.
923
+ */
924
+ var MM_default = defineConstituent("MM", [
925
+ 0,
926
+ 1,
927
+ 0,
928
+ -1,
929
+ 0,
930
+ 0,
931
+ 0
932
+ ], node_corrections_default.uZero, node_corrections_default.fMm);
933
+
934
+ //#endregion
935
+ //#region src/constituents/MN4.ts
936
+ /**
937
+ * Shallow-water quarter-diurnal (MN4).
938
+ * Compound constituent: M2 + N2
939
+ * Lunar-lunar elliptic interaction from M2 and N2 semi-diurnal components.
940
+ * Generated in shallow-water environments; typical amplitude 1-5 cm.
941
+ * Often significant in shallow seas and estuaries.
942
+ */
943
+ var MN4_default = defineCompoundConstituent("MN4", [{
944
+ constituent: M2_default,
764
945
  factor: 1
765
946
  }, {
766
- constituent: constituents.J1,
767
- factor: -1
947
+ constituent: N2_default,
948
+ factor: 1
768
949
  }]);
769
- constituents.RHO = compound_constituent_default("RHO", [{
770
- constituent: constituents.NU2,
950
+
951
+ //#endregion
952
+ //#region src/constituents/MS4.ts
953
+ /**
954
+ * Shallow-water quarter-diurnal (MS4).
955
+ * Compound constituent: M2 + S2
956
+ * Lunar-solar interaction from M2 and S2 semi-diurnal components.
957
+ * Generated in shallow-water environments; typical amplitude 1-5 cm.
958
+ * Often second-largest quarter-diurnal component after M4.
959
+ */
960
+ var MS4_default = defineCompoundConstituent("MS4", [{
961
+ constituent: M2_default,
771
962
  factor: 1
772
963
  }, {
773
- constituent: constituents.K1,
774
- factor: -1
964
+ constituent: S2_default,
965
+ factor: 1
775
966
  }]);
776
- constituents.MU2 = compound_constituent_default("MU2", [{
777
- constituent: constituents.M2,
778
- factor: 2
779
- }, {
780
- constituent: constituents.S2,
781
- factor: -1
782
- }]);
783
- constituents["2SM2"] = compound_constituent_default("2SM2", [{
784
- constituent: constituents.S2,
785
- factor: 2
786
- }, {
787
- constituent: constituents.M2,
788
- factor: -1
789
- }]);
790
- constituents["2MK3"] = compound_constituent_default("2MK3", [{
791
- constituent: constituents.M2,
967
+
968
+ //#endregion
969
+ //#region src/constituents/MSF.ts
970
+ /**
971
+ * Lunisolar synodic fortnightly (MSF = S2-M2).
972
+ * Long-period constituent representing beat frequency between solar S2 and lunar M2.
973
+ * Manifests as fortnightly modulation of tidal range (spring-neap cycle).
974
+ * Amplitude typically 5-15% of M2; represents the primary spring-neap variation.
975
+ * Important for tidal range predictions and coastal flooding assessments.
976
+ */
977
+ var MSF_default = defineCompoundConstituent("MSF", [{
978
+ constituent: S2_default,
792
979
  factor: 1
793
980
  }, {
794
- constituent: constituents.O1,
795
- factor: 1
981
+ constituent: M2_default,
982
+ factor: -1
796
983
  }]);
797
- constituents.MK3 = compound_constituent_default("MK3", [{
798
- constituent: constituents.M2,
984
+
985
+ //#endregion
986
+ //#region src/constituents/MSQM.ts
987
+ /**
988
+ * Lunar-solar interaction compound constituent.
989
+ *
990
+ * Warning: Non-standard constituent not in IHO or modern NOAA standard tables.
991
+ * Definition varies significantly across sources. Rarely used in modern tide prediction.
992
+ * Appears in Schureman's tables as variant shallow-water interaction.
993
+ *
994
+ * @see NOAA CO-OPS shallow-water constituents
995
+ * @see Schureman shallow-water analysis tables
996
+ */
997
+ var MSQM_default = defineCompoundConstituent("MSQM", [
998
+ {
999
+ constituent: M2_default,
1000
+ factor: 1
1001
+ },
1002
+ {
1003
+ constituent: S2_default,
1004
+ factor: 1
1005
+ },
1006
+ {
1007
+ constituent: K1_default,
1008
+ factor: 1
1009
+ }
1010
+ ]);
1011
+
1012
+ //#endregion
1013
+ //#region src/constituents/T2.ts
1014
+ /**
1015
+ * Solar elliptic semi-diurnal (T2).
1016
+ * Larger solar elliptic semi-diurnal constituent from solar declination effects.
1017
+ * Amplitude typically <5% of S2; increases at higher latitudes.
1018
+ * Forms part of solar semi-diurnal analysis alongside S2 and R2.
1019
+ */
1020
+ var T2_default = defineConstituent("T2", [
1021
+ 2,
1022
+ 2,
1023
+ -3,
1024
+ 0,
1025
+ 0,
1026
+ 1,
1027
+ 0
1028
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1029
+
1030
+ //#endregion
1031
+ //#region src/constituents/MTM.ts
1032
+ /**
1033
+ * Lunar-solar shallow-water interaction (M2 modulated by lunar orbit).
1034
+ *
1035
+ * Warning: Not in modern IHO standard constituents; mostly historical interest.
1036
+ * Often replaced by specific ν2, λ2, or other lunar elliptic terms in modern analysis.
1037
+ * Amplitude is location and depth-dependent.
1038
+ *
1039
+ * @see NOAA CO-OPS shallow-water variants
1040
+ * @see Schureman Manual
1041
+ */
1042
+ var MTM_default = defineCompoundConstituent("MTM", [{
1043
+ constituent: M2_default,
799
1044
  factor: 1
800
1045
  }, {
801
- constituent: constituents.K1,
1046
+ constituent: T2_default,
802
1047
  factor: 1
803
1048
  }]);
804
- constituents.MN4 = compound_constituent_default("MN4", [{
805
- constituent: constituents.M2,
806
- factor: 1
1049
+
1050
+ //#endregion
1051
+ //#region src/constituents/MU2.ts
1052
+ /**
1053
+ * Shallow-water semi-diurnal (MU2 or μ2).
1054
+ * Compound constituent: 2×M2 - S2
1055
+ * Lunar variational constituent generated in shallow-water environments.
1056
+ * Amplitude typically <2% of M2; found in coastal shallow-water predictions.
1057
+ */
1058
+ var MU2_default = defineCompoundConstituent("MU2", [{
1059
+ constituent: M2_default,
1060
+ factor: 2
807
1061
  }, {
808
- constituent: constituents.N2,
809
- factor: 1
1062
+ constituent: S2_default,
1063
+ factor: -1
810
1064
  }]);
811
- constituents.M4 = compound_constituent_default("M4", [{
812
- constituent: constituents.M2,
1065
+
1066
+ //#endregion
1067
+ //#region src/constituents/N4.ts
1068
+ /**
1069
+ * Second overtide of N2; shallow-water quarter-diurnal harmonic.
1070
+ * Amplitude ranges 0.25 to 2.25 times mean due to 18.613-year lunar node cycle.
1071
+ *
1072
+ * Note: Shallow-water constituent, typically found in tide predictions for coastal areas.
1073
+ */
1074
+ var N4_default = defineCompoundConstituent("N4", [{
1075
+ constituent: N2_default,
813
1076
  factor: 2
814
1077
  }]);
815
- constituents.MS4 = compound_constituent_default("MS4", [{
816
- constituent: constituents.M2,
1078
+
1079
+ //#endregion
1080
+ //#region src/constituents/NU2.ts
1081
+ /**
1082
+ * Lunar elliptic semi-diurnal (NU2).
1083
+ * Secondary lunar elliptic semi-diurnal from Moon's orbital variations.
1084
+ * Amplitude typically 2-5% of M2; smaller than N2.
1085
+ * Important in detailed semi-diurnal constituent analysis.
1086
+ */
1087
+ var NU2_default = defineConstituent("NU2", [
1088
+ 2,
1089
+ -1,
1090
+ 2,
1091
+ -1,
1092
+ 0,
1093
+ 0,
1094
+ 0
1095
+ ], node_corrections_default.uM2, node_corrections_default.fM2);
1096
+
1097
+ //#endregion
1098
+ //#region src/constituents/OO1.ts
1099
+ /**
1100
+ * Lunar diurnal (OO1).
1101
+ * Second-order lunar diurnal constituent from Moon's orbital eccentricity.
1102
+ * Typically very small amplitude; <2% of O1 in most locations.
1103
+ * Important for detailed harmonic analysis in some regions.
1104
+ */
1105
+ var OO1_default = defineConstituent("OO1", [
1106
+ 1,
1107
+ 3,
1108
+ 0,
1109
+ 0,
1110
+ 0,
1111
+ 0,
1112
+ -1
1113
+ ], node_corrections_default.uOO1, node_corrections_default.fOO1);
1114
+
1115
+ //#endregion
1116
+ //#region src/constituents/P1.ts
1117
+ /**
1118
+ * Solar diurnal (P1).
1119
+ * Principal solar diurnal constituent; one-per-solar-day oscillation.
1120
+ * Amplitude typically 1/3 of K1; varies with latitude.
1121
+ * Forms key component of diurnal tidal analysis alongside K1 and O1.
1122
+ */
1123
+ var P1_default = defineConstituent("P1", [
1124
+ 1,
1125
+ 1,
1126
+ -2,
1127
+ 0,
1128
+ 0,
1129
+ 0,
1130
+ 1
1131
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1132
+
1133
+ //#endregion
1134
+ //#region src/constituents/Q1.ts
1135
+ /**
1136
+ * Elliptic lunar diurnal (Q1).
1137
+ * One solar day and one lunar day modulation interaction.
1138
+ * Amplitude typically 2-5% of O1; important in diurnal constituent analysis.
1139
+ */
1140
+ var Q1_default = defineConstituent("Q1", [
1141
+ 1,
1142
+ -2,
1143
+ 0,
1144
+ 1,
1145
+ 0,
1146
+ 0,
1147
+ 1
1148
+ ], node_corrections_default.uO1, node_corrections_default.fO1);
1149
+
1150
+ //#endregion
1151
+ //#region src/constituents/R2.ts
1152
+ /**
1153
+ * Solar elliptic semi-diurnal (R2).
1154
+ * Smaller solar elliptic semi-diurnal constituent from solar declination effects.
1155
+ * Amplitude typically <2% of S2; smallest of the solar semi-diurnal group.
1156
+ * Rarely significant except in very detailed analyses.
1157
+ */
1158
+ var R2_default = defineConstituent("R2", [
1159
+ 2,
1160
+ 2,
1161
+ -1,
1162
+ 0,
1163
+ 0,
1164
+ -1,
1165
+ 2
1166
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1167
+
1168
+ //#endregion
1169
+ //#region src/constituents/R3.ts
1170
+ /**
1171
+ * Solar elliptic terdiurnal; 1.5 times R2 (smaller solar elliptic semi-diurnal).
1172
+ *
1173
+ * Note: Generated only in shallow water; very small amplitude (<0.05 cm typical).
1174
+ * Usually negligible except in extreme shallow-water environments.
1175
+ *
1176
+ * @see NOAA CO-OPS
1177
+ */
1178
+ var R3_default = defineCompoundConstituent("R3", [{
1179
+ constituent: R2_default,
1180
+ factor: 1.5
1181
+ }]);
1182
+
1183
+ //#endregion
1184
+ //#region src/constituents/RHO1.ts
1185
+ /**
1186
+ * Shallow-water diurnal (RHO1, ρ1).
1187
+ * Compound constituent: NU2-K1 (ν2-K1)
1188
+ * Derived from interaction of semi-diurnal NU2 and diurnal K1 constituents.
1189
+ * Amplitude typically very small; rarely significant.
1190
+ * Found only in shallow-water regions with strong tidal distortion.
1191
+ */
1192
+ var RHO1_default = defineCompoundConstituent("RHO1", [{
1193
+ constituent: NU2_default,
817
1194
  factor: 1
818
1195
  }, {
819
- constituent: constituents.S2,
820
- factor: 1
1196
+ constituent: K1_default,
1197
+ factor: -1
821
1198
  }]);
822
- constituents.S4 = compound_constituent_default("S4", [{
823
- constituent: constituents.S2,
824
- factor: 2
1199
+
1200
+ //#endregion
1201
+ //#region src/constituents/RHO.ts
1202
+ /**
1203
+ * Alias for compatibility between NOAA and IHO
1204
+ *
1205
+ * @see RHO1
1206
+ */
1207
+ var RHO_default = RHO1_default;
1208
+
1209
+ //#endregion
1210
+ //#region src/constituents/S1.ts
1211
+ /**
1212
+ * Solar diurnal (S1).
1213
+ * Secondary solar diurnal constituent related to solar declination inequality.
1214
+ * Usually very small amplitude; typically dominated by K1 and P1 in diurnal analysis.
1215
+ * Rarely included in routine harmonic analyses.
1216
+ */
1217
+ var S1_default = defineConstituent("S1", [
1218
+ 1,
1219
+ 1,
1220
+ -1,
1221
+ 0,
1222
+ 0,
1223
+ 0,
1224
+ 0
1225
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1226
+
1227
+ //#endregion
1228
+ //#region src/constituents/S3.ts
1229
+ /**
1230
+ * Solar terdiurnal overtide; shallow-water only.
1231
+ *
1232
+ * Note: Generated only in shallow water; not found in deep ocean.
1233
+ * Typical amplitude <1 cm except in extreme shallow-water environments.
1234
+ *
1235
+ * @see NOAA CO-OPS
1236
+ */
1237
+ var S3_default = defineCompoundConstituent("S3", [{
1238
+ constituent: S2_default,
1239
+ factor: 1.5
825
1240
  }]);
826
- constituents.M6 = compound_constituent_default("M6", [{
827
- constituent: constituents.M2,
828
- factor: 3
1241
+
1242
+ //#endregion
1243
+ //#region src/constituents/S4.ts
1244
+ /**
1245
+ * Shallow-water quarter-diurnal (S4).
1246
+ * Compound constituent: 2×S2
1247
+ * First overtide of S2; generated in shallow-water environments.
1248
+ * Amplitude typically 1-3% of S2; smallest of the common quarter-diurnal constituents.
1249
+ * Purely solar, so has fixed amplitude and phase at any location.
1250
+ */
1251
+ var S4_default = defineCompoundConstituent("S4", [{
1252
+ constituent: S2_default,
1253
+ factor: 2
829
1254
  }]);
830
- constituents.S6 = compound_constituent_default("S6", [{
831
- constituent: constituents.S2,
1255
+
1256
+ //#endregion
1257
+ //#region src/constituents/S6.ts
1258
+ /**
1259
+ * Shallow-water sixth-diurnal (S6).
1260
+ * Compound constituent: 3×S2
1261
+ * Second overtide of S2; generated in shallow-water environments.
1262
+ * Amplitude typically 0.5-1% of S2; smallest of the common overtides.
1263
+ * Rarely significant except in extreme shallow water or resonant systems.
1264
+ */
1265
+ var S6_default = defineCompoundConstituent("S6", [{
1266
+ constituent: S2_default,
832
1267
  factor: 3
833
1268
  }]);
834
- constituents.M8 = compound_constituent_default("M8", [{
835
- constituent: constituents.M2,
836
- factor: 4
1269
+
1270
+ //#endregion
1271
+ //#region src/constituents/SA.ts
1272
+ /**
1273
+ * Solar annual (Sa).
1274
+ * Long-term constituent driven by solar declination variations over the year.
1275
+ */
1276
+ var SA_default = defineConstituent("Sa", [
1277
+ 0,
1278
+ 0,
1279
+ 1,
1280
+ 0,
1281
+ 0,
1282
+ 0,
1283
+ 0
1284
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1285
+
1286
+ //#endregion
1287
+ //#region src/constituents/SGM.ts
1288
+ /**
1289
+ * Lunar diurnal variational constituent (σ1, sigma1).
1290
+ * Derived from Moon's declination variations.
1291
+ *
1292
+ * Note: Often has small amplitude; closely related to K1 and O1 variations.
1293
+ */
1294
+ var SGM_default = defineConstituent("SGM", [
1295
+ 1,
1296
+ -3,
1297
+ 2,
1298
+ 0,
1299
+ 0,
1300
+ 0,
1301
+ -1
1302
+ ], node_corrections_default.uO1, node_corrections_default.fO1);
1303
+
1304
+ //#endregion
1305
+ //#region src/constituents/SSA.ts
1306
+ /**
1307
+ * Solar semi-annual (Ssa).
1308
+ * Semi-annual constituent from solar declination with twice-yearly periodicity.
1309
+ */
1310
+ var SSA_default = defineConstituent("Ssa", [
1311
+ 0,
1312
+ 0,
1313
+ 2,
1314
+ 0,
1315
+ 0,
1316
+ 0,
1317
+ 0
1318
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1319
+
1320
+ //#endregion
1321
+ //#region src/constituents/T3.ts
1322
+ /**
1323
+ * Solar elliptic terdiurnal; 1.5 times T2 (larger solar elliptic semi-diurnal).
1324
+ *
1325
+ * Note: Generated only in shallow water; minimal amplitude (<0.1 cm typical).
1326
+ * Rarely significant except in extreme shallow-water or enclosed basins.
1327
+ *
1328
+ * @see NOAA CO-OPS
1329
+ */
1330
+ var T3_default = defineCompoundConstituent("T3", [{
1331
+ constituent: T2_default,
1332
+ factor: 1.5
837
1333
  }]);
1334
+
1335
+ //#endregion
1336
+ //#region src/constituents/Z0.ts
1337
+ /**
1338
+ * Mean sea level (Z0).
1339
+ * Not a tidal constituent in the strict sense, but represents the mean sea level offset
1340
+ * or the "zero" reference level used in tidal predictions.
1341
+ * No astronomical forcing; typically determined from harmonic analysis of observed data.
1342
+ */
1343
+ var Z0_default = defineConstituent("Z0", [
1344
+ 0,
1345
+ 0,
1346
+ 0,
1347
+ 0,
1348
+ 0,
1349
+ 0,
1350
+ 0
1351
+ ], node_corrections_default.uZero, node_corrections_default.fUnity);
1352
+
1353
+ //#endregion
1354
+ //#region src/constituents/index.ts
1355
+ const constituentModules = {
1356
+ "./2MK3.ts": _2MK3_default,
1357
+ "./2MK5.ts": _2MK5_default,
1358
+ "./2MO5.ts": _2MO5_default,
1359
+ "./2MS6.ts": _2MS6_default,
1360
+ "./2N2.ts": _2N2_default,
1361
+ "./2Q1.ts": _2Q1_default,
1362
+ "./2SM2.ts": _2SM2_default,
1363
+ "./3L2.ts": _3L2_default,
1364
+ "./3N2.ts": _3N2_default,
1365
+ "./EP2.ts": EP2_default,
1366
+ "./J1.ts": J1_default,
1367
+ "./K1.ts": K1_default,
1368
+ "./K2.ts": K2_default,
1369
+ "./L2.ts": L2_default,
1370
+ "./LAM2.ts": LAM2_default,
1371
+ "./LAMBDA2.ts": LAMBDA2_default,
1372
+ "./M1.ts": M1_default,
1373
+ "./M2.ts": M2_default,
1374
+ "./M3.ts": M3_default,
1375
+ "./M4.ts": M4_default,
1376
+ "./M6.ts": M6_default,
1377
+ "./M8.ts": M8_default,
1378
+ "./MA2.ts": MA2_default,
1379
+ "./MB2.ts": MB2_default,
1380
+ "./MF.ts": MF_default,
1381
+ "./MK3.ts": MK3_default,
1382
+ "./MKS2.ts": MKS2_default,
1383
+ "./MM.ts": MM_default,
1384
+ "./MN4.ts": MN4_default,
1385
+ "./MS4.ts": MS4_default,
1386
+ "./MSF.ts": MSF_default,
1387
+ "./MSQM.ts": MSQM_default,
1388
+ "./MTM.ts": MTM_default,
1389
+ "./MU2.ts": MU2_default,
1390
+ "./N2.ts": N2_default,
1391
+ "./N4.ts": N4_default,
1392
+ "./NU2.ts": NU2_default,
1393
+ "./O1.ts": O1_default,
1394
+ "./OO1.ts": OO1_default,
1395
+ "./P1.ts": P1_default,
1396
+ "./Q1.ts": Q1_default,
1397
+ "./R2.ts": R2_default,
1398
+ "./R3.ts": R3_default,
1399
+ "./RHO.ts": RHO_default,
1400
+ "./RHO1.ts": RHO1_default,
1401
+ "./S1.ts": S1_default,
1402
+ "./S2.ts": S2_default,
1403
+ "./S3.ts": S3_default,
1404
+ "./S4.ts": S4_default,
1405
+ "./S6.ts": S6_default,
1406
+ "./SA.ts": SA_default,
1407
+ "./SGM.ts": SGM_default,
1408
+ "./SSA.ts": SSA_default,
1409
+ "./T2.ts": T2_default,
1410
+ "./T3.ts": T3_default,
1411
+ "./Z0.ts": Z0_default,
1412
+ "./definition.ts": definition_default
1413
+ };
1414
+ const constituents = {};
1415
+ for (const [path, module] of Object.entries(constituentModules)) {
1416
+ if (path.includes("index.ts")) continue;
1417
+ const name = path.split("/").pop()?.replace(/\..*$/, "") ?? "";
1418
+ if (name === "definition") continue;
1419
+ constituents[name] = module;
1420
+ }
838
1421
  var constituents_default = constituents;
839
1422
 
1423
+ //#endregion
1424
+ //#region src/harmonics/prediction.ts
1425
+ const modulus = (a, b) => {
1426
+ return (a % b + b) % b;
1427
+ };
1428
+ const addExtremesOffsets = (extreme, offsets) => {
1429
+ if (typeof offsets === "undefined" || !offsets) return extreme;
1430
+ if (extreme.high && offsets.height?.high) if (offsets.height.type === "fixed") extreme.level += offsets.height.high;
1431
+ else extreme.level *= offsets.height.high;
1432
+ if (extreme.low && offsets.height?.low) if (offsets.height.type === "fixed") extreme.level += offsets.height.low;
1433
+ else extreme.level *= offsets.height.low;
1434
+ if (extreme.high && offsets.time?.high) extreme.time = new Date(extreme.time.getTime() + offsets.time.high * 60 * 1e3);
1435
+ if (extreme.low && offsets.time?.low) extreme.time = new Date(extreme.time.getTime() + offsets.time.low * 60 * 1e3);
1436
+ return extreme;
1437
+ };
1438
+ const getExtremeLabel = (label, highLowLabels) => {
1439
+ if (typeof highLowLabels !== "undefined" && typeof highLowLabels[label] !== "undefined") return highLowLabels[label];
1440
+ return {
1441
+ high: "High",
1442
+ low: "Low"
1443
+ }[label];
1444
+ };
1445
+ const predictionFactory = ({ timeline, constituents: constituents$1, start }) => {
1446
+ const getLevel = (hour, modelBaseSpeed, modelU, modelF, modelBaseValue) => {
1447
+ const amplitudes = [];
1448
+ let result = 0;
1449
+ constituents$1.forEach((constituent) => {
1450
+ const amplitude = constituent.amplitude;
1451
+ const phase = constituent.phase;
1452
+ const f = modelF[constituent.name];
1453
+ const speed = modelBaseSpeed[constituent.name];
1454
+ const u = modelU[constituent.name];
1455
+ const V0 = modelBaseValue[constituent.name];
1456
+ amplitudes.push(amplitude * f * Math.cos(speed * hour + (V0 + u) - phase));
1457
+ });
1458
+ amplitudes.forEach((item) => {
1459
+ result += item;
1460
+ });
1461
+ return result;
1462
+ };
1463
+ const prediction = {};
1464
+ prediction.getExtremesPrediction = (options) => {
1465
+ const { labels, offsets } = typeof options !== "undefined" ? options : {};
1466
+ const results = [];
1467
+ const { baseSpeed, u, f, baseValue } = prepare();
1468
+ let goingUp = false;
1469
+ let goingDown = false;
1470
+ let lastLevel = getLevel(0, baseSpeed, u[0], f[0], baseValue);
1471
+ timeline.items.forEach((time, index) => {
1472
+ const hour = timeline.hours[index];
1473
+ const level = getLevel(hour, baseSpeed, u[index], f[index], baseValue);
1474
+ if (level > lastLevel && goingDown) results.push(addExtremesOffsets({
1475
+ time: timeline.items[index - 1],
1476
+ level: lastLevel,
1477
+ high: false,
1478
+ low: true,
1479
+ label: getExtremeLabel("low", labels)
1480
+ }, offsets));
1481
+ if (level < lastLevel && goingUp) results.push(addExtremesOffsets({
1482
+ time: timeline.items[index - 1],
1483
+ level: lastLevel,
1484
+ high: true,
1485
+ low: false,
1486
+ label: getExtremeLabel("high", labels)
1487
+ }, offsets));
1488
+ if (level > lastLevel) {
1489
+ goingUp = true;
1490
+ goingDown = false;
1491
+ }
1492
+ if (level < lastLevel) {
1493
+ goingUp = false;
1494
+ goingDown = true;
1495
+ }
1496
+ lastLevel = level;
1497
+ });
1498
+ return results;
1499
+ };
1500
+ prediction.getTimelinePrediction = () => {
1501
+ const results = [];
1502
+ const { baseSpeed, u, f, baseValue } = prepare();
1503
+ timeline.items.forEach((time, index) => {
1504
+ const hour = timeline.hours[index];
1505
+ const prediction$1 = {
1506
+ time,
1507
+ hour,
1508
+ level: getLevel(hour, baseSpeed, u[index], f[index], baseValue)
1509
+ };
1510
+ results.push(prediction$1);
1511
+ });
1512
+ return results;
1513
+ };
1514
+ const prepare = () => {
1515
+ const baseAstro = astronomy_default(start);
1516
+ const baseValue = {};
1517
+ const baseSpeed = {};
1518
+ const u = [];
1519
+ const f = [];
1520
+ constituents$1.forEach((constituent) => {
1521
+ const model = constituents_default[constituent.name];
1522
+ if (!model) return;
1523
+ const value = model.value(baseAstro);
1524
+ const speed = model.speed(baseAstro);
1525
+ baseValue[constituent.name] = d2r * value;
1526
+ baseSpeed[constituent.name] = d2r * speed;
1527
+ });
1528
+ timeline.items.forEach((time) => {
1529
+ const uItem = {};
1530
+ const fItem = {};
1531
+ const itemAstro = astronomy_default(time);
1532
+ constituents$1.forEach((constituent) => {
1533
+ const model = constituents_default[constituent.name];
1534
+ if (!model) return;
1535
+ const constituentU = modulus(model.u(itemAstro), 360);
1536
+ uItem[constituent.name] = d2r * constituentU;
1537
+ fItem[constituent.name] = modulus(model.f(itemAstro), 360);
1538
+ });
1539
+ u.push(uItem);
1540
+ f.push(fItem);
1541
+ });
1542
+ return {
1543
+ baseValue,
1544
+ baseSpeed,
1545
+ u,
1546
+ f
1547
+ };
1548
+ };
1549
+ return Object.freeze(prediction);
1550
+ };
1551
+ var prediction_default = predictionFactory;
1552
+
840
1553
  //#endregion
841
1554
  //#region src/harmonics/index.ts
842
1555
  const getDate = (time) => {
@@ -860,21 +1573,19 @@ const getTimeline = (start, end, seconds = 600) => {
860
1573
  hours
861
1574
  };
862
1575
  };
863
- const harmonicsFactory = ({ harmonicConstituents, phaseKey, offset }) => {
1576
+ const harmonicsFactory = ({ harmonicConstituents, offset }) => {
864
1577
  if (!Array.isArray(harmonicConstituents)) throw new Error("Harmonic constituents are not an array");
865
1578
  const constituents$1 = [];
866
1579
  harmonicConstituents.forEach((constituent) => {
867
1580
  if (typeof constituent.name === "undefined") throw new Error("Harmonic constituents must have a name property");
868
1581
  if (constituents_default[constituent.name] !== void 0) constituents$1.push({
869
1582
  ...constituent,
870
- _model: constituents_default[constituent.name],
871
- _phase: d2r * constituent[phaseKey]
1583
+ phase: d2r * constituent.phase
872
1584
  });
873
1585
  });
874
1586
  if (offset !== false) constituents$1.push({
875
1587
  name: "Z0",
876
- _model: constituents_default.Z0,
877
- _phase: 0,
1588
+ phase: 0,
878
1589
  amplitude: offset
879
1590
  });
880
1591
  let start = /* @__PURE__ */ new Date();
@@ -902,13 +1613,12 @@ var harmonics_default = harmonicsFactory;
902
1613
  const tidePredictionFactory = (constituents$1, options = {}) => {
903
1614
  const harmonicsOptions = {
904
1615
  harmonicConstituents: constituents$1,
905
- phaseKey: "phase_GMT",
906
1616
  offset: false,
907
1617
  ...options
908
1618
  };
909
1619
  return {
910
- getTimelinePrediction: ({ start, end }) => {
911
- return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction().getTimelinePrediction();
1620
+ getTimelinePrediction: ({ start, end, timeFidelity }) => {
1621
+ return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction({ timeFidelity }).getTimelinePrediction();
912
1622
  },
913
1623
  getExtremesPrediction: ({ start, end, labels, offsets, timeFidelity }) => {
914
1624
  return harmonics_default(harmonicsOptions).setTimeSpan(start, end).prediction({ timeFidelity }).getExtremesPrediction({