weixin_39747577 2020-11-20 20:17
浏览 0

sac conversion - "unused" fields

hello, i am writing some conversion routines from custom ascii format to sac, using -obviously :)- obspy.

i parse my input file and after building a trace i can write to some common "stats" values, such as network, station code, etc..

{{{ tr = Trace()

fill the header (tr.stats)

common stat values

tr.stats.station = head['STATION_CODE'] }}}

using attribdict, i am also able to use some sac-specific values, like kevnm (event name), and so on

{{{

SAC-specific values

tr.stats.sac = AttribDict()

tr.stats.sac.kevnm = head['EVENT_NAME'] }}}

now, i am in the need to write in my sac header some more values, like "resp0", which seems not to be in the sac specific dict.

moreover, i need to access sac "unused" fields as well.

is that supported by obspy.sac?

thank you

该提问来源于开源项目:obspy/obspy

  • 写回答

7条回答 默认 最新

  • weixin_39747577 2020-11-20 20:17
    关注

    [russo.ingv.it] i figured it out by myself :)

    "respX" and "unusedX" fields are not in the obspy.sac supported dict.

    to add them, just edit the "sac_extra" array (line 30) in /PATH/TO/OBSPYMODULES/sac/core.py adding the desired fields, then edit the "self.fdict" definition in sacio.py, adding the correct " 'fieldname': pos " entries.

    here's my self.fdict (line 199 in file /PATH/TO/OBSPYMODULES/sac/sacio.py):

    {{{ self.fdict = {'delta': 0, 'depmin': 1, 'depmax': 2, 'scale': 3, 'odelta': 4, 'b': 5, 'e': 6, 'o': 7, 'a': 8, 'int1': 9, 't0': 10, 't1': 11, 't2': 12, 't3': 13, 't4': 14, 't5': 15, 't6': 16, 't7': 17, 't8': 18, 't9': 19, 'f': 20, 'resp0': 21, 'resp1': 22, 'resp2': 23, 'resp3': 24, 'resp4': 25, 'resp5': 26, 'resp6': 27, 'resp7': 28, 'resp8': 29, 'resp9': 30, 'stla': 31, 'stlo': 32, 'stel': 33, 'stdp': 34, 'evla': 35, 'evlo': 36, 'evdp': 38, 'mag': 39, 'user0': 40, 'user1': 41, 'user2': 42, 'user3': 43, 'user4': 44, 'user5': 45, 'user6': 46, 'user7': 47, 'user8': 48, 'user9': 49, 'dist': 50, 'az': 51, 'baz': 52, 'gcarc': 53, 'depmen': 56, 'cmpaz': 57, 'cmpinc': 58, 'xminimum': 59, 'xmaximum': 60, 'yminimum': 61, 'ymaximum': 62, 'unused6': 63, 'unused7': 64, 'unused8': 65, 'unused9': 66, 'unused10': 67, 'unused11': 68, 'unused12': 69}

    }}}

    "unused" values are at the end of the list.

    next, compile both core.py and sacio.py

    {{{ valigia:/usr/lib/pymodules/python2.5/obspy/sac# ipython

    Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) Type "copyright", "credits" or "license" for more information.

    [...]

    In [1]: import py_compile

    In [2]: py_compile.compile('core.py')

    In [3]: py_compile.compile('sacio.py')

    }}}

    to generate the corrisponding .pyc object files.

    hope this is useful to somebody else too.

    cheers

    评论

报告相同问题?