[obspy-users] AttribDict

Tobias Megies megies at geophysik.uni-muenchen.de
Tue Jun 5 10:43:53 CEST 2018


Hi Mike,


On 04/06/18 15:04, Mike Hagerty wrote:

>>     Did you write that file yourself?
> 
> 
> Hey Tobias, are you throwing me shade ?  :)  
> No, I didn't write the file, just trying to figure out if it was valid
> use of AttribDict.

;-) No, was just curious because whoever wrote that file should be made
aware of the problem if possible.


> 
> 
>>     Also, to avoid such issues in the future, you might want to consider
>>     to use "cat.write('/tmp/trash.xml', format='QUAKEML',
>>     validate=False)" which raises an AssertionError in the first (bad)
>>     usage case.
> 
> 
> I think you mean 'validate=True' - but that just checks quakeML against
> the schema (xsd), no ?
> So, it's definitely violating the quakeML schema to use AttribDict this
> way ?

Yeah, that's right, "validate=True" is what I meant.
And yes, this is definitely violating the schema and also yes, obspy
would've raised an AssertionError when using the validation option
during writing the file.

Like I mentioned it would be good if you could tell the person you got
the QuakeML from of this faulty ObsPy/QuakeML usage.

cheers,
Tobias



> 
> Cheers!
> -Mike
> 
>  
> 
> 
>     cheers,
>     Tobias
> 
> 
> 
>     On 31/05/18 17:23, Mike Hagerty wrote:
> 
>         I was given quakeML files that have blocks like this:
> 
>                <magnitude
>         publicID="smi:local/305afa78-34cb-4e82-abe5-ef610b114c80">
>                  <mag>
>                    <value>-1.69791750681</value>
>                    <uncertainty>AttribDict({'error':
>         0.06334087421841221})</uncertainty>
>                  </mag>
> 
>         obspy read_events() complains about the AttribDict:
> 
>         .../obspy/obspy/io/quakeml/core.py:181: UserWarning: Could not
>         convert AttribDict({'error': 0.70882453572021886}) to type
>         <class 'float'>. Returning None.
>            warnings.warn(msg % (text, convert_to))
> 
>         Does anyone know if/how AttribDict is supposed to be used
>         *within* quakeML ?
> 
> 
>         Cheers!
>         -Mike
> 
> 



More information about the obspy-users mailing list