gtld2-diag-scripts/classes/mtxClass.js

45 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2024-09-09 10:13:17 +03:00
export class mtxClass {
constructor(args) {
this.spec = args.spec;
this.filter = args.filter;
this.set = args.set;
if (this.tol != undefined) { this.spec.harm_tolerance = args.tol }
}
__getModDeep(ampl, base) {
let dl = (ampl - base); //разность уровней гармонической и случайной составляющей вибрации
let df = this.spec.frequency / this.filter.width; //отношение частотному разрешению спектра к ширине фильтра
let mod = Math.sqrt((10 ** (dl / 10) - 1) * df);
return mod;
}; //определение глубины модуляции ВЧ составляющих
getMatrix() {
let __result = {}; //результат
let __num = 6; //глубина матрицы (количество гармоник)
let __lvl = 0; //уровень развития дефекта
let __rows = Object.keys(this.set); //массив ключей объекта (наименование портретов)
for (let i = 0; i < __rows.length; i++) {
let __name = __rows[i]; //имена портретов
let __arr = this.set[__name]; //массив значений
let __color = __arr[0]; //предустановленный цвет
let __freq = __arr[1]; //расчетная частота
let __harms = []; //массив обнаруженных гармоник
let __harms_set = this.spec.add_harms_set(__freq, __num, __color, 2); //строим набор частот (гармонический ряд)
__harms_set.name = __name;
for (let j = 0; j < __num; j++) {
//__harms_set.harms[j].tolerance = (j + 1) * __fValue * this.tol; //устанавливаем коридор обнаружения гармоники
if (__harms_set.harms[j].is_present == true) {
__lvl = Math.round(this.__getModDeep(__harms_set.harms[j].amplitude, __harms_set.harms[j].base));
__harms.push(__lvl);
} else { __harms.push(0) };
__result[__name] = __harms;
}
}
return __result
}
}