气象数据添加ncep数据
This commit is contained in:
parent
3dcf5db691
commit
c4679d4c2b
|
|
@ -4,4 +4,5 @@ public class WeatherPrefixConstants {
|
||||||
|
|
||||||
public static final String PANGU_PREFIX = "panguweather_";
|
public static final String PANGU_PREFIX = "panguweather_";
|
||||||
public static final String CRA40_PREFIX = "CRA40_";
|
public static final String CRA40_PREFIX = "CRA40_";
|
||||||
|
public static final String NCEP_PREFIX = "cdas1";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@ package org.jeecg.common.constant;
|
||||||
public class WeatherSuffixConstants {
|
public class WeatherSuffixConstants {
|
||||||
|
|
||||||
public static final String CRA40_SUFFIX = "_GLB_0P25_HOUR_V1_0_0";
|
public static final String CRA40_SUFFIX = "_GLB_0P25_HOUR_V1_0_0";
|
||||||
|
public static final String NCEP_SUFFIX = "pgrbh";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ public enum WeatherDataTypeEnum {
|
||||||
|
|
||||||
|
|
||||||
PANGU(0, "PANGU"),
|
PANGU(0, "PANGU"),
|
||||||
CRA40(1, "CRA40");
|
CRA40(1, "CRA40"),
|
||||||
|
NCEP(2, "NCEP");
|
||||||
|
|
||||||
private Integer key;
|
private Integer key;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,12 @@ public enum WeatherVariableNameEnum {
|
||||||
CRA40_P(1, 1, "Vertical_velocity_pressure_isobaric"),
|
CRA40_P(1, 1, "Vertical_velocity_pressure_isobaric"),
|
||||||
CRA40_H(1, 2, "Relative_humidity_isobaric"),
|
CRA40_H(1, 2, "Relative_humidity_isobaric"),
|
||||||
CRA40_U(1, 3, "u-component_of_wind_isobaric"),
|
CRA40_U(1, 3, "u-component_of_wind_isobaric"),
|
||||||
CRA40_V(1, 4, "v-component_of_wind_isobaric");
|
CRA40_V(1, 4, "v-component_of_wind_isobaric"),
|
||||||
|
NCEP_T(2, 0, "Temperature_height_above_ground"),
|
||||||
|
NCEP_P(2, 1, "Pressure_msl"),
|
||||||
|
NCEP_H(2, 2, "Relative_humidity_height_above_ground"),
|
||||||
|
NCEP_U(2, 3, "u-component_of_wind_height_above_ground"),
|
||||||
|
NCEP_V(2, 4, "v-component_of_wind_height_above_ground");
|
||||||
|
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ public class SystemStorageProperties {
|
||||||
*/
|
*/
|
||||||
private String cra40;
|
private String cra40;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NCEP CFSv2数据存储路径
|
||||||
|
*/
|
||||||
|
private String ncep;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* graphcast模型预测数据存储路径
|
* graphcast模型预测数据存储路径
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,10 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
||||||
try {
|
try {
|
||||||
if (WeatherDataTypeEnum.PANGU.getKey() == dataType) {
|
if (WeatherDataTypeEnum.PANGU.getKey() == dataType) {
|
||||||
return processWeatherData(weatherType, targetTime, WeatherDataTypeEnum.PANGU);
|
return processWeatherData(weatherType, targetTime, WeatherDataTypeEnum.PANGU);
|
||||||
} else {
|
} else if (WeatherDataTypeEnum.CRA40.getKey() == dataType){
|
||||||
return processWeatherData(weatherType, targetTime, WeatherDataTypeEnum.CRA40);
|
return processWeatherData(weatherType, targetTime, WeatherDataTypeEnum.CRA40);
|
||||||
|
} else if (WeatherDataTypeEnum.NCEP.getKey() == dataType){
|
||||||
|
return processWeatherData(weatherType, targetTime, WeatherDataTypeEnum.NCEP);
|
||||||
}
|
}
|
||||||
} catch (JeecgBootException e) {
|
} catch (JeecgBootException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
@ -86,11 +88,12 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
||||||
log.error("处理天气数据失败", e);
|
log.error("处理天气数据失败", e);
|
||||||
throw new JeecgBootException("处理天气数据失败", e);
|
throw new JeecgBootException("处理天气数据失败", e);
|
||||||
}
|
}
|
||||||
|
throw new JeecgBootException("没有该类型的气象数据!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取时间序列天气数据(兼容PANGU和CRA40两种气象类型)
|
* 获取时间序列天气数据
|
||||||
* @param dataType 气象数据类型(PANGU/CRA40)
|
* @param dataType 气象数据类型
|
||||||
* @param startTime 开始时间
|
* @param startTime 开始时间
|
||||||
* @param endTime 结束时间
|
* @param endTime 结束时间
|
||||||
* @param longitude 经度
|
* @param longitude 经度
|
||||||
|
|
@ -115,7 +118,7 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
||||||
|
|
||||||
// 获取网格索引
|
// 获取网格索引
|
||||||
int[] gridIndex = getGridIndex(latitude, longitude);
|
int[] gridIndex = getGridIndex(latitude, longitude);
|
||||||
int hourInterval = 6; // PANGU每小时,CRA40每6小时
|
int hourInterval = 6;
|
||||||
|
|
||||||
// 循环处理每个时间点的数据
|
// 循环处理每个时间点的数据
|
||||||
LocalDateTime currentTime = startTime;
|
LocalDateTime currentTime = startTime;
|
||||||
|
|
@ -520,12 +523,18 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
||||||
variables.put("humidity", WeatherVariableNameEnum.PANGU_H.getValue());
|
variables.put("humidity", WeatherVariableNameEnum.PANGU_H.getValue());
|
||||||
variables.put("windU", WeatherVariableNameEnum.PANGU_U.getValue());
|
variables.put("windU", WeatherVariableNameEnum.PANGU_U.getValue());
|
||||||
variables.put("windV", WeatherVariableNameEnum.PANGU_V.getValue());
|
variables.put("windV", WeatherVariableNameEnum.PANGU_V.getValue());
|
||||||
} else {
|
} else if (WeatherDataTypeEnum.CRA40.getKey() == dataType){
|
||||||
variables.put("temperature", WeatherVariableNameEnum.CRA40_T.getValue());
|
variables.put("temperature", WeatherVariableNameEnum.CRA40_T.getValue());
|
||||||
variables.put("pressure", WeatherVariableNameEnum.CRA40_P.getValue());
|
variables.put("pressure", WeatherVariableNameEnum.CRA40_P.getValue());
|
||||||
variables.put("humidity", WeatherVariableNameEnum.CRA40_H.getValue());
|
variables.put("humidity", WeatherVariableNameEnum.CRA40_H.getValue());
|
||||||
variables.put("windU", WeatherVariableNameEnum.CRA40_U.getValue());
|
variables.put("windU", WeatherVariableNameEnum.CRA40_U.getValue());
|
||||||
variables.put("windV", WeatherVariableNameEnum.CRA40_V.getValue());
|
variables.put("windV", WeatherVariableNameEnum.CRA40_V.getValue());
|
||||||
|
} else if (WeatherDataTypeEnum.NCEP.getKey() == dataType){
|
||||||
|
variables.put("temperature", WeatherVariableNameEnum.NCEP_T.getValue());
|
||||||
|
variables.put("pressure", WeatherVariableNameEnum.NCEP_P.getValue());
|
||||||
|
variables.put("humidity", WeatherVariableNameEnum.NCEP_H.getValue());
|
||||||
|
variables.put("windU", WeatherVariableNameEnum.NCEP_U.getValue());
|
||||||
|
variables.put("windV", WeatherVariableNameEnum.NCEP_V.getValue());
|
||||||
}
|
}
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
@ -754,7 +763,7 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
||||||
.append(targetTime.format(DateTimeFormatter.ofPattern("yyyyMMddHH")))
|
.append(targetTime.format(DateTimeFormatter.ofPattern("yyyyMMddHH")))
|
||||||
.append(".")
|
.append(".")
|
||||||
.append(WeatherFileSuffixEnum.GRIB.getValue());
|
.append(WeatherFileSuffixEnum.GRIB.getValue());
|
||||||
} else {
|
} else if (WeatherDataTypeEnum.CRA40.equals(dataTypeEnum)) {
|
||||||
storagePath.append(systemStorageProperties.getCra40())
|
storagePath.append(systemStorageProperties.getCra40())
|
||||||
.append(File.separator)
|
.append(File.separator)
|
||||||
.append(WeatherPrefixConstants.CRA40_PREFIX)
|
.append(WeatherPrefixConstants.CRA40_PREFIX)
|
||||||
|
|
@ -764,10 +773,32 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
|
||||||
.append(WeatherSuffixConstants.CRA40_SUFFIX)
|
.append(WeatherSuffixConstants.CRA40_SUFFIX)
|
||||||
.append(".")
|
.append(".")
|
||||||
.append(WeatherFileSuffixEnum.GRIB2.getValue());
|
.append(WeatherFileSuffixEnum.GRIB2.getValue());
|
||||||
|
} else if (WeatherDataTypeEnum.NCEP.equals(dataTypeEnum)) {
|
||||||
|
storagePath.append(systemStorageProperties.getNcep())
|
||||||
|
.append(File.separator)
|
||||||
|
.append(targetTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")))
|
||||||
|
.append(".")
|
||||||
|
.append(WeatherPrefixConstants.NCEP_PREFIX)
|
||||||
|
.append(".")
|
||||||
|
.append(minus6HoursAndFormat(targetTime))
|
||||||
|
.append(".")
|
||||||
|
.append(WeatherSuffixConstants.NCEP_SUFFIX)
|
||||||
|
.append(".")
|
||||||
|
.append(WeatherFileSuffixEnum.GRIB2.getValue());
|
||||||
}
|
}
|
||||||
return storagePath.toString();
|
return storagePath.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 减六小时取yyyyMMddHH
|
||||||
|
* @param targetTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String minus6HoursAndFormat(LocalDateTime targetTime) {
|
||||||
|
LocalDateTime minus6Hours = targetTime.minusHours(6);
|
||||||
|
return minus6Hours.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理结果数据
|
* 处理结果数据
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user