|
@@ -507,28 +507,24 @@ def collect_vibration(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]
|
|
|
|
|
|
|
|
spectrum = None
|
|
spectrum = None
|
|
|
if sample:
|
|
if sample:
|
|
|
- arr = _parse_wave(sample.get("mesure_data"))
|
|
|
|
|
- fs = float(sample.get("sampling_frequency") or 0)
|
|
|
|
|
- if arr is not None and fs > 0:
|
|
|
|
|
- arr = arr - float(np.mean(arr))
|
|
|
|
|
- n = arr.size
|
|
|
|
|
- win = np.hanning(n)
|
|
|
|
|
- amp = np.abs(np.fft.rfft(arr * win)) * 2 / max(n, 1)
|
|
|
|
|
- freq = np.fft.rfftfreq(n, d=1 / fs)
|
|
|
|
|
- keep = freq <= fs / 2.56
|
|
|
|
|
- freq, amp = freq[keep], amp[keep]
|
|
|
|
|
- if freq.size > 1500:
|
|
|
|
|
- idx = np.linspace(0, freq.size - 1, 1500).astype(int)
|
|
|
|
|
- freq, amp = freq[idx], amp[idx]
|
|
|
|
|
|
|
+ # 与振动分析页面同源:调用 CMSAnalyst 生成频域图
|
|
|
|
|
+ try:
|
|
|
|
|
+ from app.services.CMSAnalyst import CMSAnalyst
|
|
|
|
|
+
|
|
|
|
|
+ cms = CMSAnalyst(0, None, code, [int(sample.get("id"))], light=False)
|
|
|
|
|
+ freq = json.loads(cms.frequency_domain())
|
|
|
spectrum = {
|
|
spectrum = {
|
|
|
- "freq": [round(float(x), 3) for x in freq],
|
|
|
|
|
- "amp": [round(float(x), 6) for x in amp],
|
|
|
|
|
- "fs": fs,
|
|
|
|
|
- "rms": round(float(np.sqrt(np.mean(arr ** 2))), 4),
|
|
|
|
|
|
|
+ "freq": [round(float(x), 3) for x in freq.get("x", [])],
|
|
|
|
|
+ "amp": [round(float(x), 6) for x in freq.get("y", [])],
|
|
|
|
|
+ "fs": freq.get("fs"),
|
|
|
|
|
+ "rms": freq.get("Xrms"),
|
|
|
"point": sample.get("mesure_point_name"),
|
|
"point": sample.get("mesure_point_name"),
|
|
|
"time": str(sample.get("time_stamp")),
|
|
"time": str(sample.get("time_stamp")),
|
|
|
"rpm": sample.get("rotational_speed"),
|
|
"rpm": sample.get("rotational_speed"),
|
|
|
|
|
+ "source": "CMSAnalyst",
|
|
|
}
|
|
}
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ spectrum = None
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
"available": (summary.get("c", 0) or 0) > 0,
|
|
"available": (summary.get("c", 0) or 0) > 0,
|
|
@@ -590,9 +586,9 @@ def collect_all(wind_code: str, start_month: str, end_month: str, sections=None)
|
|
|
},
|
|
},
|
|
|
"vibration": {
|
|
"vibration": {
|
|
|
"page": "振动分析",
|
|
"page": "振动分析",
|
|
|
- "source": f"energy_data_prod.{wind_code}_wave",
|
|
|
|
|
|
|
+ "source": "CMSAnalyst(振动分析页面 CMS 波形)",
|
|
|
"period": [start_month, end_month],
|
|
"period": [start_month, end_month],
|
|
|
- "filter": "time_stamp 月区间 + 波形解析",
|
|
|
|
|
|
|
+ "filter": "time_stamp 月区间 + CMS 频域分析",
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|