Difference between revisions of "Geopsy: Waveform Command Line"

From GeopsyWiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
* Execute all actions listed in "scriptfile.qs"
 
* Execute all actions listed in "scriptfile.qs"
  
To save the results, the script must end with an '''export'' command:
+
To save the results, the script must end with an [[Geopsy: Waveform Scripting Language#exportFile|'''exportFile''']] command:
  
 
   [...] // Some processings come here
 
   [...] // Some processings come here
   exportFile("output_file.sac", "SAC");
+
   exportFile("output_file.sac", false, "SAC");
  
 
Input and output formats for signal files are of course any of the supported file formats for input and output.
 
Input and output formats for signal files are of course any of the supported file formats for input and output.
Line 23: Line 23:
 
== Setting header information of ascii files ==
 
== Setting header information of ascii files ==
  
Ascii files does not refer to a particular format. It describes the encoding of each character, other option can be: ASCII, UNICODE, UTF8, UTF16,... Hence, text files might have arbitrary format. This is particularly true for organizing header information where absolutely no standard exists. For the signal samples this is less the case. They are usually organized in various columns or in several bunch of data separated by special characters (see [[Geopsy:Supported file formats|supported file formats]] for details.
+
Ascii files does not refer to a particular format. It describes the encoding of each character, other option can be: ASCII, UNICODE, UTF8, UTF16,... Hence, text files might have arbitrary format. This is particularly true for organizing header information where absolutely no standard exists. For the signal samples this is less the case. They are usually organized in various columns or in several bunch of data separated by special characters (see [[Geopsy:Supported file formats|supported file formats]] for details).
  
 
The annoying thing with this kind of file is that you cannot automatically convert or process them in a script. This can be solved by using a script for setting the basic header information upon loading the files.
 
The annoying thing with this kind of file is that you cannot automatically convert or process them in a script. This can be solved by using a script for setting the basic header information upon loading the files.
Line 31: Line 31:
 
"setheader.qs' might contain these commands for a text file with three components to set sampling frequency to 100 Hz (see [[Geopsy: Waveform Scripting Language|waveform scripting language]] for details):
 
"setheader.qs' might contain these commands for a text file with three components to set sampling frequency to 100 Hz (see [[Geopsy: Waveform Scripting Language|waveform scripting language]] for details):
  
   setHeader(0, "DeltaT", 0, 0.01);
+
   for(i=0; i<3; i++) {
  setHeader(1, "DeltaT", 0, 0.01);
+
    setHeader(i, "SamplingFrequency", 100);
  setHeader(2, "DeltaT", 0, 0.01);
+
    setHeader(i, "StartTime", "2000-01-01");
   exportFile("output_file.sac", "SAC");
+
  }
 +
   exportFile("output.mseed", "MiniSeed");
  
   $ geopsy tmp/text_file -waveform setheader.qs
+
   $ geopsy your_input_text_file -waveform setheader.qs
 +
  Loading your_input_text_file...
 
   -----INFO----- Loading ASCII Columns----
 
   -----INFO----- Loading ASCII Columns----
   The ASCII format without header imply that you fill in the correct information yourself in a table. Choose menu "view/new table" and change the DeltaT (inverse of the sampling frequency) to allow correct plotting in a graphic
+
   The ASCII format without header implies that you fill in the correct information yourself
  tmp/text_file
+
  in a table. Choose menu "view/new table" and change the SamplingPeriod (or SamplingFrequency)
  File tmp/output.mseed already exists, saving to /home/mwathele/tmp/output.mseed
+
  to allow correct plotting in a graphic
  
Once converted to miniseed, the sampling frequency is properly set and the files can be handled in a much easier way. A better script should adapt itself to the number of input signals:
+
Once converted to miniseed, the starting time and the sampling frequency are properly set and the files can be handled in a much easier way. A better script should adapt itself to the number of input signals:
  
 
   n=signalCount();
 
   n=signalCount();
 
   for(i=0;i<n;i++) {
 
   for(i=0;i<n;i++) {
     setHeader(i, "DeltaT", 0, 0.01);
+
     setHeader(i, "SamplingFrequency", 100);
 +
    setHeader(i, "StartTime", "2000-01-01");
 
   }
 
   }
   exportFile("output_file.sac", "SAC");
+
   exportFile("output.mseed", "MiniSeed");

Latest revision as of 08:57, 6 September 2022

All the scripts that can be executed in waveform console can be also processed through the command line interface.

 geopsy -waveform scriptfile.qs input_file.mseed

For instance, this command does the following tasks:

  • Import file "input_file.mseed"
  • Execute all actions listed in "scriptfile.qs"

To save the results, the script must end with an exportFile command:

 [...] // Some processings come here
 exportFile("output_file.sac", false, "SAC");

Input and output formats for signal files are of course any of the supported file formats for input and output.

 geopsy -export-formats
 geopsy -import-formats

These two commands list the supported file formats on input and output.

"scriptfile.qs" can contain any series of command specified in waveform scripting language.

Setting header information of ascii files

Ascii files does not refer to a particular format. It describes the encoding of each character, other option can be: ASCII, UNICODE, UTF8, UTF16,... Hence, text files might have arbitrary format. This is particularly true for organizing header information where absolutely no standard exists. For the signal samples this is less the case. They are usually organized in various columns or in several bunch of data separated by special characters (see supported file formats for details).

The annoying thing with this kind of file is that you cannot automatically convert or process them in a script. This can be solved by using a script for setting the basic header information upon loading the files.

 geopsy -waveform setheader.qs input_file.txt

"setheader.qs' might contain these commands for a text file with three components to set sampling frequency to 100 Hz (see waveform scripting language for details):

 for(i=0; i<3; i++) {
   setHeader(i, "SamplingFrequency", 100);
   setHeader(i, "StartTime", "2000-01-01");
 }
 exportFile("output.mseed", "MiniSeed");
 $ geopsy your_input_text_file -waveform setheader.qs
 Loading your_input_text_file...
 -----INFO----- Loading ASCII Columns----
 The ASCII format without header implies that you fill in the correct information yourself
 in a table. Choose menu "view/new table" and change the SamplingPeriod (or SamplingFrequency)
 to allow correct plotting in a graphic

Once converted to miniseed, the starting time and the sampling frequency are properly set and the files can be handled in a much easier way. A better script should adapt itself to the number of input signals:

 n=signalCount();
 for(i=0;i<n;i++) {
   setHeader(i, "SamplingFrequency", 100);
   setHeader(i, "StartTime", "2000-01-01");
 }
 exportFile("output.mseed", "MiniSeed");