Thread: How to use PHP language to read SAC data

Started: 2018-03-22 20:15:55
Last activity: 2018-03-22 20:15:55
Topics: SAC Help
黃淑真
2018-03-22 20:15:55
Dear SAC-help,

I tried to use PHP to read a SAC data, it depended on the format
which described on the website(Using SAC), but always response
some error data, the response data is different from SAC software.
Did you have any experiences about use PHP to get SAC data ?
I guessed I misunderstood the SAC format or I used some error
PHP functions to read data( unpack etc., ) .
Could you give me some hint about the exactly SAC format
or programming solution ?



Sincerely yours,

Shu-Jane Huang from Taiwan
Taiwan Earthquake Research Center, TEC
programmer of TEC

  • Leigh House
    2018-03-22 18:58:11
    Dear Shu-Jane,

    What have you looked at for the format of SAC files? You don’t say if the file is a binary SAC file or an ASCII-text SAC file.

    The binary SAC file format is described in the SAC manual, which is available from IRIS. In the manual for v 101.6a, the SAC binary file format is described on pages 36-38.

    I have no experience with using PHP to read SAC data, but typically when working with a new data format, it is helpful to try reading the first few variables and verify you have the correct data values, then read a few variables more, gradually getting to read the entire file.

    Remember, SAC files usually have a binary file header, then a stream of binary data samples. The sample rate for the data samples, and the number of data samples are given by variables in the binary file header. There are possible byte-ordering issues with binary files, also.

    Your email does not give much information about the file you are trying to read. Can you use SAC itself to read and plot the file? If SAC can read the data file, SAC can print the values from the data file header (look at list header) and can help you read the header values with your program.

    If you’ve not written a program to read a binary file with PHP, this may take you awhile. The SAC distribution contains a fortran-callable set of subroutines that read and write sac files, which you can use right-away.

    Leigh


    On Mar 22, 2018, at 10:32 AM, 黃淑真 @iris.washington.edu <irishuang<at>earth.sinica.edu.tw> wrote:

    Dear SAC-help,

    I tried to use PHP to read a SAC data, it depended on the format
    which described on the website(Using SAC), but always response
    some error data, the response data is different from SAC software.
    Did you have any experiences about use PHP to get SAC data ?
    I guessed I misunderstood the SAC format or I used some error
    PHP functions to read data( unpack etc., ) .
    Could you give me some hint about the exactly SAC format
    or programming solution ?



    Sincerely yours,

    Shu-Jane Huang from Taiwan
    Taiwan Earthquake Research Center, TEC
    programmer of TEC





    ----------------------
    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/


09:49:28 v.01697673