@idm-plugin/meteo2 0.4.2 → 0.4.3
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 +36 -36
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,8 +36,8 @@ class m0 {
|
|
|
36
36
|
timeout: 3e4
|
|
37
37
|
}, X = L(), R = X.valueOf();
|
|
38
38
|
A.isBefore(X.subtract(1, "month")) && (r == null || r.warn("[%s] get history meteo on %s: %j", Y.requestId, A.format(), q));
|
|
39
|
-
const T = "https://aod4idm.idmwx.com/api/ocean/point", d = await $.get(T, q).json(),
|
|
40
|
-
if (r == null || r.info("[%s] get meteo(cost: %d ms) from %s with options: %j", Y.requestId,
|
|
39
|
+
const T = "https://aod4idm.idmwx.com/api/ocean/point", d = await $.get(T, q).json(), N = L().valueOf();
|
|
40
|
+
if (r == null || r.info("[%s] get meteo(cost: %d ms) from %s with options: %j", Y.requestId, N - R, T, q), (d == null ? void 0 : d.code) === 0)
|
|
41
41
|
return {
|
|
42
42
|
...d.data,
|
|
43
43
|
source: o
|
|
@@ -71,8 +71,8 @@ class m0 {
|
|
|
71
71
|
timeout: 3e4
|
|
72
72
|
}, X = L(), R = X.valueOf();
|
|
73
73
|
A.isBefore(X.subtract(1, "month")) && (r == null || r.warn("[%s] get history factors on %s: %j", Y.requestId, A.format(), q));
|
|
74
|
-
const T = "https://aod4idm.idmwx.com/api/ocean/factor", d = await $.get(T, q).json(),
|
|
75
|
-
if (r == null || r.info("[%s] get factors(cost: %d ms) from %s with options: %j", Y.requestId,
|
|
74
|
+
const T = "https://aod4idm.idmwx.com/api/ocean/factor", d = await $.get(T, q).json(), N = L().valueOf();
|
|
75
|
+
if (r == null || r.info("[%s] get factors(cost: %d ms) from %s with options: %j", Y.requestId, N - R, T, q), (d == null ? void 0 : d.code) === 0)
|
|
76
76
|
return {
|
|
77
77
|
...d.data,
|
|
78
78
|
source: o
|
|
@@ -133,8 +133,8 @@ class m0 {
|
|
|
133
133
|
}).json();
|
|
134
134
|
X = L().valueOf(), r == null || r.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", O.requestId, X - A, o);
|
|
135
135
|
for (let d = 0; d < q.ts.length; d++) {
|
|
136
|
-
const
|
|
137
|
-
|
|
136
|
+
const N = this.populateUVFactor(q["wind_u-surface"][d], q["wind_v-surface"][d], !1, O);
|
|
137
|
+
N.scale = this.calculateBeaufortWindForceScale(N.speed), Y.push({
|
|
138
138
|
utc: L(q.ts[d]).utc().format(),
|
|
139
139
|
temp: q["temp-surface"][d] ? Math.round((q["temp-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
140
140
|
dp_temp: q["dewpoint-surface"][d] ? Math.round((q["dewpoint-surface"][d] - 273.15) * 100) / 100 : void 0,
|
|
@@ -143,7 +143,7 @@ class m0 {
|
|
|
143
143
|
inter3hSnow: q["past3hsnowprecip-surface"][d] ? Math.round(q["past3hsnowprecip-surface"][d] * 1e3 * 1e3) / 1e3 : 0,
|
|
144
144
|
inter3hConv: q["past3hconvprecip-surface"][d] ? Math.round(q["past3hconvprecip-surface"][d] * 1e3 * 1e3) / 1e3 : 0
|
|
145
145
|
},
|
|
146
|
-
wind:
|
|
146
|
+
wind: N,
|
|
147
147
|
gusts: {
|
|
148
148
|
speed: Math.round((q["gust-surface"][d] || 0) * 100) / 100,
|
|
149
149
|
kts: this.convertMs2Kts(q["gust-surface"][d])
|
|
@@ -158,20 +158,20 @@ class m0 {
|
|
|
158
158
|
}
|
|
159
159
|
const T = [];
|
|
160
160
|
for (let d = 0; d < R.ts.length; d++) {
|
|
161
|
-
const
|
|
161
|
+
const N = this.calculateDouglasScale(R["waves_height-surface"][d], R["waves_direction-surface"][d], R["waves_period-surface"][d]), S = this.calculateDouglasScale(R["wwaves_height-surface"][d], R["wwaves_direction-surface"][d], R["wwaves_period-surface"][d]), l = this.calculateDouglasScale(R["swell1_height-surface"][d], R["swell1_direction-surface"][d], R["swell1_period-surface"][d]), V = this.calculateDouglasScale(R["swell2_height-surface"][d], R["swell2_direction-surface"][d], R["swell2_period-surface"][d]);
|
|
162
162
|
T.push({
|
|
163
163
|
utc: L(R.ts[d]).utc().format(),
|
|
164
164
|
wave: {
|
|
165
|
-
sig:
|
|
166
|
-
wd:
|
|
165
|
+
sig: N,
|
|
166
|
+
wd: S,
|
|
167
167
|
swell: l,
|
|
168
168
|
swell2: V
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
for (const d of Y) {
|
|
173
|
-
const
|
|
174
|
-
d.wave =
|
|
173
|
+
const N = T.find((S) => S.utc === d.utc);
|
|
174
|
+
d.wave = N == null ? void 0 : N.wave;
|
|
175
175
|
}
|
|
176
176
|
} catch (A) {
|
|
177
177
|
r.warn("[%s] get-gfs-factor failed: %s", O.requestId, A);
|
|
@@ -296,7 +296,7 @@ var c0 = { exports: {} };
|
|
|
296
296
|
function d(z) {
|
|
297
297
|
return z > 96 ? z - 87 : z > 64 ? z - 29 : z - 48;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function N(z) {
|
|
300
300
|
var c = 0, W = z.split("."), a = W[0], n = W[1] || "", i = 1, t, f = 0, B = 1;
|
|
301
301
|
for (z.charCodeAt(0) === 45 && (c = 1, B = -1), c; c < a.length; c++)
|
|
302
302
|
t = d(a.charCodeAt(c)), f = 60 * f + t;
|
|
@@ -304,9 +304,9 @@ var c0 = { exports: {} };
|
|
|
304
304
|
i = i / 60, t = d(n.charCodeAt(c)), f += t * i;
|
|
305
305
|
return f * B;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function S(z) {
|
|
308
308
|
for (var c = 0; c < z.length; c++)
|
|
309
|
-
z[c] =
|
|
309
|
+
z[c] = N(z[c]);
|
|
310
310
|
}
|
|
311
311
|
function l(z, c) {
|
|
312
312
|
for (var W = 0; W < c; W++)
|
|
@@ -321,7 +321,7 @@ var c0 = { exports: {} };
|
|
|
321
321
|
}
|
|
322
322
|
function E(z) {
|
|
323
323
|
var c = z.split("|"), W = c[2].split(" "), a = c[3].split(""), n = c[4].split(" ");
|
|
324
|
-
return
|
|
324
|
+
return S(W), S(a), S(n), l(n, a.length), {
|
|
325
325
|
name: c[0],
|
|
326
326
|
abbrs: V(c[1].split(" "), a),
|
|
327
327
|
offsets: V(W, a),
|
|
@@ -407,7 +407,7 @@ var c0 = { exports: {} };
|
|
|
407
407
|
}
|
|
408
408
|
function m(z, c) {
|
|
409
409
|
var W, a;
|
|
410
|
-
for (
|
|
410
|
+
for (S(c), W = 0; W < c.length; W++)
|
|
411
411
|
a = c[W], A[a] = A[a] || {}, A[a][z] = !0;
|
|
412
412
|
}
|
|
413
413
|
function s(z) {
|
|
@@ -513,7 +513,7 @@ var c0 = { exports: {} };
|
|
|
513
513
|
var c = Array.prototype.slice.call(arguments, 0, -1), W = arguments[arguments.length - 1], a = M.utc.apply(null, c), n;
|
|
514
514
|
return !M.isMoment(z) && x(a) && (n = K(W)) && a.add(n.parse(a), "minutes"), a.tz(W), a;
|
|
515
515
|
}
|
|
516
|
-
U.version = b, U.dataVersion = "", U._zones = p, U._links = O, U._names = Y, U._countries = o, U.add = z0, U.link = b0, U.load = X0, U.zone = K, U.zoneExists = j, U.guess = F, U.names = q0, U.Zone = h, U.unpack = E, U.unpackBase60 =
|
|
516
|
+
U.version = b, U.dataVersion = "", U._zones = p, U._links = O, U._names = Y, U._countries = o, U.add = z0, U.link = b0, U.load = X0, U.zone = K, U.zoneExists = j, U.guess = F, U.names = q0, U.Zone = h, U.unpack = E, U.unpackBase60 = N, U.needsOffset = x, U.moveInvalidForward = !0, U.moveAmbiguousForward = !1, U.countries = o0, U.zonesForCountry = a0;
|
|
517
517
|
var D = M.fn;
|
|
518
518
|
M.tz = U, M.defaultZone = null, M.updateOffset = function(z, c) {
|
|
519
519
|
var W = M.defaultZone, a;
|
|
@@ -1561,7 +1561,7 @@ class C0 {
|
|
|
1561
1561
|
* @private
|
|
1562
1562
|
*/
|
|
1563
1563
|
async parseWeatherData(M, b, p = {}) {
|
|
1564
|
-
var Y, A, q, X, R, T, d,
|
|
1564
|
+
var Y, A, q, X, R, T, d, N, S, l;
|
|
1565
1565
|
const O = [], o = Math.pow(10, p.precision || 6);
|
|
1566
1566
|
for (let V = 0; V < M.length; V++) {
|
|
1567
1567
|
const E = M[V], h = E.utcOffsetSeconds(), y = E.timezone(), _ = E.current(), I = E.hourly(), G = E.sixHourly(), Q = E.daily(), P = {};
|
|
@@ -1615,7 +1615,7 @@ class C0 {
|
|
|
1615
1615
|
)
|
|
1616
1616
|
};
|
|
1617
1617
|
for (let s = 0; s < Q.variablesLength(); s += p.memberLength ?? 1) {
|
|
1618
|
-
const u = (l = (
|
|
1618
|
+
const u = (l = (S = (N = Q.variables(s).valuesArray()) == null ? void 0 : N.toString()) == null ? void 0 : S.split(",")) == null ? void 0 : l.map((F) => isNaN(F) ? null : Math.round(Number(F) * o) / o);
|
|
1619
1619
|
P.daily[b.daily[s / (p.memberLength ?? 1)]] = u;
|
|
1620
1620
|
}
|
|
1621
1621
|
const m = L();
|
|
@@ -1741,7 +1741,7 @@ class C0 {
|
|
|
1741
1741
|
precision: 6,
|
|
1742
1742
|
selfHosted: !0
|
|
1743
1743
|
}) {
|
|
1744
|
-
var
|
|
1744
|
+
var N, S, l;
|
|
1745
1745
|
b = this.toStdLng(b), this.debug && Z.info("[%s] spot forecast params: %j", A.requestId, { lat: M, lng: b, datetime: p, simplify: O, withDaily: o, withHourly: Y, options: A });
|
|
1746
1746
|
const q = {
|
|
1747
1747
|
apikey: this.apikey,
|
|
@@ -1749,7 +1749,7 @@ class C0 {
|
|
|
1749
1749
|
longitude: b,
|
|
1750
1750
|
cell_selection: "sea",
|
|
1751
1751
|
wind_speed_unit: "kn",
|
|
1752
|
-
models: ((
|
|
1752
|
+
models: ((N = A.weatherModels) == null ? void 0 : N.split(",")) || ["best_match"],
|
|
1753
1753
|
timezone: "auto"
|
|
1754
1754
|
};
|
|
1755
1755
|
let X;
|
|
@@ -1757,7 +1757,7 @@ class C0 {
|
|
|
1757
1757
|
const V = this.timezoneOffset(M, b);
|
|
1758
1758
|
X = L.utc(p).utcOffset(V), X.subtract(V > 0 ? V : -V, "h");
|
|
1759
1759
|
}
|
|
1760
|
-
o && (q.daily = ((
|
|
1760
|
+
o && (q.daily = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : S.split(",")) || []), X || (A.forecastDays = A.forecastDays || 1, A.pastDays = 0, Y = !0), Y && (q.hourly = ((l = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : l.split(",")) || []), A.pastDays = A.pastDays || 0, A.pastDays = A.pastDays > 7 ? 7 : A.pastDays < 0 ? 0 : A.pastDays, A.forecastDays = A.forecastDays ?? 1, A.forecastDays = A.forecastDays > 14 ? 14 : A.forecastDays < 0 ? 1 : A.forecastDays, this.prepare(X == null ? void 0 : X.utc().format(), !1, q, A);
|
|
1761
1761
|
const R = await this.weatherForecast(q, A), T = {
|
|
1762
1762
|
apikey: this.apikey,
|
|
1763
1763
|
latitude: M,
|
|
@@ -1812,8 +1812,8 @@ class C0 {
|
|
|
1812
1812
|
end_date: T.format("YYYY-MM-DD")
|
|
1813
1813
|
};
|
|
1814
1814
|
o && (d.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), Y && (d.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
|
|
1815
|
-
const
|
|
1816
|
-
let
|
|
1815
|
+
const N = await this.weatherForecast(d, q);
|
|
1816
|
+
let S;
|
|
1817
1817
|
if (A) {
|
|
1818
1818
|
const E = {
|
|
1819
1819
|
apikey: this.apikey,
|
|
@@ -1829,9 +1829,9 @@ class C0 {
|
|
|
1829
1829
|
start_date: R.format("YYYY-MM-DD"),
|
|
1830
1830
|
end_date: T.format("YYYY-MM-DD")
|
|
1831
1831
|
};
|
|
1832
|
-
|
|
1832
|
+
S = await this.marineForecast(E, q);
|
|
1833
1833
|
}
|
|
1834
|
-
return { weather:
|
|
1834
|
+
return { weather: N, marine: S };
|
|
1835
1835
|
}
|
|
1836
1836
|
/**
|
|
1837
1837
|
* 季节预报数据
|
|
@@ -1918,21 +1918,21 @@ class C0 {
|
|
|
1918
1918
|
if (A.code === 0) {
|
|
1919
1919
|
const q = A.data, X = k.standardWeatherModels();
|
|
1920
1920
|
for (const R of X) {
|
|
1921
|
-
const T = k.autoPickSubCategories(R.alias),
|
|
1921
|
+
const T = k.autoPickSubCategories(R.alias), N = q.filter((S) => T.includes(S.category)).map((S) => {
|
|
1922
1922
|
var l, V, E, h, y, _;
|
|
1923
1923
|
return {
|
|
1924
|
-
category:
|
|
1924
|
+
category: S.category,
|
|
1925
1925
|
meta: {
|
|
1926
|
-
endTime: L.unix((l =
|
|
1927
|
-
availabilityTime: L.unix((V =
|
|
1928
|
-
initialisationTime: L.unix((E =
|
|
1929
|
-
modificationTime: L.unix((h =
|
|
1930
|
-
temporalResolution: Math.round(((y =
|
|
1931
|
-
frequency: Math.round(((_ =
|
|
1926
|
+
endTime: L.unix((l = S.meta) == null ? void 0 : l.data_end_time).utc().format(),
|
|
1927
|
+
availabilityTime: L.unix((V = S.meta) == null ? void 0 : V.last_run_availability_time).utc().format(),
|
|
1928
|
+
initialisationTime: L.unix((E = S.meta) == null ? void 0 : E.last_run_initialisation_time).utc().format(),
|
|
1929
|
+
modificationTime: L.unix((h = S.meta) == null ? void 0 : h.last_run_modification_time).utc().format(),
|
|
1930
|
+
temporalResolution: Math.round(((y = S.meta) == null ? void 0 : y.temporal_resolution_seconds) / 3600),
|
|
1931
|
+
frequency: Math.round(((_ = S.meta) == null ? void 0 : _.update_interval_seconds) / 3600)
|
|
1932
1932
|
}
|
|
1933
1933
|
};
|
|
1934
1934
|
});
|
|
1935
|
-
|
|
1935
|
+
N.length && (this.METEO2_UPDATE[R.alias] = N);
|
|
1936
1936
|
}
|
|
1937
1937
|
this.METEO2_UPDATE.version = p + 1, this.METEO2_UPDATE.etime = O.unix();
|
|
1938
1938
|
}
|