Difference between revisions of "Geopsy: Waveform Scripting Language"
(→Syntax) |
(→Syntax) |
||
Line 154: | Line 154: | ||
== system == | == system == | ||
=== Syntax === | === Syntax === | ||
− | system(string command); | + | system(string '''command'''); |
+ | |||
=== Description === | === Description === | ||
Executes any system command with its arguments. | Executes any system command with its arguments. |
Revision as of 12:38, 17 January 2020
The scripting language is Javascript (a comprehensive tutorial)
Geopsy provides several additional functions for processing signals details here below
Contents
- 1 Categories
- 2 Alphabetical list
- 3 save
- 4 restore
- 5 exportFile
- 6 signalCount
- 7 header
- 8 setHeader
- 9 fastFourierTransfrom
- 10 subtractValue
- 11 subtractSignal
- 12 subtractSignals
- 13 multiply
- 14 filter
- 15 agc
- 16 whiten
- 17 stddevClip
- 18 shift
- 19 overSample
- 20 taper
- 21 cut
- 22 merge
- 23 mergeStations
- 24 decimateAmplitude
- 25 decimateTime
- 26 waveletTransform
- 27 stalta
- 28 discreteFourierTransform
- 29 rotateComponents
- 30 correlations
- 31 selectSignals
- 32 system
Categories
- Header data: header(), setHeader()
- Signal transformations: cut(), shift()
- Miscelaneous: signalCount(), save(), restore()
Alphabetical list
cut() | restore() | shift() |
exportFile() | save() | signalCount() |
header() | setHeader() | system() |
save
Syntax
save(string tag);
Description
Saves the current signals onto the stack under tag. tag is an arbitrary string used to restore() previously saved signals. This function is systematically produced when using the waveform menu items.
Examples
filter(); save("Low pass 10 Hz"); whiten(); save("Whiten"); restore("Low pass 10 Hz"); clipStddev();
restore
Syntax
restore(string tag);
Description
Restore signals previously saved onto the stack under tag.
Examples
see save()
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");
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); }
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");
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()
fastFourierTransfrom
subtractValue
subtractSignal
subtractSignals
multiply
filter
agc
whiten
stddevClip
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);
overSample
taper
taper( Geopsy: Time range specification, number width);
cut
cut( Geopsy: Time range specification );
merge
mergeStations
decimateAmplitude
decimateTime
waveletTransform
stalta
discreteFourierTransform
rotateComponents
correlations
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. A specific angle is defined for each station. angles={260.538, 294.444}; n=signalCount(); saveStep("all"); for(i=0; i<n;i++) {
restoreStep("all"); selectSignals(i*3, i*3+2); rotateComponents(true, angles[i], false, 0, false, 0); export();
}
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");