[obspy-users] using headonly flag in readMSEED()

thomas veymont thomas.veymont at gmail.com
Tue Oct 18 17:43:47 CEST 2011


hi Robert
understood -- thanks for the quick answer
cheers
Tom

2011/10/18 Robert Barsch <barsch at geophysik.uni-muenchen.de>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Tom,
>
>> I don't fully understand the meaning of the "headonly" flag for
>> the readMSEED function :
>>
>> http://docs.obspy.org/packages/autogen/obspy.mseed.core.readMSEED.html#obspy.mseed.core.readMSEED
>>
>>  - what informations am I going to miss if I set headonly to True
>> ? (e.g : if I have many Traces in a single file, am I going to get
>> the metadata for all traces anyway ?)
>
> headonly will omit the actual data - it will load only meta data
>
> # just preparing a sample file
>>>> from obspy.core import read st=read() st.write('out.mseed',
>>>> format='MSEED')
>
> # here we go with headonly=False (default)
>>>> st = read('out.mseed') st[0].stats
> Stats({'network': 'BW', '_format': 'MSEED', 'mseed': ...
>>>> st[0].data
> array([ 0.        ,  0.00694644,  0.07597424, ...
>
> # headonly=True
>>>> st = read('out.mseed', headonly=True) st[0].stats
> Stats({'network': 'BW', '_format': 'MSEED', 'mseed': ...
>>>> st[0].data
> array([], dtype=float64)
>
>>
>> - may I expect an positive impact on performance when setting
>> headonly to True ?
>
> yes if you only interested into meta data
>
>>>> %timeit st=read('out.mseed', headonly=True)
> 1000 loops, best of 3: 1.98 ms per loop
>
>>>> %timeit st=read('out.mseed', headonly=False)
> 100 loops, best of 3: 2.82 ms per loop
>
>>
>> - is it mutually exclusive with the quality boolean flag ?
>
> yes - although it isn't a very nice exception which is raised
>
>>>> st=read('out.mseed', headonly=True, quality=True)
> -
> ---------------------------------------------------------------------------
> KeyError                                  Traceback (most recent call
> last)
> ...
>
> We should change that or at least state this in the documentation.
>
> Cheers,
> Robert
>
>
> - --
>
> Dr. Robert Barsch
>
> Ludwig-Maximilians-Universität München
> Department of Earth and Environmental Sciences, Geophysics
> Theresienstr. 41/IV
> D-80333 Munich
> Germany
>
> Tel: +49 (0) 89 2180 4201
> Fax: +49 (0) 89 2180 9942010
> Mail: barsch at lmu.de
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
>
> iD8DBQFOnZusIVowwEY4LjQRAnKQAKCicv/RkFTLUDdAkpRQp3X1MRRp/gCgs3V6
> AjICBYZ14XMoqAXUfqKFPRI=
> =kFxU
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.sevor.de
> http://lists.obspy.org/cgi-bin/mailman/listinfo/obspy-users
>




More information about the obspy-users mailing list