Thread: Help with script

Started: 2012-07-15 20:13:07
Last activity: 2012-07-16 06:54:37
Topics: SAC Help
Oscar Perez Ramirez
2012-07-15 20:13:07
Hello everybody, I'm trying to writte a script that does the following:

I have a folder with 3 .SAC files
Each sac file has a value assigned to his t1 variable
lets say:
01.SAC has t1=300
02.SAC has t1=301
03.SAC has t1=302

And i have a file with a column of values, lets say:

"traveltimes.dat"

300.456
301.365
302.568

I want to replace the t1 values in the .SAC files for the ones that are in the file "traveltimes.dat"
 
I need to do this task for many (up to thousands of .SAC files) and I have very little experience with bash scripting so I need some help, I would appreciate a lot!!!!

Thanks

Atte. Oscar Perez R.
  • Milton Plasencia
    2012-07-16 06:54:37
    Hola Oscar,
    One way to add header to your files will be:
    1) your files must be accept change header, so the header LOVROK must be set to TRUE.

    2) I assume that you running SAC on Linux or OSX, so, with AWK you can generate a file
    with the list of commands of type:

    printf "r your_file_1.sac\nch t1 300\nwh\n\q\n" | sac
    printf "r your_file_2.sac\nch t1 301\nwh\n\q\n" | sac
    .
    .
    .
    printf "r your_file_99.sac\nch t1 399\nwh\n\q\n" | sac
    It is not elegant but do the work.

    HTH,

    Milton

    * * * * * * * * * * * * * * * * * * * * * * *
    Milton P. PLASENCIA LINARES

    Dipartimento Centro di Ricerche Sismologiche (CRS)
    Istituto Nazionale di Oceanografia e di Geofisica Sperimentale - OGS

    Borgo Grotta Gigante 42/C
    (34010) Sgonico - TRIESTE - ITALIA
    Tel: +39 040 2140 136 (Udine)
    Tel: +39 040 2140 365 / 256 (Trieste)
    Fax: +39-040-327307

    E-mail: mplasencia<at>inogs.it

    ASAIN (Antarctic Seismographic Argentinean Italian Network)
    *********************************




    On Jul 15, 2012, at 10:13 PM, Oscar Perez Ramirez wrote:

    Hello everybody, I'm trying to writte a script that does the following:

    I have a folder with 3 .SAC files
    Each sac file has a value assigned to his t1 variable
    lets say:
    01.SAC has t1=300
    02.SAC has t1=301
    03.SAC has t1=302

    And i have a file with a column of values, lets say:

    "traveltimes.dat"
    300.456
    301.365
    302.568

    I want to replace the t1 values in the .SAC files for the ones that are in the file "traveltimes.dat"

    I need to do this task for many (up to thousands of .SAC files) and I have very little experience with bash scripting so I need some help, I would appreciate a lot!!!!

    Thanks

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


11:27:39 v.22510d55