Geopsy: Waveform Scripting Language
The scripting language is Javascript (a comprehensive tutorial)
Geopsy provides several additional functions for processing signals details here below. If the description is incomplete hereinafter, run the function in the graphical user interface and check the generated code in the waveform console.
Contents
- 1 Categories
- 2 agc
- 3 correlations
- 4 cut
- 5 decimateAmplitude
- 6 decimateTime
- 7 discreteFourierTransform
- 8 exportFile
- 9 fastFourierTransfrom
- 10 filter
- 11 header
- 12 merge
- 13 mergeStations
- 14 multiply
- 15 newGroup
- 16 overSample
- 17 print
- 18 restoreStep
- 19 rotateComponents
- 20 saveStep
- 21 selectSignals
- 22 setHeader
- 23 shift
- 24 signalCount
- 25 subtractSignal
- 26 subtractSignals
- 27 subtractValue
- 28 stalta
- 29 system
- 30 taper
- 31 waveletTransform
- 32 whiten
Categories
- Header data: header, setHeader
- Signal transformations: cut, shift
- Input/ouput: exportFile
- Miscelaneous: signalCount, saveStep, restoreStep
agc
correlations
cut
Syntax
cut( Geopsy: Time range specification );
Description
Cut the signal between two time specifications
decimateAmplitude
decimateTime
discreteFourierTransform
exportFile
Syntax
exportFile(string filePath[, bool useOriginalBaseName[, string format[, number pickNumber]]]);
Description
Export signal(s) to filePath. format is one of the string returned by:
geopsy -export-formats
Examples
Export the signal (assumed to have only one) to a SAC file (big endian).
exportFile("myfolder/mysignal.sac", false, "SacBigEndian");
fastFourierTransfrom
filter
header
Syntax
header(number signalIndex, string dataName, [string dataIndex]);
Description
Returns the value of dataName from signal having signalIndex. All header data related to signal file are not valid, because the process is always applied to a temporary copy of the original signal. Hence, a property like "ShortFileName" is useless in this environment.
Examples
Removes the first and the last sample of all signals
n=signalCount(); for(i=0;i<n;i++) { dt=header(i, "DeltaT"); setHeader(i, "TimePick", "t1", header(i, "T0")+dt); setHeader(i, "TimePick", "t2", header(i, "EndTime")-dt); } cut("Pick", "t1", "Pick", "t2");
merge
mergeStations
multiply
newGroup
Syntax
newGroup(string path, string name, number start, number end);
Description
Creates a new group with signals from start to end. If path is empty, it adds the group at the root level. If not, it adds it in the tree at path.
Examples
Divides the current viewer in three groups
path="ISTerre/SmartSolo/Z" newGroup(path, "low gain", 0, 65); newGroup(path, "mid gain", 66, 131); newGroup(path, "high gain", 132, 219);
overSample
Syntax
print(string text)
Description
Prints a message to log console. It is mainly used for debug.
Examples
print("Hello "+2024+" world!");
restoreStep
Syntax
restoreStep(string tag);
Description
Restore signals previously saved onto the stack under tag.
Examples
see saveStep()
rotateComponents
saveStep
Syntax
saveStep(string tag);
Description
Saves the current signals onto the stack under tag. tag is an arbitrary string used to restoreStep() previously saved signals. This function is systematically produced when using the waveform menu items.
Examples
filter(); saveStep("Low pass 10 Hz"); whiten(); saveStep("Whiten"); restoreStep("Low pass 10 Hz"); clipStddev();
selectSignals
Syntax
selectSignals(number start, number end);
Description
Restrict the current list of signals to indexes ranging from start to end.
Examples
Rotate horizontal components to get north components parallel to the tangent of a circular array. Rotated components are exported.
n=signalCount()/3; cx=2000; cy=2000; for(i=0; i<n;i++) { restoreStep("original"); name=header(i*3, "Name"); x=header(i*3, "ReceiverX"); y=header(i*3, "ReceiverY"); a=Math.atan2(y-cy,x-cx)*180/3.141592; if(a<0) a+=360; selectSignals(i*3, i*3+2); rotateComponents(true, a, false, 0, false, 0); exportFile("/my/path/"+name+"_0001.sac"); print("Station "+name+" rotated by "+ a+" deg."); }
setHeader
Syntax
setHeader(number signalIndex, string dataName, [string dataIndex,] value);
Description
set dataName of signal having signalIndex to value. dataName may have an additional dataIndex for vectorial data (e.g. TimePick). For vectorial header data, dataIndex is mandatory.
Waveform processes described here are always applied to a temporary copy of the original signal. Hence, this function is not appropriate to modify signal header attributes of the original signal. The correct method is through Set header in menu Edit.
Examples
See signalCount() or header()
shift
Syntax
shift(number s);
Description
Shift signals by s seconds. s can a floating-point number and preferably a fraction a sampling period. The shift is made in frequency domain by altering only the phase of the signal.
Examples
Align samples to a round second for a signal sampled at 100 Hz. Current group of signal is supposed to contain only one signal (index=0).
t0=header(0, "T0"); t0rounded=Math.floor(t0*100)*0.01; shift(t0rounded-t0); setHeader(0, "T0", t0rounded);
signalCount
Syntax
integer signalCount();
Description
Returns the number of signals to process.
Examples
Sets the sampling frequency to 100 Hz for all signals
n=signalCount(); for(i=0;i<n;i++) { setHeader(i, "DeltaT", 0.01); }
subtractSignal
subtractSignals
subtractValue
stalta
system
Syntax
system(string command);
Description
Executes any system command with its arguments.
Examples
Removes file to exported right after to avoid confusion and warnings.
system("rm -f myfolder/mysignal.sac"); exportFile("myfolder/mysignal.sac", false, "SacBigEndian");
taper
Syntax
taper( Geopsy: Time range specification, number width);
Description
Multiply signal in time domain by a window function.