
Welcome back to AWIPS Tips!
Today we're going to talk a little bit about python-awips! However, unlike our previous python-awips blogs, where we talk about one of our example notebooks, today we're going to walk you through how to actually open up Jupyter and run those notebooks!
We know there are a variety of Operating Systems out there, and unfortunately, we cannot provide a walkthrough for every single one of them, but to reach the most users as possible, we would like to show you how to get up and running using our Virtual Machine install option. While we currently have this listed on our CAVE installation webpage as an option for Windows machines, this virtual machine can also be used on Linux machines. So, if you would like to follow along with this blog, please go ahead and download the Virtual Machine option for CAVE on your PC or Linux machine.
Two of the main advantages of using Unidata's virtual machine are that you don't have to do any of the other software installation, and you don't have to worry about altering your machine's environment. Python-awips is already installed with notebooks ready to use!
Working within a virtual machine means you can alter and change as many things about that virtual machine, without impacting the rest of your potential workflows or setups.
After following the above mentioned installation instructions, you should have the following downloaded and installed on your machine:
- VMWare Workstation Player
- Unidata CAVE VM distribution (unidata_cave.zip)
- Loaded the VM, CentOS 7 - Unidata CAVE [version] into VMWare Workstation Player
Shown below is the virtual machine. First we log in using the awips user with password awips, then we open a terminal, navigate to the pre-installed python-awips location, activate the existing python3-awips conda environment, and then start Jupyter notebook on our examples directory. Once started, click on the notebooks folder to view all of our notebooks:
cd python-awips
conda activate python3-awips
jupyter notebook examples

NOTE: Also, if the display doesn't seem to take up the entire VMWare Player window, try resizing and then maximizing VMWare Player like below:

From here you have access to all of our available example notebooks:

Once you open a notebook, you can run all the cells by using the Cell menu > Run all. You can also step through each cell and run them individually. Both methods are shown below:

One last quick tip, if you ever want to revert the notebooks back to how they were originally, you can open a terminal, navigate to the python-awips directory and reset the repo, using the following commands (this is assuming you're starting from a new terminal):
cd python-awips/
git reset --hard
HEAD is now at 245cfc7 Merge pull request #70 from srcarter3/main
NOTE: The response text may vary, it will change whenever we've made any additional commits to the python-awips repository.
And one last confirmation you can run, is git status, and it should look like this:
git status
# On branch main
nothing to commit, working directory clean
This process is demonstrated below:

We hope this blog helps show how to quickly get you up and running using python-awips in the Linux Virtual Machine we distribute for free download. Once you've made it this far, it might be worth your time to check out our Learn Python-AWIPS online training module. If you go through our notebook examples, please also be sure to glance through our previous AWIPS Tips about many of the individual notebooks.
Thanks again for joining us, and check back in two weeks for the next blog post, where we show off the 1 and 5 pane functionality in CAVE.
If you are running your own EDEX and have a shapefile that you use consistently, instead of having to manually import it in CAVE, we'll show you how to import it into the maps database and then add it to the Maps menu.
As an example we will be adding the NWS Region shapefile to EDEX. A number of NWS shapefiles can be found here.
First on your EDEX server as the awips user, change directories into your site's shapefile directory where 'XXX' is the site specified in your /awips2/edex/bin/setup.env file.
cd /awips2/edex/data/utility/common_static/site/XXX/shapefiles/
Create a directory that you would like the shapefile to be named and then change directories into it. In this case we will name it "NWSRegions".
NOTE: The directory name does not have to match the filename, but do not use spaces or symbols in the name. This will be the name of the corresponding table in the maps database.
mkdir NWSRegions
cd NWSRegions
Next download the zipped shapefile via command line. On your EDEX machine you can do this with the command:
wget https://www.weather.gov/source/gis/Shapefiles/Misc/rw04oc12.zip
Extract the contents by unzipping the shapefile:
unzip rw04oc12.zip
You can delete the parent zip file if you'd like. You should now have files with the following extensions (plus a few others possibly):
- dbf
- shp
- shx
Now that we have the shapefile, we need to insert it into the maps database. There is a script on your EDEX machine that will need to be run with the following arguments: the path to the specific shapefile and the new database table name.
/awips2/database/sqlScripts/share/sql/maps/importShapeFile.sh /awips2/edex/data/utility/common_static/site/OAX/shapefiles/NWSRegions/re04oc12.shp nwsregions
NOTE: Again, don't use any symbols, spaces, or capital letters in the database name.
Typical output looks like:
Importing re04oc12.shp into mapdata.nwsregions ...
NOTICE: table "nwsregions" does not exist, skipping
Field lon is an FTDouble with width 19 and precision 5
Field lat is an FTDouble with width 19 and precision 5
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
addgeometrycolumn
----------------------------------------------------------------- mapdata.nwsregions.the_geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2
(1 row)
Creating simplified geometry level 0.064 ...
Creating simplified geometry level 0.016 ...
Creating simplified geometry level 0.004 ...
Creating simplified geometry level 0.001 ...
vacuumdb: vacuuming database "maps"
INFO: vacuuming "mapdata.nwsregions"
INFO: "nwsregions": found 30 removable, 6 nonremovable row versions in 1 pages
DETAIL: 0 dead row versions cannot be removed yet.
CPU 0.04s/0.09u sec elapsed 0.14 sec.
INFO: analyzing "mapdata.nwsregions"
INFO: "nwsregions": scanned 1 of 1 pages, containing 6 live rows and 0 dead rows; 6 rows in sample, 6 estimated total rows
Now that the shapefile has been added to the maps database, we need to modify the maps menu to add it as a selection in CAVE. This is done via a map bundle xml file.
If the maps directory doesn't exist, create it:
mkdir /awips2/edex/data/utility/common_static/base/bundles/maps
Create and open a new file, named nwsregions.xml using your favorite text editor:
vi nwsregions.xml
Copy the text from this file into the file you just opened (wget will work also)
NOTE: For other examples, the two lines you will want to edit are lines 15 and 16:
<table>mapdata.nwsregions</table>
<mapName>NWS Regions</mapName>
Where the table name matches the name you used when running the importShapefile script and the mapName is whatever text you want to show up in the Maps menu.
You can also change the default color (line 9).
Save the file, close your CAVE session if open, remove caveData, and then re-open CAVE and you should see your new map listed in the Maps menu (the menu items are in alphabetical order)!
Thanks for joining us to learn more about EDEX. Check back in two weeks for the next blog post!
To view archived blogs, visit the AWIPS Tips blog tag, and get notified of the latest updates from the AWIPS team by signing up for the AWIPS mailing list. Questions or suggestions for the team on future topics? Let us know at support-awips@unidata.ucar.edu
This blog was posted in reference to v18.2.1-6 of NSF Unidata AWIPS
This blog was posted in reference to v18.2.1-6 of NSF Unidata AWIPS