'Catalog' object has no attribute 'short_str'
Closed this issue · 5 comments
Hi,
I'm trying to run the 'inversion prep' example available at:
https://pyatoa.readthedocs.io/en/latest/inversion_prep.html#getting-moment-tensors
and I'm running it using the docker image https://github.com/adjtomo/adjdocs/blob/main/readmes/docker_image_install.md
But, I'm getting this error and I don't know how go about it:
AttributeError: 'Catalog' object has no attribute 'short_str'
Thanks in advance
Note: I've added the 's' in 'get_gcmt_moment_tensors' and 'event' in get_gcmt_moment_tensors(event,origintime,magnitude) to fix some previously encountered errors.
Hi @banstia7, thanks for raising this issue; great to see you working in the container and checking out the doc material.
Looks like at some point I modified the get_gcmt_moment_tensors
function to return an ObsPy Catalog, rather than an Event. This results in gcmt_catalog
getting set up as a Catalog of Catalogs, leading to the AttributeError you're getting.
To get things working you'll have to slightly modify the code block to append the first event of each catalog (if available), rather than the whole catalog itself. That would look something like this:
In [18]: from pyatoa.core.gatherer import get_gcmt_moment_tensors
...:
...: events = []
...: for event in cat:
...: origintime = event.preferred_origin().time
...: magnitude = event.preferred_magnitude().mag
...: try:
...: event = get_gcmt_moment_tensors(event, origintime, magnitude)
...: if event:
...: events.append(event[0])
...: except FileNotFoundError:
...: print(f"No GCMT event found for: {format_event_name(event)}")
...: continue
...:
...: gcmt_catalog = Catalog(events)
...: print(f"\n{len(gcmt_catalog)}/{len(cat)} events with GCMT solutions found")
11/15 events with GCMT solutions found
In [19]: print(gcmt_catalog)
11 Event(s) in Catalog:
2019-01-13T16:45:55.900000Z | +61.260, -150.340 | 4.98 Mwc
2019-01-06T03:45:37.500000Z | +65.400, -153.420 | 4.93 Mwc
...
2011-06-16T19:06:06.800000Z | +60.790, -151.230 | 5.08 Mwc
2011-01-23T02:50:08.000000Z | +63.570, -150.890 | 5.24 Mwc
To see all events call 'print(CatalogObject.__str__(print_all=True))'
I will fix the docs page in the next PR. Thanks for pointing out the other typos and function call changes!
Bug Fix tasks:
- Add missing 's' in 'get_gcmt_moment_tensors' of inversion prep docs notebook
- Change call structure of
get_gcmt_moment_tensors
in Task 1 to include Event parameter - Edit code block in Task 1 to append first Event (if available), rather than the returned Catalog
No problem! I'm just going to re-open this as a reminder to fix those docs for the next PR after which I will mark it as closed again. Thanks again for bringing this to my attention!
Ohh okay.. I also noticed that gather_obs_multithread
is changed to _gather_obs_multithread
?
https://pyatoa.readthedocs.io/en/latest/inversion_prep.html#gathering-observation-data
I recently decided to get rid of external data gathering from the Pyatoa package (#23), and move all these capabilities into PySEP (https://github.com/adjtomo/pysep). The corresponding fetching functions have been copied over there and I will need to write up a new example or docs page to mimic the inversion prep notebook.