Commit 9e5feaee authored by Jasem Mutlaq's avatar Jasem Mutlaq

More progress on star profile plot

parent 499278a8
......@@ -126,6 +126,19 @@ Focus::Focus()
focusType = FOCUS_MANUAL;
profilePlot->setBackground(QBrush(Qt::black));
profilePlot->xAxis->setBasePen(QPen(Qt::white, 1));
profilePlot->yAxis->setBasePen(QPen(Qt::white, 1));
profilePlot->xAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
profilePlot->yAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
profilePlot->xAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
profilePlot->yAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
profilePlot->xAxis->grid()->setZeroLinePen(Qt::NoPen);
profilePlot->yAxis->grid()->setZeroLinePen(Qt::NoPen);
profilePlot->addGraph();
profilePlot->graph(0)->setLineStyle(QCPGraph::lsLine);
profilePlot->graph(0)->setPen(QPen(Qt::red, 2));
HFRPlot->setBackground(QBrush(Qt::black));
HFRPlot->xAxis->setBasePen(QPen(Qt::white, 1));
......@@ -153,17 +166,9 @@ Focus::Focus()
HFRPlot->yAxis->setLabel(i18n("HFR"));
v_graph = HFRPlot->addGraph();
//v_graph->setBrush(QBrush(QColor(170, 40, 80)));
//v_graph->setPen(QPen(Qt::red));
v_graph->setLineStyle(QCPGraph::lsNone);
v_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::white, Qt::red, 3));
//HFRPlot->axis( KPlotWidget::LeftAxis )->setLabel( i18nc("Half Flux Radius", "HFR") );
//HFRPlot->axis( KPlotWidget::BottomAxis )->setLabel( i18n("Iterations") );
//HFRPlot->axis( KPlotWidget::LeftAxis )->setLabel( i18nc("Half Flux Radius", "HFR") );
//HFRPlot->axis( KPlotWidget::BottomAxis )->setLabel( i18n("Absolute Position") );
resetButtons();
appendLogText(i18n("Idle."));
......@@ -181,7 +186,6 @@ Focus::Focus()
suspendGuideCheck->setChecked(Options::suspendGuiding());
lockFilterCheck->setChecked(Options::lockFocusFilter());
focusDarkFrameCheck->setChecked(Options::focusDarkFrame());
}
Focus::~Focus()
......@@ -977,7 +981,10 @@ void Focus::newFITS(IBLOB *bp)
hfr_value.append(currentHFR);
if (focusType == FOCUS_MANUAL || (inAutoFocus && canAbsMove == false && canRelMove == false))
{
drawProfilePlot(image_data);
drawHFRPlot();
}
}
}
// If just framing, let's capture again
......@@ -1144,6 +1151,38 @@ void Focus::drawHFRPlot()
}
void Focus::drawProfilePlot(FITSData *fitsData)
{
QVector<double> key;
QVector<double> value;
Edge *rCenter = fitsData->getMaxHFRStar();
float min=fitsData->getMin(0);
int cen_x = (int) floor(rCenter->x);
int cen_y = (int) floor(rCenter->y);
int width = fitsData->getWidth();
double maxGaus=-1;
float *image_buffer = fitsData->getImageBuffer();
// NOTE NOT WORKING! Fix it at home
for (int k=rCenter->width/2; k >= -(rCenter->width/2) ; k--)
{
key.append(-1*k);
double intensity = (image_buffer[cen_x-k+(cen_y*width)] - min);
double gaus = (1/(rCenter->stddev*sqrt(2*M_PI))) * exp(-1 * ( (intensity-rCenter->mean) * (intensity-rCenter->mean) ) / (2 * (rCenter->stddev * rCenter->stddev)));
if (gaus > maxGaus)
maxGaus = gaus;
value.append(gaus);
}
profilePlot->xAxis->setRange(key.first(), key.last());
profilePlot->yAxis->setRange(0, maxGaus);
profilePlot->graph()->setData(key, value);
profilePlot->replot();
}
void Focus::autoFocusAbs()
{
static int lastHFRPos=0, minHFRPos=0, initSlopePos=0, focusOutLimit=0, focusInLimit=0;
......
......@@ -325,6 +325,7 @@ signals:
private:
void drawHFRPlot();
void drawProfilePlot(FITSData *fitsData);
void getAbsFocusPosition();
void autoFocusAbs();
void autoFocusRel();
......
......@@ -480,6 +480,37 @@ Otherwise, the autofocus process will utilize whatever filter currently set by t
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="profileGroup">
<property name="title">
<string>Profile</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCustomPlot" name="profilePlot" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
......
......@@ -846,6 +846,14 @@ void FITSData::findCentroid(int initStdDev, int minEdgeWidth)
for (int k=rCenter->width/2; k >= -(rCenter->width/2) ; k--)
FSum += image_buffer[cen_x-k+(cen_y*stats.width)] - min;
rCenter->mean = FSum/rCenter->width;
float variance=0;
for (int k=rCenter->width/2; k >= -(rCenter->width/2) ; k--)
variance += (image_buffer[cen_x-k+(cen_y*stats.width)] - min - rCenter->mean) * (image_buffer[cen_x-k+(cen_y*stats.width)] - min - rCenter->mean);
variance /= rCenter->width;
rCenter->stddev = sqrt(variance);
// Half flux
HF = FSum / 2.0;
......@@ -876,7 +884,7 @@ void FITSData::findCentroid(int initStdDev, int minEdgeWidth)
rCenter->val = FSum;
if (Options::fITSLogging())
qDebug() << "HFR for this center is " << rCenter->HFR << " pixels and the total flux is " << FSum;
qDebug() << "HFR for this center is " << rCenter->HFR << " pixels and the total flux is " << FSum << " Mean is " << rCenter->mean << " Stddev: " << rCenter->stddev;
starCenters.append(rCenter);
......
......@@ -68,6 +68,8 @@ public:
float width;
float HFR;
float sum;
float mean;
float stddev;
};
class FITSData
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment