Python is a dynamic object-oriented programming language used by CIAO
Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools and comes with extensive standard libraries. A list of key software features is available on the About Python webpage.
Python in CIAO
The CIAO software offers Python as the user scripting environment. Python is distributed with CIAO, but users may opt to run their own custom installation instead; see "ahelp ciaorc" for information on how to change the Python version that is being used (although note that this comes with limited support by the CXC).
For more information, refer to the Scripting in CIAO webpages.
Python package versions: conda
The versions are not listed as it depends on what version of Python was chosen:
- Python version 3.7, 3.8, or 3.9
Python package versions: conda-install
The following versions are provided with CIAO 4.14 when installed with ciao-install:
- Python version 3.8.8
- IPython version 7.19.0 (including Jupyter notebook support)
- NumPy version 1.20.3
- Matplotlib version 3.3.3
- six version 1.15.0
- pip version 20.3.3
Installing extra Python packages
Extra Python packages can be installed with pip and, if CIAO was installed with conda, the conda tool. For users who have write permission to the CIAO installation (e.g. they have installed CIAO onto their own machine), a package such as AstroPy can be installed (after initializing CIAO) with the command:
unix% pip3 install astropy
or - if they don't have write permission to the CIAO installation , or do not want to risk the installation - the following will install it locally:
unix% pip3 install --user astropy
Listing installed packages
The list option can be used to see what Python packages are available:
unix% pip3 list --format=columns
Please contact the CXC HelpDesk if you encounter problems when using pip3.
Jupyter notebook support
CIAO 4.13 includes support for Jupyter notebooks, so after starting CIAO, the following command will start the server, and open a browser window, for the contents of the notebooks directory:
unix% jupyter notebook --notebook-dir notebooks
Since most CIAO tools are run from the command line, it may be useful to also install the bash kernel for Jupyter notebooks, using:
unix% pip3 install bash_kernel unix% python -m bash_kernel.install
This will let users select a "bash kernel" for running commands within a notebook.
Installing CIAO with conda
The Installing CIAO with conda page should be reviewed for updates and guidance on how to install the conda system. With conda installed, a new environment can be created with
% conda create -n ciao-4.14 -c https://cxc.cfa.harvard.edu/conda/ciao \ -c conda-forge ciao sherpa ds9 ciao-contrib caldb_main marx
which will default to Python 3.9. The screen output will provide information on how to "activate" the new environment, which is a relacement for the ciao alias that is suggested for users of ciao-install.
Changes in CIAO 4.14
Support for Python 3.6 has been dropped, and Python 3.9 added.
The conda installation now requires that the conda-forge channel is included in the installation.
Changes in CIAO 4.13
Support for Python 3.5 has been dropped, and Python 3.8 added.
In CIAO 4.13 Sherpa has added support to take advantage of Jupyter notebooks when displaying certain objects: for example, in a Jupyter notebook try the following
get_data() get_source() get_fit_results() get_conf_results()
The CIAO 4.13 release notes contain an example notebook showing some of these changes.