2025-03-31T17:24:46
This commit is contained in:
parent
e4f3cc75f3
commit
8f1d0427d3
6577
experiment_data/analysis_state/E型NC050铟放大180.txt
Normal file
6577
experiment_data/analysis_state/E型NC050铟放大180.txt
Normal file
File diff suppressed because it is too large
Load Diff
7478
experiment_data/analysis_state/E型NC050锡放大180.txt
Normal file
7478
experiment_data/analysis_state/E型NC050锡放大180.txt
Normal file
File diff suppressed because it is too large
Load Diff
12704
experiment_data/analysis_state/ceshii-new 1.txt
Normal file
12704
experiment_data/analysis_state/ceshii-new 1.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "peakpoint.h"
|
#include "peakpoint.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
QVector<FileManager::ExperimentData>PeakPoint:: _dataVtr;
|
QVector<FileManager::ExperimentData>PeakPoint:: _dataVtr;
|
||||||
float PeakPoint::_leftPointX,PeakPoint::_rightPointX;
|
|
||||||
QPointF PeakPoint::_peakPoint;
|
QPointF PeakPoint::_peakPoint;
|
||||||
QPointF PeakPoint::_leftSelectedPoint,PeakPoint::_rightSelectedPoint;
|
QPointF PeakPoint::_leftSelectedPoint,PeakPoint::_rightSelectedPoint;
|
||||||
|
|
||||||
@ -21,42 +21,52 @@ QPointF PeakPoint::findPeakPoint(){
|
|||||||
|
|
||||||
QPointF uniquePeak;
|
QPointF uniquePeak;
|
||||||
// 初始化为 float 类型能表示的最小负数,确保能处理负数 y 值
|
// 初始化为 float 类型能表示的最小负数,确保能处理负数 y 值
|
||||||
float maxY = 0.0;
|
float maxY = -std::numeric_limits<float>::infinity();
|
||||||
bool findFlag = false;
|
bool isPeak = false;
|
||||||
|
|
||||||
|
#if 1
|
||||||
// 直接在遍历过程中找出最大波峰
|
// 直接在遍历过程中找出最大波峰
|
||||||
for (int i = 1; i < n - 1; ++i) {
|
for (int i = 10; i < n - 10; ++i) { // 从第11个点开始,到倒数第11个点结束
|
||||||
const float currentX = _dataVtr.at(i).sampleTemp;
|
const float currentX = _dataVtr.at(i).sampleTemp;
|
||||||
const float currentY = _dataVtr.at(i).dsc;
|
const float currentY = _dataVtr.at(i).dsc;
|
||||||
|
|
||||||
if(currentX < _leftPointX){
|
if (currentX < _leftSelectedPoint.x()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(currentX > _rightPointX){
|
if (currentX > _rightSelectedPoint.x()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float preY = _dataVtr.at(i - 1).dsc;
|
bool isPeak = true;
|
||||||
const float lastY = _dataVtr.at(i + 1).dsc;
|
// 比较当前点与前后10个点的y值
|
||||||
|
for (int j = 1; j <= 10; ++j) {
|
||||||
|
const float preY = _dataVtr.at(i - j).dsc;
|
||||||
|
const float lastY = _dataVtr.at(i + j).dsc;
|
||||||
|
|
||||||
findFlag = false;
|
if (currentY < preY || currentY < lastY) {
|
||||||
if(currentY >= preY && currentY >= lastY){
|
isPeak = false;
|
||||||
findFlag = true;
|
break;
|
||||||
}else if(currentY <= preY && currentY <= lastY){
|
}
|
||||||
findFlag = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(findFlag){
|
if(isPeak){
|
||||||
|
#if 1
|
||||||
float absY = std::abs(currentY);
|
float absY = std::abs(currentY);
|
||||||
if(absY >= maxY){
|
if(absY > maxY){
|
||||||
maxY = absY;
|
maxY = absY;
|
||||||
uniquePeak = QPointF(currentX,currentY);
|
uniquePeak = QPointF(currentX,currentY);
|
||||||
|
|
||||||
|
// logde<<"preY:"<<preY<<",lastY:"<<lastY;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
_peakPoint = uniquePeak;
|
_peakPoint = uniquePeak;
|
||||||
|
|
||||||
|
logde<<"peakPoint:"<<_peakPoint.x()<<","<<_peakPoint.y();
|
||||||
|
|
||||||
return uniquePeak;
|
return uniquePeak;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +82,7 @@ QPair<QPointF, QPointF> PeakPoint::calculateMaxDiffPointDetail(
|
|||||||
const float currentY = _dataVtr.at(i).dsc;
|
const float currentY = _dataVtr.at(i).dsc;
|
||||||
|
|
||||||
if(type == MaxDiffPointDetailType::Left){
|
if(type == MaxDiffPointDetailType::Left){
|
||||||
if(currentX <= _leftPointX){
|
if(currentX <= _leftSelectedPoint.x()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(currentX >= _peakPoint.x()){
|
if(currentX >= _peakPoint.x()){
|
||||||
@ -82,7 +92,7 @@ QPair<QPointF, QPointF> PeakPoint::calculateMaxDiffPointDetail(
|
|||||||
if(currentX <= _peakPoint.x()){
|
if(currentX <= _peakPoint.x()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(currentX >= _rightPointX){
|
if(currentX >= _rightSelectedPoint.x()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,17 +172,14 @@ QPointF PeakPoint::findClosestPointByX(float x) {
|
|||||||
|
|
||||||
void PeakPoint::setRegionPointX(const float left, const float right)
|
void PeakPoint::setRegionPointX(const float left, const float right)
|
||||||
{
|
{
|
||||||
_leftPointX = left;
|
_leftSelectedPoint = findClosestPointByX(left);
|
||||||
_rightPointX = right;
|
_rightSelectedPoint = findClosestPointByX(right);
|
||||||
|
|
||||||
_leftSelectedPoint = findClosestPointByX(_leftPointX);
|
|
||||||
_rightSelectedPoint = findClosestPointByX(_rightPointX);
|
|
||||||
|
|
||||||
findPeakPoint();
|
findPeakPoint();
|
||||||
|
|
||||||
updateStartEndPoint();
|
updateStartEndPoint();
|
||||||
|
|
||||||
qDebug()<<"left,right point:"<<_leftSelectedPoint
|
qDebug()<<"left,right select point:"<<_leftSelectedPoint
|
||||||
<<","<<_rightSelectedPoint;
|
<<","<<_rightSelectedPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,8 +204,10 @@ double PeakPoint::calculateArea() {
|
|||||||
<<QString::number(point.y(),'f',3);
|
<<QString::number(point.y(),'f',3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if 0
|
||||||
qDebug()<<QString::number(points.at(0).x(),'f',3)<<","<<
|
qDebug()<<QString::number(points.at(0).x(),'f',3)<<","<<
|
||||||
QString::number(points.at(points.size() - 1).x(),'f',3);
|
QString::number(points.at(points.size() - 1).x(),'f',3);
|
||||||
|
#endif
|
||||||
|
|
||||||
//calculate Area
|
//calculate Area
|
||||||
float integral = 0.0;
|
float integral = 0.0;
|
||||||
@ -260,6 +269,9 @@ QPair<QPointF, QPointF> PeakPoint::calculateStartAndEndPoint()
|
|||||||
QPair<QPointF,QPointF> leftMaxDiffPointPair = PeakPoint::calculateMaxDiffPointLeft();
|
QPair<QPointF,QPointF> leftMaxDiffPointPair = PeakPoint::calculateMaxDiffPointLeft();
|
||||||
QPair<QPointF,QPointF> rightMaxDiffPointPair = PeakPoint::calculateMaxDiffPointRight();
|
QPair<QPointF,QPointF> rightMaxDiffPointPair = PeakPoint::calculateMaxDiffPointRight();
|
||||||
|
|
||||||
|
logde<<"b1:"<<leftMaxDiffPointPair.first.x()<<","<<leftMaxDiffPointPair.first.y();
|
||||||
|
logde<<"b2:"<<leftMaxDiffPointPair.second.x()<<","<<leftMaxDiffPointPair.second.y();
|
||||||
|
|
||||||
QPointF startPoint = calculateIntersection(_leftSelectedPoint,_rightSelectedPoint,
|
QPointF startPoint = calculateIntersection(_leftSelectedPoint,_rightSelectedPoint,
|
||||||
leftMaxDiffPointPair.first,leftMaxDiffPointPair.second);
|
leftMaxDiffPointPair.first,leftMaxDiffPointPair.second);
|
||||||
|
|
||||||
@ -299,10 +311,10 @@ QString PeakPoint::textFormat(const float enthalpyValue,
|
|||||||
"峰值:%2℃ \n"
|
"峰值:%2℃ \n"
|
||||||
"起始点:%3℃ \n"
|
"起始点:%3℃ \n"
|
||||||
"终止点:%4℃"
|
"终止点:%4℃"
|
||||||
).arg(QString::number(enthalpyValue, 'f', 2))
|
).arg(QString::number(enthalpyValue, 'f', 3))
|
||||||
.arg(QString::number(peakValue, 'f', 2))
|
.arg(QString::number(peakValue, 'f', 3))
|
||||||
.arg(QString::number(startPoint, 'f', 2))
|
.arg(QString::number(startPoint, 'f', 3))
|
||||||
.arg(QString::number(endPoint, 'f', 2));
|
.arg(QString::number(endPoint, 'f', 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算两条直线的交点
|
// 计算两条直线的交点
|
||||||
|
|||||||
@ -34,7 +34,6 @@ QPointF findClosestPointByX(float target);
|
|||||||
QVector<QPointF> getPeakPointGroup();
|
QVector<QPointF> getPeakPointGroup();
|
||||||
|
|
||||||
extern QVector<FileManager::ExperimentData> _dataVtr;
|
extern QVector<FileManager::ExperimentData> _dataVtr;
|
||||||
extern float _leftPointX,_rightPointX;
|
|
||||||
extern QPointF _peakPoint;
|
extern QPointF _peakPoint;
|
||||||
extern QPointF _leftSelectedPoint,_rightSelectedPoint;
|
extern QPointF _leftSelectedPoint,_rightSelectedPoint;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,6 +129,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
|||||||
|
|
||||||
_customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
_customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
|
_customPlot->rescaleAxes();
|
||||||
//
|
//
|
||||||
FileManager::writeExperimentFile(cd);
|
FileManager::writeExperimentFile(cd);
|
||||||
}
|
}
|
||||||
@ -160,7 +161,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
_customPlot->yAxis->setLabel("DSC/mW");
|
_customPlot->yAxis->setLabel("DSC/mW");
|
||||||
_customPlot->xAxis->setLabel("Temp/℃");
|
_customPlot->xAxis->setLabel("Temp/℃");
|
||||||
// 设置坐标轴范围,以便我们可以看到全部数据
|
// 设置坐标轴范围,以便我们可以看到全部数据
|
||||||
_customPlot->xAxis->setRange(0, 400);
|
_customPlot->xAxis->setRange(0, 500);
|
||||||
_customPlot->yAxis->setRange(-20, 20);
|
_customPlot->yAxis->setRange(-20, 20);
|
||||||
|
|
||||||
QVector<double> xVtr, yVtr;
|
QVector<double> xVtr, yVtr;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user