Thread: trouble with 'wh' in SAC

Started: 2012-06-26 02:57:51
Last activity: 2012-06-27 00:10:39
Topics: SAC Help
Danielle Sumy
2012-06-26 02:57:51
Hi,

I am trying to make picks on SAC files, however, when I 'wh' (write header) with the picks, the 'depmin', 'depmax', and/or 'depmen' parameters change. When I try to read the file again, I can no longer read the waveform, and the picks have disappeared.

We are using a Mac with Snow Leopard, and SAC version 101.5. Below, I outline the commands we used. We are using a lot of files, from a lot of different sources, so we do not think that this is a file downloading problem.

sac
r *.sac
rmean
taper
bp c 2 8 n 2 p 2
ppk p 6
--- I then make my picks (t0, t1, t2, etc.) ---
q
lh
---- at this stage, the picks are there (T0MARKER, T1MARKER, etc.)
wh
lh
---- now, the picks are gone, and the 'depmen', 'depmax', and/o 'depmin' now read 'nan'

When we write 'w over' instead of 'wh', the parameters are fine, but we do not want to save the file with the filter, etc. applied.

Any suggestions and help would be greatly appreciated!

Thanks so very much for your help,
Danielle
________________
Danielle Sumy
Postdoctoral Fellow
National Science Foundation
USGS-Pasadena
525 S. Wilson Ave.
Pasadena, CA 91106
danielle.sumy<at>gmail.com




  • George Helffrich
    2012-06-26 13:17:18
    Dear Danielle -

    The vanishing picks and NaNs recorded in the header possibly indicate some software problem, but there are some conceptual flaws with your processing strategy.

    If you modify the data traces by filtering, DEPMEN, DEPMAX & DEPMIN will change to reflect the data in memory. If you overwrite the header, those values will no longer describe the data in the file: there will be a data-header mismatch.

    Better would be to save the picks temporarily and then refresh the header using a macro called "savepiks":
    -----
    ppk p 6
    --- I then make my picks (t0, t1, t2, etc.) ---
    q
    m savepiks
    -----
    Contents of the macro "savepiks":
    -----
    * Build text of chnhdr command depending on whether pick set or not
    setbb cmd "|"
    if &1,t0& ne UNDEFINED
    setbb cmd append " t0 &1,t0&"
    endif
    if &1,t1& ne UNDEFINED
    setbb cmd append " t1 &1,t1&"
    endif
    * ...
    if &1,t9& ne UNDEFINED
    setbb cmd append " t9 &1,t9&"
    endif
    * Refresh and change header if any picks set
    if %cmd% ne "|"
    rh &1,filename&
    ch (after "|" "%cmd%")
    wh
    endif
    ------
    There are other, niftier ways to accomplish this (using a DO LIST loop), but the key idea is to save the picks, refresh the header from the file copy, change the picks, and overwrite the header. Then nothing done to the trace data in memory pollutes the header info in the file.

    On 26 Jun 2012, at 03:57, Danielle Sumy wrote:

    Hi,

    I am trying to make picks on SAC files, however, when I 'wh' (write header) with the picks, the 'depmin', 'depmax', and/or 'depmen' parameters change. When I try to read the file again, I can no longer read the waveform, and the picks have disappeared.

    We are using a Mac with Snow Leopard, and SAC version 101.5. Below, I outline the commands we used. We are using a lot of files, from a lot of different sources, so we do not think that this is a file downloading problem.

    sac
    r *.sac
    rmean
    taper
    bp c 2 8 n 2 p 2
    ppk p 6
    --- I then make my picks (t0, t1, t2, etc.) ---
    q
    lh
    ---- at this stage, the picks are there (T0MARKER, T1MARKER, etc.)
    wh
    lh
    ---- now, the picks are gone, and the 'depmen', 'depmax', and/o 'depmin' now read 'nan'

    When we write 'w over' instead of 'wh', the parameters are fine, but we do not want to save the file with the filter, etc. applied.

    Any suggestions and help would be greatly appreciated!

    Thanks so very much for your help,
    Danielle
    ________________
    Danielle Sumy
    Postdoctoral Fellow
    National Science Foundation
    USGS-Pasadena
    525 S. Wilson Ave.
    Pasadena, CA 91106
    danielle.sumy<at>gmail.com



    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help



    George Helffrich
    george.helffrich<at>bris.ac.uk


  • Brian Savage
    2012-06-27 00:10:39
    Danielle,

    The bug you exposed was recently fixed in 101.5c (Feb 2012). It error only occurs when issuing the "writeheader" command. Updating to the newest version should solve your problem.

    If updating does not help, please let me know.

    Thanks for reporting the bug to the sac-help mailing list.

    Cheers,
    Brian Savage


    On Jun 25, 2012, at 10:57 PM, Danielle Sumy wrote:

    Hi,

    I am trying to make picks on SAC files, however, when I 'wh' (write header) with the picks, the 'depmin', 'depmax', and/or 'depmen' parameters change. When I try to read the file again, I can no longer read the waveform, and the picks have disappeared.

    We are using a Mac with Snow Leopard, and SAC version 101.5. Below, I outline the commands we used. We are using a lot of files, from a lot of different sources, so we do not think that this is a file downloading problem.

    sac
    r *.sac
    rmean
    taper
    bp c 2 8 n 2 p 2
    ppk p 6
    --- I then make my picks (t0, t1, t2, etc.) ---
    q
    lh
    ---- at this stage, the picks are there (T0MARKER, T1MARKER, etc.)
    wh
    lh
    ---- now, the picks are gone, and the 'depmen', 'depmax', and/o 'depmin' now read 'nan'

    When we write 'w over' instead of 'wh', the parameters are fine, but we do not want to save the file with the filter, etc. applied.

    Any suggestions and help would be greatly appreciated!

    Thanks so very much for your help,
    Danielle
    ________________
    Danielle Sumy
    Postdoctoral Fellow
    National Science Foundation
    USGS-Pasadena
    525 S. Wilson Ave.
    Pasadena, CA 91106
    danielle.sumy<at>gmail.com



    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help



09:19:55 v.01697673