Geopsy: Waveform Scripting Language

From GeopsyWiki
Revision as of 09:01, 11 August 2011 by Marc (talk | contribs) (→‎Syntax)
Jump to navigation Jump to search

The scripting language is based on the ECMAScript scripting language, as defined in standard ECMA-262. Basic structures, variables,... are described in this document. Other references:

Geopsy provides several additional functions for processing signals details here below

Categories

Alphabetical list

cut(), exportFile(), header(), restore(), save(), setHeader(), shift(), signalCount()

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 index, string data, [number dataIndex,]);

Description

Returns the value of data from signal having index. 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", 0, header(i, "T0")+dt);
   setHeader(i, "TimePick", 1, header(i, "EndTime")-dt);
 }
 cut("Pick", 0, "Pick", 1);

setHeader

Syntax

 setHeader(number signalIndex, string dataName, [string dataIndex,] value);

Description

set data of signal having index to value. data may have an additional dataIndex for vectorial data (e.g. TimePick).

Examples

See signalCount()

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