Commit ce1c8917 authored by Laurent Belcour's avatar Laurent Belcour

Updating the input vertical segment code

parent bca6dd57
......@@ -92,6 +92,8 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
{
continue ;
}
else
{
vec v(dimX() + 3*dimY()) ;
for(int i=0; i<dimX(); ++i)
......@@ -101,44 +103,41 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
linestream >> v[dimX() + i] ;
for(int i=0; i<dimY(); ++i)
{
// TODO, the firts case does not account for the
// dimension of the ouput vector
{
double min_dt = 0.0;
double max_dt = 0.0;
if(vs[i] == 2)
{
linestream >> v[dimX() + dimY()+i] ;
linestream >> v[dimX() + 2*dimY()+i] ;
linestream >> min_dt ;
linestream >> max_dt ;
min_dt = min_dt-v[dimX()+i];
max_dt = max_dt-v[dimX()+i];
}
else if(vs[i] == 1)
{
double dt ;
linestream >> dt ;
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0 - dt) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] * (1.0 + dt) ;
min_dt = -dt;
max_dt = dt;
}
else
{
// TODO Specify the delta in case
// Handle multiple dim
double dt = args.get_float("dt", 0.1);
#ifdef RELATIVE_ERROR
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0 - dt) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] * (1.0 + dt) ;
#else
if(v[dimX() + i] > dt)
{
v[dimX() + dimY()+i] = v[dimX() + i] - dt ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + dt ;
{
double dt = args.get_float("dt", 0.1);
min_dt = -dt;
max_dt = dt;
}
if(args.is_defined("dt-relative"))
{
v[dimX() + dimY()+i] = v[dimX() + i] * (1.0 + min_dt) ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] * (1.0 + max_dt) ;
}
else
{
v[dimX() + dimY()+i] = 0.0 ;
v[dimX() + 2*dimY()+i] = dt ;
v[dimX() + dimY()+i] = v[dimX() + i] + min_dt ;
v[dimX() + 2*dimY()+i] = v[dimX() + i] + max_dt ;
}
#endif
}
}
// If data is not in the interval of fit
......@@ -163,6 +162,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
_min[k] = std::min(_min[k], v[k]) ;
_max[k] = std::max(_max[k], v[k]) ;
}
}
}
std::cout << "<<INFO>> loaded file \"" << filename << "\"" << std::endl ;
......
......@@ -17,6 +17,16 @@ class vertical_segment : public data
// Load data from a file
virtual void load(const std::string& filename) ;
//! \brief Load data from a file using the command line arguments
//!
//! \details
//! Specific arguments for the vertical segment data
//! --dt specify a value for the absolute/relative segment if not defined
//! in the data
//! --data-positive for the data to be positive
//! --dt-relative use a relative segment intervale. The dt is used
//! multipled by the data
virtual void load(const std::string& filename, const arguments& args) ;
......
......@@ -6,3 +6,7 @@ DESTDIR = ../../build
SOURCES += main.cpp
LIBS += -L../../build -lcore
unix{
PRE_TARGETDEPS += ../../build/libcore.a
}
......@@ -7,5 +7,6 @@ INCLUDEPATH += ../../ ../../libs/rational_1d \
SOURCES += main.cpp
LIBS += -L../../build -lcore
#QMAKE_CXXFLAGS += -frounding-math -fPIC
#QMAKE_LFLAGS += -Wl,-rpath='\$\$ORIGIN:.:./build:./plugins'
unix{
PRE_TARGETDEPS += ../../build/libcore.a
}
CONFIG += qt
INCLUDEPATH += ../../
DESTDIR = ../../build
SOURCES += main.cpp
LIBS += -L../../build -lcore
#include <core/args.h>
#include <core/data.h>
#include <core/params.h>
#include <core/function.h>
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
#include <cstdlib>
#include <cmath>
int main(int argc, char** argv)
{
QApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> data2moments --input data.file --output gnuplot.file --data loader.so --param RUSIN_TH_PH_TD_PD --partial 0" << std::endl ;
std::cout << " - input, output and data are mandatory parameters" << std::endl ;
return 0 ;
}
if(! args.is_defined("input")) {
std::cerr << "<<ERROR>> the input filename is not defined" << std::endl ;
return 1 ;
}
if(! args.is_defined("output")) {
std::cerr << "<<ERROR>> the output filename is not defined" << std::endl ;
return 1 ;
}
if(! args.is_defined("data")) {
std::cerr << "<<ERROR>> the data loader is not defined" << std::endl ;
return 1 ;
}
if(! args.is_defined("param")) {
std::cerr << "<<ERROR>> the parametrization is not defined" << std::endl ;
return 1 ;
}
// Import data
data* d = NULL ;
d = manager.get_data(args["data"]) ;
d->load(args["input"]);
// Create output file
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
if(d != NULL)
{
vec L(3), V(3), tempParam(params::dimension(p_in)), tempCart(6);
for(int i=0; i<d->size(); ++i)
{
// Copy the input vector
vec x = d->get(i);
vec out_x = x;
// Convert input to required param
params::convert(&x[0], d->parametrization(), p_in, &tempParam[0]);
// TODO Integrate
}
file.close();
}
else
{
std::cerr << "<<ERROR>> load file \"" << args["input"] << "\"" << std::endl ;
}
return 0 ;
}
......@@ -9,6 +9,8 @@ int main(int argc, char** argv)
std::ofstream f("input.gnuplot") ;
arguments args(argc, argv);
std::cout.precision(10);
int nbx = 100;
int nby = 100;
int nbz = 100;
......@@ -22,12 +24,14 @@ int main(int argc, char** argv)
{
f << "#DIM 1 1" << std::endl ;
f << "#PARAM_IN COS_TH" << std::endl;
f << "#VS 2" << std::endl;
for(int i=0; i<nbx; ++i)
{
const float x = i / (float)nbx ;
const float y = 100.0f * exp(-10.0 * x*x) * x*x - 0.01 *x*x*x + 0.1 ;
//const float y = 100.0f * exp(-10.0 * x*x) * x*x - 0.01 *x*x*x + 0.1 ;
const float y = (1.0) / (1.0E-5 + x*x*x);
f << x << "\t" << y << "\t" << 0.1f << std::endl ;
f << x << "\t" << y << "\t" << y*0.9f << "\t" << y*1.1f << std::endl ;
}
}
else if(k == 2)
......@@ -52,7 +56,7 @@ int main(int argc, char** argv)
const float y = j / (float)nby ;
const float z = 1 + 0.1f*x;
f << x << "\t" << y << "\t" << z << "\t" << 0.1f << std::endl ;
f << x << "\t" << y << "\t" << z << "\t" << z-0.1f << "\t" << z+0.1 << std::endl ;
}
}
else if(k == 4)
......@@ -63,7 +67,8 @@ int main(int argc, char** argv)
{
const float x = i / (float)nbx ;
const float y = j / (float)nby ;
const float z = exp(-10.0 * x*x) + x*y ;
const float z = x*y / (1.0E-3 + x*x*x) + 10.;
f << x << "\t" << y << "\t" << z << "\t" << 0.1f << std::endl ;
}
......
......@@ -5,4 +5,5 @@ SUBDIRS = generate_data \
brdf2gnuplot \
data2gnuplot \
data2diff \
data2moments \
# fourieranalysis
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