Skip to content

Commit

Permalink
Merge pull request #25 from pradal/gitign
Browse files Browse the repository at this point in the history
Add .gitignore file
  • Loading branch information
mlabadie committed Mar 29, 2021
2 parents faa978a + edeeecd commit e621889
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 24 deletions.
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# {# pkglts, github
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# pkglts files
.pkglts/info.log*

# Packages
*.egg
*.egg-info
.eggs
.Python
*.pth
dist/
build/
env/
downloads/
eggs/
parts/
bin/
var/
sdist/
develop-eggs/
.installed.cfg
lib/
lib64/

# editors
.idea/

# Vim files
*.swp
*.*~

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.settings


# C extensions
*.so
*.dll
*.dylib

# Compiled Static libraries
*.lai
*.la
*.a

# Compiled Object files
*.os

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
.amlog
.sconsign.dblite

# Translations
*.mo
*.pot

# Django stuff:
*.log

# PyBuilder
target/

# jupyter notebooks
.ipynb_checkpoints/

# svn
.svn
.cache/

# coverage
.coverage

# sphinx autogen file
doc/_dvlpt/


# #}

# user custom filters

# Mac
.DS_Store
16 changes: 10 additions & 6 deletions example/test_newmtg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from alinea.adel.AdelR import devCsv,setAdel,RunAdel,genGeoLeaf,genGeoAxe
import alinea.adel.fitting as fitting

import alinea.adel.data as data
from openalea.core.path import path as Path


def adelR(nplants,dd):
devT = devCsv('./data/axeTCa0N.csv','./data/dimTCa0N.csv','./data/phenTCa0N.csv','./data/earTCa0N.csv','./data/ssi2sen.csv')
Expand All @@ -12,16 +15,17 @@ def adelR(nplants,dd):
pars = setAdel(devT,geoLeaf,geoAxe,nplants)
cantable = RunAdel(dd,pars)
return pars,cantable

def leaves_db(dlevel=9):
import cPickle as Pickle
fn = r'../adel/data/leaves_simple.db'
d = data.__path__[0]
fn = r'%s/leaves_simple.db'%str(d)
f = open(fn)
leaves = Pickle.load(f)
f.close()
leaves,discard = fitting.fit_leaves(leaves, dlevel)
return leaves

#from openalea.mtg import mtg2axialtree
#affichage : aller voir __str__dans mtg.py
#dp = {'plant':[1,1,1,1,1], 'axe' : [0,0,1,1,2], 'numphy': [1,2,1,2,1], 'Laz': [0,180,90,180,180],'Einc':[0,0,45,-45,45], 'El': [1,1,1,1,1],'Ev':[1,1,1,1,1], 'Esen':[0,0,0,0,0], 'Ed':[0.1,0.1,0.1,0.1,0.1]}
Expand All @@ -32,18 +36,18 @@ def leaves_db(dlevel=9):
#more test
p,d= adelR(1,1000)
leaves=leaves_db()
g=mtg_factory(d,adel_metamer,leaf_db=leaves, stand=[((0,0,0),0),((10,0,0),90), ((0,10,0), 0)])
g=mtg_factory(d,adel_metamer,leaves=leaves, stand=[((0,0,0),0),((10,0,0),90), ((0,10,0), 0)])
g=mtg_interpreter(g)
scene = plot3d(g)
pgl.Viewer.display(scene)
#
def test_leaf_shape():
""" test leaf positioning/ inclination """
d = {'plant':[1,1],'axe_id':['MS','T1'],'ms_insertion':[0,1],'numphy':[1,1],
d = {'plant':[1,1],'axe_id':['MS','T1'],'ms_insertion':[0,1],'numphy':[1,1],
'Laz': [0,90], 'Ll' :[3,3], 'Lv' :[3,3] , 'Lsen':[0,0], 'L_shape':[3,3], 'Lw_shape':[.3,.3], 'Linc':[0,0],
'Einc':[0,45],'El':[1,1],'Ev':[1,1],'Esen':[0,0],'Ed': [0.1,0.1]}
g=mtg_factory(d,adel_metamer,leaf_db=leaves_db())
g=mtg_interpreter(g)
scene = plot3d(g)
pgl.Viewer.display(scene)
pgl.Viewer.display(scene)
return(g)
43 changes: 25 additions & 18 deletions test/test_leaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,33 @@
import cPickle as Pickle
from pylab import plot, show,clf

db = r'../src/alinea/adel/data/leaves.db'
db = r'../src/alinea/adel/data/leaves_simple.db'
f = open(db)

leaves = Pickle.load(f)
rank = leaves.keys()[0]
leaf = leaves[rank][0]
f.close()

dbf = r'../src/alinea/adel/data/leaves.db'
f = open(db)

leaves_f = Pickle.load(f)
rankf = leaves.keys()[0]
leaff = leaves[rank][0]
f.close()
#
# build a database of function
# 1. fit leaves
# 2. write a function
# 3. draw the result

# 3 bis. write a class
# 3 bis. write a class
# 4 parse the string and build the scene
# 5. create the can file
# 5. create the can file
translation = pgl.Vector3(0,0,0)
zt = 6
yt = 13
yt = 13

def test1(leaf=leaf, scene = None):
"""
Expand All @@ -38,8 +45,8 @@ def test1(leaf=leaf, scene = None):

x, y, s, r= leaf
spline_leaf, leaf_surface = fitting.fit_leaf(x, y, s, r)
mesh = fitting.discretize(spline_leaf,30, 7, 1)
mesh = fitting.discretize(spline_leaf,30, 7, 1)

scene += pgl.Translated(translation, mesh)
Viewer.update()

Expand All @@ -65,7 +72,7 @@ def test2(leaves=leaves):
#raw_input('Enter something for next leaf...')
translation.y = -60 + yt*int(k)
translation.z = 0

def test3(leaf=leaf, scene = None):
"""
Obtain a leaf at different time.
Expand All @@ -79,7 +86,7 @@ def test3(leaf=leaf, scene = None):
spline_leaf, leaf_surface = fitting.fit_leaf(x, y, s, r)
translation = pgl.Vector3()
n = 7

for i in range (1,n+1):
mesh = fitting.partial_leaf(spline_leaf, 30, n, i, 1)
scene += pgl.Translated(translation, mesh)
Expand All @@ -102,15 +109,15 @@ def test5(leaf=leaf):
"""
x, y, s, r= leaf
#spline_leaf, leaf_surface = fitting.fit_leaf(x, y, s, r)
tckp, u = splprep([x,y],k=5)
tckp, u = splprep([x,y],k=5)
xp, yp = splev(linspace(0,1,6),tckp)
#xn, yn, rn = splev(linspace(0,1,100),spline_leaf)
#xn, yn, rn = splev(linspace(0,1,100),spline_leaf)
sn=fitting.curvilinear_abscisse(x,y)
l=sn.sum()
clf()
plot(x,y,'.')
plot(xp, yp)

# def test6(leaves=leaves,rank=rank):
# # try with rank=7
# index = 0
Expand All @@ -130,10 +137,10 @@ def test7(leaf=leaf, scene = None):

x, y, s, r= leaf
spline_leaf, leaf_surface = fitting.fit_leaf(x, y, s, r)
pts, ind = fitting.mesh(spline_leaf,30, 7, 7, 1)
pts, ind = fitting.mesh(spline_leaf,30, 7, 7, 1)
fitting.write_smf('leaf_full.smf', pts, ind)
Viewer.display(fitting.plantgl_shape(pts, ind))


def test8(leaf=leaf, scene = None):
global translation, zt
Expand All @@ -144,7 +151,7 @@ def test8(leaf=leaf, scene = None):
x, y, s, r= leaf
leaf_new, leaf_surface = fitting.fit2(x, y, s, r)

pts, ind = fitting.mesh2(leaf_new, 7, 7, 1)
pts, ind = fitting.mesh2(leaf_new, 7, 7, 1)
#pts2, ind2 = fitting.qslim(13, pts, ind)
#mesh = fitting.plantgl_shape(pts2, ind2)

Expand All @@ -155,7 +162,7 @@ def test8(leaf=leaf, scene = None):
#mesh_final = mesh
scene += pgl.Translated(translation, fitting.plantgl_shape(pts, ind))
#scene += pgl.Translated(translation+(0,yt/3.,0), mesh_final)

Viewer.update()

def test81(leaf=leaf, scene = None):
Expand All @@ -167,7 +174,7 @@ def test81(leaf=leaf, scene = None):
mesh = fitting.leaf_shape2(leaf,10, 7, 7, 1)

scene += pgl.Translated(translation+(0,yt/3.,0), mesh)

Viewer.update()

# def test9(leaves=leaves):
Expand Down Expand Up @@ -197,10 +204,10 @@ def test81(leaf=leaf, scene = None):
# def test10():
# pass
#sc=pgl.SurfComputer(pgl.Discretizer())
#m=pgl_shape mesh2
#m=pgl_shape mesh2
#m2=pgl_shape qslim
#m.apply(sc)
#sc.surface
#m2.apply(sc)
#sc.surface
#sc.surface

0 comments on commit e621889

Please sign in to comment.