Beispiel #1
0
def hilbert(data: str) -> dict:
    signal = VibrationSignal(
        data=binary_deserializer(data), fs=10000, compute_axis=False
    )
    env = signal.to_envelope()
    env.compute_spectrum(compute_axis=False)
    return {"vib": signal.data, "env_vib": env.data, "env_fft": env.spec}
Beispiel #2
0
async def read_warning_log_data_by_id(data_id: int,
                                      mp_id: int,
                                      fault_mode: FaultRule,
                                      conn: Database = Depends(get_db)):
    """
    Get warning log data by ID and fault pattern.
    """
    data = await get_data_by_id(
        conn=conn,
        mp_id=mp_id,
        orm_model=VibData,
        require_mp_type=0,
        data_id=data_id,
    )
    if not data:
        raise HTTPException(status_code=400, detail="Item not found")
    signal = VibrationSignal(data=np.fromstring(data["ima"], dtype=np.float32),
                             fs=10000,
                             type=2)

    if (fault_mode == FaultRule.ub or fault_mode == FaultRule.ma
            or fault_mode == FaultRule.al or fault_mode == FaultRule.bl
            or fault_mode == FaultRule.rb):
        signal = signal.to_velocity(detrend_type="poly")
        signal.compute_spectrum()
        return {"spec": signal.spec, "freq": signal.freq}
    if fault_mode == FaultRule.bw:
        signal = signal.to_filted_signal(filter_type="highpass",
                                         co_frequency=2 * 1000 /
                                         10000).to_envelope()
        signal.compute_spectrum()
        return {"spec": signal.spec, "freq": signal.freq}
    if fault_mode == FaultRule.sg:
        signal.compute_spectrum()
        return {"spec": signal.spec, "freq": signal.freq}
Beispiel #3
0
def acceleration_to_velocity(data: str) -> dict:
    acc = VibrationSignal(data=binary_deserializer(data), fs=10000)
    vel = acc.to_velocity()
    acc.compute_spectrum(compute_axis=False)
    vel.compute_spectrum(compute_axis=False)
    return {
        "vel": vel.data,
        "acc": acc.data,
        "acc_spec": acc.spec,
        "vel_spec": vel.spec,
    }
Beispiel #4
0
    def surge_diagnosis(self, diag_obj: VibrationSignal):
        low_index1, low_energy1 = diag_obj.get_band_energy(
            fr=self.fr, band_range=(0, 0.4)
        )
        low_index2, low_energy2 = diag_obj.get_band_energy(
            fr=self.fr, band_range=(0.6, 0.8)
        )

        self.sg_index = np.array([low_index1, low_index2])
        self.lt_fr_amp = np.array([low_energy1, low_energy2])

        self.sg_indicator = 0.45 * low_energy1 + 0.35 * low_energy2

        self.sg_level = np.searchsorted(self.sg_threshold, self.sg_indicator)
Beispiel #5
0
def calculate_feature_row(row, station_id, inner_station_id):
    feature_model = VibFeature.model(station_id=station_id, inner_id=inner_station_id)
    signal = np.fromstring(row.ima, dtype=np.float32)
    signal = VibrationSignal(data=signal, fs=10000)
    return feature_model(
        rms=float(signal.rms_fea),
        max=float(signal.max_fea),
        p2p=float(signal.pp_fea),
        avg=float(np.mean(signal.data)),
        var=float(signal.var_fea),
        kurtosis=float(signal.kurtosis),
        data_id=row.id,
        time=row.time,
    )
Beispiel #6
0
def fast_fournier_transform(signal: str) -> dict:
    signal = VibrationSignal(
        data=binary_deserializer(signal), fs=10000, compute_axis=False
    )
    signal.compute_spectrum(compute_axis=False)
    return {"spec": signal.spec, "vib": signal.data}
Beispiel #7
0
def empirical_mode_decomposition(data: str) -> dict:
    signal = VibrationSignal(
        data=binary_deserializer(data), fs=10000, compute_axis=False
    )
    res = signal.get_empirical_mode_decomposition()
    return res
Beispiel #8
0
def welch_spectrum_estimation(data: str) -> dict:
    signal = VibrationSignal(
        data=binary_deserializer(data), fs=10000, compute_axis=False
    )
    res = signal.get_welch_spectrum_estimation()
    return {"vib": signal.data, **res}
Beispiel #9
0
def multi_scale_envelope_spectrum(data: str) -> dict:
    signal = VibrationSignal(
        data=binary_deserializer(data), fs=10000, compute_axis=False
    )
    res = signal.get_multi_scale_envelope_spectrum(n_Ssta=1.0, n_Send=8.0, n_Sint=0.2)
    return res
Beispiel #10
0
def short_time_fournier_transform(data: str) -> dict:
    signal = VibrationSignal(
        data=binary_deserializer(data), fs=10000, compute_axis=False
    )
    res = signal.get_short_time_fournier_transform()
    return res