Skip to content

Commit

Permalink
data plot with filters
Browse files Browse the repository at this point in the history
  • Loading branch information
aportelli committed Jun 19, 2024
1 parent f4dff86 commit 6fbb0f7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
38 changes: 37 additions & 1 deletion lib/LatAnalyze/Core/Plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions lib/LatAnalyze/Core/Plot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class PlotData: public PlotObject
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;
};
Expand Down
5 changes: 5 additions & 0 deletions lib/LatAnalyze/Statistics/XYStatData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class FitResult: public DVec
******************************************************************************/
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;
Expand All @@ -89,6 +92,8 @@ class XYStatData: public FitInterface
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);
Expand Down

0 comments on commit 6fbb0f7

Please sign in to comment.