Synopsis
Python is a dynamic object-oriented programming language used by CIAO
Description
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.
Refer to the Python Programming Language website for more information. Several web sites dedicated to using Python for Astronomical research exist, including the AstroBetter Wiki.
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.8, 3.9, or 3.10
- IPython
- NumPy
- Matplotlib
- six
- pip
Python package versions: conda-install
The following versions are provided with CIAO 4.15 when installed with ciao-install:
- Python version 3.9.9
- IPython version 8.0.0 (including Jupyter notebook support)
- NumPy version 1.22
- Matplotlib version 3.5.1
- six version 1.16.0
- pip version 22.0.4
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.15 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.15
Python versions
Support for Python 3.7 has been dropped, and Python 3.10 added.
macOS ARM support
Unfortunately certain packages that CIAO requires are still not available for macOS ARM systems, so CIAO 4.15 remains using the Rosetta2 emulation system.
Changes in CIAO 4.14
Python versions
Support for Python 3.6 has been dropped, and Python 3.9 added.
Conda installation
The conda installation now requires that the conda-forge channel is included in the installation.
Changes in CIAO 4.13
Python versions
Support for Python 3.5 has been dropped, and Python 3.8 added.
IPython support
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.