Difference between revisions of "CyberShake output data headers"

From SCECpedia
Jump to navigationJump to search
Line 41: Line 41:
 
This is a Python script to read in and print the header information.
 
This is a Python script to read in and print the header information.
  
 +
#!/usr/bin/env python
 +
 
  import sys
 
  import sys
 
  import struct
 
  import struct
 
+
 
  if len(sys.argv)<2:
 
  if len(sys.argv)<2:
 
     print "Usage: %s <input seismogram>" % sys.argv[0]
 
     print "Usage: %s <input seismogram>" % sys.argv[0]
 
     sys.exit(1)
 
     sys.exit(1)
 
+
 
  seismogram = sys.argv[1]
 
  seismogram = sys.argv[1]
 
+
 
  with open(seismogram, "rb") as fp_in:
 
  with open(seismogram, "rb") as fp_in:
 
     header_str = fp_in.read(56)
 
     header_str = fp_in.read(56)
Line 81: Line 83:
 
     print "Maximum stochastic frequency = %f" % stoch_max_freq
 
     print "Maximum stochastic frequency = %f" % stoch_max_freq
 
     fp_in.close()
 
     fp_in.close()
 
  
 
== PSA header ==
 
== PSA header ==

Revision as of 19:18, 9 October 2017

This page details the header formats for various kinds of CyberShake output data files. These headers have been used in CyberShake since Run ID 1310.

Seismogram header

The seismogram header is 56 bytes, and is defined (in C) as follows:

struct seisheader {
 char version[8];
 char site_name[8];
 //in case we think of something later
 char padding[8];
 int source_id;
 int rupture_id;
 int rup_var_id;
 float dt;
 int nt;
 int comps;
 float det_max_freq;
 float stoch_max_freq;
};
  • Version: The current version is 12.10.
  • Site name: The name of the CyberShake site.
  • Padding: Empty space in case we have a use for it later.
  • Source ID: The source ID of the event this seismogram is for.
  • Rupture ID: The rupture ID of the event this seismogram is for.
  • Rup Var ID: The rupture variation ID of the event this seismogram is for.
  • DT: the timestep size used in the seismogram.
  • NT: the number of timesteps in the seismogram.
  • Comps: This tracks the components in the seismogram. There are three flags, one for each component (X=1, Y=2, Z=4), and the flags are ANDed together to produce the value here.
  • Det_max_freq: the maximum frequency of the deterministic part of the seismogram. This was 0.5 for studies before 15.4, and 1.0 for 15.4, 15.12, and 17.3.
  • Stoch_max_freq: the maximum frequency of the stochastic part of the seismogram. For studies with no stochastic component this is -1; for studies 1.4 and 15.12 it is 10.0.

This header precedes every two-component seismogram.

Sample C code

Sample Python code

This is a Python script to read in and print the header information.

#!/usr/bin/env python

import sys
import struct

if len(sys.argv)<2:
   print "Usage: %s <input seismogram>" % sys.argv[0]
   sys.exit(1)

seismogram = sys.argv[1]

with open(seismogram, "rb") as fp_in:
   header_str = fp_in.read(56)
   version = header_str[0:8]
   if version[0:6]!="12.10":
       print "Error: version does not match expected string '12.10', aborting."
       sys.exit(2)
   site = header_str[8:16]
   source_id = struct.unpack('i', header_str[24:28])
   rupture_id = struct.unpack('i', header_str[28:32])
   rup_var_id = struct.unpack('i', header_str[32:36])
   dt = struct.unpack('f', header_str[36:40])
   nt = struct.unpack('i', header_str[40:44])
   comps = struct.unpack('i', header_str[44:48])
   x_flag = comps & 1
   y_flag = comps & 2
   z_flag = comps & 4
   det_max_freq = struct.unpack('f', header_str[48:52])
   stoch_max_freq = struct.unpack('f', header_str[52:56])
   print "Version = %s" % version
   print "Site = %s" % site
   print "Source ID = %d" % source_id
   print "Rupture ID = %d" % rupture_id
   print "Rupture Variation ID = %d" % rup_var_id
   print "DT = %f" % dt
   print "NT = %d" % nt
   print "X component? %d" % x_flag
   print "Y component? %d" % y_flag
   print "Z component? %d" % z_flag
   print "Maximum deterministic frequency = %f" % det_max_freq
   print "Maximum stochastic frequency = %f" % stoch_max_freq
   fp_in.close()

PSA header

RotD header

Duration header