JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25108F
  • License CeCILL

PlantGL jupyter widget

Package Exports

  • pgljupyter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pgljupyter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pgljupyter

PlantGL & L-Py jupyter widgets

Quick Examples

  • lpy tree model - leuwenberg @nbviewer

  • simple PlantGL shapes - spheres @nbviewer

  • notebook magics - champignon @nbviewer

  • notebook magics with scalar parameters - broccoli @nbviewer

  • notebook magics with curve parameters - sweep surface @nbviewer

Usage

from pgljupyter import SceneWidget, LsystemWidget

SceneWidget

Renderer for PlantGL Scenes, Shapes, Geometries

Arguments:

  • arg0 list | plantgl.Shape | plantgl.Scene: a list of shapes or scenes or a single object
  • position tuple (float, float, float): x, y, z position of arg0 (default (0, 0, 0))
  • scale float: scale factor for arg0 (default 1)
  • size_display tuple (int, int): width and height of the canvas (minimum 400)
  • size_world float: extend on the 3D scene in all directions

LsystemWidget

Renderer for lpy.Lstrings derived from lpy.Lsystem code

Arguments:

  • arg0 string: file name / path of lpy code file
  • unit string enum: the unit used in the Lsystem model ('m', 'dm', 'cm', 'mm', default 'm')
  • scale float: scale factor for arg0 (default 1)
  • animate bool: if True runs animation automatically
  • size_display tuple (int, int): width and height of the canvas (minimum 400)
  • size_world float: extend on the 3D scene in all directions

%%lpy

A cell magic to inline L-Py code in a notebook

# activated by importing pgljupyter
import pgljupyter

Arguments:

  • --size, -s int,int: same as size_display
  • --world, -w float: same as size_world
  • --unit, -u enum: same as unit
  • --params, -p LsystemParameters: name of LsystemParameters instance
  • --animate, -a True: runs animation automatically

%lpy_plot

A line magic to plot all derivation steps of an Lsystem on a square plane

# activated by importing pgljupyter
import pgljupyter

Arguments:

  • arg0, string: L-Py file
  • --size, -s int,int: width and hight of the canvas
  • --cell, -c float: size of cell for a single derivation step

Installation

Install with pip - inside conda env

JupyterLab < 3.0 requires nodejs. In case it is not available on your system add nodejs to the conda create command.

conda create -y -n pgl -c fredboudon -c conda-forge \
    openalea.lpy jupyterlab ipywidgets ipython=7

For windows specify python 3.7 (there are some issues with jupyter on windows with python 3.8)

conda create -y -n pgl -c fredboudon -c conda-forge python=3.7 \
    openalea.lpy jupyterlab ipywidgets ipython=7

Some examples also require matplotlib, xarray-simlab and rpy2.

For JupyterLab 3:

conda activate pgl
jupyter labextension install @jupyter-widgets/jupyterlab-manager
pip install pgljupyter

For JupyterLab 2:

conda activate pgl
pip install "pgljupyter<1.0.0"
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager
jupyter lab build && jupyter lab

Build, install and run from source

  • install lpy, plantgl, jupyterlab, widgets and widgetsextension
conda create -y -n pgl -c fredboudon -c conda-forge openalea.lpy jupyterlab ipywidgets
conda activate pgl
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ..
  • get pgljupyter source
git clone https://github.com/jvail/plantgl-jupyter.git
cd plantgl-jupyter
  • fetch plantgl and install pgljs deps
git submodule update --init --recursive
cd src/pgljs
npm install
cd ../..
  • install pgljupyter deps and build (requires activation of emsdk i.e. source ./emsdk_env.sh)
npm install
npm run build:all
  • install python modules and jupyter extensions
pip install -e .
jupyter nbextension install --sys-prefix --overwrite --py pgljupyter
jupyter nbextension enable --sys-prefix --py pgljupyter
jupyter labextension install .
jupyter lab clean
  • run the lab
jupyter lab --notebook-dir=./examples

Docker

Run jupyter as docker container locally. Replace /examples with the path to your notebooks. Tag latest might not always be up-to-date since docker is primarily used for binder

docker pull jvail/plantgl-jupyter:0.2.1
docker run --rm \
    -p 8888:8888 \
    -v $PWD/examples:/home/jovyan/work jvail/plantgl-jupyter:0.2.1 \
    jupyter lab