exportFile

This forum is dedicated to discuss all problems and suggestions related to the use of geopsy database and its plugins (array processing, H/V,...).
Post Reply
olivo
Posts: 3
Joined: Wed Sep 28, 2011 2:03 pm

exportFile

Post by olivo »

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
admin
Site Admin
Posts: 841
Joined: Mon Aug 13, 2007 11:48 am
Location: ISTerre
Contact:

Re: exportFile

Post by admin »

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.

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
I did not check it, tell me if you find any error or missing feature.
Post Reply