没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
Python integration with the py_gamma module, Version of 06-June-2019
Documentation – User’s Guide
Python integration with the py_gamma module
Christophe Magnard
Gamma Remote Sensing, Worbstrasse 225, CH-3073 Gümligen, Switzerland
June 2019
Python integration with the py_gamma module, Version of 06-June-2019
2
TABLE OF CONTENTS
1 Introduction ........................................................................................................................ 3
2 Installation ........................................................................................................................... 3
2.1 General instructions ....................................................................................................... 3
2.2 Additional instructions for Windows ............................................................................. 4
2.3 Python version ............................................................................................................... 4
3 py_gamma documentation ................................................................................................. 5
4 py_gamma module contents .............................................................................................. 5
4.1 Calling Gamma Software programs as Python functions .............................................. 6
4.2 Functions in py_gamma ................................................................................................. 8
4.3 ParFile object ............................................................................................................... 12
4.3.1 Variables ................................................................................................................ 13
4.3.2 Methods ................................................................................................................. 13
4.4 Variables used by the py_gamma module.................................................................... 15
5 Examples............................................................................................................................ 15
5.1 Importing modules ....................................................................................................... 15
5.2 Help and documentation .............................................................................................. 15
5.3 Reading and writing binary images ............................................................................. 16
5.4 Interacting with Gamma Software programs ............................................................... 17
5.5 Processing data ............................................................................................................. 18
5.6 Point lists and point data .............................................................................................. 20
5.7 Run shell commands .................................................................................................... 21
Python integration with the py_gamma module, Version of 06-June-2019
3
1 INTRODUCTION
Python programming language is getting more and more popular, with many researchers, including
among Gamma Software users, increasingly using Python for processing data, analyzing results,
developing their own scripts.
We now offer the possibility to integrate the Gamma Software into Python through a wrapper: the
py_gamma module. It permits a smooth usage of the Gamma Software tools and data formats within
Python scripts as well as within a Python Interactive Development Environment (IDE) such as Spyder
or PyCharm.
Using the wrapper:
• Binary images, point lists and data, parameter files, tab files, can be easily read, inspected, and
written.
• Gamma Software program calls become Python function calls where variables can be used as
function arguments, and system outputs can be stored in variables or written to log files.
• Usage within an interactive Python environment permits function name search and automatic
completion.
• The documentation for each function can be easily accessed.
2 INSTALLATION
2.1 General instructions
The Gamma Software installation has to be completed first.
The Gamma Software Python wrapper consists of a file py_gamma.py located in the main directory of
the Gamma Software distribution. Hence, to be able to import the wrapper into your Python
environment, the main directory of the Gamma Software distribution has to be added to the
PYTHONPATH. This can be done in the .bashrc file by adding the following line:
export PYTHONPATH=$GAMMA_HOME:$PYTHONPATH
or e.g. from within the Spyder interface (Tools -> PYTHONPATH manager)
Another possibility is to temporarily add the Gamma Software main directory path within an interactive
Python console or in a Python script as follows:
import sys
sys.path.insert(0, '/path/to/Gamma/Software/main/directory')
Once the path has been set, simply import the py_gamma module in your interactive Python console or
in your Python script, e.g.:
import py_gamma as pg
Python integration with the py_gamma module, Version of 06-June-2019
4
2.2 Additional instructions for Windows
In order to be able to run programs and scripts (e.g. Perl, csh, bash, ...) on Windows with a Python IDE,
the MSYS64 and GAMMA_LOCAL (binary distribution) or MINGW64 (source code distribution)
environment variables have to be set.
On Windows 10, this can be done as follows:
• right click on your computer icon (may be called “This PC”) -> Properties -> Advanced system
settings -> Environment Variables
• add MSYS64 environment variable with the path to MSYS2 main directory as value, e.g.:
C:\msys64
• add GAMMA_LOCAL or MINGW64 environment variables, with the path to the main directory
as variable, e.g.:
C:\GAMMA_LOCAL_w64_20190606
or
C:\msys64\mingw64
• the "PYTHONPATH" environment variable can also be created or updated there by setting its value
to the location of the Gamma Software main directory.
2.3 Python version
The py_gamma module was developed with Python 3.7. While it was tested on Python 2.7 and 3.6, full
compatibility with older Python versions is not guaranteed. We recommend using the latest Python 3
version.
Python IDEs such as Spyder (available e.g. in Anaconda or WinPython) or PyCharm provide numerous
practical tools such as:
• Scroll and completion of function names
• An editor with live analysis of the code and error description
• Visualization of variables
• Command history
We highly recommend using one of these.
剩余20页未读,继续阅读
地信的刀下鬼
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0