From ac1a7c9cb165a54bf8537c23fae5e48ea7d59835 Mon Sep 17 00:00:00 2001 From: pradal Date: Tue, 2 Dec 2025 14:53:32 +0100 Subject: [PATCH 1/2] Remove alinea namespace --- src/alinea/astk/__init__.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/alinea/astk/__init__.py diff --git a/src/alinea/astk/__init__.py b/src/alinea/astk/__init__.py deleted file mode 100644 index dc63d20..0000000 --- a/src/alinea/astk/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from openalea.astk import * - -from warnings import warn - -warn("This is deprecated; Use openalea namespace instead alinea!", DeprecationWarning, stacklevel=2) From 96b37da484b9cadcd9ef568f0757687eeeb15279 Mon Sep 17 00:00:00 2001 From: pradal Date: Tue, 2 Dec 2025 15:08:10 +0100 Subject: [PATCH 2/2] Modernize the code and document it! --- src/openalea/astk/TimeControl.py | 17 ++++++++--------- src/openalea/astk/Weather.py | 5 +++-- src/openalea/astk/colormap.py | 2 +- src/openalea/astk/icosphere.py | 21 ++++++++++++--------- src/openalea/astk/pgl_display.py | 16 ++++++++++++++++ src/openalea/astk/plantgl_utils.py | 17 +++++++++++++++-- src/openalea/astk/sky_luminance.py | 7 ++++++- src/openalea/astk/sky_sources.py | 2 +- src/openalea/astk_wralea/__wralea__.py | 6 +++--- 9 files changed, 65 insertions(+), 28 deletions(-) diff --git a/src/openalea/astk/TimeControl.py b/src/openalea/astk/TimeControl.py index 88273bc..750bc35 100644 --- a/src/openalea/astk/TimeControl.py +++ b/src/openalea/astk/TimeControl.py @@ -15,12 +15,11 @@ Provides utilities for scheduling models in simulation """ from __future__ import division -import numpy -#from six.moves import map -#from six.moves import zip from functools import reduce -class TimeControlSet(object): +import numpy + +class TimeControlSet: def __init__(self, **kwd): """ Create a TimeControlSet , that is a simple class container for named object""" @@ -36,7 +35,7 @@ def simple_delay_timing(delay = 1, steps =1): return (TimeControlSet(dt=delay) if not i % delay else TimeControlSet(dt=0) for i in range(steps)) -class TimeControl(object): +class TimeControl: def __init__(self, delay=None, steps=None, model=None, weather=None, start_date=None): """ create a generator-like timecontrol object """ @@ -63,7 +62,7 @@ def __next__(self): return next(self._timing) -class TimeControler(object): +class TimeControler: def __init__(self, **kwd): """ create a controler for parallel run of time controls @@ -96,7 +95,7 @@ def evaluation_sequence(delays): seq = [[True if i == 0 else False for i in range(int(d))] for d in delays] return reduce(lambda x,y: x + y, seq) -class EvalValue(object): +class EvalValue: def __init__(self, eval, value, dt): self.eval = eval @@ -106,7 +105,7 @@ def __init__(self, eval, value, dt): def __nonzero__(self): return self.eval -class IterWithDelays(object): +class IterWithDelays: def __init__(self, values = [None], delays = [1]): self.delays = delays @@ -220,7 +219,7 @@ def rain_filter_node(time_sequence, weather): filter = rain_filter(time_sequence, weather) return time_sequence, filter, weather.data -class DegreeDayModel(object): +class DegreeDayModel: """ Classical degreeday model equation """ diff --git a/src/openalea/astk/Weather.py b/src/openalea/astk/Weather.py index e8eafa4..358a1bd 100644 --- a/src/openalea/astk/Weather.py +++ b/src/openalea/astk/Weather.py @@ -20,13 +20,14 @@ from __future__ import division from __future__ import print_function -import pandas import pytz from datetime import timedelta from pathlib import Path +import pandas + from .TimeControl import * -from openalea.astk.sun_position import sun_position +from .sun_position import sun_position from . import sky_sources as sunsky from .data_access import meteo00_01 diff --git a/src/openalea/astk/colormap.py b/src/openalea/astk/colormap.py index ca8a692..6287361 100644 --- a/src/openalea/astk/colormap.py +++ b/src/openalea/astk/colormap.py @@ -19,7 +19,7 @@ from math import isnan -class ColorMap(object): +class ColorMap: """A RGB color map, between 2 colors defined in HSV code :Examples: diff --git a/src/openalea/astk/icosphere.py b/src/openalea/astk/icosphere.py index 1dde8b4..ea28e52 100644 --- a/src/openalea/astk/icosphere.py +++ b/src/openalea/astk/icosphere.py @@ -161,17 +161,17 @@ def split_triangles(vertices, faces, tags=None): """ Iterate an icosphere by sub-dividing each triangle into 4. Args: - vertices (list of tuples): list of 3D coordinates of icosphere vertices - faces (list of tuple): list of vertex indices defining the faces - tags (list of int): list of integer identifying a face. if None (default) - no tags are returned + - vertices (list of tuples): list of 3D coordinates of icosphere vertices + - faces (list of tuple): list of vertex indices defining the faces + - tags (list of int): list of integer identifying a face. if None (default) + no tags are returned Returns: - a list of vertices and a list of faces and, if tags is not None, a list - of tags referencing the tag of the parent face + - a list of vertices and a list of faces and, if tags is not None, a list + of tags referencing the tag of the parent face This is a python implementation of the C code found here: http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html -""" + """ # copy input new_faces = [f for f in faces] new_vertices = [v for v in vertices] @@ -224,8 +224,11 @@ def split_triangles(vertices, faces, tags=None): def sorted_faces(center, face_indices, faces): - """ return face indices sorted to form a counter clockwise rotation - around its centroid""" + """ Sort faces. + + Return face indices sorted to form a counter clockwise rotation + around its centroid. + """ indices = [i for i in face_indices] sorted_indices = [indices.pop(0)] while len(indices) > 0: diff --git a/src/openalea/astk/pgl_display.py b/src/openalea/astk/pgl_display.py index 7e184bc..a2b1e32 100644 --- a/src/openalea/astk/pgl_display.py +++ b/src/openalea/astk/pgl_display.py @@ -1,4 +1,20 @@ +# -*- python -*- +# +# Copyright 2016-2025 Inria - CIRAD - INRAe +# +# Distributed under the Cecill-C License. +# See accompanying file LICENSE.txt or copy at +# http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html +# +# WebSite : https://github.com/openalea-incubator/astk +# +# File author(s): Christian Fournier +# +# +# +# ============================================================================== + import warnings from openalea.astk.colormap import jet_colors diff --git a/src/openalea/astk/plantgl_utils.py b/src/openalea/astk/plantgl_utils.py index bf1fbcb..c7b42a8 100644 --- a/src/openalea/astk/plantgl_utils.py +++ b/src/openalea/astk/plantgl_utils.py @@ -14,7 +14,7 @@ from __future__ import division from openalea.plantgl import all as pgl -#from six.moves import range + def _is_iterable(x): try: @@ -23,8 +23,21 @@ def _is_iterable(x): return False return True - def get_area_and_normal(scene_geometry): + """ Calculate the area and normal of objects in a PlantGL scene + + Parameters + ---------- + scene_geometry: dict([id, geometry]) + Dictionnary of geometries of objects in the scene. + + Returns + ------- + areas: dict([id, list of float]) + Dictionnary of list of surface of triangles composing each object in the scene. + normals: dict([id, list of pgl.Vector3]) + Dictionnary of list of normal vectors of triangles composing each object in the scene. + """ def _surf(ind,pts): A,B,C = [pts[i] for i in ind] diff --git a/src/openalea/astk/sky_luminance.py b/src/openalea/astk/sky_luminance.py index deaa70f..119bc12 100644 --- a/src/openalea/astk/sky_luminance.py +++ b/src/openalea/astk/sky_luminance.py @@ -20,7 +20,12 @@ f_clear_sky, all_weather_sky_brightness ) -from openalea.astk.sky_map import ksi_grid, scale_sky, sky_ni, sky_lum +from openalea.astk.sky_map import ( + ksi_grid, + scale_sky, + sky_ni, + sky_lum +) def cie_luminance_gradation(z, a=4, b=-0.7): diff --git a/src/openalea/astk/sky_sources.py b/src/openalea/astk/sky_sources.py index 9098b1f..30c00f3 100644 --- a/src/openalea/astk/sky_sources.py +++ b/src/openalea/astk/sky_sources.py @@ -17,7 +17,7 @@ import numpy from .icosphere import turtle_mesh, spherical_face_centers -from openalea.astk.sky_luminance import sky_luminance +from .sky_luminance import sky_luminance from .sky_map import sky_grid, sky_map, sky_hi diff --git a/src/openalea/astk_wralea/__wralea__.py b/src/openalea/astk_wralea/__wralea__.py index f0ec204..59974f7 100644 --- a/src/openalea/astk_wralea/__wralea__.py +++ b/src/openalea/astk_wralea/__wralea__.py @@ -9,11 +9,11 @@ __editable__ = True __description__ = '' __license__ = 'CeCILL-C' -__url__ = 'http://openalea.gforge.inria.fr' +__url__ = 'https://openalea-astk.rtfd.io' __alias__ = [] -__version__ = '1.0.0' +__version__ = '3.0.0' __authors__ = '' -__institutes__ = None +__institutes__ = 'inria, CIRAD, INRAE' __icon__ = ''