Thursday, February 16, 2023

Converting Basemap to Cartopy within ObsPy Jupyter Notebooks

 So far my trick is to replace the statement 

from mpl_toolkits.basemap import Basemap

with

import cartopy.crs as ccrs

and this seems to work in the first notebook I tried  (QLove notebook for SNZO)

Upgrading the Python Version within Anaconda

 The upgrading of Python within Anaconda is complicated by the planned obsolescence of Python versions in the Anaconda software.  As of 02/16/2023, Anaconda has support for Python 3.7 and higher.  As a result, simply upgrading

conda install python=3.9

might work if you have 3.7 or 3.8 already installed.  However, I had my obspy environment set up with Python 3.6, and the version would not update automatically.  This prevented me from updating obspy and many other packages.  My solution is to create a new environment for the upgrade, and install Python 3.9 directly into it.  From the webpage:

https://www.geophysik.uni-muenchen.de/~megies/installation2.pdf

Create a new environment within Anaconda

conda create -n obspy39 python=3.9

conda activate obspy39

conda info --envs

assuming that you are in the obspy39 environment . . .

conda install -c conda-forge obspy

conda install jupyter

conda install cartopy

Note that I installed cartopy, rather than basemap.  The latter would not install properly, and it is the older version anyway.  At the end of this exercise, I had two obspy environments, obspy and obspy39.  One can delete the older creakier version once you are certain that the new one works.




Updating Anaconda Navigator from Version 1.x to Version 2.x

 Once Anaconda sits on your computer, the updates start to annoy you.  If you ignore them long enough, however, they don't go away.  Eventually, the upgrades will no longer be simple.  For three of my MacOS computers, I first installed Anaconda 1.x, and for the home iMac I basically tore out my original installation in order to upgrade to Anaconda 2.x.  Upgrading from 1.x to 2.x need not be that drastic.  I discovered a procedure that works at a website

https://appdividend.com/2022/01/19/how-to-update-anaconda-upgrade-anaconda-navigator/

This procedure relies on entering line-commands in a terminal window, which you open within Anaconda Navigator.  Just go to the base environment and open a Terminal, rather than search for a Jupyter Notebook or a Python window.  In this Terminal, you might need to first update the conda app to its latest version

conda update conda

or

conda update -n base -c defaults conda

Then update Anaconda itself to a specific version, tied to a year and month, e.g., 

conda update anaconda=2022.10
or  
conda install anaconda=2022.10
In one case I installed the new Anaconda first, because the condo update hung the computer.

That metapackage represents the pinned state that has undergone testing as a collection.

If you want to update all the packages under conda distribution, you can use the following command.

conda update --all

The conda update –all will upgrade everything. This updates all packages in the current environment to the latest version.

 
Link