I often have issues with students using ObsPy. As each student has its own computer, anaconda version, etc, it’s not easy to solve all problems and I’ve been exploring using python online platforms, like Google’s Colab (
It works mostly well, but maps are not generated, I suspect due to some problem with Cartopy (although simple cartopy maps are well plotted). For example, the code below will not generate the map of stations.
Does anyone have any idea of how to fix this? Or alternatively, do you recommend a better online platform for shared python editing and running?
!pip install cartopy obspy
from obspy.clients.fdsn import Client
from obspy import Catalog, UTCDateTime
client = Client(“USGS”)
ti = UTCDateTime(“2022-01-01”)
tf = UTCDateTime(“2023-01-01”)
minMag = 7
cat = client.get_events(starttime=ti, endtime=tf, minmagnitude=minMag)
I was able reproduce your issue, but I could not resolve it.
March 23, 2023, 8:52am
Hi Susana, we have had some tickets towards colab in the past, maybe you can find something there:
Issues · obspy/obspy · GitHub
Especially this one looks like it might have input:
03:49AM - 06 Aug 21 UTC
05:13AM - 06 Aug 21 UTC
Hi, I ran into a problem when I used obspy to plot event map on
… the google colab platform.
Ubuntu 18.04.5 LTS
/usr/local/lib/python3.7/dist-packages/obspy/imaging/maps.py:66: UserWarning: Neither basemap nor cartopy installed, map plots will not work.
ImportError Traceback (most recent call last)
<ipython-input-7-0867c9f93335> in <module>()
1 get_ipython().magic('matplotlib inline')
2 import obspy
----> 3 fig = obspy.read_events().plot()
/usr/local/lib/python3.7/dist-packages/obspy/imaging/maps.py in plot_map(method, *args, **kwargs)
795 return plot_cartopy(*args, **kwargs)
--> 797 raise ImportError('Neither Basemap nor Cartopy could be imported.')
798 elif method == 'basemap':
799 if not HAS_BASEMAP:
ImportError: Neither Basemap nor Cartopy could be imported.
**GitHub should mainly be used for bug reports and code developments/discussions. For generic questions, please use either the [[obspy-users] mailing list](http://lists.swapbytes.de/mailman/listinfo/obspy-users) (for scientific questions to the general ObsPy community) or our [gitter chat](https://gitter.im/obspy/obspy) (for technical questions and direct contact to the developers).**
Before submitting an Issue, please review the [Issue Guidelines](https://github.com/obspy/obspy/blob/master/CONTRIBUTING.md#submitting-an-issue).
* Please check whether the bug was already reported or fixed.
* Please provide the following information:
- ObsPy version, Python version and Platform (Windows, OSX, Linux ...)
- How did you install ObsPy and Python (pip, anaconda, from source ...)
- If possible please supply a [short, self contained, correct example](http://sscce.org/) that
demonstrates the issue.
- If this is a regression (used to work in an earlier version of ObsPy),
please note when it used to work.
* Please take the time to [format your ticket appropriately](https://guides.github.com/features/mastering-markdown/)
(e.g. put error tracebacks into code blocks)
Aside from those, you could try if seismo live works for your classes. It has been a bit wonky over the years but currently the binder servers seem quite good again.
(click through to any notebook and then “open in binder” at the top)