TABLE OF CONTENTS

1. ganessa.en2emu/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.en2emu provides compatibility for a limited set of functions used by Ganessa tools, such as OpenFileMMI.SelectModel. It makes use of owa_epanet22 if owa-epanet is installed, otherwise it uses epanet22 legacy, limited API.

It creates a hidden _emu_object ENmodel object for the current model, caching Pipes, tanks, hydaulic EPS results, pressure and flow unit and coefficients etc.

HISTORY

2. ganessa.epanet2/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.epanet2 provides epanettools API for epanet 2.00.12. It is a copy of epanettools 0.4.3, with minor fixes.

3. ganessa.epanet22/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.epanet22 provides epanettools API for epanet 2.2, similar to Epanet 2.0 (legacy API to a single project).

4. ganessa.multithread/Functions_mt [ Introduction ]

[ Top ] [ Introduction ]

4.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

4.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

5. ganessa.owa_epanet22/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

The module ganessa.owa_epanet22 provides epanettools compatibility for owa-epanet package, in the sense it hides the Epanet 2.2 project argument by using a default single project, but allow to close / create that project for multiprocessing.

HISTORY

6. ganessa.parallel/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

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

7. ganessa.parallel/Classes_mt [ Introduction ]

[ Top ] [ Introduction ]

7.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

8. ganessa.plot/functions_plot [ Introduction ]

[ Top ] [ Introduction ]

8.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

Determine number of pages (nf), lines and columns; then plot page by page

       nf, nl, nc = layout(len(mes))
       for i in range(nf):
           plotmes(graphs[i*nl*nc:(i+1)*nl*nc] , ...)

8.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

9. ganessa.proj/Classes_proj [ Introduction ]

[ Top ] [ Introduction ]

9.1. Classes_proj/FrenchProjMapping [ Objects ]

[ Top ] [ Classes_proj ] [ Objects ]

PURPOSE

Provides and maintains a bijective dict of symbolic -> EPSG usual French CRS.

SYNTAX

projs = FrenchProjMapping()

METHODS

REMARK

Initial dict values are available as FrenchProjMapping().mapping. They include wgs84, various lambert systems for French Metropolitan, utm20n (Martinique and Guadeloupe), rgaf09 (Martinique), utm40s (la Reunion), utm22n (Guyanne), and macao

HISTORY

10. ganessa.proj/functions_proj [ Introduction ]

[ Top ] [ Introduction ]

10.1. functions_proj/get_spatial_ref [ Fonctions ]

[ Top ] [ functions_proj ] [ Fonctions ]

PURPOSE

Query or retrieves the spatial ref from the (current) model

SYNTAX

crs_name = get_spatial_ref(pic_module [, model_file])

ARGUMENT

RESULT

Name of the CRS as defined in the Piccolo models as "SPATIAL-REF" command

REMARKS

HISTORY

10.2. functions_proj/guess_proj, to_epsg,
to_symbolic [ Fonctions ]

[ Top ] [ functions_proj ] [ Fonctions ]

PURPOSE

Determines the CRS (projection) amongst usual French metropolitan CRS

SYNTAX

ARGUMENT

RESULT

str name_or_epsg: EPSG:xxxx or symbolic name, depending on the value of as_epsg:

EXAMPLE

guess_proj((646464.64, 6868686.8), True) should return EPSG:2154

HISTORY

11. 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:

The module name ganessa.sim&th is used for items available 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 C: or D:

USE

Syntax:

       import ganessa.sim as pic   (or ganessa.th for Picalor)
       pic.cmdfile("my file.dat")

Or:

       from ganessa.sim import *
       cmdfile("my file.dat")

the import will perform the following initialisation tasks:

CONTENT

The package provides the following content:

REMARKS

HISTORY

The history of the package is:

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

[ Top ] [ Introduction ]

DESCRIPTION

Classes available to ganessa.sim and ganessa.th

12.1. Classes/Graph_, extrnodes,
adjlinks, adjnodes,
propagate, dtree,
antennas [ Objects ]

[ Top ] [ Classes ] [ Objects ]

PURPOSE

Builds a simple graph from the current model topology.

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

13. 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.

14. ganessa.sim&th/Constants_ [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Several categories of constants are available:

15. ganessa.sim&th/Exceptions_ [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Exceptions available to ganessa.sim and ganessa.th

16. ganessa.sim&th/Functions_ [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

functions available to ganessa.sim and ganessa.th

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

[ Top ] [ Introduction ]

DESCRIPTION

Iterators available to ganessa.sim and ganessa.th

17.1. 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

17.2. 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.

17.3. 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

17.4. Iterators/Links_, Branches_ [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

RESULT

string id: returns each BRANCH id in turn

REMARK

Branches and Links are equivalent.

HISTORY

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

17.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.

17.6. Iterators/Pipes [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for id in Pipes():

for id, *retvals in Pipes(*attrs):

ARGUMENT

optional str attrs: attributes values to be returned

RESULT

Returns the id [and attributes values if one or more "attr" given] of each pipe element in turn:

HISTORY

17.7. Iterators/Selectid, Selected [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for id in Selectid(select_name):

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

ARGUMENT

string select_name: selection definition or selection name 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

17.8. Iterators/SupplyNodes [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for id in SupplyNodes():

RESULT

Returns each supply node id in turn

HISTORY

Created in 2.3.5 (221111)

17.9. 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:

REMARKS

HISTORY

17.10. Iterators/TableValues [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

for item, objcount, vect in TableValues(table):

ARGUMENTS

string table: requested table (2 char symbol or table name)

RESULT

Returns each table entry and associated object count and values in turn:

The vector size depends on the table:

REMARKS

HISTORY

17.11. Iterators/Tanks_, Reservoirs_ [ Iterator ]

[ Top ] [ Iterators ] [ Iterator ]

SYNTAX

RESULT

string id: returns each reservoir id in turn

REMARK

Tanks and Reservoirs are equivalent and return both tanks and pressure references. In order to return specifically either, use Selectid with the appropriate selection: (FR) "RESERVOIR (VO > 0) FIN" or "RESERVOIR (VO = 0) FIN" (UK) "RESERVOIR (VO > 0) END"

HISTORY

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

17.12. 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

18. ganessa.sim/sFunctions [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

functions available to ganessa.sim ONLY.

18.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.

18.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

18.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

18.4. sFunctions/getallminmax [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

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

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

18.6. sFunctions/inv_summary, inv_varcount,
inv_variable [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

SYNTAX

ARGUMENTS

RESULT

REMARK

HISTORY

18.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

18.8. sFunctions/setWQresultfile [ Fonctions ]

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

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

SYNTAX

setWQresultfile([fnode] , [flink])

ARGUMENTS

REMARK

18.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

18.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

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

[ Top ] [ sFunctions ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

19. ganessa.sim/sIterators [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

Iterators available to ganessa.sim ONLY

19.1. sIterators/ControlEntities [ Iterator ]

[ Top ] [ sIterators ] [ Iterator ]

PURPOSE

Provide access to the control entities

SYNTAX

for name, item_names, descr_combs, pump_count, combis in ControlEntities():

ARGUMENTS

none

RESULT

Returns each control entity information in turn:

REMARKS

EXAMPLE

For a control entity comprising 1 valve and 2 pumps and 4 combinations, the iterator will return ('ENTITY_NAME', ['VALVE_NAME', 'PUMP1', 'PUMP2'], ['Descr1', 'Descr2', 'Descr3', 'Descr4'], 2, combis) where shape(combis) is (4, 5):

HISTORY

19.2. sIterators/Controls_ [ Iterator ]

[ Top ] [ sIterators ] [ Iterator ]

PURPOSE

Provide access to the controls on pumps and manual valves

SYNTAX

for control_id, control_data in Controls([which]):

ARGUMENTS

str which: "GU" or "GROUPE-CONTROLE" for getting control entities; leave blank for valves and pumps

RESULT

Returns each control information in turn - control_id is a ControlId NamedTuple:

control_data = ControlData NamedTuple:

REMARKS

HISTORY

19.3. 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

19.4. 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

19.5. sIterators/IPSVariable [ Iterator ]

[ Top ] [ sIterators ] [ Iterator ]

PURPOSE

Provide access to the fitted values after IPS

SYNTAX

for sid, val, delta in IPSVariable(stype):

ARGUMENTS

str stype: IPS variable category (ZN, PR, K, CS)

RESULT

Returns each variable identifier and value:

REMARK

HISTORY

19.6. sIterators/WQSources [ Iterator ]

[ Top ] [ sIterators ] [ 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

20. ganessa.sort/About [ Introduction ]

[ Top ] [ Introduction ]

PURPOSE

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

21. ganessa.sort/sClasses [ Introduction ]

[ Top ] [ Introduction ]

21.1. sClasses/HeapSort [ Objects ]

[ Top ] [ sClasses ] [ Objects ]

SYNTAX

hs = HeapSort([key]): creates the heap structure. Instances provide the following methods:

ARGUMENTS

RESULT

HISTORY

22. ganessa.th/tFunctions [ Introduction ]

[ Top ] [ Introduction ]

DESCRIPTION

functions available to ganessa.th ONLY

22.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

22.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

23. 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'

24. ganessa.util/functions [ Introduction ]

[ Top ] [ Introduction ]

24.1. functions/call_until_false [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

Calls a function with args until return is false

SYNTAX

res = call_until_false(func, args [, maxcount=99])

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

24.2. functions/cmp_version [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

Compare two tuples and/or version numbers "x[.y[.z]]"

SYNTAX

res = cmp_version(vers1, vers2)

ARGUMENT

tuple or str vers1, vers2: either tuples or list of integers or version string

RESULT

-1 if vers1 < vers2; 0 if vers1 == vers2; 1 if vers1 > vers2

REMARK

str args are converted to tuple of integers before comparison so mixed comparison is allowed

EXAMPLE

cmp_version("3.9", "3.10") (equivalent to cmp_version("3.9", (3, 10))) returns -1

24.3. functions/decode_time, decode_date,
as_seconds [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

24.4. 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

24.5. functions/envoi_msg [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

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

ARGUMENT

RESULT

HISTORY

24.6. functions/FichInfo, banner [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

a class member containing the following fields and method:

HISTORY

24.7. 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.

24.8. 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

24.9. 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

24.10. 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

24.11. functions/IniFile, get_,
set_, getall,
setall, save_ [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

24.12. functions/IniFile1L, get_,
set_, remove_,
save_ [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

24.13. 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

24.14. functions/is_wq [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

bret = is_wq(attr, lang=None)

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

24.15. functions/lec_csv, csv_with_tabs [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

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

content = csv_with_tabs(filename [, sep=','] [, skip_before=-1] [, skip_after=0] [, as_tuple=False] [, trim=True])

ARGUMENT

RESULT

REMARKS

24.16. 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.

24.17. functions/piccolo_context [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

PURPOSE

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

SYNTAX

attr, cname, tvals, cvals = piccolo_context(fcontext, attr=None, verbose=False)

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

24.18. functions/quotefilename [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

txt = quotefilename(name)

ARGUMENT

RESULT

HISTORY

24.19. 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

24.20. 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.

24.21. 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

24.22. functions/utf8_bom_encoding [ Fonctions ]

[ Top ] [ functions ] [ Fonctions ]

SYNTAX

encoding = utf8_bom_encoding(filename=None)

ARGUMENT

RESULT

string encoding:

HISTORY

24.23. 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

24.24. 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

25. ganessa.util/iterators [ Introduction ]

[ Top ] [ Introduction ]

25.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

26. Exceptions/useExceptions, GanessaError,
SimulationError, IsolatedNodeSimulationError [ Exceptions ]

[ Top ] [ Exceptions ]

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

27. Constants/BRANCH, LINK_,
NODE_, NOEUD,
TANK_, RESERVOIR_,
RSV [ Constants ]

[ Top ] [ 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

28. Constants/DICT_ [ Constants ]

[ Top ] [ Constants ]

DESCRIPTION

The DICT class provide a dictionnary tree for keywords

SYNTAX

DICT.SYMBOLIC_NAME

CONTENT

29. Constants/M [ Constants ]

[ Top ] [ 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.

30. Constants/STR_ATTR_FR, STR_ATTR_EN,
STR_ATTR_SP [ Constants ]

[ Top ] [ Constants ]

DESCRIPTION

Sets of attributes whose values are str; other attributes are numeric. * STR_ATTR_FR: French str attributes * STR_ATTR_EN: English str attributes * STR_ATTR_SP: Spanish str attributes

REMARK

see attr_is_str for testing against current language.

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

[ Top ] [ 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

32. Functions/areas [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

return areas associated with nodes/links

SYNTAX

area = areas(typelt, attr)

ARGUMENTS

RESULT

HISTORY

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

33. Functions/attr_is_str [ Fonctions ]

[ Top ] [ Fonctions ]

DESCRIPTION

Returns True if the given attribute in the current language is a str value.

SYNTAX

ret = attr_is_str(attrib)

ARGUMENT

str attrib: symbol for the attribute

RESULT

bool ret: True if the attribute value is of type str, False if not

REMARK

Allow to select which function to use

EXAMPLE

linkattr if attr_is_str(attr) else linkattrs

HISTORY

Created 2024-07-18 (2.4.4)

34. Functions/cmd, addcmdw,
execute_, cmdfile [ Fonctions ]

[ Top ] [ 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

35. Functions/commit [ Fonctions ]

[ Top ] [ 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

36. Functions/cwfold [ Fonctions ]

[ Top ] [ 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

37. Functions/dist2link [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

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

SYNTAX

d, s1, s2 = dist2link(id, x, y)

ARGUMENTS

RESULT

HISTORY

introduced in 1.3.7 (160706)

REMARKS

38. Functions/dll_version, full_version [ Fonctions ]

[ Top ] [ 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

39. Functions/extrnodes [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

Returns the from and to node (indexes) form link index

SYNTAX

i_from, i_to = extrnodes(i_link)

ARGUMENTS

RESULT

REMARKS

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

[ Top ] [ 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

41. Functions/getall [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

getall returns the value for all objects of the given type

SYNTAX

vect = getall(typelt, attr)

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.

42. Functions/getcodescount, nextcode [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

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

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

[ Top ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

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

44. Functions/getid [ Fonctions ]

[ Top ] [ 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.

45. Functions/getindex, exists_ [ Fonctions ]

[ Top ] [ Fonctions ]

SYNTAX

ARGUMENT

RESULT

HISTORY

46. Functions/getkeyword, modulekeyword,
attrkeyword, attrname,
attrindex [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

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

SYNTAX

ARGUMENTS

RESULT

HISTORY

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

[ Top ] [ 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.

48. Functions/implemented_ [ Fonctions ]

[ Top ] [ Fonctions ]

SYNTAX

ret = implemented(name)

ARGUMENT

str name: name of the function or iterator

RESULT

bool ret: True if implemented, False if not

HISTORY

Created 2022-07-21 (2.3.1)

49. Functions/importEpanet, exportEpanet [ Fonctions ]

[ Top ] [ 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.

50. Functions/is_embedded [ Fonctions ]

[ Top ] [ Fonctions ]

SYNTAX

ret = is_embedded()

RESULT

HISTORY

51. Functions/linkattr, nodeattr,
tankattr, linkattrs,
nodeattrs, tankattrs,
attr_, attrs_,
meanattr, linkattrv,
tankattrv [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

52. Functions/linkbbox [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

Returns the link bounding box

SYNTAX

xmin, xmax, ymin, ymax, num = linkbbox(id)

ARGUMENTS

RESULT

HISTORY

Created in 1.8.5 (171128)

53. Functions/linkXYZV, branchXYZV [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

Returns the XYZ polyline representing a link, and eventually an additional node attribute

SYNTAX

vec_x, vec_y, vec_z, vec_v, len = linkXYZV(id, [attr], [include_depth])

ARGUMENTS

RESULT

HISTORY

optional argument include_depth introduced in 1.4.2 (160908)

REMARKS

54. Functions/loadbin [ Fonctions ]

[ Top ] [ 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

55. Functions/loadres [ Fonctions ]

[ Top ] [ 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.

56. Functions/nbobjects [ Fonctions ]

[ Top ] [ 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

57. Functions/nbvertices [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

Returns the number of links with vertices (bends)

SYNTAX

nb = nbvertices()

RESULT

int nb: number of links with vertices

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

[ Top ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENTS

RESULT

REMARKS

HISTORY

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

59. Functions/nodeXYZ [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

Returns the XYZ coordinates and depth of a node

SYNTAX

x, y, z, dz = nodeXYZ(id)

ARGUMENTS

RESULT

REMARKS

60. Functions/openg, init_ [ Fonctions ]

[ Top ] [ Fonctions ]

SYNTAX

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

61. Functions/quit_, close_ [ Fonctions ]

[ Top ] [ 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

HISTORY

62. Functions/reset_ [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

Clears (removes) all model objects

SYNTAX

istat = reset()

RESULT

int istat: error status (0 if OK)

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

[ Top ] [ 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

64. Functions/save_, savemodel [ Fonctions ]

[ Top ] [ 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

65. Functions/selectlen, select_ [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

SYNTAX

ARGUMENT

string sname: name of selection

RESULT

66. Functions/setbatchmode [ Fonctions ]

[ Top ] [ 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)

67. Functions/setlang [ Fonctions ]

[ Top ] [ Fonctions ]

SYNTAX

oldlang = setlang([new_lang = "None"])

ARGUMENT

str new_lang: one of 'English', 'French', 'Spanish'. Defaults to 'None'.

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 (or 'None'), it will be ignored withour raising an error, so the function will just return the current language.

HISTORY

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

[ Top ] [ Fonctions ]

SYNTAX

ARGUMENTS

RESULT

int istat: error status:

REMARKS

HISTORY

69. Functions/shearstr [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

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

SYNTAX

val, grad = shearstr(id, v)

ARGUMENTS

RESULT

REMARKS

HISTORY

70. Functions/wqtracevectsize [ Fonctions ]

[ Top ] [ Fonctions ]

PURPOSE

wqtracevectsize returns the max count of water quality concentrations allowed, including chlorine (C1).

SYNTAX

n = wqtracevectsize()

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)