Пример #1
0
def export_to_mtg(lstring):
    from openalea.mtg.io import axialtree2mtg
    # Name of the modules to export
    tree_parameters = ['treename', 'estimation', 'loading', 'variety', 'seed']
    for m in lstring:
        if m.name == 'Tree':
            tree_parameters = list(m[0].parameter_names())
            break

    params_to_export = [
        tree_parameters,
        [
            'burst_date', 'cycle', 'mtgid', 'nature', 'mixed_inflo',
            'final_length_gu', 'length', 'radius', 'final_length_leaves',
            'nb_internodes'
        ],
        [
            'burst_date', 'bloom_date', 'fullbloom_date', 'cycle',
            'final_length', 'length', 'fruiting', 'nb_axes', 'nb_fruits',
            'fruits_weight', 'fruits_maturity_date', 'leaffruit_ratio'
        ],
        [
            'inflo_fullbloom_date', 'cycle', 'growth', 'maturity_date',
            'growth_stage_date', 'initial_weight', 'weight'
        ]
    ]

    # Convert lstring into mtg
    mtg = axialtree2mtg(lstring,
                        scale=dict(list(zip(modules_to_export, scales))),
                        scene=None,
                        parameters=dict(
                            list(zip(modules_to_export, params_to_export))))
    assert not mtg is None
    return mtg
Пример #2
0
def export_to_mtg_light(lstring, cycle):
    from openalea.mtg.io import axialtree2mtg
    lmodules_to_export = modules_to_export + ['InflorescenceBud']
    lscales = scales + [2]
    params_to_export = [['treename', 'variety'], ['burst_date', 'cycle'],
                        ['fullbloom_date', 'bloom_date', 'cycle', 'nb_fruits'],
                        ['inflo_fullbloom_date', 'cycle'],
                        ['fullbloom_date', 'bloom_date', 'cycle', 'nb_fruits']]
    params_to_export = [['p'] + p for p in params_to_export]
    parameters = dict(list(zip(lmodules_to_export, params_to_export)))
    # Convert lstring into mtg
    mtg = axialtree2mtg(lstring,
                        scale=dict(list(zip(lmodules_to_export, lscales))),
                        scene=None,
                        parameters=parameters)
    labels = mtg.property('label')
    toupdate = [
        (v, 'Inflorescence') for v, n in list(labels.items())
        if n == 'InflorescenceBud' and mtg.property('cycle')[v] == cycle
    ]
    labels.update(toupdate)
    toremove = [v for v, n in list(labels.items()) if n == 'InflorescenceBud']
    for vid in toremove:
        mtg.remove_vertex(vid)
        for pname in parameters['InflorescenceBud']:
            if vid in mtg.property(pname):
                del mtg.property(pname)[vid]
    return mtg
Пример #3
0
def str2mtg(s):
    #s = s.replace('N', 'F')
    tree = AxialTree(s)
    l = Lsystem()
    l.addInterpretationRule('N --> F', 0)
    geom_tree = l.homomorphism(tree)
    scene = l.sceneInterpretation(geom_tree)
    scale = dict(list(zip(('P', 'A', 'N', 'L', 'F'), (1, 2, 3, 3, 3))))
    mtg = axialtree2mtg(tree, scale, scene)
    return tree, mtg, scene
Пример #4
0
def str2mtg(s):
    #s = s.replace('N', 'F')
    tree = AxialTree(s) 
    l = Lsystem()
    l.addInterpretationRule('N --> F', 0)
    geom_tree = l.homomorphism(tree)
    scene = l.sceneInterpretation(geom_tree)
    scale = dict(zip(('P','A','N', 'L', 'F'),(1,2,3,3,3)))
    mtg = axialtree2mtg(tree, scale, scene)
    return tree, mtg, scene
Пример #5
0
def to_mtg(model):
    scales = {}
    scales['P'] = 1
    scales['A'] = 1
    scales['I'] = 1
    scales['B'] = 1

    params = {}
    params['P'] = ['age']
    params['A'] = ['age']
    params['I'] = ['age']

    g = axialtree2mtg(m.axialtree, scales, None, params)
    return g
Пример #6
0
def to_mtg(model):
    scales = {}
    scales['P'] = 1
    scales['A'] =1
    scales['I'] = 1
    scales['B'] = 1

    params ={}
    params['P'] = ['age']
    params['A'] = ['age']
    params['I'] = ['age']
	
    g = axialtree2mtg(m.axialtree, scales, None, params)
    return g