Class SACHeader

java.lang.Object
llnl.gnem.core.io.SAC.SACHeader
All Implemented Interfaces:
Closeable, AutoCloseable

public class SACHeader extends Object implements Closeable
  • Field Details

  • Constructor Details

  • Method Details

    • isDefault

      public static boolean isDefault(int variable)
    • isDefault

      public static boolean isDefault(float variable)
    • isDefault

      public static boolean isDefault(String variable)
    • padTo

      public static String padTo(String S, int length)
    • chAllt

      public void chAllt(float value)
      reproduces the ch allt modifications to the time variables
      Parameters:
      value - - the added time in seconds
    • changeHeader

      public void changeHeader(String type, String value)
      Equivalent to the ch command in SAC
      Parameters:
      type - : the header variable name
      value - : a String version of the value being assigned to the header
    • changeTimePick

      public void changeTimePick(String type, String value)
      Equivalent to the ch command in SAC Checking two possibilities here 1.) generic: e.g. 'ch t0 100 ' will change the "t0" header to 100 2.) specific:e.g. 'ch Lg 100 ' will change all picks labelled "Lg" to 100
      Parameters:
      type - : the time pick header variable name
      value - : a String version of the float value being assigned to the header
    • checkByteSwap

      public boolean checkByteSwap()
    • clearTimePicks

      public void clearTimePicks()
      Clear all designated time picks and their identifiers resets to default the values: t[0-10], kt[0-10], tf and kf
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • createEvid

      public int createEvid()
      method to replace an undefined evid with a unique number based on the origin or reference time
      Returns:
      the nevid value
    • getBeginTime

      public TimeT getBeginTime()
      Get the begin Epoch time as a TimeT object
    • getEndTime

      public TimeT getEndTime()
      Get the end Epoch time as a TimeT object
    • getEventCoordinates

      public GeodeticCoordinate getEventCoordinates() throws Exception
      Throws:
      Exception
    • getFloatDefault

      public float getFloatDefault()
    • getItype

      public String getItype(int itype)
    • getIztype

      public Iztype getIztype()
    • getOriginTime

      public TimeT getOriginTime()
      Get the origin Epoch time as a TimeT object
    • getReferenceTime

      public TimeT getReferenceTime()
      Convert the date header fields into a TimeT object Note: if the nzyear... variables are not set - return null
    • getStationCoordinates

      public GeodeticCoordinate getStationCoordinates() throws Exception
      Throws:
      Exception
    • getTimePick

      public Object[] getTimePick(int index)
      A simple method for retrieving pick times and names
      Parameters:
      index - Object[] timepick = sfh.getTimePick(0); Float value = (Float) timepick[0]; String pickname = (String) timepick[1];
    • getTimePick

      public float getTimePick(String phase)
      Look for a specific pick Note both kt[] and t[] must be defined for this to return successfully e.g. float time = getTimePick("Pn");
      Parameters:
      phase - the name of the phase searched for - kt[ii] must be the same - including capitalization
      Returns:
      the pick time value, or the default value
    • getTimePicks

      public ArrayList getTimePicks()
      Collect all the Time Picks as a Vector of Strings pickstring = "Pn 452.2" To extract the result use StringTokenizer;
    • getVariableMap

      public TreeMap<String,Object> getVariableMap()
      Make a treemap of all the defined variables
      Returns:
      a treemap of defined variables
    • listHeader

      public String listHeader(String type)
      Equivalent to the lh command in SAC
      Parameters:
      type - : the header variable name
      Returns:
      result: a String version of the value being assigned to the header
    • setAzimuths

      public void setAzimuths()
      Calculate the source-receiver azimuth and backazimuth if they aren't calculated already
    • setBeginTime

      public void setBeginTime(TimeT begintime)
      b is defined by the start of the seismogram relative to the reference time (nzyear, ...,nzmsec) NOTE the reference time should be already be defined
    • setDistances

      public void setDistances()
      Calculate the source-receiver distance if it isn't calculated already
    • setEventLocation

      public void setEventLocation(float evla, float evlo, float evel, float evdp)
    • setItype

      public int setItype(String type)
    • setIztype

      public void setIztype(Iztype iztype)
    • setOriginTime

      public void setOriginTime(TimeT origintime)
      Set the origin time relative to the sac file's reference time
      Parameters:
      origintime - - a TimeT version of the event
    • setStationLocation

      public void setStationLocation(float stla, float stlo, float stel, float stdp)
    • setTime

      public void setTime(TimeT timet)
      Set the nz(date) fields based on a TimeT object
      Parameters:
      timet - : The time as a TimeT object
    • setTimePick

      public void setTimePick(int index, float value, String pickname)
      A simple method for defining pick times and names
      Parameters:
      index -
      value -
      pickname -
    • setVariableMap

      public void setVariableMap(TreeMap<String,Object> variablemap)
      assign variables based on a treemap
      Parameters:
      variablemap - contains all the variables that are not default valued
    • validate

      public void validate()
      Certain variables are interrelated - make sure that any changes are applied to each
    • write

      public void write(RandomAccessFile sacout)
      Write the header at the start of a RandomAccessFile Note the sacout.length() at the conclusion will be 158*4 = 632. Data is written starting at sacout.seek(632)
      Parameters:
      sacout -
    • write

      public void write(DataOutput outputStream)