Beispiel #1
0
def MTG(filename):
    """
    MTG constructor.

    Builds a MTG from a coding file (text file) containing the description of one or several plants.

    :Usage:

    ::

        MTG(filename)

    :Parameters:

        - `filename` (str): name of the coding file describing the mtg

    :Returns:

        If the parsing process succeeds, returns an object of type :func:`MTG`.
        Otherwise, an error is generated, and the formerly active `MTG` remains active.

    :Side Effect:

        If the :func:`MTG` is built, the new :func:`MTG` becomes the active :func:`MTG` (i.e. the :func:`MTG` implicitly
        used by other functions such as :func:`Father()`, :func:`Sons()`, :func:`VtxList()`, ...).

    :Details:

        The parsing process is approximatively proportional to the number of components
        defined in the coding file.

    :Background:

        MTG is an acronyme for Multiscale Tree Graph.

    .. seealso:: :func:`Activate` and all :mod:`openalea.mtg.aml` functions.
    """
    global _g
    _g = read_mtg_file(filename)
    return _g
Beispiel #2
0
import openalea.mtg.io as io

reload(io)

#io.debug = 1
fn = r'data/agraf.mtg'
fn2 = r'data/rapple.mtg'

#fn = r'data/mtg5.mtg'
"""
f = open(fn)
s = f.read()
f.close()

r = io.Reader(s)
# skip the header
r.header()

# read the MTG header
r._nb_feature=2
r._feature_head = ['nbEl', 'diam']
r._feature_slice=slice(5,7)

#debug
r.preprocess_code()
print r._new_code
"""
g = io.read_mtg_file(fn)