예제 #1
0
void Histogram::display(Gnuplot & g ) const
{

  vector<float> tmp = get_bin_edges();
  tmp.pop_back();
  
  vector<float> tmp2 = vector<float>(0);
  tmp2.reserve(hist_array_.size());
  
  for(vectori::const_iterator it = hist_array_.begin();
      it<hist_array_.end(); ++it)
    tmp2.push_back(*it);
  
  try
  {
    
    g.plot_xy(tmp,tmp2);
    g.set_style("histograms");
    
    g.set_grid();
    g.replot();
    
    wait_for_key();
  }
  catch(GnuplotException & e)
  {
    cout<<e.what()<<endl;
  }
  
}
예제 #2
0
파일: main.cpp 프로젝트: MiszelHub/Numerki
void rysuj()
{
    Gnuplot mainPlot;

	mainPlot.set_style("lines");   //styl rysowania wykresu
	mainPlot.set_grid();		   //siatka poprawiająca czytelnosc
	mainPlot.set_xrange(rangeStart, rangeEnd);	//zakres osi x wg. zadanych wartoœci
	mainPlot.plot_xy(functionX, functionY, "Funkcja aproksymowana");

    mainPlot.set_style("lines");   //styl rysowania wykresu
	mainPlot.set_grid();		   //siatka poprawiająca czytelnoœæ
	mainPlot.set_xrange(rangeStart, rangeEnd);	//zakres osi x wg. zadanych wartoœci
	mainPlot.plot_xy(functionX, approximationY, "Funkcja aproksymujaca");


    getchar();

    system("PAUSE");
}
예제 #3
0
파일: test.cpp 프로젝트: sigidagi/oivibs
int main(int argc, const char** argv)
{
    // don't forget to set LD_LIBRARY_PATH to directory where libOiVibrations.so libary resides
    // LD_LIBRARY_PATH=/home/john/sharedlibs
    // export LD_LIBRARY_PATH

    cout << "\n";
	if (argc < 2)
	{
		cout << "\n";
        cout << "Requires one or more command arguments.\n";
        cout << " Universal file name : FileName.uff \n";
		exit(1);
	}

    Oi::Proxy proxy;
    bool bSucceess = proxy.init(argc, argv);
    if (bSucceess)
        cout << "Initialization succeeded!\n";
    else
    {
        cout << "Initialization failed!\n";
        exit(1);
    }
    cout << "\n";

    int i(0);
    int nrows(0), ncols(0);
    const double* pnodes = proxy.getNodes(nrows, ncols); 
    
    vector<Point> nodesCollection;
    nodesCollection.reserve(nrows);

    Point pt1, pt2, pt3; 
    if (pnodes != NULL && ncols == 3)
    {
        for (i = 0; i < nrows; ++i)
        {
            Point pt; 
            pt.x = pnodes[0*nrows + i];
            pt.y = pnodes[1*nrows + i];             
            pt.z = pnodes[2*nrows + i];

            nodesCollection.push_back(pt);
        }
    }

    const unsigned int* plines = proxy.getLines(nrows, ncols);
    
    vector<Line> linesCollection;
    linesCollection.reserve(nrows);

    if (plines != NULL && ncols == 2 && !nodesCollection.empty())
    {
        unsigned int idx1(0), idx2(0);
        for (i = 0; i < nrows; ++i)
        {
            Line line;
            idx1 = plines[0*nrows + i];
            idx2 = plines[1*nrows + i];
            
            // number of node (point) starts from 1, where the indexes of vector<Point> 
            // starts from 0.
            line.point1 = nodesCollection[idx1-1]; 
            line.point2 = nodesCollection[idx2-1]; 

            linesCollection.push_back(line);
        }
    }
    
    const unsigned int* psurfaces = proxy.getSurfaces(nrows, ncols); 
    
    vector<Surface> surfacesCollection;
    surfacesCollection.reserve(nrows);

    if (psurfaces != NULL && ncols == 3)
    {
        unsigned int idx1(0), idx2(0), idx3(0);
        for (i = 0; i < nrows; ++i)
        {
            Surface surface;
            idx1 = psurfaces[0*nrows + i];
            idx2 = psurfaces[1*nrows + i];
            idx3 = psurfaces[2*nrows + i];
             
            surface.point1 = nodesCollection[idx1-1]; 
            surface.point2 = nodesCollection[idx2-1]; 
            surface.point3 = nodesCollection[idx3-1]; 

            surfacesCollection.push_back(surface);
        }
    }
    
/*
 *    std::cout << "------ Nodes ---------\n";
 *    std::ostream_iterator<Point> os_pit( std::cout, "\n" );
 *    std::copy(nodesCollection.begin(), nodesCollection.end(), os_pit);
 *    std::cout << std::endl;
 *
 *    std::cout << "------- Lines --------\n";
 *    std::ostream_iterator<Line> os_it( std::cout, "\n" );
 *    std::copy(linesCollection.begin(), linesCollection.end(), os_it); 
 *    std::cout << std::endl; 
 */
   
    vector<double> singularValues;

    int length(0);
    
    int numberOfMeasurements = proxy.getNumberOfMeasurements();    
    vector<const double*> pvalues(numberOfMeasurements);
    vector<const double*> pfreq(numberOfMeasurements);
    vector<Gnuplot*> plots;

    for (i = 0; i < numberOfMeasurements; ++i)
    {
        //pvalues[i] = proxy.getSingularValues(i, nrows, ncols);
        pvalues[i] = proxy.getSpectralDensity(i, nrows, ncols);

        pfreq[i] = proxy.getFrequencies(length);

        if (pvalues[i] != 0)
        {
            try 
            {
                std::stringstream ss;
                ss << "Measurement: " << (i+1); 
                Gnuplot* gplot = new Gnuplot(ss.str());
                gplot->set_title(ss.str());
                
                ss.str(""); ss.clear();
                
                gplot->set_grid();
                gplot->set_ylogscale();
                gplot->set_style("steps");
                for (int j = 0; j < ncols; ++j)
                {
                    ss << "singular values " << j; 
                    gplot->plot_xy(pfreq[i], pfreq[i]+length, pvalues[i]+j*nrows, pvalues[i]+(j+1)*nrows, ss.str() );                   
                    ss.str(""); ss.clear();
                }

                plots.push_back(gplot);
                
            }
            catch(GnuplotException& e)
            {
                std::cout << e.what() << "\n";
                std::for_each(plots.begin(), plots.end(), delete_plot);     
            }

        }

    }

    wait_for_key();
    std::for_each(plots.begin(), plots.end(), delete_plot); 
    

    /*
     *double natFreq = 33.8;
     *int nchannels(0), nsvd(0);
     *const complex<double>* pmodes = proxy.getModes(natFreq, 0, nchannels, nsvd);
     *
     *vector< complex<double> > modesList(nchannels*nsvd);
     *std::copy(pmodes, pmodes+nchannels*nsvd, &modesList[0]);
     */


	return 0;
}