TABLE OF CONTENTS

1. ganessa.multithread/Functions_mt [ Introduction ]

[ Top ] [ Introduction ]

1.1. Functions_mt/mp_run [ Fonctions ]

[ Top ] [ Functions_mt ] [ Fonctions ]

DESCRIPTION

This function is provided for legacy Compatibility. parallel.MultiProc should be used instead.

SYNTAX

mp_run(logprint, tasks [, nb_cpu= -1] [, wait= 0.0] [, use_wpnum= False])

ARGUMENT

see MultiProc and run

RESULT

this function is implemented as:

HISTORY

1.2. Functions_mt/required_cpu [ Fonctions ]

[ Top ] [ Functions_mt ] [ Fonctions ]

SYNTAX

ncpu = required_cpu(nb_cpu)

ARGUMENT

int nb_cpu: expected number of parallel processes, up to the hardware core count. A negative or null value indicates the number of hardware cores + nb_cpu.

RESULT

int ncpu: actual number of parallel processes (1 ... max physical core count)

EXAMPLE

2. ganessa.parallel/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.parallel provides a multitasking (parallel) computing capability based on multiprocessing Process and Queue objects.

3. ganessa.parallel/Classes_mt [ Introduction ]

[ Top ] [ Introduction ]

3.1. Classes_mt/MultiProc, run,
run_sequential [ Objects ]

[ Top ] [ Classes_mt ] [ Objects ]

DESCRIPTION

The MultiProc class allows to define and run tasks in parallel. A number of N processing instances (nb_cpu provided, default all cores but one) are created; then tasks from the tasks list are dispatched to the processing instances.

An init task (resp. a term task) may be provided; if so it is called by each processing instance before the 1st task (resp. after the last one). If init is not provided, first N tasks are guaranteed to be run on distinct instances and can also be used for initialisation purposes. Then each task in the list is associated to the next processing instance available in turn. The execution order is not guaranteed (except the first N tasks if init is not provided).

run executes the tasks list in parallel processing instances; run_sequential executes the tasks list sequentially, i.e. init, tasks in order, term.

SYNTAX

ARGUMENT

RESULT

When reduce function is not provided:

When reduce function is provided:

REMARKS

HISTORY

4. ganessa.plot/functions_plot [ Introduction ]

[ Top ] [ Introduction ]

4.1. functions_plot/layout [ Fonctions ]

[ Top ] [ functions_plot ] [ Fonctions ]

PURPOSE

Determines the number of pages, lines and columns of a figure

SYNTAX

npages, nlines, ncols = layout(nbplots [, nlmax=6 ] [, ncmax= 4] [, orient= 'h'])

ARGUMENT

RESULT

EXAMPLE

4.2. functions_plot/plotmes, plotmesx,
pageplot, pageplotx [ Fonctions ]

[ Top ] [ functions_plot ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENT

REMARK

Type of data and units are displayed (in french) in the figure title

HISTORY

5. ganessa.sim&th/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.sim (resp. ganessa.th) provides a Python interface to Picwin32.dll and Ganessa_SIM.dll (resp. Ganessa_TH.dll) kernel API. It is provided as python wheels:

    - all versions up to version 2.1.9 (april 2021) are compatible with python 2.7.
    - from version 2, it is compatible with 32 and 64 bits versions of python 3.6/3.7.
    - from version 2.1, it is compatible with python 3.7.6 and 3.8.
    - from version 2.1.5, it is compatible with python 3.9.

The module name ganessa.sim&th is used for items availble both in .sim and .th environments

INSTALLATION

python -M pip install [--trusted-host pypi.org] ganessa

The package expects the simulation kernel .dll to be found either in the folders given by %GANESSA_DIR% environment variable (for Ganessa_xx.dll) or %PICCOLO_DIR% (for Picwin32.dll), or in the %PATH% environment variable (either name), or in %LOCALAPPDATA%/Programs folders:

or in one of the Program Files (x86) sub folders (Picalor6 replaces Piccolo6 if needed):

in either drive D: or C:

USE

Syntax:

Or:

the import will perform the following initialisation tasks:

CONTENT

The package provides the following content:

REMARKS

HISTORY

The history of the package is:

           postponed: <<add epanet 2.2.0 API as _epanet22 - same interface as _epanet2>>.

6. ganessa.sim&th/Classes [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Classes available to ganessa.sim and ganessa.th

6.1. Classes/Graph, extrnodes,
adjlinks, adjnodes,
propagate, dtree,
PURPOSE [ Objects ]

[ Top ] [ Classes ] [ Objects ]

SYNTAX

Graph = Graph([orientation])

METHODS

ARGUMENTS

RESULT

The Graph is built from the current model Links and Nodes:

REMARK

first key, value returned by dtree is the root NODE, and ('', 0)

HISTORY

7. ganessa.sim&th/Compatibility [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The installation of pyganessa is compatible with several versions of Picwin32.dll (regular Piccolo / Picalor). Missing functions in older versions should NOT be called.

HISTORY

REMARK

pyganessa is compatible with matching or newer versions of Ganessa_SIM/Ganessa_TH.dll only; except a Compatibility break on 170117.

8. ganessa.sim&th/Constants [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Several categories of Constants are available:

8.1. Constants/BRANCH, LINK,
NODE, NOEUD,
TANK, RESERVOIR,
RSV [ Constants ]

[ Top ] [ Constants ] [ Constants ]

DESCRIPTION

Those Constants allow to select one of the three types of model Elements:

REMARK

M.LNK, M.NOD and M.RSV are object Constants for calling BRANCH, NODE and RESERVOIR modules

8.2. Constants/DICT [ Constants ]

[ Top ] [ Constants ] [ Constants ]

DESCRIPTION

The DICT class provide a dictionnary tree for keywords

SYNTAX

DICT.SYMBOLIC_NAME

CONTENT

8.3. Constants/M, NONE [ Constants ]

[ Top ] [ Constants ] [ Constants ]

DESCRIPTION

The M class provide a dictionnary tree for modules. It provides a hierarchical naming of the commands by modules, for building language-independant commands using gencmd, gencmdw, _gencmdw functions.

SYNTAX

One of the following:

CONTENT

The available MODULE_SYMBOLIC_NAME are:

ROOT: modules names: BRA, NOD, RSV, DYN, MOD, SIM, QUA, MES, LAB, FIR, INV, OPT. They can be used in three forms, as first argument for the functions above:

GEN: general PURPOSE commands:

LNK: LINK commands and submodules, including LINK types (.PIPE .PUMP .NRV .PRV .PSV .FCV .TCV etc.)

NOD: NODE commands and submodules:

RSV: RESERVOIR command and submodules:

MES: measurement commands:

SIM: simulation commands:

QUA: Water quality module commands

REMARK

The above codes are not exhaustive. Please refer to the script.

9. ganessa.sim&th/Functions [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Functions available to ganessa.sim and ganessa.th

9.1. Functions/addSHLtype, addSHL,
updateSHL, delSHL [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

int istat: error status (0 if OK) COMMENTS If shltype is not given or is '' for delSHL then all SHL are removed from pipe.

REMARK

9.2. Functions/areas [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

HISTORY

From version 1.9.0 (05/04/2018) area are returned as unicode strings.

9.3. Functions/cmd, addcmdw,
execute, cmdfile [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ARGUMENTS

RESULT

int istat: error status (0 if OK)

REMARKS

If an error occurs while reading a file or nested files, the execution stops. If the useException mode is set, the error will raise a GanessaError

HISTORY

9.4. Functions/commit [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Executes all the commands available on the stack (first in, first executed)

SYNTAX

istat = commit()

RESULT

int istat: error status (0 if OK)

REMARK

If an error occurs, the remaining part of the stack is cleared

9.5. Functions/cwfold [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ret = cwfold(folder)

ARGUMENT

str folder: folder name where journal (piccolo.jnl) and work files will be created

RESULT

bool ret: True if folder exists; False otherwise

HISTORY

introduced in 1.7.7 (170705) * 1.9.6 (180615): fix non-ascii folder str converted to cp1252

9.6. Functions/dist2link [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the distance and curvilinear abcissae of a point from the given LINK

SYNTAX

ARGUMENTS

RESULT

HISTORY

introduced in 1.3.7 (160706)

REMARKS

9.7. Functions/dll_version, full_version [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

RESULT

REMARK

Starting with 2.2.4 (210901), if called before init(), dll_version() will return the version if the .dll is newer than 210831, 0 otherwise.

HISTORY

9.8. Functions/extrnodes [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the from and to NODE (indexes) form LINK index

SYNTAX

i_from, i_to = extrnodes(i_link)

ARGUMENTS

RESULT

REMARKS

9.9. Functions/gencmd, gencmdw,
raw_gencmdw, _gencmdw [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Those fuctions allow to generate a language independant command line based upon the keywords id of a module and its commands (see M).

SYNTAX

ARGUMENTS

RESULT

int istat: error status (0 if OK)

REMARKS

EXAMPLES

The following are equivalent:

The following are equivalent:

HISTORY

1.8.0 (170908): added raw_gencmdw

9.10. Functions/getall [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

getall(typelt, attr): when typelt =1 (Links), attr can be either a regular attribute ('Q', 'V', 'D', etc.) or a NODE-based attribute such as 'P:M' for mean pressure, 'P:G' for geometric mean, 'P:N' for min and 'p:X' for max.

9.11. Functions/getcodescount, nextcode [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

From version 1.9.0 (05/04/2018) codes are returned as unicode strings.

9.12. Functions/getdemandbycode, getcodedemandinit,
nextcodedemand [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

From version 1.9.0 (05/04/2018) codes are returned as unicode strings.

9.13. Functions/getid [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the id of an element by type and index

SYNTAX

id = getid(typelt, numelt)

ARGUMENTS

RESULT

unicode string id: id of the element

REMARKS

HISTORY

From version 1.9.0 (05/04/2018) ids are returned as unicode strings.

9.14. Functions/getindex, exists [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

9.15. Functions/getkeyword, modulekeyword,
attrkeyword [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

get keyword or command name by index - for building command language independant functions

SYNTAX

ARGUMENTS

RESULT

str sret: trimmed value of the keyword or global command or module submodule

         (null string if the code or module/submodule is not recognised)

HISTORY

9.16. Functions/getvar, getunitname,
getunitcoef [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the value of a Piccolo expression or variable

SYNTAX

ARGUMENTS

RESULT

REMARKS

Internal units are SI units excepted:

EXAMPLE

If the user flow unit is 'l/s', since internal flow unit is 'm3/s', getunitcoef('Q') returns 0.001

HISTORY

From version 1.9.0 (05/04/2018) info returned as unicode strings.

9.17. Functions/importEpanet, exportEpanet [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ARGUMENTS

string fname: file name to import from / export to (should be an .inp)

RESULT

int istat: error status (0 if OK)

REMARK

At import, .inp file is first converted to a .inp_cvt.dat Piccolo file, then this file is read. Syntax error if any will refer to the converted .dat file.

9.18. Functions/init [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

init([folder] [, silent=False] [, debug=False])

ARGUMENT

str folder: optional folder name where journal and work files will be created silent: if set to True, most information and warning message will not show

DESCRIPTION

Initialises the ganessa simulation/command language engine.

REMARKS

HISTORY

9.19. Functions/is_embedded [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

RESULT

HISTORY

9.20. Functions/linkattr, nodeattr,
tankattr, linkattrs,
nodeattrs, tankattrs,
attr, attrs,
meanattr [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

From version 1.9.0 (05/04/2018) ids and attributes are returned as unicode strings.

9.21. Functions/linkbbox [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the LINK bounding box

SYNTAX

ARGUMENTS

RESULT

HISTORY

Created in 1.8.5 (171128)

9.22. Functions/linkXYZV, branchXYZV [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the XYZ polyline representing a LINK, and eventually an additional NODE attribute

SYNTAX

ARGUMENTS

RESULT

HISTORY

optional argument include_depth introduced in 1.4.2 (160908)

REMARKS

9.23. Functions/loadbin [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Clears (removes) all model objects and loads a binary file

SYNTAX

istat = loadbin(fname)

ARGUMENT

string fname: binary data/result file name to be loaded

RESULT

int istat: error status (0 if OK)

REMARKS

9.24. Functions/loadres [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Loads the default binary result file.

SYNTAX

istat = loadres()

RESULT

int istat: error status (0 if OK)

REMARK

The current model is discarded before the data corresponding to the last simulation making use of the default result file is loaded.

9.25. Functions/nbobjects [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the number of model Elements in the given type

SYNTAX

nb = nbobjects(typelt)

ARGUMENT

int typelt: type of element (LINK, NODE, TANK)

RESULT

int nb: number of element in that type

9.26. Functions/nbvertices [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the number of Links with vertices (bends)

SYNTAX

nb = nbvertices()

RESULT

int nb: number of Links with vertices

9.27. Functions/nlinkattr, nnodeattr,
ntankattr, nlinkattrs,
nnodeattrs, ntankattrs,
nattr, nattrs [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

From version 1.9.0 (05/04/2018) ids and attributes are returned as unicode strings.

9.28. Functions/nodeXYZ [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the XYZ coordinates and depth of a NODE

SYNTAX

ARGUMENTS

RESULT

REMARKS

9.29. Functions/quit, close [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ret = quit([True])

ARGUMENT

optional bool verbose: if set to True, a message is printed. Defaults to False.

RESULT

text ret: text string telling that he module has been unloaded. Terminates the ganessa session and unloads the module ganessa.sim&th

REMARKS

9.30. Functions/reset [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Clears (removes) all model objects

SYNTAX

istat = reset()

RESULT

int istat: error status (0 if OK)

9.31. Functions/resfile, res_filename,
model_filename [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the name of the default binary result file; the model filename.

SYNTAX

name = resfile() name = res_filename() name = model_filename() folder = emb_model_folder()

RESULT

str name: file name or '' if undefined str folder: folder if called from embedded python or '' if not

HISTORY

9.32. Functions/save, savemodel [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ARGUMENTS

RESULT

int istat: error status (0 if OK)

REMARKS

EXAMPLE

savemodel('myModel.dat', version='3.95', extra_data=[('NOEUD', 'YY ZZ')])

HISTORY

9.33. Functions/selectlen, select [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENT

string sname: name of selection

RESULT

9.34. Functions/setbatchmode [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

oldmode = setbatchmode(mode)

ARGUMENT

int mode: batch mode to activate

RESULT

int oldmode: batch mode that was in effect

REMARK

Defaults to 1 (True)

9.35. Functions/setlang [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

oldlang = setlang(new_lang)

ARGUMENT

str new_lang: one of 'English', 'French', 'Spanish'

RESULT

str old_lang: previous language

DESCRIPTION

Modifiy the current command language to new_lang (console version and macros only). If the language name is misspelled, it will be ignored withour raising an error.

HISTORY

introduced in 1.8.0 (170912) reviewed 2.2.7 (211124) : accepts new_lang with at least 1 letter

9.36. Functions/setlinkattr, setbranchattr,
setnodeattr [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ARGUMENTS

RESULT

int istat: error status:

REMARKS

HISTORY

9.37. Functions/shearstr [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

Returns the shear stress associated with a velocity for the given pipe

SYNTAX

val, grad = shearstr(id, v)

ARGUMENTS

RESULT

REMARKS

HISTORY

9.38. Functions/useExceptions, GanessaError,
SimulationError, IsolatedNodeSimulationError [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

SYNTAX

ARGUMENTS

bool status: if True, errors will raise exceptions

RESULT

DESCRIPTION

SimulationError is a derived class of GanessaError. IsolatedNodeSimulationError is a derived class of SimulationError, thrown when a simulation error originates form isolated Nodes.

The simulation error subtypes (exc.reason) are the following:

REMARK

Defaults to False: errors do not raise 'GanessaError' exceptions. If set to True, errors raise exceptions with a string name giving the error message and a int reason giving the type of exception.

HISTORY

9.39. Functions/wqtracevectsize [ Fonctions ]

[ Top ] [ Functions ] [ Fonctions ]

PURPOSE

SYNTAX

RESULT

REMARK

One may expect a return value of either 9 (C1 .. C9) or 45 (C1 .. C9 + $0 .. $9 + $A .. $Z).

HISTORY

introduced 2.0.0 (180820)

10. ganessa.sim&th/Iterators [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Iterators available to ganessa.sim and ganessa.th

10.1. Iterators/Branches, Links [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

RESULT

string id: returns each BRANCH id in turn

REMARK

Branches and Links are synonyms

HISTORY

From version 1.9.0 (05/04/2018) ids are returned as unicode strings.

10.2. Iterators/DemandCodes [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for code, demand, nodecount in DemandCodes():

RESULT

Returns each demand code and NODE count in turn:

REMARK

HISTORY

Added 11/09/2015

10.3. Iterators/Demands [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for code, csm in Demands(node_id):

ARGUMENT

string node_id: id of NODE

RESULT

Returns each demand code and nominal value for the NODE in turn:

REMARK

HISTORY

From version 1.9.0 (05/04/2018) codes are returned as unicode strings.

10.4. Iterators/Elements [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for id in Elements(typelt):

ARGUMENT

int typelt: type element Constants LINK, NODE, TANK

RESULT

string id: id of each element of the given type in turn

HISTORY

From version 1.9.0 (2018/04/05) ids are returned as unicode strings. From version 2.0.3 (2018/12/03) len Compatibility with python3

10.5. Iterators/Nodes [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for id in Nodes():

RESULT

Returns each NODE id in turn

HISTORY

From version 1.9.0 (05/04/2018) ids are returned as unicode strings.

10.6. Iterators/Selected [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for id, typelt in Selected(sname [, return_type=True]):

ARGUMENT

string sname: name of a selection bool return_type: if False, the type is not returned (default True)

RESULT

Returns the id [and type] of each element in the selection in turn:

HISTORY

10.7. Iterators/Table [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for item, objcount in Table(Table, typelt):

ARGUMENTS

RESULT

Returns each Table entry and associated object count in turn:

REMARK

HISTORY

From version 1.9.0 (05/04/2018) items are returned as unicode strings.

10.8. Iterators/Tanks, Reservoirs [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

RESULT

string id: returns each RESERVOIR id in turn

HISTORY

From version 1.9.0 (05/04/2018) ids are returned as unicode strings.

10.9. Iterators/Unstable [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

PURPOSE

Provide access to the list of Elements which status cannot be determined thus causing a simulation not converge.

SYNTAX

for item, typelt in Unstable():

ARGUMENTS

NONE

RESULT

Returns each Unstable element in turn:

REMARK

HISTORY

10.10. Iterators/WQSources [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

PURPOSE

Provide access to the sequence of source items

SYNTAX

for NODE, code, attr, tvec, cvec, nvec in WQSources(NODE=NONE):

ARGUMENTS

string NODE: specific NODE to look for, or '' for all Nodes.

RESULT

Returns each source boundary condition in turn:

If NODE is given (non blank string):

If the NODE is not given, all WQ data will be returned

REMARK

HISTORY

11. ganessa.sim/sFunctions [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Functions available to ganessa.sim ONLY.

11.1. sFunctions/browseH, browseWQ [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

Retrieves and interpolate results from a given time step or instant:

SYNTAX

ARGUMENTS

RESULT

int istat: error status (0 if OK)

REMARKS

For hydraulic results, two set of results may be available at a given instant:

In such a situation the results are those from the end of the previous interval.

11.2. sFunctions/defcalind, getcalind [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

Compute and return calibration indicators

SYNTAX

ARGUMENTS

RESULT

val: percentage of values below threshold ival: indicator rank, from 1 (best) to 4 (worse) (-1 if not defined)

REMARK

defcalind actually compute all indicators; getcalind returns them.

11.3. sFunctions/full_solveH [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

Runs the full simulation and loads the result file for browsing results

SYNTAX

istat = full_solveH([resultfile] [, silent] [, iverb] [, retry])

ARGUMENT

RESULT

int istat: error status (0 if OK)

REMARKS

HISTORY

11.4. sFunctions/getallminmax [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

11.5. sFunctions/hstepcount, tslen,
mslen, tsval,
msval, tsvalbymts,
tsinterv, wqtslen,
refdate [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTOTY 12/12/2016 (1.5.1): bug fix when no simulation result available 15/03/2020 (2.1.1): added wqtslen; fix tsval for WQ ts

11.6. sFunctions/inv_summary [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

SYNTAX

ARGUMENTS

NONE

RESULT

REMARK

HISTORY

new in 1.3.4

11.7. sFunctions/msmooth [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

Defines the smoothing time width for time series of measurements

SYNTAX

msmooth(twidth)

ARGUMENTS

twidth: characteristic time window for smoothing, in seconds

REMARKS

11.8. sFunctions/setWQresultfile [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

Defines the binary result file(s) for WQ simulation.

SYNTAX

setWQresultfile([fnode] , [flink])

ARGUMENTS

REMARK

11.9. sFunctions/solveH [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

Runs the simulation at a given instant

SYNTAX

istat = solveH(time [, retry])

ARGUMENT

RESULT

int istat: error status (0 if OK)

HISTORY

11.10. sFunctions/stat_quantiles, stat_duration [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

stat_quantiles and stat_duration returns stat info associated with result TS of a given attribute for all Elements in a selection. raw_stat_quantiles and raw_stat_duration are pass_thru versions where the selection is provided as its type, buffer and length

SYNTAX

ARGUMENTS

RESULT

The functions return an empty list if the selection or qtl is empty .

EXAMPLE

REMARK

Allowed attributes are:

See also: getallminmax, getMinMax, Dynamic_Stats

HISTORY

11.11. sFunctions/tsdemand, tsdevice,
tsdemandlen, tsdevicelen [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

12. ganessa.sim/sIterators [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Iterators available to ganessa.sim ONLY

12.1. sIterators/Dynamic_Stats [ Iterator ]

[ Top ] [ sIterators ] [ Iterator ]

PURPOSE

Iterator which returns stat info associated with result TS of a given attribute for all Elements in a selection in turn.

SYNTAX

for id, retval in Dynamic_Stats(sel, attr [, quantile= qtl] [, duration= (sop, threshold)]):

ARGUMENT

RESULT

Returns the id and type of each element in the selection in turn:

The return value depends on the input parameters:

REMARK

See also getallminmax, stat_quantiles, stat_duration, getMinMax

HISTORY

12.2. sIterators/getMinMax [ Iterator ]

[ Top ] [ sIterators ] [ Iterator ]

PURPOSE

Returns the id, min, max, avg value reached by the attribute for each object of the given type or selection in turn

SYNTAX

for id, vmin, vmax, vavg in getMinMax(typelt or selection, sattr):

ARGUMENT

RESULT

id, vmin, vmax, vavg: str element id, minimum, maximum and average values for the attribute over the simulation

HISTORY

13. ganessa.sort/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.sort provides sorting functions and Classes used by the Ganessa tools.

14. ganessa.sort/sClasses [ Introduction ]

[ Top ] [ Introduction ]

14.1. sClasses/HeapSort [ Objects ]

[ Top ] [ sClasses ] [ Objects ]

SYNTAX

Instances provide the following methods:

ARGUMENTS

RESULT

HISTORY

Introduced in 1.8.2 (171031)

15. ganessa.th/tFunctions [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Functions available to ganessa.th ONLY

15.1. tFunctions/solveTH [ Fonctions ]

[ Top ] [ tFunctions ] [ Fonctions ]

PURPOSE

Runs the thermo-hydraulic simulation

SYNTAX

istat = solveH([silent=False [, iverb=-1 [, retry=True]]])

ARGUMENTS

RESULT

int istat: error status (0 if OK)

HISTORY

15.2. tFunctions/symmetric_node [ Fonctions ]

[ Top ] [ tFunctions ] [ Fonctions ]

SYNTAX

ids = symmetric_node(sid)

ARGUMENTS

string sid: NODE ID for which the symmetric (counterpart NODE on the other circuit) is looked for

RESULT

REMARKS

HISTORY

new in 1.3.6

16. ganessa.util/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.util provides useful functions used by the Ganessa tools.

REMARK

Some of the functions must be preceded by 'import ganessa.sim'

17. ganessa.util/functions [ Introduction ]

[ Top ] [ Introduction ]

17.1. functions/call_until_false [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

Calls a function with args until return is false

SYNTAX

ARGUMENT

RESULT

REMARK

Use of this function is meaningful with side-effect functions. The function is repeatedly called with the same argument list; the result is not just duplicated.

HISTORY

17.2. functions/decode_time, decode_date [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

17.3. functions/dist_to_poly, dist_p_seg,
dist, split_poly_at [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

Computes the distance of a point (xn, yn) to a polyline or a segment

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

17.4. functions/envoi_msg [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

status = envoi_msg(exp, dst, objet, texte [, serveur=smtp.safege.net] [, pwd=NONE])

ARGUMENT

RESULT

HISTORY

17.5. functions/FichInfo, banner [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

string filename: input file name - expects the name of the caller '__file__'

RESULT

a class member containing the following fields and method:

HISTORY

17.6. functions/formatting: strf2, strf3,
strf2loc, strf3loc,
stri, hhmmss,
strd [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

REMARK

HISTORY

23/11/2020 (2.1.6): added 'days' keyword to hhmmss.

17.7. functions/get_proxy [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

proxy = get_proxy([folder=NONE] [, default=''])

ARGUMENTS

RESULT

string proxy: value of the proxy, False if not found

REMARKS

The .json configuration files are searched for either a "proxy" key or the first element of the first list. Files names are: 'https_proxy', 'Mise_a_jour_packages', 'proxy'.

HISTORY

1.8.8 (171212) created get_proxy 2.1.0 (200214) fix urllib3 requiring proxy scheme (http[s]://) 2.1.5 (210927) fix kwarg name default in doc; fix return value

17.8. functions/get_python_exe [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

name = get_python_exe()

RESULT

str name: path/name to the python executable in use, possibly without extension

HISTORY

2.0.7 (190821) created

17.9. functions/gfloat, gint,
gbool [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

string input_str: string value to be converted to a float or int or bool. The decimal separator can either be '.' or ','.

RESULT

HISTORY

171127: gbool added

17.10. functions/IniFile, get,
set, getall,
setall, save [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

17.11. functions/IniFile1L, get,
set, remove,
save [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

17.12. functions/is_text, myascii,
unistr, str2uni,
utf2uni, con2uni [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

input_str: value to be converted. Can be of any type: non text input are first converted to unicode.

RESULT

HISTORY

17.13. functions/is_wq [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

unicode or byte string attr: attribute str lang: kernel lang (default NONE)

RESULT

bool bret: true if att in T, C0 .. C9, $0 .. $9, $A .. $Z

HISTORY

17.14. functions/lec_csv [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

header, content = lec_csv(filename [, sep=','] [, skip_before=0] [, skip_after=0] [, as_tuple=False])

ARGUMENT

RESULT

REMARK

The entire file is read into 'content'

17.15. functions/list2file [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

fname = list2file(idlist [, header] [, footer] [, folder] [, suffix])

ARGUMENT

RESULT

str fname: name of a temporary file containing header if any, Elements of idlist, footer if any, one per line.

17.16. functions/piccolo_context [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

Reads Context.pic and return colorset and tresholds for given attribute

SYNTAX

ARGUMENT

RESULT

REMARK

Returns as many colors as str thresholds if attr is alphanumeric; one more color than float thresholds if attr is numeric.

A tuple of NONE is returned in case of failure

HISTORY

17.17. functions/quotefilename [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

17.18. functions/roundval, scaladjust [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

Computes a rounded approximation of a float number

SYNTAX

ARGUMENT

RESULT

REMARK

scaladjust is used to determine the grid interval for plots as scaladjust(0.25*(ymax-ymin)) HISTORY: * 20.03.13 (2.1.1) fixed rounding when val < 1

17.19. functions/toidpic [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

out_str = toidpic(input_str)

ARGUMENT

unicode or string input_str: string value to be converted to a Piccolo ID

RESULT

ascii string where blank, comma, equal are replaced with underscore, other non litteral or digit are replaced with minus.

17.20. functions/update_package [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

stat = update_package(package_name [, minvers=''] [, pypi_name=NONE] [, deps= False] [, https_proxy= NONE] [, verbose= True])

ARGUMENT

RESULT

bool stat: true if the package has been installed or updated

REMARKS

HISTORY

17.21. functions/utf8_bom_encoding [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

encoding = utf8_bom_encoding(filename=NONE)

ARGUMENT

RESULT

string encoding:

    * 'utf_8_sig' if no file argument passed
    * 'utf_8_sig' if file exists and encoding is utf8-bom
    * NONE if file does not exists or encoding is not utf8-bom

HISTORY

17.22. functions/winstr, utf,
ws, aws,
codewinfile [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

unicode or byte string input_str: string value to be encoded to windows-compatible string

RESULT

REMARK

codewinfile and winstr are synonyms

HISTORY

17.23. functions/XMLduration [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ival = XMLduration(input_string)

ARGUMENT

string input_str: XML duration string value to be converted to a number of seconds.

The input format is [-]PnYnMnDTnHnMnS where:

RESULT

int ival: number of seconds

18. ganessa.util/iterators [ Introduction ]

[ Top ] [ Introduction ]

18.1. iterators/group [ Iterator ]

[ Top ] [ iterators ] [ Iterator ]

SYNTAX

for items in group(iterable, count= 2):

ARGUMENT

RESULT

this iterator allows to return the Elements of iterable grouped by lists of size count. The last list may contain less than group Elements

HISTORY