13.2.3. Macro “dataserverLoadASCIIFilePasture.C

13.2.3.1. Objective

The objective of this macro is to load two TDataServer objects using two different ways: either with an ASCII file "pasture.dat" or with a design-of-experiments. Then, we evaluate the analytic function ModelPasture on this two TDataServer. The data file "pasture.dat" is written in the “Salome-table” format of Uranie:

#COLUMN_NAMES: time| yield

9 8.93
14 10.8
21 18.59
28 22.33
42 39.35
57 56.11
63 61.73
70 64.62
79 67.08

13.2.3.2. Macro Uranie

#include "TMath.h"

void ModelPasture(Double_t *x, Double_t *y)
{
    Double_t theta1=69.95, theta2=61.68, theta3=-9.209, theta4=2.378;

    y[0] = theta1;
    y[0] -= theta2* TMath::Exp( -1.0 * TMath::Exp( theta3 + theta4 * TMath::Log(x[0])));
}

void dataserverLoadASCIIFilePasture(const string& style="", const bool progressBar=true)
{
    TCanvas *C = new TCanvas("mycanvas","mycanvas",1);
    
    TDataServer* tds = new TDataServer();
    tds->fileDataRead("pasture.dat");

    tds->getTuple()->SetMarkerStyle(8);
    tds->getTuple()->SetMarkerSize(1.5);
    tds->draw("yield:time");
    
    TLauncherFunction *tlf = new TLauncherFunction(tds, ModelPasture,"time","yhat");
    tlf->run();

    tds->getTuple()->SetMarkerColor(kBlue);
    tds->getTuple()->SetLineColor(kBlue);
    
    tds->draw("yhat:time","","lpsame");
    
    TDataServer *tds2 = new TDataServer();
    tds2->addAttribute( new TUniformDistribution("time2",9, 80));

    TSampling *tsamp = new TSampling(tds2, "lhs", 1000);
    tsamp->generateSample();

    tds2->getTuple()->SetMarkerColor(kGreen);
    tds2->getTuple()->SetLineColor(kGreen);
    tlf = new TLauncherFunction(tds2, ModelPasture,"","yhat2");
    tlf->run();

    tds2->draw("yhat2:time2","","psame");
    tds->draw("yhat:time","","lpsame");

    gPad->SaveAs("pasture.png");
}

The design ModelPasture is defined in a function

void ModelPasture(Double_t *x, Double_t *y)
{
    Double_t theta1=69.95, theta2=61.68, theta3=-9.209, theta4=2.378;

    y[0] = theta1;
    y[0] -= theta2* TMath::Exp( -1.0 * TMath::Exp( theta3 + theta4 * TMath::Log(x[0])));
}

The first TDataServer is filled with the ASCII file "pasture.dat" through the fileDataRead method

    tds->fileDataRead("pasture.dat");

The design is evaluated with the function ModelPasture applied on the input attribute time, leading to the output attribute named yhat.

    TLauncherFunction *tlf = new TLauncherFunction(tds, ModelPasture,"time","yhat");
    tlf->run();

A TAttribute, obeying an uniform law on [9;80] is added to the second TDataServer which is filled with a design-of-experiments of 1000 patterns, using the LHS method.

    tds2->addAttribute( new TUniformDistribution("time2",9, 80));
    TSampling *tsamp = new TSampling(tds2, "lhs", 1000);
    tsamp->generateSample();

The design is now evaluated with this TDataServer on the attribute time2

    tlf = new TLauncherFunction(tds2, ModelPasture,"","yhat2");
    tlf->run();

13.2.3.3. Graph

../../_images/pasture.png

Figure 13.2 Graph of the macro "dataserverLoadASCIIFilePasture.C"

13.2.3.4. Console

--- Uranie v4.11/0 --- Developed with ROOT (6.36.06)
                      Copyright (C) 2013-2026 CEA/DES 
                      Contact: support-uranie@cea.fr 
                      Date: Thu Feb 12, 2026

Info in <TCanvas::Print>: png file pasture.png has been created