예제 #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
예제 #2
0
def adelR(nplants,dd):
    from alinea.adel.AdelR import setAdel,RunAdel,genGeoLeaf,genGeoAxe
    import alinea.adel.data_samples as adel_data
    devT = adel_data.devT()
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    pars = setAdel(devT,geoLeaf,geoAxe,nplants,xydb=adel_data.xydb(),srdb=adel_data.srdb())
    cantable = RunAdel(dd,pars)
    return pars,cantable
예제 #3
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
예제 #4
0
def adelR(nplants, dd):
    from alinea.adel.AdelR import setAdel, RunAdel, genGeoLeaf, genGeoAxe
    import alinea.adel.data_samples as adel_data
    devT = adel_data.devT()
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    pars = setAdel(devT,
                   geoLeaf,
                   geoAxe,
                   nplants,
                   xydb=adel_data.xydb(),
                   srdb=adel_data.srdb())
    cantable = RunAdel(dd, pars)
    return pars, cantable
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)
예제 #6
0
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)
예제 #7
0
def test_adelR_postprocessing(nplants, dd):
    import alinea.adel.data_samples as adel_data
    devT = adel_data.devT()
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    xydb = adel_data.xydb()
    srdb = adel_data.srdb()
    pars = setAdel(devT,geoLeaf,geoAxe,nplants,xydb=xydb, srdb=srdb)
    
    def run_adel(dd):
        cantable = RunAdel(dd, pars)
        RcanT = dataframe(cantable)
        out = canL2canS(RcanT,srdb)
        out_df = DataFrame(out)
        return out_df
    out_dfs = map(run_adel, [dd, dd + 100])
    concat_df = concat(out_dfs, ignore_index=True)
    domain_area = 1
    axis_df = postprocessing.axis_statistics(concat_df, domain_area)
    plot_df = postprocessing.plot_statistics(axis_df, nplants, domain_area)
    return concat_df, axis_df, plot_df
예제 #8
0
def test_adelR_postprocessing(nplants, dd):
    import alinea.adel.data_samples as adel_data
    devT = adel_data.devT()
    geoLeaf = genGeoLeaf()
    geoAxe = genGeoAxe()
    xydb = adel_data.xydb()
    srdb = adel_data.srdb()
    pars = setAdel(devT, geoLeaf, geoAxe, nplants, xydb=xydb, srdb=srdb)

    def run_adel(dd):
        cantable = RunAdel(dd, pars)
        RcanT = dataframe(cantable)
        out = canL2canS(RcanT, srdb)
        out_df = DataFrame(out)
        return out_df

    out_dfs = map(run_adel, [dd, dd + 100])
    concat_df = concat(out_dfs, ignore_index=True)
    domain_area = 1
    axis_df = postprocessing.axis_statistics(concat_df, domain_area)
    plot_df = postprocessing.plot_statistics(axis_df, nplants, domain_area)
    return concat_df, axis_df, plot_df
예제 #9
0
    fn = r'leaves_simple.db'
    f = open(fn)
    leaves = Pickle.load(f)
    f.close()
    leaves = fitting.fit_leaves(leaves, 9)
    symbols = build_symbols(leaves[0])
    db = leaves[0]
    return db, symbols


db, symbols = load_leaves_db()
devT, debFeu, endFeu = ps.adel_tables(15, db, 200, 20, 6, 1, 1.4, 180, 20, 60,
                                      40, 40, 2, 1)
geoLeaf = genGeoLeaf()
geoAxe = genGeoAxe()
plant_pars = setAdel(devT, geoLeaf, geoAxe, 1, seed=1)
adel_pars = {
    'senescence_leaf_shrink': 0.5,
    'startLeaf': debFeu.mean(),
    'endLeaf': endFeu.mean(),
    'stemLeaf': 1.2,
    'epsillon': 1e-6
}
cantables = map(lambda (x): RunAdel(x, plant_pars, adel_pars),
                range(0, 900, 60))
strings = map(ps.getString, cantables)
scenes = map(lambda (x): ps.generate_scene(x, symbols), strings)


def animate(scenes, delay=0.2):
    from time import sleep
예제 #10
0
    def __init__(self, nplants = 1, duplicate=1, nsect = 1, devT = None, sample = 'random', seed = None, leaves = None, stand = None, aspect='square', convUnit = 0.01, thermal_time_model = None, geoAxe=None, incT=60, dinT=5, dep = 7, run_adel_pars = None, split=False, face_up=False, aborting_tiller_reduction = 1.0, classic=False, leaf_db = None, positions = None, ssipars=None):
    
        if devT is None: 
            devT = adel_data.devT()
            
        if run_adel_pars is None:
            run_adel_pars = {'senescence_leaf_shrink' : 0.5,'leafDuration' : 2, 'fracLeaf' : 0.2, 'stemDuration' : 2. / 1.2, 'dHS_col' : 0.2,'dHS_en':0, 'epsillon' : 1e-6, 'HSstart_inclination_tiller': 1, 'rate_inclination_tiller': 30, 'drop_empty':True}
            
        if leaf_db is not None:
            print('!!!!Warning!!!! leaf_db argument is deprecated, use adel.geometric_elements.Leaves class instead')
        if positions is not None:
            print('!!!!Warning!!!! positions argument is deprecated, use stand = adel.Stand class instead')
            
        if leaves is None:
            leaves = Leaves()
            
        if stand is None:
            stand = AgronomicStand(sowing_density = 250, plant_density=250, inter_row=0.15)
        self.stand=stand
            
        if thermal_time_model is None:
            thermal_time_model = DegreeDayModel(Tbase=0)

        if geoAxe is None:
            geoAxe = genGeoAxe(incT=incT,dinT=dinT,dep=dep)
        
        self.devT = devT
        
        if self.stand.density_curve is None:
            self.nplants, self.domain, self.positions, area_m2 = stand.stand(nplants * duplicate, aspect=aspect)
        else:
            self.nplants, self.domain, self.positions, area_m2 = stand.smart_stand(nplants * duplicate)

        #split nplants into nquot and nrem, such that nplants = nquote * duplicate + nrem
        self.nrem = self.nplants % duplicate
        self.nquot = (self.nplants - self.nrem) / duplicate
        self.duplicate = duplicate
        if self.nquot == 0 and self.duplicate > 0:# degenerated case
            self.nquot = 1
            self.nrem = 0
            self.duplicate = self.nplants

            
        
        
        self.domain_area = area_m2
        self.plant_azimuths = numpy.random.random(self.nplants) * 2 * numpy.pi
        
        pars = {'devT':devT, 'RcodegeoLeaf':leaves.geoLeaf, 'RcodegeoAxe':geoAxe,
                'seed':seed, 'sample':sample, 'xydb':leaves.xydb, 'srdb':leaves.srdb, 'ssipars':ssipars}
        self.pars = setAdel(nplants=self.nquot, **pars)
        if self.nquot > 0:
            self.pars_quot = setAdel(nplants=self.nquot, **pars)
        if self.nrem > 0:
            self.pars_rem = setAdel(nplants = self.nrem, **pars)
        self.leaves = leaves
        self.nsect = nsect

        
        self.thermal_time = thermal_time_model
        self.run_adel_pars = run_adel_pars
        self.split = split
        self.face_up = face_up
        self.aborting_tiller_reduction = aborting_tiller_reduction
        self.classic = classic
        self.convUnit = convUnit
예제 #11
0
    def __init__(self,
                 devT=None,
                 sample='random',
                 thermal_time_model=None,
                 geoAxe=None,
                 incT=60,
                 dinT=5,
                 dep=7,
                 run_adel_pars=None,
                 aborting_tiller_reduction=1.0,
                 ssipars=None,
                 nplants=1,
                 duplicate=None,
                 species=None,
                 nsect=1,
                 leaves=None,
                 stand=None,
                 aspect='smart',
                 split=False,
                 face_up=False,
                 classic=False,
                 devT_unit='cm',
                 scene_unit='cm',
                 age=None,
                 seed=None,
                 leaf_db=None,
                 positions=None,
                 convUnit=None):

        if species is not None or isinstance(leaves, dict):
            raise ValueError('multi_species canopies not yet implemented')

        if devT is None:
            devT = adel_data.devT()
            devT_unit = 'cm'

        if devT_unit != scene_unit:
            convert = self.conv_units[devT_unit] / self.conv_units[scene_unit]
            for x in ('L_internode', 'W_internode', 'W_sheath', 'W_blade',
                      'L_sheath', 'L_blade'):
                devT['dimT'][x] *= convert

        self.devT = devT

        self.ref_plants = list(set(self.devT['axeT']['id_plt']))
        super(AdelWheat, self).__init__(nref_plants=len(self.ref_plants),
                                        nplants=nplants,
                                        duplicate=duplicate,
                                        nsect=nsect,
                                        species=species,
                                        leaves=leaves,
                                        stand=stand,
                                        aspect=aspect,
                                        split=split,
                                        face_up=face_up,
                                        classic=classic,
                                        scene_unit=scene_unit,
                                        age=age,
                                        seed=seed,
                                        leaf_db=leaf_db,
                                        positions=positions,
                                        convUnit=convUnit)

        if run_adel_pars is None:
            run_adel_pars = {
                'senescence_leaf_shrink': 0.5,
                'leafDuration': 2,
                'fracLeaf': 0.2,
                'stemDuration': 2. / 1.2,
                'dHS_col': 0.2,
                'dHS_en': 0,
                'epsillon': 1e-6,
                'HSstart_inclination_tiller': 1,
                'rate_inclination_tiller': 30,
                'drop_empty': True
            }

        if thermal_time_model is None:
            thermal_time_model = DegreeDayModel(Tbase=0)

        if geoAxe is None:
            geoAxe = genGeoAxe(incT=incT, dinT=dinT, dep=dep)

        assert len(self.leaves.keys()) == 1
        k = self.leaves.keys()[0]

        pars = {
            'devT': self.devT,
            'RcodegeoLeaf': self.leaves[k].geoLeaf,
            'RcodegeoAxe': geoAxe,
            'seed': self.seed,
            'sample': sample,
            'xydb': self.leaves[k].xydb,
            'srdb': self.leaves[k].srdb,
            'ssipars': ssipars
        }

        if self.duplicate is None:
            self.pars = setAdel(nplants=self.nplants, **pars)
        else:
            if self.nquot > 0:
                self.pars_quot = setAdel(nplants=self.nquot, **pars)
            if self.nrem > 0:
                self.pars_rem = setAdel(nplants=self.nrem, **pars)

        self.thermal_time = thermal_time_model
        self.run_adel_pars = run_adel_pars
        self.aborting_tiller_reduction = aborting_tiller_reduction
예제 #12
0
파일: testadel.py 프로젝트: DrXav/scanalea
def load_leaves_db():
    import cPickle as Pickle
    import alinea.adel.fitting as fitting
    from alinea.adel.symbol import build_symbols
    
    fn = r'leaves_simple.db'
    f = open(fn)
    leaves = Pickle.load(f)
    f.close()
    leaves = fitting.fit_leaves(leaves, 9)
    symbols = build_symbols(leaves[0])
    db = leaves[0]
    return db, symbols


db,symbols = load_leaves_db()
devT, debFeu,endFeu = ps.adel_tables(15,db,200,20,6,1,1.4,180,20,60,40,40,2,1)
geoLeaf = genGeoLeaf()
geoAxe = genGeoAxe()
plant_pars = setAdel(devT,geoLeaf,geoAxe,1,seed = 1)
adel_pars ={'senescence_leaf_shrink' : 0.5,'startLeaf' : debFeu.mean(), 'endLeaf' : endFeu.mean(), 'stemLeaf' : 1.2,'epsillon' : 1e-6}
cantables = map(lambda(x): RunAdel(x,plant_pars, adel_pars), range(0,900,60))
strings = map(ps.getString,cantables)
scenes = map(lambda(x): ps.generate_scene(x,symbols), strings)

def animate(scenes,delay=0.2):
    from time import sleep
    for s in scenes:
        Viewer.display(s)
        sleep(delay)