Unidata Python Gallery¶
This is a collection of using Python for various meteorological tasks, across many different libraries.
This gallery provides a great set of examples and starting points for your projects. We have an environment file to make running these examples easier. To get started, you can setup your environment following these steps:
Head over to conda.io/miniconda.html and download the miniconda installer for your operating system. You’ll want the Python 3.X version. Windows 32-bit machines are NOT supported by most packages and cannot be used.
After downloading the installer, open it and click through the graphical install utility. Accept all of the default installation settings.
You should now have a program called “Anaconda Prompt” installed. Open it (this will be your Python command prompt).
After downloading the bash installer, open a command prompt (terminal program on the Mac).
Change the directory at the terminal to wherever the installer was downloaded. On most systems, this will default to the downloads directory in your user account. If that’s the case, cd ~/Downloads will get you there, or replace the path with wherever you saved the file.
Run the installer script by typing bash Miniconda3-latest-MacOSX-x86_64.sh.
Note: Your file name may be different depending upon your operating system! replace Miniconda3-latest-MacOSX-x86_64.sh with whatever the name of the file you downloaded was.
Accept the defaults.
After the installer has completed completely close and restart your terminal program (this sources the newly modified path).
Verify that your install is working by typing conda –version into the terminal. You should see a response like conda 4.5.11 or similar (though yours may be a different version number).
Setting up the environment¶
We’ll be using conda environments for the workshop (again, we’ll explain more during the course or checkout this MetPy Monday if you can’t wait). After installing conda, open a terminal (or the Anaconda Prompt if you’re on a Windows machine).
Download the environment.yml file that will tell your system what all we need for the workshop. Note where you download it, this will be the Downloads directory by default on most systems, which is fine. Right click and “save” this link to download.
Open a terminal (Anaconda prompt on Windows) and navigate to whatever directory the environment.yml file was saved in. Generally cd ~/Downloads.
Run the command conda env create and wait for the installation to finish.
Run the command conda activate gallery to activate the unidata environment and verify that everything is ready.
Running an example¶
Find the example you wish to run and download the example as a python script or jupyter notebook, depending on how you wish to run it.
Ensure that the gallery environment is activated.
If you are running the example as a script, run python the_script_name.py
If you are running the example as a notebook start the jupyter environment with jupyter notebook or jupyter lab
When you want to return to the root environment, run the command conda deactivate to exit the gallery environment.