Thread: cosine taper

Started: 2016-09-23 17:36:06
Last activity: 2016-09-24 04:57:30
Topics: SAC Help
Peter Schmidt
2016-09-23 17:36:06
Hi All

Just a small note that perhaps would be reasonable to edit in the SAC manual

According to manual (V101.6a, November 21, 2013) "TAPER TYPE COSINE
WIDTH v" will apply a symmetric taper on format: 1-COS(...) to each end
of the data. However after getting some inconsistent results I had a
look in the source code and found out that the applied taper is really:
ABS(SIN(...)). Perhaps a future edit of the manual could properly state
this.


regP

--
********************************************************************************
Peter Schmidt Tel: +46-18-4712259
Swedish National Seismic Network (SNSN) Mobile: +46-73-3190975
Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
Uppsala University
Villavagen 16
SE-75236 Uppsala
********************************************************************************

  • Brian Savage
    2016-09-23 18:24:40
    Peter,

    Can you point me to the file and line number where the abs(sin(..)) appears.
    I am having trouble finding this in the source.

    Brian
    On Sep 23, 2016, at 5:40 AM, Peter Schmidt wrote:

    Hi All

    Just a small note that perhaps would be reasonable to edit in the SAC manual

    According to manual (V101.6a, November 21, 2013) "TAPER TYPE COSINE
    WIDTH v" will apply a symmetric taper on format: 1-COS(...) to each end
    of the data. However after getting some inconsistent results I had a
    look in the source code and found out that the applied taper is really:
    ABS(SIN(...)). Perhaps a future edit of the manual could properly state
    this.


    regP

    --
    ********************************************************************************
    Peter Schmidt Tel: +46-18-4712259
    Swedish National Seismic Network (SNSN) Mobile: +46-73-3190975
    Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
    Uppsala University
    Villavagen 16
    SE-75236 Uppsala
    ********************************************************************************

    ----------------------
    SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/


    • Peter Schmidt
      2016-09-24 01:59:07
      Brian, and others

      Sorry for the confusion, this is all my fault, there's no abs(sin(...))
      in the source code. The taper is implemented in accordance with the post
      by George Hellfrich.

      By writing abs(sin(...)) I was merely expressing the fact that if any
      operator applied to the tapered waveform that implicitly assumes the
      waveform to be infinite and periodically repeating would see a taper on
      format abs(sin(...)) (as sin(...) in it self is an odd function).

      The question I wanted to raise is the fact that the sac manual clearly
      states that the form of the cosine taper is 1-cos(...) which by no means
      is the same as what is being used in the source code. As a simple
      example. d(taper)/d(sample) , for the 1-cos(...) taper this goes from 0
      to maximum over the tapered part of the waveform, whilst the sin(...)
      taper goes from maximum value to 0. I.e. the two do not behave the same.

      Thus I wold suggest editing the manual to properly state the form of the
      cosine taper.


      regards Peter



      On 2016-09-23 17:25, Brian Savage wrote:
      Peter,

      Can you point me to the file and line number where the abs(sin(..)) appears.
      I am having trouble finding this in the source.

      Brian
      On Sep 23, 2016, at 5:40 AM, Peter Schmidt wrote:

      Hi All

      Just a small note that perhaps would be reasonable to edit in the SAC manual

      According to manual (V101.6a, November 21, 2013) "TAPER TYPE COSINE
      WIDTH v" will apply a symmetric taper on format: 1-COS(...) to each end
      of the data. However after getting some inconsistent results I had a
      look in the source code and found out that the applied taper is really:
      ABS(SIN(...)). Perhaps a future edit of the manual could properly state
      this.


      regP

      --
      ********************************************************************************
      Peter Schmidt Tel: +46-18-4712259
      Swedish National Seismic Network (SNSN) Mobile: +46-73-3190975
      Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
      Uppsala University
      Villavagen 16
      SE-75236 Uppsala
      ********************************************************************************

      ----------------------
      SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/

      ----------------------
      SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/


      --
      ********************************************************************************
      Peter Schmidt Tel: +46-18-4717104
      Swedish National Seismological Network (SNSN) Mobile: +46-73-3190975
      Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
      Uppsala University
      Villavagen 16
      SE-75236 Uppsala
      ********************************************************************************

    • Peter Schmidt
      2016-09-24 02:00:24
      Brian, and others

      Sorry for the confusion, this is all my fault, there's no abs(sin(...))
      in the source code. The taper is implemented in accordance with the post
      by George Hellfrich.

      By writing abs(sin(...)) I was merely expressing the fact that if any
      operator applied to the tapered waveform that implicitly assumes the
      waveform to be infinite and periodically repeating would see a taper on
      format abs(sin(...)) (as sin(...) in it self is an odd function).

      The question I wanted to raise is the fact that the sac manual clearly
      states that the form of the cosine taper is 1-cos(...) which by no means
      is the same as what is being used in the source code. As a simple
      example. d(taper)/d(sample) , for the 1-cos(...) taper this goes from 0
      to maximum over the tapered part of the waveform, whilst the sin(...)
      taper goes from maximum value to 0. I.e. the two do not behave the same.

      Thus I wold suggest editing the manual to properly state the form of the
      cosine taper.


      regards Peter


      p.s. I tried to send an earlier post in response to Geoge's first reply,
      but that does not seem to have made it through while writing this



      On 2016-09-23 17:25, Brian Savage wrote:
      Peter,

      Can you point me to the file and line number where the abs(sin(..)) appears.
      I am having trouble finding this in the source.

      Brian
      On Sep 23, 2016, at 5:40 AM, Peter Schmidt wrote:

      Hi All

      Just a small note that perhaps would be reasonable to edit in the SAC manual

      According to manual (V101.6a, November 21, 2013) "TAPER TYPE COSINE
      WIDTH v" will apply a symmetric taper on format: 1-COS(...) to each end
      of the data. However after getting some inconsistent results I had a
      look in the source code and found out that the applied taper is really:
      ABS(SIN(...)). Perhaps a future edit of the manual could properly state
      this.


      regP

      --
      ********************************************************************************
      Peter Schmidt Tel: +46-18-4712259
      Swedish National Seismic Network (SNSN) Mobile: +46-73-3190975
      Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
      Uppsala University
      Villavagen 16
      SE-75236 Uppsala
      ********************************************************************************

      ----------------------
      SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/

      ----------------------
      SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/


      --
      ********************************************************************************
      Peter Schmidt Tel: +46-18-4717104
      Swedish National Seismological Network (SNSN) Mobile: +46-73-3190975
      Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
      Uppsala University
      Villavagen 16
      SE-75236 Uppsala
      ********************************************************************************

      • Arthur Snoke
        2016-09-23 21:03:45
        This is my third try. I hope I get it right this time.

        Peter is right: the manual is inconsistent with the code. The reason is that the equation in the manual applies only to the Hanning and Hamming options, which use a half cycle of the cosine in the taper. In the coding, that equation is not used for the COSINE option, which uses a quarter cycle of the sine function. I had to looked at the code before today and had not looked for the plots like the oe generated by

        fg boxcar begin -1.02 npts 303 delta .01; write box.sac; r box.sac; cut 0 1.0; r; taper t cos; p1

        (which I generated for the first time today), and made an invalid assumption about that option.

        I have seen papers that used a windowing function that was a full cycle of a cosine, which is the same as one gets from taper -t hanging -w 0.5. When I use a taper, I want one that goes to zero gradually at the ends as is done in the tanning taper because I usually am going to do a pfft and do not want large steps at the end. The -t cosine has its maximum slope at the ends of the window. Does anyone know where that feature is desirable?

        At least some of you may find my fg boxcar .. line useful for seeing what a taper actually looks like. We will add a figure i the next sac manual showing that. (There was one in the 1980s manual.)

        On Sep 23, 2016, at 1:01 PM, Peter Schmidt <peter.schmidt<at>geo.uu.se> wrote:


        Thus I wold suggest editing the manual to properly state the form of the
        cosine taper.



  • George Helffrich
    2016-09-24 04:57:30
    Dear All -

    This is not true of the original Fortran code (10.6d or 10.6f). In that source, the taper is calculated from

    sin(j*pi/(2*npts)), j = 0, npts

    where

    npts = w*(e - b)/delta

    with e, b and delta having their SAC file header definitions and w is the fractional taper length. Hence, if this is how the C SAC source code behaves, it should be viewed as a bug or as an incompatible change with respect to historical behavior.

    On 23 Sep 2016, at 18:40, Peter Schmidt <peter.schmidt<at>geo.uu.se> wrote:

    Hi All

    Just a small note that perhaps would be reasonable to edit in the SAC manual

    According to manual (V101.6a, November 21, 2013) "TAPER TYPE COSINE
    WIDTH v" will apply a symmetric taper on format: 1-COS(...) to each end
    of the data. However after getting some inconsistent results I had a
    look in the source code and found out that the applied taper is really:
    ABS(SIN(...)). Perhaps a future edit of the manual could properly state
    this.


    regP

    --
    ********************************************************************************
    Peter Schmidt Tel: +46-18-4712259
    Swedish National Seismic Network (SNSN) Mobile: +46-73-3190975
    Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
    Uppsala University
    Villavagen 16
    SE-75236 Uppsala
    ********************************************************************************

    ----------------------
    SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/



    George Helffrich
    george<at>elsi.jp


    • Arthur Snoke
      2016-09-23 18:17:00
      I have been working with tape a bit in my research lately, so am familiar with the routine.

      There is a problem in the code for src/scm/taper.c. The line is

      value = sin(omega * (float) (j))

      which is the same as in the Fortran code. The problem is that the default width is 0.05, which makes sense for the Hanning and Hamming, but I do not think it is reset to 0.5 if one called t cosine with no width parameter. One can check this with the following

      fg boxcar begin -1.02 npts 303 delta .01; write box.sac; r box.sac; cut 0 1.0; r; taper t cos; p1

      If one follows this with

      taper w 0.5

      one sees the full cosine taper.

      Perhaps we should replace the coding for COS with T HANNING w 0.5 and modify the HELP file.


      On Sep 23, 2016, at 8:58 AM, George Helffrich wrote:


      Dear All -

      This is not true of the original Fortran code (10.6d or 10.6f). In that source, the taper is calculated from

      sin(j*pi/(2*npts)), j = 0, npts

      where

      npts = w*(e - b)/delta

      with e, b and delta having their SAC file header definitions and w is the fractional taper length. Hence, if this is how the C SAC source code behaves, it should be viewed as a bug or as an incompatible change with respect to historical behavior.

      On 23 Sep 2016, at 18:40, Peter Schmidt <peter.schmidt<at>geo.uu.se> wrote:

      Hi All

      Just a small note that perhaps would be reasonable to edit in the SAC manual

      According to manual (V101.6a, November 21, 2013) "TAPER TYPE COSINE
      WIDTH v" will apply a symmetric taper on format: 1-COS(...) to each end
      of the data. However after getting some inconsistent results I had a
      look in the source code and found out that the applied taper is really:
      ABS(SIN(...)). Perhaps a future edit of the manual could properly state
      this.


      regP

      --
      ********************************************************************************
      Peter Schmidt Tel: +46-18-4712259
      Swedish National Seismic Network (SNSN) Mobile: +46-73-3190975
      Dept. of Earth Sciences:geophysics e-mail: peter.schmidt<at>geo.uu.se
      Uppsala University
      Villavagen 16
      SE-75236 Uppsala
      ********************************************************************************

      ----------------------
      SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/



      George Helffrich
      george<at>elsi.jp


      ----------------------
      SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/


      • Arthur Snoke
        2016-09-23 18:48:04
        Following up on my earlier note …

        I looked more closely at the code and output plot, and I think my “fix” may not be what is intended.

        I assumed that at the extremes, a taper should go smoothly to zero. The taper t cosine is the first quarter cycle of a sin wave and when goes to zero with maximum slope. Maybe that is what is intended, so the fact the w is not specified may be on purpose.

        If that was intended, both the code and the wording in the help file are fine as is.


Page built 21:20:21 | v.b'108166