This is an alpha release of a Python
http://www.python.org/download/releases/2.7.3/ language extension for PixInsight. Python is a scripting language that is hugely popular
in scientific computing and many other areas. It is well defined, modern and powerful. As such,
I hope it is a powerful extension for PixInsight.
I am releasing this module in alpha state in the hope to find collaborators that help to
advance development of this module. See section "Development" below.
Features:
---------
- Allows to run Python 2.7 scripts within PixInsight
- all provided and used software has licenses compatible with use in PixInsight.
- Python scripts can access PCL classes for creating and manipulating images
- Python with PixInsight can use many popular Python extensions such an numpy
http://numpy.scipy.org/,
scipy
http://www.scipy.org/, matplotlib
http://matplotlib.org/, pyephem
http://rhodesmill.org/pyephem/,
and other modules such as those from PiPy
http://pypi.python.org/pypi.
Those module can do many useful tasks such as solving equation
systems, image processing, plotting graphs, and computing the ephemerides of celestial objects.
They save a lot of work/lines of code. JavaScript and other scripting languages
are not nearly as strong in this domain. See the examples for proof.
- PixInsight can pass parameters as sys.argv to Python
- Python output (print, error messages) goes to the PixInsight console
- Depending on local (blue rectangle/drag blue triangle) or global execution (blue circle), different methods in Python
(execute_on()/execute_global()) are called.
- New Instance (blue triangle) also works as with normal processes.
- A Python IDE (IDLE, with context help etc) can be used to edit scripts
- The following PCL objects are bound to corresponding Python objects:
- pcl::String/IsoString <-> str
- pcl::Array<type> -> list where elements are the correspondingly translated Python types
- pcl::Exception <-> Exception. A Python Exception raises a pcl::SourceCodeError
- pcl::ImageWindow <-> ImageWindow
- pcl::View <-> View
- pcl::ImageVariant <-> Image
- method names have been translated to Python naming convention, e.g. GetLuminance()->get_luminance().
The methods that have been translated currently are only a small subset of those available.
- some basic help is available for instance via help(View) in Python
- Execution of a script happens as follows:
- read in script, with sys.argv set as defined by user. This will execute code in the __Main__ module.
- For Apply() (drag blue triangle on Image, blue rectangle), execute_on(view) is called.
- For global apply (blue circle), execute() is called.
- Both return True for success, or False if something goes wrong. PI responds to this as usual.
- Errors and Exceptions are captured and forwarded to PCL.
- The execution model should enable use with ImageContainer (not tested yet)
- The execution model should (at some time) allow writing proper PixInsight processes in Python
This is an Alpha Release!
-------------------------
This is a very early release of this module. Problems are to be expected. At this stage, the
module should only be used by those that are bold and stress resistant (such as developers).
Known problems:
- so far only developed on Fedora 17-x64 Linux. No attempt porting it to other platforms,
in particular Windows or MacOS, has been made. However, it should be possible to port the
software to any PI platform: The supporting modules are available for them as well.
- The language bindings cover only a small part of the PCL interface. I implemented only what was
needed for the example scripts, or what was trivial.
- There are known problems. In particular:
- Image.get_luminance() does not work for unknown reasons
- After the use of the IDLE gui, we sometimes get SIGSEGV (11). Scripts outside IDL work without problems
though. This needs further investigation.
- There are incompatibilities between library versions. For instance, Python must not use any library
that uses Qt (such as PyQt), because PixInsight is using an incompatible version
- only rudimentary tests have been performed.
Use:
----
Here some explanations on how to use the current module:
- The module appears as "Python" in the module list. Selecting it opens the GUI shown in gui.JPG.
- GUI Elements:
- IDLE button: If pressed, opens the IDLE development environment. NOTE: This still frequently crashed. Be careful!
-If Use File is selected, it opens an editor with syntax coloring for the selected file (idleEditor.JPG)
-If Use File is not selected, it opens in interactive mode with context help (idleInteractive.JPG)
- Use File checkbox: If selected, the selected file contains the Python script to be executed. Otherwise, the script
text contained in the TextBox at the bottom of the dialog is executed. File selection happens with a standard
file selection dialog.
- Arguments: blank separated arguments that are passed to the script sys.argv, just like command line arguments would
be passed to a shell script.
- Text box: Enter your script text here if Use File is not selected.
- Apply Global (blue circle), Apply (blue rectangle) and New Instance (Blue Triangle) can be used as usual.
See under "Features" on what happens on Apply/Apply Global.
Next posting: Some examples.
Georg