The documentation was not up-to-date. In fact, there are some functions available for justifying numbers.
results with '0002'
I modified the
documentation to list all function provided by geopsy on top of usual Javascript functions.
In particular, several functions to manipulate absolute time are available. A script to split a signal into blocks of one hour could be written this way:
Code: Select all
for(t=startTime(0);elapsedSeconds(t, endTime(0))>=3600;t=addSeconds(t, 3600)) {
print(t);
cut("[abs "+t+"; delta 1h]");
exportFile("cut_"+t+".sac", false, "SacBigEndian");
restoreStep("original");
}
The functions
startTime() and
endTime() will be available in the next release 3.6.0. They are currently only available if the code is compiled from the git repository. Meanwhile a workaround can be built with
header(0, "StartTime") which returns the same information as
startTime() with a distinct format not suitable for
addSeconds() and
elapsedSeconds().
Code: Select all
function convertTime(t)
{
t=t.replace("-", "");
t=t.replace("-", "");
t=t.replace(":", "");
t=t.replace(":", "");
t=t.replace(" ", "");
return t;
}
for(t=convertTime(header(0, "StartTime"));
elapsedSeconds(t, convertTime(header(0, "EndTime")))>=3600;
t=addSeconds(t, 3600)) {
print(t);
cut("[abs "+t+"; delta 1h]");
exportFile("cut_"+t+".sac", false, "SacBigEndian");
restoreStep("original");
}