Thread: variable not recognized?

Started: 2014-05-21 00:20:11
Last activity: 2014-05-21 00:23:00
Topics: SAC Help
Guust Nolet
2014-05-21 00:20:11
We have a script that refuses to work in version 101.6, though before that it worked fine.

The script computes the decimation factor in order to
decimate from delta 0.025 to 0.1s; here is its echo to the screen:

setbb new 0.1
r AU.WR0..BHZ
rmean
evaluate to old &AU.WR0..BHZ,delta
==> evaluate to old 0.025
evaluate to factor %new / %old
==> evaluate to factor 4
decimate %factor
==> decimate 4
ERROR interpreting command: decimate %factor
ILLEGAL OPTION: ^

It does not like the "%"...

But if I simply do the following it works:
setbb factor 4
decimate %factor

Why does the script go wrong???

Guust Nolet
Géoazur
250, rue Albert Einstein
06560 Sophia Antipolis
France
+33.4.83.61.86.32

https://www.geoazur.fr/GLOBALSEIS/nolet/index.html












  • Brian Savage
    2014-05-20 19:02:27
    Guust,

    The decimate command is expecting an integer and the division at line

    evaluate to factor %new / %old


    produces a floating point number.

    You could use the following line to produce the integer required

    SAC> evaluate to factor (integer ( ( %new / %old ) + 0.5 ) )

    This will work, but is not correct for all cases.

    A sadly undocumented function, new in 101.6, is "round" (my apologies)

    SAC> evaluate to factor ( round ( %new / %old ) )

    The older versions of SAC may have truncated your floating point number to an integer, possibly a 3 in this case, not a 4 as you would have hoped.

    Brian Savage
    savage<at>uri.edu

    On May 20, 2014, at 11:20 AM, Guust Nolet wrote:

    We have a script that refuses to work in version 101.6, though before that it worked fine.

    The script computes the decimation factor in order to
    decimate from delta 0.025 to 0.1s; here is its echo to the screen:

    setbb new 0.1
    r AU.WR0..BHZ
    rmean
    evaluate to old &AU.WR0..BHZ,delta
    ==> evaluate to old 0.025
    evaluate to factor %new / %old
    ==> evaluate to factor 4
    decimate %factor
    ==> decimate 4
    ERROR interpreting command: decimate %factor
    ILLEGAL OPTION: ^

    It does not like the "%"...

    But if I simply do the following it works:
    setbb factor 4
    decimate %factor

    Why does the script go wrong???

    Guust Nolet
    Géoazur
    250, rue Albert Einstein
    06560 Sophia Antipolis
    France
    +33.4.83.61.86.32

    https://www.geoazur.fr/GLOBALSEIS/nolet/index.html











    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help



    • George Helffrich
      2014-05-21 00:23:00
      Dear All -

      In a spirit of user-friendliness (and to prevent script breakage like what is reported here), SAC/BRIS implements the integer argument check by allowing rounding leeway (if within 1e-4 of an integer, the value is taken to be the nearby integer on the number line). Maybe SAC/IRIS should too and avoid requiring all scripts to be changed to use undocumented and/or newly introduced features. (This was implemented in Sep. 2006.)

      On 20 May 2014, at 17:02, Brian Savage wrote:

      Guust,

      The decimate command is expecting an integer and the division at line

      evaluate to factor %new / %old


      produces a floating point number.

      You could use the following line to produce the integer required

      SAC> evaluate to factor (integer ( ( %new / %old ) + 0.5 ) )

      This will work, but is not correct for all cases.

      A sadly undocumented function, new in 101.6, is "round" (my apologies)

      SAC> evaluate to factor ( round ( %new / %old ) )

      The older versions of SAC may have truncated your floating point number to an integer, possibly a 3 in this case, not a 4 as you would have hoped.

      Brian Savage
      savage<at>uri.edu

      On May 20, 2014, at 11:20 AM, Guust Nolet wrote:

      We have a script that refuses to work in version 101.6, though before that it worked fine.

      The script computes the decimation factor in order to
      decimate from delta 0.025 to 0.1s; here is its echo to the screen:

      setbb new 0.1
      r AU.WR0..BHZ
      rmean
      evaluate to old &AU.WR0..BHZ,delta
      ==> evaluate to old 0.025
      evaluate to factor %new / %old
      ==> evaluate to factor 4
      decimate %factor
      ==> decimate 4
      ERROR interpreting command: decimate %factor
      ILLEGAL OPTION: ^

      It does not like the "%"...

      But if I simply do the following it works:
      setbb factor 4
      decimate %factor

      Why does the script go wrong???

      Guust Nolet
      Géoazur
      250, rue Albert Einstein
      06560 Sophia Antipolis
      France
      +33.4.83.61.86.32

      https://www.geoazur.fr/GLOBALSEIS/nolet/index.html











      _______________________________________________
      sac-help mailing list
      sac-help<at>iris.washington.edu
      http://www.iris.washington.edu/mailman/listinfo/sac-help


      _______________________________________________
      sac-help mailing list
      sac-help<at>iris.washington.edu
      http://www.iris.washington.edu/mailman/listinfo/sac-help



      George Helffrich
      george.helffrich<at>bris.ac.uk



Page built 08:51:08 | v.b'108166