Thread: how to find the value of tn marker ?

Started: 2008-11-06 18:37:05
Last activity: 2009-01-13 00:15:57
Topics: SAC Help
weitao
2008-11-06 18:37:05
Dear All
Is there any sac command to find the value of tn marker ? I mean if
t1=100. can I find out the Y-value at that time?
thanks all.

weitao

  • Pablo Palacios
    2009-01-12 17:23:24

    Dear Weitao,

    I had the same necesity some time ago. I can not find a sac intruction for solve it. In my case I was looking for the maximum value of a spectrum. For reach it I made a csh script, the following lines are part of that script and could be useful. If you know another easy form to do, please tell me.

    P.

    # cutting the file between C1 and C2 marks and building the spectrum file
    sac<<EOF
    cut $C1 $C2
    r ${stn}_${cmp}_${event}.sac
    chnhdr A UNDEF
    chnhdr F UNDEF
    dft wom a
    writesp am
    EOF

    # smoothig the spectrum and writting it as text file
    sac<<EOF
    r ${stn}_${cmp}_${event}.sac.am
    smooth mean h 10
    write over
    write alpha change .am .am.alpha
    EOF

    # extracting the number of point of the file to compute de maximum frequency
    sac<<EOF >! header
    r ${stn}_${cmp}_${event}.sac.am
    listhdr NPTS
    EOF
    # computing the spectrum variation between consecutive points
    set delta = `awk '/NPTS/{print 25/($3-1)}' header`
    # converting the spectrum text file to spectrum column file without header (30 first lines)
    set spectrum = `echo ${stn}_${cmp}_${event}.sac.am.alpha`
    awk 'NR>30{print $0}' $spectrum | awk 'BEGIN{OFS="\n"}{print $1,$2,$3,$4,$5}' > spectrum-c
    # selecting the point of the maximum frequency and computing this value
    set MaxFreq = `awk '{if(NR==1){max=$1}else if($1>max){max=$1;print NR,max}}' spectrum-c | tail -1 | awk '{print $1}'`
    set MaxFreq = `echo $delta $MaxFreq | awk '{print $1*($2-1)}'`
    # deleting temporal work files
    rm -f header
    rm -f ${stn}_${cmp}_${event}.sac.am.alpha
    rm -f spectrum-c

    # automatic picking in the spectrum file of the maximum frequency
    sac<<EOF
    r ${stn}_${cmp}_${event}.sac.am
    chnhdr F $MaxFreq
    write over
    EOF

    Date: Thu, 6 Nov 2008 10:37:05 -0700
    From: wangwtustc<at>gmail.com
    To: sac-help<at>iris.washington.edu
    Subject: [SAC-HELP] how to find the value of tn marker ?

    Dear All
    Is there any sac command to find the value of tn marker ? I mean if t1=100. can I find out the Y-value at that time?
    thanks all.

    weitao

    _________________________________________________________________
    Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
    http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
    • George Helffrich
      2009-01-13 00:15:57
      Dear Pablo -

      See the list (below) of built-in numeric functions in MacSAC.
      SAC2000 has all except GETVAL, I believe. You can do what you want by
      using something like this example in any version of SAC:

      ---
      funcgen seismogram
      cutim ((GETTIME MAX) - (&1,DELTA / 2)) ((GETTIME MAX) + (&1,DELTA / 2))
      message "Maximum value is &1,depmax& at (GETTIME MAX)"
      ---

      Change (GETTIME MAX) to something else for another value in memory,
      e.g. &1,t0&
      It only works on one trace in memory, however, and destroys the memory
      copy it.

      ---
      fg seismogram
      message "Only in MacSAC, max value is (GETVAL (GETTIME MAX)) at
      (GETTIME MAX)"
      ---

      It would be nice if SAC2000 implemented GETVAL; the query arises
      regularly enough
      to put it on the to do list.

      Numeric functions
      Name Num. args. Example Notes

      ------------------------------------------------------------------------
      ------
      PI 0 (PI) Value of pi
      ADD >0 (ADD 1 2)
      SUBTRACT >0 (SUBTRACT 2 1)
      MULTIPLY >0 (MULTIPLY 1 2 3 4)
      DIVIDE >0 (DIVIDE 12 3)
      MINIMUM >0 (MINIMUM 0.78 -3.5 15.2)
      MAXIMUM >0 (MAXIMUM 0.78 -3.5 15.2)
      SQRT 1 (SQRT 2) Square root
      EXP 1 (EXP 2) Powers of e
      ALOG 1 (ALOG 2.5) Natural logarithm
      POWER 1 (POWER 3) Powers of 10
      ALOG10 1 (ALOG10 1000) Base 10 logarithm
      SINE 1 (SINE 0.37) Argument in radians
      ARCSINE 1 (ARCSINE 0.37) Result in radians
      ASINE 1 (ASINE 0.37) Synonym
      COSINE 1 (COSINE 0.37) Argument in radians
      ARCCOSINE 1 (ARCCOSINE 0.37) Result in radians
      ACOSINE 1 (ACOSINE 0.37) Synonym
      TANGENT 1 (TANGENT 0.37) Argument in radians
      ARCTANGENT 1 (ARCTANGENT 1.00) Result in radians
      ATANGENT 1 (ATANGENT 1.00) Synonym
      INTEGER 1 (INTEGER 1.05) Integer part of expression
      ABSOLUTE 1 (ABSOLUTE 1.05)
      GETTIME 1,2 (GETTIME 17.05) Time of first occurrence
      of
      (GETTIME MAX 17.05) value in file, or value
      greater
      (GETTIME MIN -7.05) than (MAX) or less than
      (MIN) in
      (GETTIME MAX) file, or DEPMAX or DEPMIN
      if no
      (GETTIME MIN) value provided
      GETVAL 1,3 (GETVAL 157.32) Data values of at 157.32
      s in
      each file in memory.
      (GETVAL FILE N 157.32) Data value at 157.32 s in
      file N
      in memory; N integer > 0.


      String functions
      Name Num. args. Syntax Description

      ------------------------------------------------------------------------
      ------
      CHANGE 3 (CHANGE X Y Z) Changes X to Y in Z
      DELETE 2 (DELETE X Y) Deletes X in Y
      BEFORE 2 (BEFORE X Y) Returns text in Y
      preceding X
      AFTER 2 (AFTER X Y) Returns text in Y
      following X
      SUBSTRING 3 (SUBSTRING X Y Z) Returns characters X to Y
      in Z
      Index starts with 1; X or
      Y may be
      END to indicate last
      character
      CONCATENATE - (CONCATENATE X Y Z ...) Joins all strings together

      On 12 Jan 2009, at 14:23, Pablo Palacios wrote:

      Dear Weitao,

      I had the same necesity some time ago. I can not find a sac intruction
      for solve it. In my case I was looking for the maximum value of a
      spectrum. For reach it I made a csh script, the following lines are
      part of that script and could be useful. If you know another easy form
      to do, please tell me.

      P.

      # cutting the file between C1 and C2 marks and building the spectrum
      file
      sac<<EOF
      cut $C1 $C2
      r ${stn}_${cmp}_${event}.sac
      chnhdr A UNDEF
      chnhdr F UNDEF
      dft wom a
      writesp am
      EOF

      # smoothig the spectrum and writting it as text file
      sac<<EOF
      r ${stn}_${cmp}_${event}.sac.am
      smooth mean h 10
      write over
      write alpha change .am .am.alpha
      EOF

      # extracting the number of point of the file to compute de maximum
      frequency
      sac<<EOF >! header
      r ${stn}_${cmp}_${event}.sac.am
      listhdr NPTS
      EOF
      # computing the spectrum variation between consecutive
      points
      set delta = `awk '/NPTS/{print 25/($3-1)}' header`
      # converting the spectrum text file to spectrum column
      file without header (30 first lines)
      set spectrum = `echo ${stn}_${cmp}_${event}.sac.am.alpha`
      awk 'NR>30{print $0}' $spectrum | awk
      'BEGIN{OFS="\n"}{print $1,$2,$3,$4,$5}' > spectrum-c
      # selecting the point of the maximum frequency and
      computing this value
      set MaxFreq = `awk '{if(NR==1){max=$1}else
      if($1>max){max=$1;print NR,max}}' spectrum-c | tail -1 | awk '{print
      $1}'`
      set MaxFreq = `echo $delta $MaxFreq | awk '{print
      $1*($2-1)}'`
      # deleting temporal work files
      rm -f header
      rm -f ${stn}_${cmp}_${event}.sac.am.alpha
      rm -f spectrum-c

      # automatic picking in the spectrum file of the maximum frequency
      sac<<EOF
      r ${stn}_${cmp}_${event}.sac.am
      chnhdr F $MaxFreq
      write over
      EOF

      Date: Thu, 6 Nov 2008 10:37:05 -0700
      From: wangwtustc<at>gmail.com
      To: sac-help<at>iris.washington.edu
      Subject: [SAC-HELP] how to find the value of tn marker ?

      Dear All
      Is there any sac command to find the value of tn marker ? I mean
      if t1=100. can I find out the Y-value at that time?
      thanks all.

      weitao

      Invite your mail contacts to join your friends list with Windows Live
      Spaces. It's easy! Try it!
      _______________________________________________
      sac-help mailing list
      sac-help<at>iris.washington.edu
      http://www.iris.washington.edu/mailman/listinfo/sac-help

      George Helffrich
      george<at>geology.bristol.ac.uk



16:20:47 v.b3198453