The examples in this repository are described in detail in the book Earth Observation Using Python: A Practical Programming Guide. You may use these examples in your work, but please acknowledge or cite this book if you do not significantly alter or improve upon it.
You can launch a binder instance to run the code interactively online. This does not require a Python installation, but your work will not be saved if you close the browser.
-
Download the contents of the repository on your computer (see links on the left sidebar). If you are on the GitHub repository, you can do this by clicking the Code button on the top right, followed by download ZIP. You will need to then uncompress the file. You can also download these
-
You will need Anaconda to run these examples, which you can install following the steps on their website. You can also use Miniconda if you need save disk space.
-
Python has many useful add-on packages that can help you with your coding projects. However, packages are frequently updated and may change over time. I recommend creating a dedicated Python environments for examples in this tutorial and for your future projects. You create an environment in Anaconda Navigator or using the terminal to access a command line. You can use the following tools, depending on your operating system:
- Windows: Anaconda Prompt
- MacOs/Linux: Terminal
Open your command line program. You will need to navigate to the folder that contains the notebooks using the cd command (change directory). For example, if you are using a Windows machine and saved your code in your Documents folder, it may look like:
cd C:\Users\your_name_here\Documents\Earth-Obs-Py
Next, we can setup our environment. This will install all the libraries we need to run the examples. To do this, we use the following command:
conda env create -f environment.yml
This may take a few minutes. After the new environment is created (named earthsciviz), we need to switch to it instead of using our default environment. To do this, type:
conda activate earthsciviz
- launch Jupyter Notebooks to view and run the contents interactively. Type the command:
jupyter notebook
This will open a window in your default browser. Navigate to the folder that contains the notebooks (*.ipynb) and click on the tutorial that you wish to run. Any changes you make to these files will be saved to your local machine.
You can end your session by closing the command line program. If you wish to resume at a later time, you will need to again change to the correct directory (via cd ...) reactive the environment (via conda activate...) and launch Jupyter Notebooks.
I will occasionally upload short tutorials to my YouTube channel, Python for Earth Science. I also offer virtual and in-person workshops at the American Geophysical Union annual meeting and in the Washington D.C. area.
Pandas
- Short Introduction
- Cookbook Pandas operations.
Matplotlib
Reading self describing file
-
NETCDF files are common in Earth remote sensing. In addition to this book, Unidata also provides a detailed tutorial.
-
HDF files are another common format and can be opened using h5py, which has an excellent user manual.
-
GRIB2 files are a World Meteorology Association standard format and commonly used with weather-related models like ECMWF and GFS. These files can be opened using pygrib. You can find an example here.
-
BUFR files can be opened using the python-bufr package.
Free online Tutorials
- YouTube series for absolute beginners CS Dojo
- Enhance your workflow Automate Boring Stuff
Please submit an issue in the GitHub repository if you encounter any problems. Examples in this repository will always be the most up-to-date version.