Hi All,
I learning, slowly. I see that I can implement command-line macros to run automatically some commands without using the GUIs, and this is one of my needs.
Questions:
1) how can I provide to the macro some input parameters?
2) how can I manage file-names into the macro?
The first basic thing I would like to do is
- read a file
- apply filters
- export the file into a new file.
So I run:
geopsy -waveform macro.gs my_file.sac
where macro.gs is:
filter("Butterworth", "BandPass", 1, 5, -4);
exportFile("new_file.sac",false,"SacBigEndian");
Now this should be done for several files and different corner frequencies, so I would like to input from the command line the two corner frequencies ( 1 and 5) and export the file with name my_file.1.5.sac according to the used corners.
Can anybody give me some hints ?
thanks
Marco
exportFile
Re: exportFile
Currently, the script does not support arguments. What I would do instead is a bash script that defines the script to run and starts geopsy for each file.
I did not check it, tell me if you find any error or missing feature.
Code: Select all
#!/bin/bash
FREQUENCY_MIN=1
FREQUENCY_MAX=5
OUPUT_DIR=output_${FREQUENCY_MIN}_${FREQUENCY_MAX}
test -d $OUTPUT_DIR || mkdir $OUTPUT_DIR
for FILENAME in $(ls .sac); do
(
cat <<END
filter("Butterworth", "BandPass", $FREQUENCY_MIN, $FREQUENCY_MAX, -4);
exportFile("$OUTPUT_DIR/$FILENAME.sac",false,"SacBigEndian");
END
) > macro.qs
geopsy -waveform macro.qs $FILENAME
done
rm macro.qs