@idm-plugin/meteo2 0.2.4 → 0.2.6
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 +28 -25
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -157,13 +157,13 @@ class P0 {
|
|
|
157
157
|
}
|
|
158
158
|
const L = [];
|
|
159
159
|
for (let a = 0; a < n.ts.length; a++) {
|
|
160
|
-
const N = this.calculateDouglasScale(n["waves_height-surface"][a], n["waves_direction-surface"][a], n["waves_period-surface"][a]), t = this.calculateDouglasScale(n["wwaves_height-surface"][a], n["wwaves_direction-surface"][a], n["wwaves_period-surface"][a]),
|
|
160
|
+
const N = this.calculateDouglasScale(n["waves_height-surface"][a], n["waves_direction-surface"][a], n["waves_period-surface"][a]), t = this.calculateDouglasScale(n["wwaves_height-surface"][a], n["wwaves_direction-surface"][a], n["wwaves_period-surface"][a]), m = this.calculateDouglasScale(n["swell1_height-surface"][a], n["swell1_direction-surface"][a], n["swell1_period-surface"][a]), V = this.calculateDouglasScale(n["swell2_height-surface"][a], n["swell2_direction-surface"][a], n["swell2_period-surface"][a]);
|
|
161
161
|
L.push({
|
|
162
162
|
utc: e(n.ts[a]).utc().format(),
|
|
163
163
|
wave: {
|
|
164
164
|
sig: N,
|
|
165
165
|
wd: t,
|
|
166
|
-
swell:
|
|
166
|
+
swell: m,
|
|
167
167
|
swell2: V
|
|
168
168
|
}
|
|
169
169
|
});
|
|
@@ -307,7 +307,7 @@ var A0 = { exports: {} };
|
|
|
307
307
|
for (var A = 0; A < z.length; A++)
|
|
308
308
|
z[A] = N(z[A]);
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function m(z, A) {
|
|
311
311
|
for (var c = 0; c < A; c++)
|
|
312
312
|
z[c] = Math.round((z[c - 1] || 0) + z[c] * 6e4);
|
|
313
313
|
z[A - 1] = 1 / 0;
|
|
@@ -320,7 +320,7 @@ var A0 = { exports: {} };
|
|
|
320
320
|
}
|
|
321
321
|
function v(z) {
|
|
322
322
|
var A = z.split("|"), c = A[2].split(" "), d = A[3].split(""), R = A[4].split(" ");
|
|
323
|
-
return t(c), t(d), t(R),
|
|
323
|
+
return t(c), t(d), t(R), m(R, d.length), {
|
|
324
324
|
name: A[0],
|
|
325
325
|
abbrs: V(A[1].split(" "), d),
|
|
326
326
|
offsets: V(c, d),
|
|
@@ -388,7 +388,7 @@ var A0 = { exports: {} };
|
|
|
388
388
|
C.prototype.scoreOffsetAt = function(z) {
|
|
389
389
|
this.offsetScore += Math.abs(this.zone.utcOffset(z.at) - z.offset), this.zone.abbr(z.at).replace(/[^A-Z]/g, "") !== z.abbr && this.abbrScore++;
|
|
390
390
|
};
|
|
391
|
-
function
|
|
391
|
+
function E(z, A) {
|
|
392
392
|
for (var c, d; d = ((A.at - z.at) / 12e4 | 0) * 6e4; )
|
|
393
393
|
c = new l(new Date(z.at + d)), c.offset === z.offset ? z = c : A = c;
|
|
394
394
|
return z;
|
|
@@ -396,7 +396,7 @@ var A0 = { exports: {} };
|
|
|
396
396
|
function D() {
|
|
397
397
|
var z = (/* @__PURE__ */ new Date()).getFullYear() - 2, A = new l(new Date(z, 0, 1)), c = A.offset, d = [A], R, T, u, r;
|
|
398
398
|
for (r = 1; r < 48; r++)
|
|
399
|
-
u = new Date(z, r, 1).getTimezoneOffset(), u !== c && (T = new l(new Date(z, r, 1)), R =
|
|
399
|
+
u = new Date(z, r, 1).getTimezoneOffset(), u !== c && (T = new l(new Date(z, r, 1)), R = E(A, T), d.push(R), d.push(new l(new Date(R.at + 6e4))), A = T, c = u);
|
|
400
400
|
for (r = 0; r < 4; r++)
|
|
401
401
|
d.push(new l(new Date(z + r, 0, 1))), d.push(new l(new Date(z + r, 6, 1)));
|
|
402
402
|
return d;
|
|
@@ -1419,7 +1419,8 @@ const V0 = [
|
|
|
1419
1419
|
rank: 0,
|
|
1420
1420
|
name: "Best Match",
|
|
1421
1421
|
alias: "BEST MATCH",
|
|
1422
|
-
model: "best_match"
|
|
1422
|
+
model: "best_match",
|
|
1423
|
+
models: ["best_match"]
|
|
1423
1424
|
},
|
|
1424
1425
|
{
|
|
1425
1426
|
rank: 1,
|
|
@@ -1432,7 +1433,8 @@ const V0 = [
|
|
|
1432
1433
|
tips: "3-25km",
|
|
1433
1434
|
length: 16,
|
|
1434
1435
|
frequency: 1,
|
|
1435
|
-
models: [
|
|
1436
|
+
// models: ['gfs_seamless', 'gfs_global', 'gfs_hrrr', 'ncep_nbm_conus', 'gfs_graphcast025'],
|
|
1437
|
+
models: ["gfs_seamless"],
|
|
1436
1438
|
// ncep_gfs013: 美国国家环境预报中心(NCEP)的全球预报系统(GFS),0.13度
|
|
1437
1439
|
// ncep_gfs025: 美国国家环境预报中心(NCEP)的全球预报系统(GFS),0.25度
|
|
1438
1440
|
// ncep_gfs_graphcast025: 是美国国家环境预测中心(NCEP)设立的一个实验性中期全球天气预报系统
|
|
@@ -1561,7 +1563,8 @@ const V0 = [
|
|
|
1561
1563
|
rank: 0,
|
|
1562
1564
|
name: "Best Match",
|
|
1563
1565
|
alias: "BEST MATCH",
|
|
1564
|
-
model: "best_match"
|
|
1566
|
+
model: "best_match",
|
|
1567
|
+
models: ["best_match"]
|
|
1565
1568
|
},
|
|
1566
1569
|
{
|
|
1567
1570
|
rank: 1,
|
|
@@ -1809,23 +1812,23 @@ class G0 {
|
|
|
1809
1812
|
async parseWeatherData(M, b, p = {}) {
|
|
1810
1813
|
var o, W, q, X, n, L, a, N, t;
|
|
1811
1814
|
const O = [], Y = Math.pow(10, p.precision || 6);
|
|
1812
|
-
for (let
|
|
1813
|
-
const V = M[
|
|
1814
|
-
if (
|
|
1815
|
+
for (let m = 0; m < M.length; m++) {
|
|
1816
|
+
const V = M[m], v = V.utcOffsetSeconds(), g = V.timezone(), F = V.current(), _ = V.hourly(), l = V.sixHourly(), C = V.daily(), E = {};
|
|
1817
|
+
if (E.timezone = g || void 0, E.offset = this.prettyTimezoneOffset(v), E.model = b.models[m], F) {
|
|
1815
1818
|
const D = e();
|
|
1816
|
-
|
|
1819
|
+
E.current = {
|
|
1817
1820
|
time: e.unix(Number(F.time())).utc().format()
|
|
1818
1821
|
};
|
|
1819
1822
|
for (let s = 0; s < F.variablesLength(); s++) {
|
|
1820
1823
|
const B = F.variables(s).value();
|
|
1821
|
-
|
|
1824
|
+
E.current[b.current[s]] = isNaN(B) ? null : Math.round(B * Y) / Y;
|
|
1822
1825
|
}
|
|
1823
1826
|
const I = e();
|
|
1824
1827
|
this.debug && Z.debug("[%s] fetch current variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1825
1828
|
}
|
|
1826
1829
|
if (_) {
|
|
1827
1830
|
const D = e(), I = e.unix(Number(_.time())).add(b.fake ? 1 : 0, "year");
|
|
1828
|
-
|
|
1831
|
+
E.hourly = {
|
|
1829
1832
|
date: I.utc().format(),
|
|
1830
1833
|
time: this.range(Number(_.time()), Number(_.timeEnd()), _.interval()).map(
|
|
1831
1834
|
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
@@ -1833,14 +1836,14 @@ class G0 {
|
|
|
1833
1836
|
};
|
|
1834
1837
|
for (let B = 0; B < _.variablesLength(); B++) {
|
|
1835
1838
|
const h = (q = (W = (o = _.variables(B).valuesArray()) == null ? void 0 : o.toString()) == null ? void 0 : W.split(",")) == null ? void 0 : q.map((K) => isNaN(K) ? null : Math.round(Number(K) * Y) / Y);
|
|
1836
|
-
|
|
1839
|
+
E.hourly[b.hourly[B]] = h;
|
|
1837
1840
|
}
|
|
1838
1841
|
const s = e();
|
|
1839
1842
|
this.debug && Z.debug("[%s] fetch hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1840
1843
|
}
|
|
1841
1844
|
if (l) {
|
|
1842
1845
|
const D = e(), I = e.unix(Number(l.time())).add(b.fake ? 1 : 0, "year");
|
|
1843
|
-
|
|
1846
|
+
E.sixHourly = {
|
|
1844
1847
|
date: I.utc().format(),
|
|
1845
1848
|
time: this.range(Number(l.time()), Number(l.timeEnd()), l.interval()).map(
|
|
1846
1849
|
(B) => e.unix(B).add(b.fake ? 1 : 0, "year").diff(I, "h")
|
|
@@ -1848,26 +1851,26 @@ class G0 {
|
|
|
1848
1851
|
};
|
|
1849
1852
|
for (let B = 0; B < l.variablesLength(); B += p.memberLength ?? 1) {
|
|
1850
1853
|
const h = (L = (n = (X = l.variables(B).valuesArray()) == null ? void 0 : X.toString()) == null ? void 0 : n.split(",")) == null ? void 0 : L.map((K) => isNaN(K) ? null : Math.round(Number(K) * Y) / Y);
|
|
1851
|
-
l.variables(B),
|
|
1854
|
+
l.variables(B), E.sixHourly[b.six_hourly[B / (p.memberLength ?? 1)]] = h;
|
|
1852
1855
|
}
|
|
1853
1856
|
const s = e();
|
|
1854
1857
|
this.debug && Z.debug("[%s] fetch 6-hourly variables cost: %d ms", p.requestId, s.diff(D, "ms"));
|
|
1855
1858
|
}
|
|
1856
1859
|
if (C) {
|
|
1857
1860
|
const D = e();
|
|
1858
|
-
|
|
1861
|
+
E.daily = {
|
|
1859
1862
|
time: this.range(Number(C.time()), Number(C.timeEnd()), C.interval()).map(
|
|
1860
1863
|
(s) => e.unix(s).add(b.fake ? 1 : 0, "year").utc().format()
|
|
1861
1864
|
)
|
|
1862
1865
|
};
|
|
1863
1866
|
for (let s = 0; s < C.variablesLength(); s += p.memberLength ?? 1) {
|
|
1864
1867
|
const B = (t = (N = (a = C.variables(s).valuesArray()) == null ? void 0 : a.toString()) == null ? void 0 : N.split(",")) == null ? void 0 : t.map((h) => isNaN(h) ? null : Math.round(Number(h) * Y) / Y);
|
|
1865
|
-
|
|
1868
|
+
E.daily[b.daily[s / (p.memberLength ?? 1)]] = B;
|
|
1866
1869
|
}
|
|
1867
1870
|
const I = e();
|
|
1868
1871
|
this.debug && Z.debug("[%s] fetch daily variables cost: %d ms", p.requestId, I.diff(D, "ms"));
|
|
1869
1872
|
}
|
|
1870
|
-
O.push(
|
|
1873
|
+
O.push(E);
|
|
1871
1874
|
}
|
|
1872
1875
|
return O;
|
|
1873
1876
|
}
|
|
@@ -1987,7 +1990,7 @@ class G0 {
|
|
|
1987
1990
|
precision: 6,
|
|
1988
1991
|
selfHosted: !0
|
|
1989
1992
|
}) {
|
|
1990
|
-
var N, t,
|
|
1993
|
+
var N, t, m;
|
|
1991
1994
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot forecast params: %j", W.requestId, { lat: M, lng: b, datetime: p, simplify: O, withDaily: Y, withHourly: o, options: W });
|
|
1992
1995
|
const q = {
|
|
1993
1996
|
apikey: this.apikey,
|
|
@@ -2003,7 +2006,7 @@ class G0 {
|
|
|
2003
2006
|
const V = this.timezoneOffset(M, b);
|
|
2004
2007
|
X = e.utc(p).utcOffset(V), X.subtract(V > 0 ? V : -V, "h");
|
|
2005
2008
|
}
|
|
2006
|
-
Y && (q.daily = ((t = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : t.split(",")) || []), X || (W.forecastDays = W.forecastDays || 1, W.pastDays = 0, o = !0), o && (q.hourly = ((
|
|
2009
|
+
Y && (q.daily = ((t = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : t.split(",")) || []), X || (W.forecastDays = W.forecastDays || 1, W.pastDays = 0, o = !0), o && (q.hourly = ((m = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : m.split(",")) || []), W.pastDays = W.pastDays || 0, W.pastDays = W.pastDays > 7 ? 7 : W.pastDays < 0 ? 0 : W.pastDays, W.forecastDays = W.forecastDays ?? 1, W.forecastDays = W.forecastDays > 14 ? 14 : W.forecastDays < 0 ? 1 : W.forecastDays, this.prepare(X == null ? void 0 : X.utc().format(), !1, q, W);
|
|
2007
2010
|
const n = await this.weatherForecast(q, W), L = {
|
|
2008
2011
|
apikey: this.apikey,
|
|
2009
2012
|
latitude: M,
|
|
@@ -2041,7 +2044,7 @@ class G0 {
|
|
|
2041
2044
|
async spotHistorical(M, b, p, O, Y = !0, o = !0, W = !1, q = {
|
|
2042
2045
|
precision: 6
|
|
2043
2046
|
}) {
|
|
2044
|
-
var
|
|
2047
|
+
var m, V;
|
|
2045
2048
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot historical params: %j", q.requestId, { lat: M, lng: b, startDate: p, endDate: O, withMarine: W, options: q });
|
|
2046
2049
|
const X = this.timezoneOffset(M, b), n = e.utc(p).utcOffset(X), L = e.utc(O).utcOffset(X);
|
|
2047
2050
|
n.subtract(X > 0 ? X : -X, "h"), L.subtract(X > 0 ? X : -X, "h");
|
|
@@ -2051,7 +2054,7 @@ class G0 {
|
|
|
2051
2054
|
longitude: b,
|
|
2052
2055
|
cell_selection: "sea",
|
|
2053
2056
|
wind_speed_unit: "kn",
|
|
2054
|
-
models: ((
|
|
2057
|
+
models: ((m = q.weatherModels) == null ? void 0 : m.split(",")) || ["best_match"],
|
|
2055
2058
|
timezone: "auto",
|
|
2056
2059
|
url: this.HISTORICAL.OM_URL,
|
|
2057
2060
|
start_date: n.format("YYYY-MM-DD"),
|