LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read SAC (Seismic Analysis Code) on labview

Solved!
Go to solution

I am engaged in seismic research, and my seismic waveform data is in SAC (Seismic Analysis Code) format. I am not good at file parsing, can anyone help me analyze SAC, or provide examples. VI

I want to convert SAC files into txt files. Or parse the value of the XYZ axis and the content in the header from the file.

Thanks.

Attach the file I want to parse~

----------------------------------------------------------------------------------------

Seismic Analysis Code

 

0 Kudos
Message 1 of 5
(1,913 Views)

Hi koukileo,

 


@koukileo wrote:

I am engaged in seismic research, and my seismic waveform data is in SAC (Seismic Analysis Code) format. I am not good at file parsing, can anyone help me analyze SAC, or provide examples. VI


There are some links with descriptions of that file format, but your files don't fit with those descriptions (IMHO)…

 

This is all I got with some reasonable plots:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(1,874 Views)

You answered your own question.  Click on the Link you included to "Semantic Analysis Code", and read the section "SAC Data File Format".  It tells you exactly how to write a routine (in LabVIEW) to open, parse, and structure the data in the file.  Pay attention to the fact that (depending on the SAC File format) most of the Floats are Sgls, where the LabVIEW default is Dbls (but the newer SAC format has 22 variables where additional precision is required as Dbls).

 

It may sound like a tortuous job, but taking a well-defined (binary) file structure and writing a routine in LabVIEW to read it, parse it, and turn it into a (structured) LabVIEW dataset is not that difficult (I've done it several times).  Look for "structured data" and employ TypeDefs (such as Clusters for "mixed-type Data" and Arrays for "repetetive sets of identically-structured Data").

 

Bob Schor

0 Kudos
Message 3 of 5
(1,870 Views)
Solution
Accepted by topic author koukileo

Hi Bob,

 

thanks for your reminder, I forgot to switch that array constant to SGL datatype in my previous message:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(1,867 Views)

@Bob_Schor wrote:

You answered your own question.  Click on the Link you included to "Semantic Analysis Code", and read the section "SAC Data File Format".  It tells you exactly how to write a routine (in LabVIEW) to open, parse, and structure the data in the file.  Pay attention to the fact that (depending on the SAC File format) most of the Floats are Sgls, where the LabVIEW default is Dbls (but the newer SAC format has 22 variables where additional precision is required as Dbls).

 

It may sound like a tortuous job, but taking a well-defined (binary) file structure and writing a routine in LabVIEW to read it, parse it, and turn it into a (structured) LabVIEW dataset is not that difficult (I've done it several times).  Look for "structured data" and employ TypeDefs (such as Clusters for "mixed-type Data" and Arrays for "repetetive sets of identically-structured Data").

 

Bob Schor


I'm going to say this is one of the more fun things to do in LabVIEW.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 5
(1,857 Views)