Welcome to the BEAM Forum!

We encourage you to sign in our forum and participate in the BEAM community. The forum is maintained by the BEAM project team who will most likely answer your questions within 24 hours (except during common holidays) - if not done by other community members. Collaborate, share your knowledge and learn from other users!

If you don't find what you are looking for, please also consider the following external forums:

Combination View Flat View Tree View
Threads [ Previous | Next ]
Python Scripts
toggle
Python Scripts
python
6/28/13 12:46 PM
Dear all,
Besides this entry (http://www.brockmann-consult.de/beam-wiki/display/BEAM/Exercise+4+-+Scripting) I did not find any more examples or a tutorial on using Python with Java? or even documentation that can be used
Thanks
Antonio
Flag Flag
RE: Python Scripts
6/28/13 1:52 PM as a reply to Antonio Rocha.
Dear Antonio,

the scripting console the wiki page is referring to is to be considered experimental, so I'm afraid there is no additional documentation.

However, there is good news! Currently, we are developing a Python bridge to BEAM, which will allow you to use the whole BEAM-API from your python scripts. We plan to deliver this API in early autumn, alongside BEAM 5.0.

Best regards,
Thomas
Flag Flag
RE: Python Scripts
python
6/28/13 2:00 PM as a reply to Thomas Storm.
Dear Thomas,
In my case my intention is to develop python scripts to run BEAM modules/operations. So, this will only be fully supported and operational after autumn. I tried to use the Python Scripts that I found in other topics and It was not possible to use

Regards,
Antonio
Flag Flag
RE: Python Scripts
10/28/13 12:15 AM as a reply to Antonio Rocha.
Dear Thomas and the BEAM team,

Will the new Python bridge to BEAM allow users to write new GPF Operators in Python?
(This will enable scientists to create new processing graphs without having to do any Java programming)

thanks,
Kutila
Flag Flag
RE: Python Scripts
10/28/13 8:32 AM as a reply to Kutila Gunasekera.
Hi Kutila,

this is one of the reasons why the new Python bridge is developed.
You won't need to develop in Java any more. You can stay in the Python language.

cheers
Marco
Flag Flag
RE: Python Scripts
10/30/13 12:27 AM as a reply to Marco Peters.
Great!

Looking forward to the next release,
Kutila
Flag Flag
RE: Python Scripts
python
4/2/14 3:20 PM as a reply to Marco Peters.
Hej Marco,

Any news from the Python bridge development? some Beta release? Looking forward to play with it.
Cheers,

Jose
Flag Flag
RE: Python Scripts
4/2/14 3:58 PM as a reply to Jose M. Beltran.
Hi Jose,

yes there is progress but still some glue is missing. But for the release it will be possible to use the BEAM API in python and it will be possible to write operators in python and use them in BEAM.

best wishes
Marco
Flag Flag
RE: Python Scripts
6/4/14 12:04 PM as a reply to Jose M. Beltran.
Python users might be interested to find the new BEAM Python bridge beam-python in BEAM 5.0.

It allows you to access the BEAM Java API from Python and also to extend BEAM by EO data "operators" written in the Python language. See examples in the module directory ($BEAM_HOME/modules/beam-python-5.0).

It currently requires Python 3.3 or higher. We will release an update of this module (5.0.1) in a few days. It will allow you to also use Python 2.7. Please check BEAM VISAT's module manager

-- Norman
Flag Flag
RE: Python Scripts
6/5/14 4:03 PM as a reply to Norman Fomferra.
Great News Norman,

Does the upgrade will fix the JVM trouble to load libraries when there is more than one python version installed.
error like:

1File "setup.py", line 124, in <module>
2    import jpy
3ImportError: libjvm.so: cannot open shared object file: No such file or directory


I tried with

1export LD_LIBRARY_PATH=$JDK_HOME/jre/lib/server:$LD_LIBRARY_PATH


and It did not worked yet.

Cheers,

Jose
Flag Flag
RE: Python Scripts
6/10/14 4:26 PM as a reply to Jose M. Beltran.
Jose, thanks for testing!

Jose M. Beltran:

Does the upgrade will fix the JVM trouble to load libraries when there is more than one python version installed.


jpy 0.7.2-snapshot (trunk from https://github.com/bcdev/jpy) fixes the missing Python 2.7 support (https://github.com/bcdev/jpy/issues/34). Supporting multiple Python installations (https://github.com/bcdev/jpy/issues/35) is not yet addressed, but the workaround is to simply edit the $USER/.jpy file to make it point to the wanted jpy Python shared library file.

beam-python 5.0.1-SNAPSHOT (trunk from https://github.com/bcdev/beam/tree/master/beam-python) uses jpy 0.7.2-snapshot in order to deal with Python 2.7.

Note that neither beam-python 5.0.1 (incl. beampy) nor jpy 0.7.2 has been publicly released yet. You can't use the beampy snapshot version without the jpy snapshot one. I hope to release both tomorrow.

Jose M. Beltran:

error like:
1File "setup.py", line 124, in <module>
2    import jpy
3ImportError: libjvm.so: cannot open shared object file: No such file or directory


1export LD_LIBRARY_PATH=$JDK_HOME/jre/lib/server:$LD_LIBRARY_PATH

and It did not worked yet.


Please make sure the directory $JDK_HOME/jre/lib/server exists, is accessible, contains the desired libjvm.so, and is binary compatible with the desired Python version (32 vs. 64 bit).

-- Norman
Flag Flag
RE: Python Scripts
beam beampy jpy ubuntu
6/15/14 8:30 PM as a reply to Norman Fomferra.
Dear Norman,

Finally my installation was successful. Here are the variables that were added into my .bashrc file. I am using UBUNTU 14.04 64 bits.

1export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
2export JDK_HOME="/usr/lib/jvm/java-7-oracle"
3export LD_LIBRARY_PATH="/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server/"
4export BEAM_HOME="~/beam-5.0"


Note that the path for the LD_LIBRARY_PATH variable is slightly different as the installation proposed.

Cheers!
Joseemoticon
Flag Flag
RE: Python Scripts
6/15/14 10:05 PM as a reply to Jose M. Beltran.
Dear Norman,
After running all the proposed test for beampy, only one test failed. Details below:

 1~/beam-5.0/modules/beam-python-5.0/beampy$ python beampy_product_test.py
 2..FFFFError: Could not load mediaLib accelerator wrapper classes. Continuing in pure Java mode.
 3Occurs in: com.sun.media.jai.mlib.MediaLibAccessor
 4com.sun.media.jai.mlib.MediaLibLoadException
 5.
 6======================================================================
 7FAIL: test_getSceneRasterWidthAndHeight (__main__.TestBeamIO)
 8----------------------------------------------------------------------
 9Traceback (most recent call last):
10  File "beampy_product_test.py", line 54, in test_getSceneRasterWidthAndHeight
11    self.assertEqual(h,  705)
12AssertionError: 2081 != 705
13
14======================================================================
15FAIL: test_readPixels_with_java_array (__main__.TestBeamIO)
16----------------------------------------------------------------------
17Traceback (most recent call last):
18  File "beampy_product_test.py", line 64, in test_readPixels_with_java_array
19    self.assertAlmostEqual(a[100], expected_a100, places=5)
20AssertionError: 118.462646484375 != 89.462776 within 5 places
21
22======================================================================
23FAIL: test_readPixels_with_numpy_array (__main__.TestBeamIO)
24----------------------------------------------------------------------
25Traceback (most recent call last):
26  File "beampy_product_test.py", line 84, in test_readPixels_with_numpy_array
27    self.assertAlmostEqual(a[100], expected_a100, places=5)
28AssertionError: 118.46265 != 89.462776 within 5 places
29
30======================================================================
31FAIL: test_readPixels_with_python_array (__main__.TestBeamIO)
32----------------------------------------------------------------------
33Traceback (most recent call last):
34  File "beampy_product_test.py", line 74, in test_readPixels_with_python_array
35    self.assertAlmostEqual(a[100], expected_a100, places=5)
36AssertionError: 118.462646484375 != 89.462776 within 5 places
37
38----------------------------------------------------------------------
39Ran 7 tests in 3.308s
40
41FAILED (failures=4)
Flag Flag