feiyu02
7 天以前 594de76ed51fd49fb79b912212bb0052a63e7671
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
@@ -12,6 +12,7 @@
import kotlin.math.min
import kotlin.math.round
import kotlin.math.sqrt
import kotlin.time.times
/**
 * 数据平滑预处理
@@ -82,7 +83,7 @@
                val it = mDataList[i].values?.get(y) ?: continue
                if (!calTypes.contains(it.factorName)) continue
                val vMax = FactorType.getVMax(it.factorName) ?: continue
                val vMax = FactorType.getVMin(it.factorName) ?: continue
                it.factorData ?: continue
                if (it.factorData!! > vMax) {
@@ -148,9 +149,10 @@
            i = 0
        }
        while (i < mDataList.size) {
            // 针对每个监测因子,分别做数据平滑处理
            for (y in mDataList[i].values?.indices ?: 0..0) {
                val it = mDataList[i].values?.get(y) ?: continue
                val vMax = FactorType.getVMax(it.factorName) ?: continue
                val vMax = FactorType.getVMin(it.factorName) ?: continue
                it.factorData ?: continue
                if (it.factorData!! > vMax) {
@@ -192,6 +194,29 @@
                }
            }
            // 根据物理规律,剔除或修正不合理的数据
            val data = mDataList[i]
            // 1. PM2.5 应该始终小于PM10
            val pm25 = data.getFactorData(FactorType.PM25)
            val pm10 = data.getFactorData(FactorType.PM10)
            if (pm25 != null && pm10 != null) {
                // 若pm2.5大于pm10
                if (pm25 >= pm10){
                    val lastIndex = i - 1
                    // 则将pm2.5修改为前一个数据的值
                    if (lastIndex >= 0) {
                        data.setFactorData(FactorType.PM25, mDataList[lastIndex].getFactorData(FactorType.PM25))
                    } else {
                        if (lastData.isEmpty()) {
                            // 没有历史数据时,修改为pm10的80%(后续待优化比例 2026.3.6)
                            data.setFactorData(FactorType.PM25, data.getFactorData(FactorType.PM10)?.times(.8))
                        } else {
                            data.setFactorData(FactorType.PM25, lastData.last().getFactorData(FactorType.PM25))
                        }
                    }
                }
            }
            i++
        }