Thread: formatting blackboard variables

Started: 2019-10-29 15:47:40
Last activity: 2019-10-30 10:50:21
Topics: SAC Help
Ray Russo
2019-10-29 15:47:40
Hello SACexperts!

I'm trying to get SAC header info from a large number of data files and I
need some consistent formatting of the blackboard variables that are
output. So, for example, I use:

rh BK.HUMO..BH.2004.128.01.26.41.radial
setbb slon &1,stlo&
setbb slat &1,stla&
setbb sname &1,kstnm&
getbb TO stations.gmt names off newline off slon slat sname

which results in:

-122.96 42.607 HUMO

Fine. But, I'd like to extract the complete station lon/lat stored in the
header, which is actually:

FILE: BK.HUMO..BH.2004.128.01.26.41.radial - 1
-----------------------------------------
STLA = 4.260710e+01
STLO = -1.229567e+02

Other SAC header info getbb calls return all the stored decimal digits but
report in (undesirable) scientific notation:

-1.163647e+02 4.580190e+01 W30

Is there a way to control the getbb output formatting?

Many thanks in advance for your help!

--
R. M. Russo
Associate Professor, Graduate Coordinator
Department of Geological Science
University of Florida
Gainesville, FL 32611 USA
+1 352 392 6766
+1 352 392 9294 fax
rrusso<at>ufl.edu for all University of Florida business
rmrusso2010<at>gmail.com for all other contacts

  • Geo .
    2019-10-30 09:46:46
    Hi Ray,
    One work around would be to use the saclst utlitiy distributed with SAC
    together with awk that gives you better control over formatting. The
    downside is that you might have to execute saclst outside of SAC if you are
    using awk.

    e.g. to print out station latitude and great circle arc of a file named
    my_file.SAC to stations.gmt with 3 decimal points

    saclst stla gcarc f my_file.SAC | awk '{ printf("%.3f %.3f\n",$2,$3)}' >
    stations.gmt
    48.000 1.372


    Januka

    Januka Attanayake
    Research Fellow | Earthquake Seismology
    Homepage: *https://sites.google.com/site/janukaattanayake
    https://sites.google.com/site/janukaattanayake*

    School of Earth Sciences | McCoy Bldg. 200
    University of Melbourne | Parkville 3010 VIC
    Australia




    On Wed, 30 Oct 2019 at 06:49, Ray Russo <rmrusso2010<at>gmail.com> wrote:

    Hello SACexperts!

    I'm trying to get SAC header info from a large number of data files and I
    need some consistent formatting of the blackboard variables that are
    output. So, for example, I use:

    rh BK.HUMO..BH.2004.128.01.26.41.radial
    setbb slon &1,stlo&
    setbb slat &1,stla&
    setbb sname &1,kstnm&
    getbb TO stations.gmt names off newline off slon slat sname

    which results in:

    -122.96 42.607 HUMO

    Fine. But, I'd like to extract the complete station lon/lat stored in the
    header, which is actually:

    FILE: BK.HUMO..BH.2004.128.01.26.41.radial - 1
    -----------------------------------------
    STLA = 4.260710e+01
    STLO = -1.229567e+02

    Other SAC header info getbb calls return all the stored decimal digits but
    report in (undesirable) scientific notation:

    -1.163647e+02 4.580190e+01 W30

    Is there a way to control the getbb output formatting?

    Many thanks in advance for your help!

    --
    R. M. Russo
    Associate Professor, Graduate Coordinator
    Department of Geological Science
    University of Florida
    Gainesville, FL 32611 USA
    +1 352 392 6766
    +1 352 392 9294 fax
    rrusso<at>ufl.edu for all University of Florida business
    rmrusso2010<at>gmail.com for all other contacts


    ----------------------
    SAC Help
    Topic home: http://ds.iris.edu/message-center/topic/sac-help/ |
    Unsubscribe: sac-help-unsubscribe<at>lists.ds.iris.edu

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/


  • George Helffrich
    2019-10-30 10:50:21
    Dear All -

    awk is a useful reformatting tool. In SAC, this also works with the version of SAC described in the SAC book (SAC/BRIS):

    SAC> fg seismogram
    SAC> sc to bbvar echo &1,stla& &1,stlo& | awk '{printf "@%7.2f @%7.2f",@$1,@$2}'
    SAC> message "%bbvar%"
    48.00 -120.00
    SAC>

    Change the awk command and you can get any header variable in any format you want.

    The SYSTEMCOMMAND command will put its output directly into a blackboard variable; multi-line output may be parsed, like in the Unix shell, with SAC’s WHILE READ command. (Note the @ escapes needed to prevent SAC from interpreting the awk grammatical elements.)

    On 30 Oct 2019, at 04:48, Ray Russo <rmrusso2010<at>gmail.com> wrote:

    Hello SACexperts!

    I'm trying to get SAC header info from a large number of data files and I need some consistent formatting of the blackboard variables that are output. So, for example, I use:

    rh BK.HUMO..BH.2004.128.01.26.41.radial
    setbb slon &1,stlo&
    setbb slat &1,stla&
    setbb sname &1,kstnm&
    getbb TO stations.gmt names off newline off slon slat sname

    which results in:

    -122.96 42.607 HUMO

    Fine. But, I'd like to extract the complete station lon/lat stored in the header, which is actually:

    FILE: BK.HUMO..BH.2004.128.01.26.41.radial - 1
    -----------------------------------------
    STLA = 4.260710e+01
    STLO = -1.229567e+02

    Other SAC header info getbb calls return all the stored decimal digits but report in (undesirable) scientific notation:

    -1.163647e+02 4.580190e+01 W30

    Is there a way to control the getbb output formatting?

    Many thanks in advance for your help!

    --
    R. M. Russo
    Associate Professor, Graduate Coordinator
    Department of Geological Science
    University of Florida
    Gainesville, FL 32611 USA
    +1 352 392 6766
    +1 352 392 9294 fax
    rrusso<at>ufl.edu <rrusso<at>ufl.edu> for all University of Florida business
    rmrusso2010<at>gmail.com <rmrusso2010<at>gmail.com> for all other contacts


    ----------------------
    SAC Help
    Topic home: http://ds.iris.edu/message-center/topic/sac-help/ | Unsubscribe: sac-help-unsubscribe<at>lists.ds.iris.edu

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/



    George Helffrich
    george<at>elsi.jp


Page built 04:02:47 | v.b'59d0d2