USAGE:
           xchan-units-with-si.pl [opt] file

MAKE IT EASY:
           ln -s xchan-units-with-si.pl  xchan-units

PURPOSE:
           Extracts time and measurement columns from GWR files
           of type A1* A2* G1* (and *.TSF ?)
           and prints to stdout.
           For .GGP files there is a sister script xggp.
           Options that apply identically to xggp are indicated
           by a  `+´-sign below.
                  |
                  V

OPTIONS:
 -c               + Prints an easily readable table of the channels.
 -q               - Like -c, all in one row, no decorations.
 -Q               - Like -q but comma-separated.

 
-C cset[,cset..] - units conversion presets:
                    cset = signal:factor  e.g. G1-Sig:-776.0 See remark


 -u               - Do unit conversion (still incomplete)
                    OBS! The temperatures T1-Ext T2-Ext T3-Ext are not
                    of conversion type TDVOhm; the header is wrong about this.
                    Available:
                      factors, He-lvl, SiDiodes-2 -3 -4,
Pt100V, TDOhm, TDVOhm

                    Some of these, especially the SiDiodes, are rather sophisticated functions.
                    
                    `factors´ are simple; they can be set once with the -C option,
                    and they can be hard-wired.

 -l                 (letter l, not 1) Prints a long string with all labels.
                    Use
                       eval set labs \= \'`xchan-units -l RAW_o054/A2111210.054`\'
                    to assign to a single set parameter, or
                       set labs =
`xchan-units -l RAW_o054/A2111210.054`
                    to assign to an array

 
-H c[,c...]      + Prints the header of column c (integer number).
                    Each c may be a range c1..c2

 -N c[,c...]        Prints the channel number for measurement named c.
 
 -x c[,c...]      + The requested channel numbers to retrieve.
                    Each c may be a range c1..c2 See remark
                  -
The requested channel names ...; no ranges then!

 -x H             + Print number of channels


 -I #c[,#c...]    - Signal information for specified channel number.
 -S c[,c...]      - Signal information for specified channel name.
                    Verbose mode, no data out.
                    prints   CONVERSION #chn S-name Conversion Units
                    like     CONVERSION 31 T2-Ext TDVOhm Celsius
                    upon xchan-units -S T2-Ext RAW_o054/A1121013.054
                    or   xchan-units -I 31 RAW_o054/A1121013.054


 -m
m             + Print only each m'th line

 -n r             + The number of records for output              [100000]
                    A value < 0 will suppress printing;
                    0 doesn't work, "Look at that stupid pe-herl!"
                    (Jagger&Richards)

 -s s             - Skip s records


 -l l             - Output l records (same function as -n but different
                    logic - maybe useful after a differenciated change.

  -v               - Verbose mode, helpul for debug.
 -V               - reduced verbose. Shows selected channels
                    and unit conversions.


Remarks:

 -x  - If any of the  -x channel numbers is beyond the actual range,
       the previous column will be doubled.


 -C  - We have avoided to hard-wire this particular conversion
       since the factor might change and since we might
       like to keep the Volt units but convert the other channels.
       If you want to hard-wire a factor for a particular channel, read here.


EXAMPLES:

  xchan-units -C G1-Sig:-776.0 -u -x 5..8 RAW_o054/A1091107.054 > tmp.dat

retrieves channels 5 6 7 8 and does unit conversion.
Unit conversion would be with a preset factor of 1
(since the measurement file provides no information on factors for
these particular channels).
However, for channel 5 = G1-Sig the calibration factor is imposed.

Result from example
2009 11 07 00 00 00  -278.73291440    -0.08514400     0.00000000    -0.00030520
2009 11 07 00 01 00  -285.36375680    -0.08575440    -0.00030520    -0.00030520
2009 11 07 00 02 00  -246.05221760    -0.08361820    -0.00030520     0.00000000
2009 11 07 00 03 00  -384.35303280    -0.07629390     0.00000000     0.00030520
2009 11 07 00 04 00  -416.32322400    -0.06896970     0.00000000     0.00000000
2009 11 07 00 05 00  -363.75000000    -0.07263180     0.00000000    -0.00030520
...
12345678901234567890123456789012345678901234567890123456789012345678901234567890
         1         2         3         4         5         6         7         8

Convert to mc-binary file using

tslist tmp.dat -A -g'(I4,5I3,f15.0)' -k3 -F1p,e18.10 -C3 -O`label GRAV,VALnms2` file.mc -I
tslist tmp.dat -A -g'(I4,5I3,t35,f15.0)' -k3 -F1p,e18.10 -C3 -O`label MODE,VALnms2` file.mc -I
...

xchan-units -V -x 32..34 -n -1 RAW_o054/A1100301.054
SELECTION REQUESTED: 32 33 34
SELECTION GRANTED:   32 33 34
CONVERSION 32 T2-Ext TDVOhm Celsius
CONVERSION 33 T3-Ext TDVOhm Celsius
CONVERSION 34 Temp-G1 TDVOhm Celsius


xchan-units -H 32..34 -n -1 RAW_o054/A1100301.054
32:T2-Ext 33:T3-Ext 34:Temp-G1


xchan-units -x H RAW_o054/A1100301.054

48


xchan-units -V -x 48,49 -n -1 RAW_o054/A1100301.054                                                           
SELECTION REQUESTED: 48 49
Channel 49 not in file
SELECTION GRANTED:   48 48
CONVERSION 48 RelHum2 factor,1.0 %
CONVERSION 48 RelHum2 factor,1.0 %


xchan-units -V -x 1..48 -n -1 RAW_o054/A1100301.054 | m
SELECTION REQUESTED: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
SELECTION GRANTED:   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

CONVERSION 1 LHe-Lvl GEPLHe19 %
CONVERSION 2 AGnd factor,1.0 Volts
CONVERSION 3 AD-1 factor,1.0 Volts
CONVERSION 4 AD-2 factor,1.0 Volts
CONVERSION 5 G1-Sig factor,1.0 nm/sec2
CONVERSION 6 G1-Mode factor,1.0 Volts
CONVERSION 7 G2-Sig factor,1.0 nm/sec2
CONVERSION 8 G2-Mode factor,1.0 Volts
CONVERSION 9 Dewr-P PSI_1_1 PSI
CONVERSION 10 GBal-1 factor,1.0 nm/sec2
CONVERSION 11 TX-Pwr POWERV %Power
CONVERSION 12 TX-Bal factor,1.0 Volts
CONVERSION 13 NeckT-1 SiDiode-3 Kelvin
CONVERSION 14 NeckT-2 SiDiode-3 Kelvin
CONVERSION 15 BelyT-3 SiDiode-3 Kelvin
CONVERSION 16 BodyT-4 SiDiode-4 Kelvin
CONVERSION 17 LHeLvl GEPLHe19 %
CONVERSION 18 GBal-2 factor,1.0 nm/sec2
CONVERSION 19 TY-Pwr POWERV %Power
CONVERSION 20 TY-Bal factor,1.0 Volts
CONVERSION 21 Tmp-Bal factor,1.0 Volts
CONVERSION 22 HtrCrnt POWERV %Power
CONVERSION 23 Temp-6K factor,1.0 Volts
CONVERSION 24 Temp-77 factor,1.0 Volts
CONVERSION 25 FB-Mod factor,1.0 Volts
CONVERSION 26 P1GasCl PSI-3000 PSI
CONVERSION 27 P2GasRg PSI-500 PSI
CONVERSION 28 P3CmpHi PSI-500 PSI
CONVERSION 29 P4CmpLo PSI-500 PSI
CONVERSION 30 P5CmpBl PSI-500 PSI
CONVERSION 31 T1-Ext TDVOhm Celsius
CONVERSION 32 T2-Ext TDVOhm Celsius
CONVERSION 33 T3-Ext TDVOhm Celsius
CONVERSION 34 Temp-G1 TDVOhm Celsius
CONVERSION 35 Temp-G2 TDVOhm Celsius
CONVERSION 36 Temp-TX TDVOhm Celsius
CONVERSION 37 Temp-TY TDVOhm Celsius
CONVERSION 38 Temp-TE TDVOhm Celsius
CONVERSION 39 Temp-AX TDVOhm Celsius
CONVERSION 40 Temp-CH TDVOhm Celsius
CONVERSION 41 Temp-Gt PT100V_K Kelvin
CONVERSION 42 Dwr-Htr factor,20.0 mA
CONVERSION 43 Comp-DC factor,1.0 Volts
CONVERSION 44 CH-DC factor,1.0 Volts
CONVERSION 45 Tmpr1 factor,1.0 Celsius
CONVERSION 46 Tmpr2 factor,1.0 Celsius
CONVERSION 47 RelHum1 factor,1.0 %
CONVERSION 48 RelHum2 factor,1.0 %


xchan-units -N Dwr-Htr,Temp-Gt RAW_o054/A1110101.054
41 Temp-Gt
42 Dwr-Htr

xchan-units -N Dwr-Htr,Temp-Gt RAW_o054/A1120101.054
40 Temp-Gt
41 Dwr-Htr

 


ADDING A FACTOR CONVERSION
In ~/TD/xchan-units , a perl script, find the lines below and add a factor scheme like the existing one for Dwr-Htr.
Note: The channel symbol is the one we convert to when GWR has provided one that we don't like
(they called it Dwr_Htr and our software gets upset at underscores; search for Dwr_Htr in the script.)
%conv = (  "T1-Ext" => "TDVOhm",
           "T2-Ext" => "TDVOhm",
           "T3-Ext" => "TDVOhm",
          "Temp-G1" => "TDVOhm",
          "Temp-G2" => "TDVOhm",
          "Temp-TX" => "TDVOhm",
          "Temp-TY" => "TDVOhm",
          "Temp-TE" => "TDVOhm",
          "Temp-AX" => "TDVOhm",
          "Temp-CH" => "TDVOhm",
          "Dwr-Htr" => "factor,0.02"
         );

%units = ( "T1-Ext" => "Celsius",
           "T2-Ext" => "Celsius",
           "T3-Ext" => "Celsius",
          "Temp-G1" => "Celsius",
          "Temp-G2" => "Celsius",
          "Temp-TX" => "Celsius",
          "Temp-TY" => "Celsius",
          "Temp-TE" => "Celsius",
          "Temp-AX" => "Celsius",
          "Temp-CH" => "Celsius",
          "Dwr-Htr" => "mA"
         );

.bye