1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-19 21:25:36 +01:00

data plot with filters

This commit is contained in:
Antonin Portelli 2024-06-19 17:22:59 +09:00
parent f4dff86ce6
commit 6fbb0f70ef
3 changed files with 46 additions and 1 deletions

View File

@ -206,6 +206,42 @@ PlotData::PlotData(const XYStatData &data, const Index i, const Index j, const b
setCommand("'" + tmpFileName + "' " + usingCmd);
}
PlotData::PlotData(const XYStatData & data, XYStatData::CoordFilter f, Index i, const Index j, const bool abs)
{
string usingCmd, tmpFileName;
if (!abs)
{
usingCmd = (data.isXExact(i)) ? "u 1:3:4 w yerr" : "u 1:3:2:4 w xyerr";
}
else
{
usingCmd = (data.isXExact(i)) ? "u 1:(abs($3)):4 w yerr" : "u 1:(abs($3)):2:4 w xyerr";
}
tmpFileName = dumpToTmpFile(data.getTable(i, j, f));
pushTmpFile(tmpFileName);
setCommand("'" + tmpFileName + "' " + usingCmd);
}
PlotData::PlotData(const XYStatData & data, XYStatData::PointFilter f, Index i, const Index j, const bool abs)
{
string usingCmd, tmpFileName;
if (!abs)
{
usingCmd = (data.isXExact(i)) ? "u 1:3:4 w yerr" : "u 1:3:2:4 w xyerr";
}
else
{
usingCmd = (data.isXExact(i)) ? "u 1:(abs($3)):4 w yerr" : "u 1:(abs($3)):2:4 w xyerr";
}
tmpFileName = dumpToTmpFile(data.getTable(i, j, f));
pushTmpFile(tmpFileName);
setCommand("'" + tmpFileName + "' " + usingCmd);
}
// PlotPoint constructor ///////////////////////////////////////////////////////
PlotPoint::PlotPoint(const double x, const double y)
{
@ -775,7 +811,7 @@ void Plot::display(void)
ostringstream scriptBuf;
getProgramPath();
command = gnuplotPath_ + "/" + gnuplotBin_ + " 2>/dev/null";
command = gnuplotPath_ + "/" + gnuplotBin_;
gnuplotPipe = popen(command.c_str(), "w");
if (!gnuplotPipe)
{

View File

@ -94,6 +94,10 @@ public:
PlotData(const DMatSample &x, const DVec &y, const bool abs = false);
PlotData(const XYStatData &data, const Index i = 0, const Index j = 0,
const bool abs = false);
PlotData(const XYStatData &data, XYStatData::CoordFilter f, Index i = 0,
const Index j = 0, const bool abs = false);
PlotData(const XYStatData &data, XYStatData::PointFilter f, Index i = 0,
const Index j = 0, const bool abs = false);
// destructor
virtual ~PlotData(void) = default;
};

View File

@ -65,6 +65,9 @@ private:
******************************************************************************/
class XYStatData: public FitInterface
{
public:
typedef std::function<bool(const std::vector<Index> &)> CoordFilter;
typedef std::function<bool(const DVec &)> PointFilter;
public:
// constructor
XYStatData(void) = default;
@ -89,6 +92,8 @@ public:
DVec getXError(const Index i) const;
DVec getYError(const Index j) const;
DMat getTable(const Index i, const Index j) const;
DMat getTable(const Index i, const Index j, CoordFilter &coordFilter) const;
DMat getTable(const Index i, const Index j, PointFilter &ptFilter) const;
// get total fit variance & correlation matrices and their pseudo-inverse
const DMat & getFitVarMat(void);
const DMat & getFitVarMatPInv(void);