def on_change_node_waffle_parameter(widget, event, data): if not date_selection_waffle.v_model: pass else: with waffle: waffle.clear_output() genotype = genotypes_selection_waffle.v_model vids = get_vid_of_genotype(misc.all_mtg, [genotype]) df = extract_at_node_scale(misc.all_mtg, vids=vids) tmp = df2waffle(df, index='rank', date=date_selection_waffle.v_model, variable=data, order=order_selection_waffle.v_model) # TODO: remove the legend here (which only apply to branching_type) l_names = { "1": "Stolon", "2": "Vegetative bud", "3": "Initiated bud", "4": "Aborted bud", "5": "Floral bud", "6": "Branch crown" } fig = plot_waffle( tmp, # layout=layout, legend_name=l_names, plot_func=plot_type_waffle.v_model) display(fig)
def test_extraction_at_node_scale(): files = shared_data(openalea.strawberry).glob('*.mtg') mtg_path = dict((name(f), f) for f in files) gariguette = read_mtg_file(mtg_path['Gariguette']) gariguette_extraction_at_node_scale = extract_at_node_scale(gariguette) assert len(gariguette_extraction_at_node_scale) == 784 gariguette_axillary_prod = prob_axillary_production(gariguette, order=0) assert len(gariguette_axillary_prod) == 19
def on_change_node_waffle_genotype(widget, event, data): genotype = genotypes_selection_waffle.v_model vids = get_vid_of_genotype(misc.all_mtg, [genotype]) df = extract_at_node_scale(misc.all_mtg, vids=vids) param = list(df.columns) param.remove("Genotype") param.remove('date') date_selection_waffle.items = list(df.date.unique()) date_selection_waffle.v_model = "" variable_selection_waffle.items = param order = list(df.order.unique()) order.append({'text': 'All', 'value': None}) order_selection_waffle.items = order
def test_df2waffle(): files = shared_data(openalea.strawberry).glob('*.mtg') mtg_path = dict((name(f), f) for f in files) mtg = read_mtg_file(mtg_path['Capriss']) df = extract_at_node_scale(mtg) node_scale = df2waffle(df, index='rank', date='2015/03/02', variable='branching_type') assert node_scale.shape == (20, 9) df = extract_at_module_scale(mtg) module_scale = df2waffle(df, index='order', date='2015/03/02', variable='crown_status', aggfunc='median') assert module_scale.shape == (3, 9)
def test_extract_at_node_scale(): files = shared_data(openalea.strawberry).glob('*.mtg') mtg_path = dict((name(f), f) for f in files) mtg = MTG() for k, genotype in enumerate(mtg_path): if (genotype=="Sicile") or (genotype=="Nils") or (genotype=='origine_stolon_gariguetteDV_6novembre2018') \ or (genotype=='friendlyfruit_varieties'): pass else: mtg = union(mtg, read_mtg_file(mtg_path[genotype])) genotypes = mtg.property('Genotype') for geno in set(genotypes.values()): vids = [ vid for vid in mtg.vertices(scale=1) if genotypes.get(vid) == geno ] df = extract_at_node_scale(mtg, vids) assert not df.empty assert set(df['Genotype']) == {geno}