Ejemplo n.º 1
0
def growth_wheat():
    seq, weather = sample_weather()
    wdata = weather.get_weather(seq)

    nsect = 1  #the number of element per leaf

    adel = AdelWheat(nsect=nsect, nplants=1, seed=2)

    # age=900に固定
    g = adel.setup_canopy(900)
    adel.grow(g, wdata)

    # csv保存
    with open('label.csv', 'w') as f:
        writer = csv.writer(f)
        label = g.property('label')
        geometry = g.property('geometry')
        is_green = g.property('is_green')
        writer.writerow([label])
        writer.writerow([geometry])
        writer.writerow([is_green])
    f.close()

    # 茎,緑葉,茶葉,全体を生成して保存
    for i in range(0, 4, 1):
        st = plot3d1(g, i)
        for t in range(len(st)):
            st[t].name = str(t)
        # 自動的に.mtlも保存してくれるっぽい
        st.save("./" + "compare/" + str(i) + "/nsect" + str(nsect) + ".obj")

    st = plot3d1(g, 4)
    w = obj.ObjCodec()
    w.write2("./compare/1/aa.obj", st)
Ejemplo n.º 2
0
def growth_wheat_someage():
    seq, weather = sample_weather()
    wdata = weather.get_weather(seq)
    nsect = 1  #the number of element per leaf
    adel = AdelWheat(nsect=nsect, nplants=1, seed=2)

    # save_dir = './obj'
    # save_dir = '/home/demo/document/ykato_git/datasets/omg_instance_segmentation/dataset_ver4/obj'
    if os.name == 'nt':
        save_dir = 'I:/ykato_git/datasets/omg_instance_segmentation/dataset_ver4/obj'
    else:
        save_dir = '/home/demo/document/ykato_git/datasets/omg_instance_segmentation/dataset_ver4/obj'

    makeDirectory(save_dir)

    for age in range(100, 1100, 100):

        g = adel.setup_canopy(age)
        adel.grow(g, wdata)

        # パラメータcsv保存
        with open(save_dir + '/param_age{}.csv'.format(age), 'w') as f:
            writer = csv.writer(f)
            label = g.property('label')
            geometry = g.property('geometry')
            is_green = g.property('is_green')
            writer.writerow([label])
            writer.writerow([geometry])
            writer.writerow([is_green])
        f.close()

        # 茎,緑葉,茶葉,全体, 葉を生成して保存

        folder_name = [
            'all', 'stem', 'leaf', 'green_stem', 'green_leaf', 'brown_stem',
            'brown_leaf'
        ]
        for i in range(len(folder_name)):
            makeDirectory(save_dir + '/' + folder_name[i] + '_age' + str(age))
            st = plot3d1(g, i)
            for t in range(len(st)):
                st[t].name = str(t)
            # 自動的に.mtlも保存してくれるっぽい
            st.save(save_dir + '/' + folder_name[i] + '_age' + str(age) +
                    '.obj')

            # if i != 3:
            w = obj.ObjCodec()
            w.write2(save_dir + '/' + folder_name[i] + '_age' + str(age), st)
Ejemplo n.º 3
0
def growth_wheat_someage():
    seq, weather = sample_weather()
    wdata = weather.get_weather(seq)
    nsect = 1  #the number of element per leaf
    for sed in range(100):
        adel = AdelWheat(nsect=nsect, nplants=1, seed=sed)

        # save_dir = './obj'
        # save_dir = '/home/demo/document/ykato_git/datasets/omg_instance_segmentation/dataset_ver4/obj'
        if os.name == 'nt':
            save_dir = 'I:/ykato_git/datasets/omg_instance_segmentation/dataset_simulate_100/{}'.format(
                sed)
        else:
            save_dir = '/home/demo/document/ykato_git/datasets/omg_instance_segmentation/dataset_ver4/obj'

        makeDirectory(save_dir)

        for age in range(100, 1100, 100):

            g = adel.setup_canopy(age)
            adel.grow(g, wdata)

            # パラメータcsv保存
            with open(save_dir + '/param_age{}.csv'.format(age), 'w') as f:
                # writer=csv.writer(f)
                label = [g.property('label')]
                geometry = [g.property('geometry')]
                is_green = [g.property('is_green')]
                # writer.writerow([label])
                # writer.writerow([geometry])
                # writer.writerow([is_green])

                header = label[0].keys()
                writer = csv.DictWriter(f, header)
                # header_row = {'j':k for k in header}
                writer.writeheader()
                for row in label:
                    writer.writerow(row)

                header = geometry[0].keys()
                writer = csv.DictWriter(f, header)
                # header_row = {'k':k for k in header}
                # writer.writerow(header_row)
                writer.writeheader()
                for row in geometry:
                    writer.writerow(row)

                header = is_green[0].keys()
                writer = csv.DictWriter(f, header)
                # header_row = {'k':k for k in header}
                # writer.writerow(header_row)
                writer.writeheader()
                for row in is_green:
                    writer.writerow(row)

            # 茎,緑葉,茶葉,全体, 葉を生成して保存

            folder_name = [
                'all', 'stem', 'leaf', 'green_stem', 'green_leaf',
                'brown_stem', 'brown_leaf'
            ]
            for i in range(len(folder_name)):
                makeDirectory(save_dir + '/' + folder_name[i] + '_age' +
                              str(age))
                st = plot3d1(g, i)
                for t in range(len(st)):
                    st[t].name = str(t)
                # 自動的に.mtlも保存してくれるっぽい
                st.save(save_dir + '/' + folder_name[i] + '_age' + str(age) +
                        '.obj')

                # if i != 3:
                w = obj.ObjCodec()
                w.write2(save_dir + '/' + folder_name[i] + '_age' + str(age),
                         st)
Ejemplo n.º 4
0
from alinea.adel.astk_interface import AdelWheat
from alinea.astk.Weather import sample_weather


seq, weather = sample_weather()
wdata = weather.get_weather(seq)

adel = AdelWheat(nsect=2)

g = adel.setup_canopy(100)
adel.grow(g, wdata)
Ejemplo n.º 5
0
from alinea.adel.astk_interface import AdelWheat
from alinea.astk.Weather import sample_weather

seq, weather = sample_weather()
wdata = weather.get_weather(seq)

adel = AdelWheat(nsect=2)

g = adel.setup_canopy(100)
adel.grow(g, wdata)