What is Python?
Python is a high-level, general purpose programming language. The language is object orientated, meaning that objects (e.g. variables) ‘carry’ their methodology with them, and emphasises readability paving the way for collaboration on projects, irrespective of size. Importantly, Python is free, and has a vibrant user community that contribute much to supporting questions on its use and an aggressively expanding codebase that extends well beyond numerical computation.
Exhaustive information about Python can be found through the following links:
If you have never used Python, or other programming language, do not worry - we are able to provide support for all levels of users, and you should see this as a chance to learn about the potential of python for your future data use, rather than expecting to become an expert in all aspects (indeed it is something the trainers are continually learning themselves!).
If you have not already worked with Python. Please install a Python 3.7 distribution of Anaconda as described below.
How to install Python?
How you install Python can be very much dependant on what operating system you run - but we would highly recommend installing the Anaconda distribution (discussed below) as a default - this is what we have used to develop course material.
First off, Python is very common, and, to avoid ambiguity, you should check that you don’t have it installed already; you can do this by following the instruction below:
If Python is not installed, you can download the appropriate official version by following the links on the aforementioned page. However, this version only supplies the basic Python installation, with a more limited set of libraries. In order to install further libraries, you will need to configure the python package manager, pip. Instructions on how to install and configure pip can be found here:
Please be aware of the warning box toward the top of this page if you are attempting to install new libraries on a system which has a pre-existing Python version, but to which you do not have root access.
Alternatively, SNAP supports Anaconda Python distributions, which are packaged with more libraries that are suitable for data analysis. These are available here:
Note that, if you install the Anaconda version, you have two options for managing the installation of additional libraries, the GUI based Navigator or the command line based conda. Information on configuring these options can be found via this link:
Alternatively, if you are a Mac user and run versions of the Homebrew or Macports package manager, then most Python versions, and Python package managers (e.g. pip) can be installed through this route.
Important notes: If you intend to use Python to interface to the SNAP Java API (more information on this below) or BRAT then please take note of the following:
The officially supported versions are Python 2.7, 3.3, and 3.4 64-bit (Linux + Darwin) and both 32-bit and 64-bit (Windows) as well as Anaconda distributions. Please note that Python 3.5 is not yet supported. Windows users: Please note that you must use a 32-bit Python if your SNAP installation is 32-bit and accordingly use a 64-bit Python if your SNAP installation is 64-bit.
While currently not supported, later versions of the BRAT for altimetry package will also allow Python interfacing, however, only Python 3 compatible scripts will be supported (Python 2 scripts are not guaranteed to be executed).
How to use Python?
If this is your first time using Python, good step by step resources on using it can be found here:
To help show how we will use Python in this course, some examples are provided. These examples are written in Jupyter Notebook, which is an interactive way of showing how code is written, and explaining what it does. More information on Jupyter Notebook, including its installation, can be found here:
Installation requirements for the upcoming course
If you do not have Python currently installed, or would like to ensure you have a version that will be compatible with the scripts we will provide, please install the latest version of Anaconda for Python 3.7 here: https://www.anaconda.com/download/
We recommended that you install the following packages at minimum, in the form relevant for your Python version (if you have used the Anaconda installation, please follow the installation guidelines below, from your command line interface for the highlighted packages - cartopy and netcdf4):
numpy (Included with Anaconda)
scipy (Included with Anaconda)
cartopy (NOT included with Anaconda and required).
To install cartopy for Anaconda type:
conda install -c conda-forge cartopy into your terminal/anaconda prompt
matplotlib (Included with Anaconda)
xarray (Included with Anaconda)
netCDF4 (NOT included with Anaconda and required).
To install netCDF4 for Anaconda type:
'conda install -c anaconda netcdf4' into your terminal/anaconda prompt
ipython (Included with Anaconda)
jupyter (Included with Anaconda). To install outside of Anaconda, please consult: http://jupyter.org/install.htm
rasterio (NOT included with Anaconda and required):
To install rasterio for Anaconda type:
'conda install -c conda-forge rasterio' in to your terminal/anaconda prompt
plotly (NOT included with Anaconda and required):
To install plotly for Anaconda type:
'conda install -c plotly plotly' in to your terminal/anaconda prompt
earthpy (NOT included with Anaconda and required):
To install earthpy for Anaconda type:
'conda install -c conda-forge earthpy' in to your terminal/anaconda prompt
scikit-learn (NOT included with Anaconda and required):
To install sklearn for Anaconda type:
‘conda install scikit-learn’ in to your terminal/anaconda prompt
pyshp (Included with Anaconda)
gdal (Included with Anaconda)
time (included with Anaconda)
To use your conda environment (important if your system already has a Python installation) you then need to run 'conda activate base' in the terminal before running scripts