gvf_transform is a utility for transforming data from 
binary GVF format to ascii VGOSDA and back. Transformation
Transformation VGODSA --> Binary GVF accepts VGODA database created by

1) PIMA from fringe output;
2) gvf_transform from existing binary GVF;
3) vgosDxConvertor db2da from a binary file in VGOSDB format.
   If gvf_transform detects that the database was generated by
   vgosDxConvertor, it performs a number of transformations to
   be compliant with pSolve and discards a number of fields specific 
   for nuSolve package. The reverse transformation will not result
   in the original database in VGOSDA format.

Binary GVF <--> ascii VGOSDA for databases generated by PIMA or
pSolve is lossless. 

Use cases:

1)  To transform the data from GVF format to VGOSDA.
 
    gvf_transform -to_ascii envelop_file output_file [repo]
 
    where envelop_file is the envelop file for the dataset in GVF
    format. Optional argument repo defines the repository.
    If argument repo is omitted, then gvf_transforms checks
    environment variable VCAT_REPO that defines repository.
    If VCAT_REPO is not set, the default repository OBS is used.
 
    The directory name and extension of the envelop file 
    can be omitted.
  
    Examples: 
 
       gvf_transform -to_ascii /vlbi/gvf/env/20190801_p_v002.env /tmp/p1.vda
 
       gvf_transform -to_ascii 20190801_p_v002 /tmp/p2.vda OBS

2) To transform the database from VGOSDA to GVF.
 
    gvf_transform -to_binary input_file envelop_file [repo]
 
    The envelop file may have the following forms:
 
    a) full path name of the envelop file;
 
    b) base envelop file name without path and extension;
 
    c) @ form. In that form, the names of binary files in GVF format will
       be used as they are defined in FILE section. The envelop file name
       will be derived from the file names defined in the FILE section.
 
       This form is useful for a pair of transformation: 
       GVF --> VGOSDA (editing) --> GVF.
 
    d) @x form, where "x" is a low case letter. In that case the bgf file
       names will be in form Date_Suffix_Expname_SEG_v001.bvg,
       where Date is the date of the first observation in yyyymmdd format,
       Suffix ix the letter that followed @ in the second argument,
       Expname is the experiment name in low case extracted from EXP_CODE
       locde; SEG is the segment name (fr1, fr2, cl1, sl1, th1). The envelop
       file will be Date_Suffix_v001.env if no th1 segment is found 
       or Date_Suffix_v002.env otherwise.
 
     Examples: 
 
       gvf_transform -to_binary   /s0/vda/2019/19MAR04VG.vda vt9063_v001.env
 
       gvf_transform -to_binary   /s0/vda/2019/19MAR04XA.vda @a
 
       gvf_transform -to_binary   /s0/vda/2019/19MAR07XI.vda @   INT
 
3) Python3 wrapper gvf_export.py and gvf_import.py are provided.

   3a) gvf_export.py. 

       Usage: gvf_export.py db_name dir_out [compress|nocompress] [repo]

       The first mandatory argument is database name in one of the form:
       Date_Suffix_Version or Date_Suffix where Date_Suffix is the 8-character
       long root database name, Suffix is the 1-character long suffix and 
       Version is the 4-character long version. If the database version is 
       omitted, the last version is taken. gvf_export.py reads database in 
       binary GVF format from the specified GVF repository, creates a file in 
       the output directory in VDA format that corresponds to the input file, 
       and it may compresses it with bzip2, depending whether the third 
       argument is compress or nocompress. If the third argument is omitted, 
       gvf_export.py compresses the output file. The extension of the output 
       file is either .vda.bz2 (compressed with bzip2) or .vda (no compression).
       If argument repo is omitted, then gvf_export.py checks environment 
       variable VCAT_REPO that defines the repository. If VCAT_REPO is not 
       set, the default repository OBS is used.

       Examples:

       gvf_export.py 20221114_a 
       gvf_export.py 20221121_p nocompress
       gvf_export.py 20231023_m compress   INT


   3b) gvf_import.py 

       Usage: gvf_import.py input_vda_file [repo]

       The first mandatory argument input_vda_file specifies the database file 
       in VGOSDA format that can be compressed with bz2, gzip, or xz. 
       gvf_import.py converts that database to the binary format and puts it
       in the given GVF repository. If argument repo is omitted, then 
       gvf_import.py checks environment variable VCAT_REPO that defines the 
       repository. If VCAT_REPO is not set, the default repository OBS is used.
     
       Examples:

       gvf_import.py /tmp/20061209_k.vda.bz2 
       gvf_import.py /tmp/20230930_j.vda     INT
