LLNL / mttime

Time Domain Moment Tensor Inversion in Python
https://mttime.readthedocs.io/en/latest/index.html
Other
58 stars 19 forks source link

KeyError: 'components' and AttributeError: components when running Jupyter Notebook 03_Run_Inversion. #2

Closed VioletaSeo closed 3 years ago

VioletaSeo commented 3 years ago

Hi. I was testing with the Jupyter Notebooks in the tdmtpy/examples/notebooks/ directory to check if the code works well. However, I got KeyError: 'components' and AttributeError: components errors when I executed the third cell of the notebook 03_Run_Inversion which looks like follows:

# Pass the parameters to the Inversion object and launch the inversion
# The default is to plot all solutions
tdmt = tdmtpy.Inversion(config=config)
tdmt.invert()

The printed errors look like follows:

Deviatoric Moment Tensor Inversion
Depth = 10.0000 km
Mw = 4.32
Percent DC/CLVD/ISO = 93/7/0
VR = 51.69%%

Deviatoric Moment Tensor Inversion
Depth = 12.0000 km
Mw = 4.27
Percent DC/CLVD/ISO = 88/12/0
VR = 53.74%%

Deviatoric Moment Tensor Inversion
Depth = 20.0000 km
Mw = 4.32
Percent DC/CLVD/ISO = 93/7/0
VR = 51.64%%

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/obspy/core/util/attribdict.py in __getattr__(self, name, default)
    127         try:
--> 128             return self.__getitem__(name, default)
    129         except KeyError as e:

~/anaconda3/lib/python3.7/site-packages/obspy/core/util/attribdict.py in __getitem__(self, name, default)
     73         try:
---> 74             return self.__dict__[name]
     75         except KeyError:

KeyError: 'components'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-3-5302a250a3ce> in <module>
      2 # The default is to plot all solutions
      3 tdmt = tdmtpy.Inversion(config=config)
----> 4 tdmt.invert()

~/anaconda3/lib/python3.7/site-packages/tdmtpy-1.0.0-py3.7.egg/tdmtpy/inversion.py in invert(self)
    127 
    128         if self.config.plot:
--> 129             self.plot(view="normal")
    130             if len(self.config.depth) > 1:
    131                 self.plot(view="depth")

~/anaconda3/lib/python3.7/site-packages/tdmtpy-1.0.0-py3.7.egg/tdmtpy/inversion.py in plot(self, **kwargs)
    528             else:
    529                 for tensor in self.moment_tensors:
--> 530                     tensor._beach_waveforms_3c(*args)
    531         elif view == "depth":
    532             from .image import beach_mw_depth

~/anaconda3/lib/python3.7/site-packages/tdmtpy-1.0.0-py3.7.egg/tdmtpy/tensor.py in _beach_waveforms_3c(self, inv_type, components, df, show, format)
    457 
    458         for page, group in enumerate(pages):
--> 459             f, ax0, ax1 = new_page(len(group), nrows+1, ncols, annot=annot,title=self.inverted.components)
    460             # Plot beach balls
    461             for i in range(len(fm)):

~/anaconda3/lib/python3.7/site-packages/obspy/core/util/attribdict.py in __getattr__(self, name, default)
    128             return self.__getitem__(name, default)
    129         except KeyError as e:
--> 130             raise AttributeError(e.args[0])
    131 
    132     __setattr__ = __setitem__

AttributeError: components

I would like to know what might be the cause of these errors.

ahchiang commented 3 years ago

Plotting issue has been fixed.