Thread: Not able to get complete header information by using C code

Started: 2011-12-25 21:12:55
Last activity: 2011-12-27 02:20:47
Topics: SAC Help
I am writing C code to read sac file.
But what I have found that my out put sac file
does not contain all the header information as to my input sac file.

I am using
wsac1 (kname, yarray, & npts, &beg, &del, &nerr, strlen( out ));
to write it to the sac header.

Did i am doing some wrong or probably my code is not complete.
how to write the complete header information.

my read (in) header info
         NPTS = 35999
            B = 0.000000e+00
            E = 1.799900e+03
       IFTYPE = TIME SERIES FILE
        LEVEN = TRUE
        DELTA = 5.000000e-02
       DEPMIN = -1.670385e+04
       DEPMAX = 1.073576e+04
       DEPMEN = -3.021250e-01
      OMARKER = -675.06
     T1MARKER = 115.61           (Pdiff)
     T7MARKER = 704.17           (SKS)
     T8MARKER = 751.13           (SKKS)
     T9MARKER = 1277.3           (PKKS)
       KZDATE = JUL 29 (210), 2011
       KZTIME = 07:53:37.694
        KSTNM = ADKI
        CMPAZ = 0.000000e+00
       CMPINC = 9.000000e+01
         STLA = 1.584456e+01
         STLO = 7.996883e+01
         STEL = 4.900000e+01
         EVLA = -2.378000e+01
         EVLO = 1.797600e+02
         EVDP = 5.230000e+05
         DIST = 1.168606e+04
           AZ = 2.809172e+02
          BAZ = 1.108402e+02
        GCARC = 1.049953e+02
       LOVROK = TRUE
        USER1 = 2.543314e+02
        USER7 = 2.541673e+02
        USER8 = 4.006796e+02
        USER9 = 1.573983e+02
        NVHDR = 6
        NWFID = 1
       LPSPOL = FALSE
       LCALDA = TRUE
       KCMPNM = BHN
          MAG = 6.700000e+00

my write (out) sac header info
       NPTS = 35999
          B = 0.000000e+00
          E = 1.799900e+03
     IFTYPE = TIME SERIES FILE
      LEVEN = TRUE
      DELTA = 5.000000e-02
     DEPMIN = -1.670385e+04
     DEPMAX = 1.073576e+04
     DEPMEN = -3.021250e-01
      KSTNM = sta
     LOVROK = TRUE
      NVHDR = 6
     LPSPOL = FALSE
     LCALDA = TRUE
     KCMPNM = Q

Thanks for help

Sunil Roy
Seismological Observatory
National Geophysical Research Institute
Hyderabad, India

  • Hello Sunil,

    The WSAC0() function will write more complete header
    information than WSAC1().  You will need to use it in conjunction with
    the functions NEWHDR() and SET?HV(). 
    Here is an example of how I populate a header.  I doubt this is the most elegant way to do it, but it seems to work:

    .
    .
    .
    /* Add header values */
        newhdr();
        setnhv("NPTS", & np, & NERR, 4);
        setfhv("DELTA" , & DEL, & NERR, 5);
        setfhv("B" , & BEG, & NERR, 1);
        setfhv("STLA", & STLA, & NERR, 4);
        setfhv("STLO", & STLO, & NERR, 4);
        setfhv("EVLA", & EVLA, & NERR, 4);
       
    setfhv("EVLO", & EVLO, & NERR, 4);
        setfhv("EVDP", & EVDP, & NERR, 4);
        setfhv("MAG", & MAG, & NERR, 3);
        setfhv("O", & O, & NERR, 1);
        setkhv("KSTNM" , kstnm , & NERR , 5 , strlen(kstnm));
        setnhv("NZYEAR", & NZYEAR, & NERR, 6);
        setnhv("NZJDAY", & NZJDAY, & NERR, 6);
        setnhv("NZHOUR", & NZHOUR, & NERR, 6); 
        setnhv("NZMIN", & NZMIN, & NERR, 5);
        setnhv("NZSEC", & NZSEC, & NERR, 5);
        setnhv("NZMSEC", & NZMSEC, & NERR, 6);

        /* Use SAC libraries to write the binaries: */
        strcpy(KCMPNM, "N"); // N-S component
        setkhv("KCMPNM" , KCMPNM, & NERR , 6 , strlen(KCMPNM));
       
    wsac0(sacN, T, N, & NERR, strlen(sacN));
    .
    .
    .

    Good Luck!
    Ken


    Kenneth A. Macpherson
    Research Fellow
    Earth Observatory of Singapore (EOS)
    Nanyang Technological University
    50 Nanyang Avenue, Block N2-01a-15, Singapore 639798
    Telephone: (65) 6592 1772

    --- On Sun, 12/25/11, Sunil Roy <seismo_003<at>rediffmail.com> wrote:

    From: Sunil Roy <seismo_003<at>rediffmail.com>
    Subject: [SAC-HELP] Not able to get complete header information by using C code
    To: "sac-help<at>iris.washington.edu" <sac-help<at>iris.washington.edu>
    Date: Sunday, December 25, 2011, 8:12 AM

    I am writing C code to read sac file.
    But what I have found that my out put sac file
    does not contain all the header information as to my input sac file.

    I am using
    wsac1 (kname, yarray, & npts, &beg, &del, &nerr, strlen( out ));
    to write it to the sac header.

    Did i am doing some wrong or probably my code is not complete.
    how to write the complete header information.

    my read (in) header info
             NPTS = 35999
                B = 0.000000e+00
                E = 1.799900e+03
           IFTYPE = TIME SERIES FILE
            LEVEN = TRUE
            DELTA = 5.000000e-02
           DEPMIN = -1.670385e+04
           DEPMAX = 1.073576e+04
           DEPMEN = -3.021250e-01
          OMARKER = -675.06
         T1MARKER = 115.61           (Pdiff)
         T7MARKER = 704.17           (SKS)
         T8MARKER = 751.13           (SKKS)
         T9MARKER = 1277.3           (PKKS)
           KZDATE = JUL 29 (210), 2011
           KZTIME = 07:53:37.694
            KSTNM = ADKI
            CMPAZ = 0.000000e+00
           CMPINC = 9.000000e+01
             STLA = 1.584456e+01
             STLO = 7.996883e+01
             STEL = 4.900000e+01
             EVLA = -2.378000e+01
             EVLO = 1.797600e+02
             EVDP = 5.230000e+05
             DIST = 1.168606e+04
               AZ = 2.809172e+02
              BAZ = 1.108402e+02
            GCARC = 1.049953e+02
           LOVROK = TRUE
            USER1 = 2.543314e+02
            USER7 = 2.541673e+02
            USER8 = 4.006796e+02
            USER9 = 1.573983e+02
            NVHDR = 6
            NWFID = 1
           LPSPOL = FALSE
           LCALDA = TRUE
           KCMPNM = BHN
              MAG = 6.700000e+00

    my write (out) sac header info
           NPTS = 35999
              B = 0.000000e+00
              E = 1.799900e+03
         IFTYPE = TIME SERIES FILE
          LEVEN = TRUE
          DELTA = 5.000000e-02
         DEPMIN = -1.670385e+04
         DEPMAX = 1.073576e+04
         DEPMEN = -3.021250e-01
          KSTNM = sta
         LOVROK = TRUE
          NVHDR = 6
         LPSPOL = FALSE
         LCALDA = TRUE
         KCMPNM = Q

    Thanks for help

    Sunil Roy
    Seismological Observatory
    National Geophysical Research Institute
    Hyderabad, India


    Follow Rediff Deal ho jaye! to get exciting offers in your city everyday.
    -----Inline Attachment Follows-----

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

Page built 05:03:00 | v.b'59d0d2