13.3.3. Macro “dataserverLoadASCIIFilePasture.py”
13.3.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.3.3.2. Macro Uranie
"""
Example of data loading with pasture file
"""
from URANIE import DataServer, Sampler, Launcher
import ROOT
C = ROOT.TCanvas("mycanvas", "mycanvas", 1)
ROOT.gROOT.LoadMacro("UserFunctions.C")
tds = DataServer.TDataServer()
tds.fileDataRead("pasture.dat")
tds.getTuple().SetMarkerStyle(8)
tds.getTuple().SetMarkerSize(1.5)
tds.draw("yield:time")
tlf = Launcher.TLauncherFunction(tds, "ModelPasture", "time", "yhat")
tlf.run()
tds.getTuple().SetMarkerColor(ROOT.kBlue)
tds.getTuple().SetLineColor(ROOT.kBlue)
tds.draw("yhat:time", "", "lpsame")
tds2 = DataServer.TDataServer()
tds2.addAttribute(DataServer.TUniformDistribution("time2", 9, 80))
tsamp = Sampler.TSampling(tds2, "lhs", 1000)
tsamp.generateSample()
tds2.getTuple().SetMarkerColor(ROOT.kGreen)
tds2.getTuple().SetLineColor(ROOT.kGreen)
tlf = Launcher.TLauncherFunction(tds2, "ModelPasture", "", "yhat2")
tlf.run()
tds2.draw("yhat2:time2", "", "psame")
tds.draw("yhat:time", "", "lpsame")
ROOT.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])));
}
Which is C++ and is loaded thanks to the function ROOT.gROOT.LoadMacro("UserFunctions.C").
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.
tlf = Launcher.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.
tsamp = Sampler.TSampling(tds2, "lhs", 1000)
tsamp.generateSample()
The design is now evaluated with this TDataServer on the attribute time2
tlf = Launcher.TLauncherFunction(tds2, "ModelPasture", "", "yhat2")
tlf.run()
13.3.3.3. Graph
Figure 13.2 Graph of the macro
"dataserverLoadASCIIFilePasture.py"
13.3.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