@idm-plugin/meteo2 0.9.9 → 1.0.1

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.
@@ -29,6 +29,7 @@ export interface OMParams {
29
29
  apikey?: string;
30
30
  fake?: boolean;
31
31
  fakes?: boolean[];
32
+ meta?: any;
32
33
  }
33
34
  /**
34
35
  * @see https://open-meteo.com/en/docs
@@ -44,20 +45,48 @@ export declare class MeteoHelper2 {
44
45
  private readonly SEASONAL;
45
46
  private METEO2_UPDATE;
46
47
  constructor(apikey: string, debug?: boolean);
48
+ /**
49
+ * 标准大气模式
50
+ */
47
51
  standardWeatherModels(): Promise<any>;
52
+ /**
53
+ * 标准海洋模式
54
+ */
48
55
  standardMarineModels(): Promise<any>;
56
+ /**
57
+ * 自动匹配大气模式和海洋模式
58
+ * @param model0
59
+ */
49
60
  autoPickMeteoModel(model0?: string): Promise<OMOptions>;
61
+ /**
62
+ * 生成指定范围内的数字序列
63
+ * @param start
64
+ * @param stop
65
+ * @param step
66
+ */
50
67
  static range(start: number, stop: number, step: number): number[];
51
68
  /**
52
69
  * 大气数据
53
70
  * @param params
54
71
  * @param callback
72
+ * @param seasonal 是否季节预报, 季节预报不调整时间区间
73
+ * @param climate 是否气候预报, 气候预报不调整时间区间
74
+ * @param historical 是否历史数据, 历史数据不调整时间区间
75
+ * @param options
76
+ */
77
+ weatherForecast(params: any, callback: Function | undefined, seasonal: boolean, climate: boolean, historical: boolean, options?: OMOptions): Promise<any[]>;
78
+ /**
79
+ * 尝试调用天气接口, 并解析数据
80
+ * @param url
81
+ * @param params
82
+ * @param callback
83
+ * @param fakeYear
55
84
  * @param options
85
+ * @private
56
86
  */
57
- weatherForecast(params: any, callback: Function | undefined, options?: OMOptions): Promise<any[]>;
87
+ private tryToFetchWeatherApi;
58
88
  /**
59
89
  * 海洋数据
60
- *
61
90
  * Data Set | Region | Spatial Resolution | Temporal Resolution | Data Availability | Update frequency
62
91
  * MeteoFrance MFWAM | Global | 0.08° (~8 km) | 3-Hourly | October 2021 with 10 day forecast | Every 12 hours
63
92
  * MeteoFrance SMOC Currents, Tides & SST | Global | 0.08° (~8 km) | Hourly | January 2022 with 10 day | forecast Every 24 hours
@@ -73,9 +102,35 @@ export declare class MeteoHelper2 {
73
102
  */
74
103
  marineForecast(params: any, options?: OMOptions): Promise<any[]>;
75
104
  /**
76
- * 解析请求数据
105
+ * 尝试调用海洋接口
106
+ * @param url
107
+ * @param params
108
+ * @param options
109
+ * @private
110
+ */
111
+ private tryToFetchMarineApi;
112
+ /**
113
+ * 检查时间区间, 并调整为合理范围(不超时90天)
114
+ * @param startDate
115
+ * @param endDate
116
+ * @param adjustable 是否季节预报, 季节预报不调整时间区间
117
+ * @param options
118
+ * @private
119
+ */
120
+ private checkTimeInterval;
121
+ /**
122
+ * 从消息中提取时间区间, 并调整为合理范围
123
+ * @param message
124
+ * @param interval
125
+ * @param options
126
+ * @private
127
+ */
128
+ private matchDateRange;
129
+ /**
130
+ * 解析天气数据
77
131
  * @param rsps
78
132
  * @param params
133
+ * @param fakeYear 对应用前一年数据的预报进行时间调整
79
134
  * @param options
80
135
  * @private
81
136
  */
@@ -88,21 +143,49 @@ export declare class MeteoHelper2 {
88
143
  */
89
144
  private parseSeasonalDailyVariable;
90
145
  private mergeSegments;
146
+ /**
147
+ * 合并天气数据, 以IFS025为主, 并用IFS的能见度数据补全IFS025
148
+ * @param rows
149
+ * @private
150
+ */
91
151
  private mergeWeatherData;
152
+ /**
153
+ * 合并海洋数据, 以best_match为主, 并用meteofrance_currents的海流数据补全其他模型, 用ecmwf_wam的波浪数据补全meteofrance_wave, 用meteofrance_wave的波浪数据补全ecmwf_wam, 并对齐时间
154
+ * @param rows
155
+ * @param st
156
+ * @private
157
+ */
92
158
  private mergeMarineData;
159
+ /**
160
+ * 选择预报地址
161
+ * @param marine 是否为海洋预报
162
+ * @param selfHosted 是否自建服务,默认为true
163
+ * @param historical 是否为历史数据,默认为false,如果为true,则会使用历史数据接口
164
+ * @param options
165
+ * @private
166
+ */
93
167
  private pickForecastUrl;
168
+ /**
169
+ * 选择天气模型, 如果没有指定模型,则使用best_match,如果指定了模型,则按照优先级排序,并去重,确保ecmwf_ifs025和ecmwf_ifs同时存在
170
+ * @param models
171
+ * @private
172
+ */
94
173
  private pickWeatherModels;
174
+ /**
175
+ * 选择海洋模型, 如果没有指定模型,则使用best_match,如果指定了模型,则按照优先级排序,并去重,确保meteofrance_currents和ecmwf_wam025同时存在
176
+ * @param models
177
+ * @private
178
+ */
95
179
  private pickMarineModels;
96
180
  /**
97
- * 完善start_hour/end_hour 或者是forecast_days变量,二选一
98
- * @param datetime 从指定时间开始,不指定时从当前时间开始
99
- * @param marine 是否为海洋预报
100
- * @param params 要查询的要素
101
- * @param options 请求参数
181
+ * 构建公共参数
182
+ * @param datetime 指定预报开始时间,格式为ISO 8601字符串,例如"2024-01-01T00:00:00Z",不指定时从当前时间开始
183
+ * @param params
184
+ * @param options
102
185
  * @private
103
186
  */
104
187
  private prepare;
105
- private toStdLng;
188
+ static toStdLng(lng: number, precision?: number): number;
106
189
  private timezoneOffset;
107
190
  /**
108
191
  * 格式化时区
@@ -161,13 +244,20 @@ export declare class MeteoHelper2 {
161
244
  * @param lng
162
245
  * @param startDate
163
246
  * @param endDate
247
+ * @param withDaily
248
+ * @param withHourly
164
249
  * @param withMarine
165
250
  * @param options
166
251
  */
167
- spotHistorical(lat: number, lng: number, startDate: string, endDate: string, withDaily?: boolean, withHourly?: boolean, withMarine?: boolean, options?: OMOptions): Promise<{
168
- weather: any[];
169
- marine: any[] | undefined;
170
- }>;
252
+ spotHistorical(lat: number, lng: number, startDate: string, endDate: string, withDaily?: boolean, withHourly?: boolean, withMarine?: boolean, options?: OMOptions): Promise<any>;
253
+ /**
254
+ * Fetch historical data for a single date range
255
+ */
256
+ private _fetchHistoricalData;
257
+ /**
258
+ * Merge multiple historical data chunks
259
+ */
260
+ private _mergeHistoricalResults;
171
261
  /**
172
262
  * 季节预报数据
173
263
  * 提供未来45天~9个月的预报数据
@@ -203,9 +293,24 @@ export declare class MeteoHelper2 {
203
293
  * @param endDate
204
294
  * @param options
205
295
  */
206
- spotClimate(lat: number, lng: number, startDate: string, endDate: string | undefined, options?: OMOptions): Promise<{
207
- weather: any[];
208
- }>;
296
+ spotClimate(lat: number, lng: number, startDate: string, endDate: string | undefined, options?: OMOptions): Promise<any>;
297
+ /**
298
+ * Fetch climate data for a single date range
299
+ */
300
+ private _fetchClimateData;
301
+ /**
302
+ * Merge multiple climate data chunks
303
+ */
304
+ private _mergeClimateResults;
305
+ /**
306
+ * 更新模型信息,获取最新的模型更新时间和可用性等信息,避免使用过期的数据
307
+ * @param options
308
+ */
209
309
  update(options?: OMOptions): Promise<any>;
310
+ /**
311
+ * 选择需要更新的模型,按照更新时间排序,返回模型和更新时间等信息
312
+ * @param model
313
+ * @param options
314
+ */
210
315
  pickUpdateMeta(model: string | string[], options?: OMOptions): Promise<any[]>;
211
316
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -13,7 +13,6 @@ export declare class TidesHelper {
13
13
  private readonly apikey;
14
14
  private readonly debug;
15
15
  constructor(apikey: string, debug?: boolean);
16
- private toStdLng;
17
16
  /**
18
17
  * 潮汐预报数据
19
18
  * @param lat
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idm-plugin/meteo2",
3
3
  "private": false,
4
- "version": "0.9.9",
4
+ "version": "1.0.1",
5
5
  "description": "idm plugin for meteo2(open meteo)",
6
6
  "type": "module",
7
7
  "keywords": [
@@ -39,12 +39,13 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@idm-plugin/geo2": "^1.4.7",
42
- "@idm-plugin/meteo": "^0.6.7",
43
- "@idm-plugin/tag": "^0.2.3"
42
+ "@idm-plugin/meteo": "^0.7.1",
43
+ "@idm-plugin/tag": "^0.2.3",
44
+ "openmeteo": "^1.2.3"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@idm-plugin/geo2": "^1.4.7",
47
- "@idm-plugin/meteo": "^0.6.7",
48
+ "@idm-plugin/meteo": "^0.7.2",
48
49
  "@idm-plugin/tag": "^0.2.3",
49
50
  "@types/jest": "^25.2.2",
50
51
  "@types/node": "^18.14.2",
@@ -70,7 +71,7 @@
70
71
  "tsconfig-paths": "^3.12.0",
71
72
  "typescript": "^4.9.3",
72
73
  "vite": "^4.1.0",
73
- "vite-plugin-dts": "^2.0.2",
74
+ "vite-plugin-dts": "^4.5.4",
74
75
  "vite-plugin-static-copy": "^0.17.0"
75
76
  },
76
77
  "lint-staged": {