Beispiel #1
0
def adelR(nplants,dd):
    devT = devCsv('./data/axeTCa0N.csv','./data/dimTCa0N.csv','./data/phenTCa0N.csv','./data/earTCa0N.csv','./data/ssi2sen.csv')
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    pars = setAdel(devT,geoLeaf,geoAxe,nplants)
    cantable = RunAdel(dd,pars)
    return pars,cantable
Beispiel #2
0
def adelR(nplants, dd):
    devT = devCsv('./data/axeTCa0N.csv', './data/dimTCa0N.csv',
                  './data/phenTCa0N.csv', './data/earTCa0N.csv',
                  './data/ssi2sen.csv')
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    pars = setAdel(devT, geoLeaf, geoAxe, nplants)
    cantable = RunAdel(dd, pars)
    return pars, cantable
Beispiel #3
0
def devT():
    from alinea.adel.AdelR import devCsv

    axeT = datadir + '/data/axeTCa0N.csv'
    dimT = datadir + '/data/dimTCa0N.csv'
    phenT = datadir + '/data/phenTCa0N.csv'
    earT = datadir + '/data/earTCa0N.csv'
    ssisenT = datadir + '/data/ssi2sen.csv'

    return devCsv(axeT, dimT, phenT, earT, ssisenT)
Beispiel #4
0
def devT():
    from alinea.adel.AdelR import devCsv
    
    axeT = datadir + '/data/axeTCa0N.csv'
    dimT = datadir + '/data/dimTCa0N.csv'
    phenT = datadir + '/data/phenTCa0N.csv'
    earT = datadir + '/data/earTCa0N.csv'
    ssisenT = datadir + '/data/ssi2sen.csv'
    
    return devCsv(axeT,dimT,phenT,earT,ssisenT)
def test_organ_length():
    dir = './data/test_Adel_Maxwell_plante11/Maxwell_'
    sufix = '_plante11.csv'
    axeTpath = dir + 'axeT' + sufix
    dimTpath = dir + 'dimT' + sufix
    phenTpath = dir + 'phenT' + sufix
    earTpath = dir + 'earT.csv'
    ssi2senpath = dir + 'ssi2sen.csv'
    devT = devCsv(axeTpath, dimTpath, phenTpath, earTpath, ssi2senpath)
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    pars = setAdel(devT,geoLeaf,geoAxe,1,seed = 1)
    cantables = map(lambda(x): RunAdel(x,pars), range(0,2300,100))
    expected = csvAsDict(dir + 'reference_simulation.csv')
    for k in ('TT','plant','numphy','Ll','Gl','El','Lv','Gv','Ev','Esen','Lsen','Gsen'):
        sim = reduce(lambda x,y: x + y, (t[k].tolist() for t in cantables))
        exp = expected[k]
        np.testing.assert_allclose(sim,exp)
def test_organ_length():
    dir = './data/test_Adel_Maxwell_plante11/Maxwell_'
    sufix = '_plante11.csv'
    axeTpath = dir + 'axeT' + sufix
    dimTpath = dir + 'dimT' + sufix
    phenTpath = dir + 'phenT' + sufix
    earTpath = dir + 'earT.csv'
    ssi2senpath = dir + 'ssi2sen.csv'
    devT = devCsv(axeTpath, dimTpath, phenTpath, earTpath, ssi2senpath)
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    pars = setAdel(devT,geoLeaf,geoAxe,1,seed = 1)
    cantables = map(lambda(x): RunAdel(x,pars), range(0,2300,100))
    expected = csvAsDict(dir + 'reference_simulation.csv')
    for k in ('TT','plant','numphy','Ll','Gl','El','Lv','Gv','Ev','Esen','Lsen','Gsen'):
        sim = reduce(lambda x,y: x + y, (t[k].tolist() for t in cantables))
        exp = expected[k]
        #np.testing.assert_allclose(sim,exp)
Beispiel #7
0
def create_init_MTG_with_tillers(nplants=1,
                                 sowing_density=250.,
                                 plant_density=250.,
                                 inter_row=0.15,
                                 nff=12,
                                 nsect=1,
                                 seed=1,
                                 leaves=None):
    stand = AgronomicStand(sowing_density=sowing_density,
                           plant_density=plant_density,
                           inter_row=inter_row,
                           noise=0.04,
                           density_curve_data=None)
    em = TillerEmission(primary_tiller_probabilities={
        'T1': 1.,
        'T2': 0.5,
        'T3': 0.5,
        'T4': 0.3
    })
    reg = TillerRegression(ears_per_plant=3)
    axp = AxePop(MS_leaves_number_probabilities={str(nff): 1},
                 Emission=em,
                 Regression=reg)
    plants = axp.plant_list(nplants=nplants)
    hs = HaunStage(mean_nff=nff)
    pgen = PlantGen(HSfit=hs)
    axeT, dimT, phenT = pgen.adelT(plants)
    axeT = axeT.sort_values(['id_plt', 'id_cohort', 'N_phytomer'])
    devT = devCsv(axeT, dimT, phenT)
    adel = AdelWheatDyn(nplants=nplants,
                        nsect=nsect,
                        devT=devT,
                        stand=stand,
                        seed=seed,
                        sample='sequence',
                        leaves=leaves,
                        scene_unit='m')
    age = hs.TT(
        reg.hs_debreg(nff=nff)
    )  # date a laquelle debut des regression. Problemes : 1) toutes les feuilles pas encore visibles, 2) il y a des feuilles senescentes
    g = adel.setup_canopy(
        age
    )  # MG : je ne crois pas que id_cohort soit renvoyee par la fonction R runAdel
    return adel, g
def create_init_MTG_with_tillers(nplants=1, sowing_density=250., plant_density=250.,
                           inter_row=0.15, nff=12, nsect=1, seed=1):
    stand = AgronomicStand(sowing_density=sowing_density,
                           plant_density=plant_density, inter_row=inter_row,
                           noise=0.04, density_curve_data=None)
    em = TillerEmission()
    reg = TillerRegression(ears_per_plant=3)
    axp = AxePop(MS_leaves_number_probabilities={str(nff): 1}, Emission=em, Regression=reg)
    plants = axp.plant_list(nplants=nplants)
    hs = HaunStage(mean_nff=nff)
    pgen = PlantGen(HSfit=hs)
    axeT, dimT, phenT = pgen.adelT(plants)
    axeT = axeT.sort_values(['id_plt', 'id_cohort', 'N_phytomer'])
    devT = devCsv(axeT, dimT, phenT)
    adel = AdelWheatDyn(nplants=nplants, nsect=nsect, devT=devT, stand=stand,
                     seed=seed, sample='sequence',   scene_unit='m')
    age = hs.TT(12)
    g = adel.setup_canopy(age)
    return adel, g
Beispiel #9
0
def alep_custom_reconstructions(variety='Tremie13', nplants=30, 
                                sowing_density=250.,
                                plant_density=250., inter_row=0.15,
                                nsect=7, seed=1, 
                                scale_HS = 1,
                                scale_leafDim_length = 1,
                                scale_leafDim_width = 1,
                                scale_leafRate=1,
                                scale_stemDim = 1,
                                scale_stemRate=1, 
                                scale_fallingRate=1,
                                scale_leafSenescence=1,
                                scale_tillering=1,
                                **kwds):
    parameters = reconstruction_parameters()
    stand = AgronomicStand(sowing_density=sowing_density,
                            plant_density=plant_density, 
                            inter_row=inter_row, noise=0.04, 
                            density_curve_data = None)       
    n_emerged = nplants
    
    MS_leaves_number_probabilities={'11': 0.3, '12': 0.7}
    tiller_proba = {'T1':1., 'T2':0.5, 'T3':0.5, 'T4':0.3}
    ears_per_plant = 2.5
    
    if 'tiller_probability' in kwds:
        tiller_proba = {k:min(1, p*kwds['tiller_probability']) for k,p in tiller_proba.iteritems()}

    if 'proba_main_nff' in kwds:
        MS_leaves_number_probabilities = {'11':1-kwds['proba_main_nff'], '12':kwds['proba_main_nff']}
    
    # scale _tillering
    tiller_proba = {k:min(1, p * scale_tillering) for k,p in tiller_proba.iteritems()}
    em = pgen_ext.TillerEmission(primary_tiller_probabilities=tiller_proba)
    reg = pgen_ext.TillerRegression(ears_per_plant = ears_per_plant * scale_tillering)
    
    #generate plants
    HSfit = HS_fit()[variety]
    axp = pgen_ext.AxePop(MS_leaves_number_probabilities = MS_leaves_number_probabilities,
                          Emission=em, Regression=reg, std_em=HSfit.std_TT_hs_0)
    plants = axp.plant_list(n_emerged)
    
    # Measure and save Green leaf durations on the reference
    adel_pars = parameters['adel_pars']

    HSfit.mean_nff = axp.mean_nff()
    Dimfit = dimension_fits(HS_fit(), **parameters)[variety]
    GLfit = GL_fits(HS_fit(), **parameters)[variety]
    pgen = pgen_ext.PlantGen(HSfit=HSfit, GLfit=GLfit, Dimfit=Dimfit, adel_pars = adel_pars)
    axeT, dimT, phenT = pgen.adelT(plants)
    axeT = axeT.sort(['id_plt', 'id_cohort', 'N_phytomer'])
    GreenDuration1_ref = axeT['TT_sen_phytomer1'] - axeT['TT_em_phytomer1']
    phenT = phenT.sort(['id_phen', 'index_phytomer'])
    dTTsen_ref = phenT['dTT_sen_phytomer']
    dTTem_ref = phenT['dTT_em_phytomer']

    
    # Modify fits
    
    # HS_fit
    
    # petit commentaire : scale_HS determine ligulation rate + emergence rate
    # la duree emergence-ligulation est impactee du fait de ce changement (inevitable si on impose leaf_rate)
    # mais aussi en raison de scale_leafRate(non souhaite => compensation ci dessous)
    HS_ref = HSfit.a_cohort
    leafDuration_ref = adel_pars['leafDuration']
    HSfit.a_cohort /= scale_HS
    # on compense en decalant l'emergence des plante
    HSfit.TT_hs_0 += (1 - adel_pars['fracLeaf']) / HS_ref * leafDuration_ref * (float(scale_HS) / scale_leafRate - 1) 
    
    
    # Modify leaf dimension and growth rate  
    
    adel_pars['leafDuration'] = ((scale_leafDim_length*scale_leafDim_width) / scale_HS)* \
                                (leafDuration_ref / scale_leafRate)
    Dimfit.scale['L_blade'] *= scale_leafDim_length
    Dimfit.scale['W_blade'] *= scale_leafDim_width
                                    
    # Modify stem dimension and growth rate
    stemDuration_ref = adel_pars['stemDuration']
    adel_pars['stemDuration'] = (scale_stemDim / scale_HS)* \
                                (stemDuration_ref / scale_stemRate)
    Dimfit.scale['L_internode'] *= scale_stemDim

    
    
    # Scale GL : GL flag, bolting and start_senescence : apply factor
    # TEST EXTREME WITH LEAF RATE
    #GLfit.GL_bolting *= scale_leafSenescence
    #GLfit.GL_flag *= scale_leafSenescence
    #GLfit.n0 *= scale_leafSenescence

    # Modify  green leaf durations and falling rate
    pgen = pgen_ext.PlantGen(HSfit=HSfit, GLfit=GLfit, Dimfit=Dimfit, adel_pars = adel_pars)
    axeT, dimT, phenT = pgen.adelT(plants)
    axeT = axeT.sort(['id_plt', 'id_cohort', 'N_phytomer'])    
    phenT = phenT.sort(['id_phen', 'index_phytomer'])
    
    # Modify senescence
    axeT['TT_sen_phytomer1'] = axeT['TT_em_phytomer1'] + scale_leafSenescence * GreenDuration1_ref
    phenT['dTT_sen_phytomer'] = dTTsen_ref  + (phenT['dTT_em_phytomer'] - dTTem_ref)
    devT = devCsv(axeT, dimT, phenT)
    
    leaves = leafshape_fits(**parameters)[variety]
    bins_ref = leaves.bins
    bins_ref[-1] = 21.
    bins = [x * scale_HS / scale_fallingRate if i_x!=0 else x*scale_HS for i_x,x in enumerate(bins_ref)]
    leaves.bins = bins
    
    return AdelWheat(nplants = nplants, nsect=nsect, devT=devT, stand = stand , 
                    seed=seed, sample='sequence', leaves = leaves, run_adel_pars = adel_pars)
Beispiel #10
0
def alep_custom_reconstructions(variety='Tremie13',
                                nplants=30,
                                sowing_density=250.,
                                plant_density=250.,
                                inter_row=0.15,
                                nsect=7,
                                seed=1,
                                scale_HS=1,
                                scale_leafDim_length=1,
                                scale_leafDim_width=1,
                                scale_leafRate=1,
                                scale_stemDim=1,
                                scale_stemRate=1,
                                scale_fallingRate=1,
                                scale_leafSenescence=1,
                                scale_tillering=1,
                                **kwds):
    parameters = reconstruction_parameters()
    stand = AgronomicStand(sowing_density=sowing_density,
                           plant_density=plant_density,
                           inter_row=inter_row,
                           noise=0.04,
                           density_curve_data=None)
    n_emerged = nplants

    MS_leaves_number_probabilities = {'11': 0.3, '12': 0.7}
    tiller_proba = {'T1': 1., 'T2': 0.5, 'T3': 0.5, 'T4': 0.3}
    ears_per_plant = 2.5

    if 'tiller_probability' in kwds:
        tiller_proba = {
            k: min(1, p * kwds['tiller_probability'])
            for k, p in tiller_proba.iteritems()
        }

    if 'proba_main_nff' in kwds:
        MS_leaves_number_probabilities = {
            '11': 1 - kwds['proba_main_nff'],
            '12': kwds['proba_main_nff']
        }

    # scale _tillering
    tiller_proba = {
        k: min(1, p * scale_tillering)
        for k, p in tiller_proba.iteritems()
    }
    em = pgen_ext.TillerEmission(primary_tiller_probabilities=tiller_proba)
    reg = pgen_ext.TillerRegression(ears_per_plant=ears_per_plant *
                                    scale_tillering)

    #generate plants
    HSfit = HS_fit()[variety]
    axp = pgen_ext.AxePop(
        MS_leaves_number_probabilities=MS_leaves_number_probabilities,
        Emission=em,
        Regression=reg,
        std_em=HSfit.std_TT_hs_0)
    plants = axp.plant_list(n_emerged)

    # Measure and save Green leaf durations on the reference
    adel_pars = parameters['adel_pars']

    HSfit.mean_nff = axp.mean_nff()
    Dimfit = dimension_fits(HS_fit(), **parameters)[variety]
    GLfit = GL_fits(HS_fit(), **parameters)[variety]
    pgen = pgen_ext.PlantGen(HSfit=HSfit,
                             GLfit=GLfit,
                             Dimfit=Dimfit,
                             adel_pars=adel_pars)
    axeT, dimT, phenT = pgen.adelT(plants)
    axeT = axeT.sort(['id_plt', 'id_cohort', 'N_phytomer'])
    GreenDuration1_ref = axeT['TT_sen_phytomer1'] - axeT['TT_em_phytomer1']
    phenT = phenT.sort(['id_phen', 'index_phytomer'])
    dTTsen_ref = phenT['dTT_sen_phytomer']
    dTTem_ref = phenT['dTT_em_phytomer']

    # Modify fits

    # HS_fit

    # petit commentaire : scale_HS determine ligulation rate + emergence rate
    # la duree emergence-ligulation est impactee du fait de ce changement (inevitable si on impose leaf_rate)
    # mais aussi en raison de scale_leafRate(non souhaite => compensation ci dessous)
    HS_ref = HSfit.a_cohort
    leafDuration_ref = adel_pars['leafDuration']
    HSfit.a_cohort /= scale_HS
    # on compense en decalant l'emergence des plante
    HSfit.TT_hs_0 += (1 -
                      adel_pars['fracLeaf']) / HS_ref * leafDuration_ref * (
                          float(scale_HS) / scale_leafRate - 1)

    # Modify leaf dimension and growth rate

    adel_pars['leafDuration'] = ((scale_leafDim_length*scale_leafDim_width) / scale_HS)* \
                                (leafDuration_ref / scale_leafRate)
    Dimfit.scale['L_blade'] *= scale_leafDim_length
    Dimfit.scale['W_blade'] *= scale_leafDim_width

    # Modify stem dimension and growth rate
    stemDuration_ref = adel_pars['stemDuration']
    adel_pars['stemDuration'] = (scale_stemDim / scale_HS)* \
                                (stemDuration_ref / scale_stemRate)
    Dimfit.scale['L_internode'] *= scale_stemDim

    # Scale GL : GL flag, bolting and start_senescence : apply factor
    # TEST EXTREME WITH LEAF RATE
    #GLfit.GL_bolting *= scale_leafSenescence
    #GLfit.GL_flag *= scale_leafSenescence
    #GLfit.n0 *= scale_leafSenescence

    # Modify  green leaf durations and falling rate
    pgen = pgen_ext.PlantGen(HSfit=HSfit,
                             GLfit=GLfit,
                             Dimfit=Dimfit,
                             adel_pars=adel_pars)
    axeT, dimT, phenT = pgen.adelT(plants)
    axeT = axeT.sort(['id_plt', 'id_cohort', 'N_phytomer'])
    phenT = phenT.sort(['id_phen', 'index_phytomer'])

    # Modify senescence
    axeT['TT_sen_phytomer1'] = axeT[
        'TT_em_phytomer1'] + scale_leafSenescence * GreenDuration1_ref
    phenT['dTT_sen_phytomer'] = dTTsen_ref + (phenT['dTT_em_phytomer'] -
                                              dTTem_ref)
    devT = devCsv(axeT, dimT, phenT)

    leaves = leafshape_fits(**parameters)[variety]
    bins_ref = leaves.bins
    bins_ref[-1] = 21.
    bins = [
        x * scale_HS / scale_fallingRate if i_x != 0 else x * scale_HS
        for i_x, x in enumerate(bins_ref)
    ]
    leaves.bins = bins

    return AdelWheat(nplants=nplants,
                     nsect=nsect,
                     devT=devT,
                     stand=stand,
                     seed=seed,
                     sample='sequence',
                     leaves=leaves,
                     run_adel_pars=adel_pars)