Help for GLLMVLN

PURPOSE:

GLLMVLN was orginally designed to move a portion of Galileo SSI UDR to a FORWARD location.  GLLMVLN can now move a portion of the Galileo SSI UDR to a FORWARD and BACKWARD location.


Its use is defined by the following example:
 
	PROCEDURE

        BODY
        GLLMVLN inp="inputfilename" outpath="outputpath"                   line=movefromline_integer movetoline=movetoline_integer                   catusr="catusername" catsrv="catservername"                   catdb="catdatabasename" [catpw="catpassword"]                   [update="update"]
	 <rest of procedure>
 
	END-PROC
 

OPERATION

GLLMVLN moves lines starting from LINE to MOVETOLINE. It blanks lines 
between LINE and MOVETOLINE-1 if a forward move is requested. All 
the data in prefixes of blanked lines are set to zero. In case if LINE is
out side SL (starting line of region of interest) then the process will
terminate. Also for READOUTMODE of SAMPLE data may occur on every other
or every fourth line. This is determined by simply looking at the TLMFMT.
If TLMFMT is HMA then data occurs on every other line else if TLMFLT is
HCA then on every fourth line. If user inputs line or movetoline to
be one on which there is no data then the program will terminate with
an error message. The following example illustrates the process.

                                                     UDR FILE AFTER
                   ORIGINAL UDR FILE               GLLMVLN PROCESSING
          -------------------------------      ------------------------------- 
          |        TELEM HEADER         |      |        TELEM HEADER         |
          |                             |      |   WITH NEW CUT_OUT_WINDOW   |
          -------------------------------      -------------------------------
          | PREFIX |     PIXEL DATA     |      | PREFIX |     PIXEL DATA     |
          -------------------------------      -------------------------------
  LINE 10 |        |                    |  10  |          BLANK              |
          -------------------------------      -------------------------------
       11 |        |                    |  11  |          BLANK              |
          -------------------------------      -------------------------------
       12 |        |                    |  12  |          BLANK              | 
          -------------------------------      ------------------------------- 
MOVETO 13 |        |                    |  13  |  10    |       10           | 
LINE      -------------------------------      ------------------------------- 
       14 |        |                    |      |  11    |       11           | 
          -------------------------------      ------------------------------- 
       15 |        |                    |      |  12    |       12           | 
          -------------------------------      ------------------------------- 
       16 |        |                    |      |  13    |       13           | 
          -------------------------------      ------------------------------- 
          |   .    |       ...          |      |  14    |       14           | 
          |   .    |       ...          |      |   .    |     ...            | 
          |   .    |       ...          |      |   .    |     ...            | 
          -------------------------------      -------------------------------

The subroutine to calculate sclk for moved lines was provided by Gary Yagi.
It explanation, as given by Gary, is as follow :

  Note : SCLK is only calculated for img[line],
           where MOVETOLINE <= LINE < SL+NL and img[line].prefix.log_seq != 0.

  Subroutine get_readout_sclk:

  Purpose: Computes spacecraft clock at readout time for a given line.

  The Galileo spacecraft clock consists of four counters which increment
  as follows:

	rim   = 60 2/3 sec
        mod91 = 2/3 sec
        mod10 = 66 2/3 msec = .066667 sec
        mod8  = 8 1/3 msec  = .008333 sec

  Note that 91 mod91 = 1 rim,
            10 mod10 = 1 mod91,
             8 mod8  = 1 mod10.

  Ignoring extended-exposure and on-chip mosaics (to be addressed later),
  SSI images are acquired in one frame cycle.  The frame cycle consists of
  a prepare step (light flood, dark-current sweep, filter wheel step, and
  exposure) and a readout step.  The length of the frame cycle, prepare step,
  and readout step is a function of the telemetry format:

                HIM       HMA        HIS        HCA    IM4,IM8    AI8
  frame time   60 2/3    30 1/3     15 1/6     8 2/3    8 2/3    2 1/3 (sec)
  prepare time  7 1/3     3 2/3      1 5/6     2        2          2/3 (sec)
  readout time 53 1/3    26 2/3     13 1/3     6 2/3    6 2/3    1 2/3 (sec)
  line rate    66 2/3    66 2/3     33 1/3    33 1/3    8 1/3    4 1/6 (msec)
  # lines        800      400        400       200      800      400

  Note that:
     frame time = prepare time + readout time
     readout time = (line rate) x (# lines)

  To avoid the use of fractions, we define our base time unit to be:
		u = 4 1/6 milliseconds.
  Then:  mod8  = 2 u
         mod10 = 8 mod8   = 16u
         mod91 = 10 mod10 = 160u
         rim   = 91 mod91 = 14560u

  The above table can be converted into units of u:

               HIM       HMA       HIS       HCA     IM8/IM4    AI8
  frame time   14560u    7280u     3640u     2080u    2080u     560u
  prepare time  1760u     880u      440u      480u     480u     160u
  readout time 12800u    6400u     3200u     1600u    1600u     400u
  line rate       16       16         8         8        2        1  (u/line)
  During a RIM, there is 1 frame cycle for HIM,
                         2 frame cycles for HMA,
                         4 frame cycles for HIS,
                         7 frame cycles for HCA, and
                        26 frame cycles for AI8.

  The first frame cycle always starts at the beginning of a RIM.  For AI8,
  for example, the 26 frame cycles will begin with u=0, 560, 1120, ...

  Extended-exposure frames are images in which the exposure time is too long
  to fit within the specified prepare step.  The exposure is allowed to "spill
  over" into the readout step.  The readout is suppressed and is initiated
  during the next frame cycle.  Therefore, extended-exposure frames require
  two frame cycles.

  On-chip mosaics are images in which multiple exposures are taken by
  suppressing the readout after each exposure.  Each exposure requires a
  frame cycle.  The readout can occur during the frame cycle containing the
  last exposure, or in the following frame cycle.

  Our first task is to determine the starting time of the frame cycle during
  which readout occurs.  Because of the possibility of extended-exposures
  and on-chip mosaics, we cannot rely on the sclkstartcnt, since this is the
  time at the start of the first frame cycle. Instead, we make use of the
  sclkstopcnt, which is the time at the end of the last frame cycle.
  Line adjustment for sample readout mode:  Normally, image lines are read
  out of the camera contiguously, i.e., image lines 1, 2, 3, ....
  In telemetry formats HMA and HCA, the image lines may be read out in
  CONTIGUOUS or SAMPLE readout mode:

       In HMA CONTIGUOUS mode, lines 1,2,3,...,400 are read out.
       In HMA SAMPLE mode, lines 1,3,5,...,799 are read out.

       In HCA CONTIGUOUS mode, lines 1,2,3,...,200 are read out.
       In HCA SAMPLE mode, lines 1,5,9,...,797 are read out.

  DATABASE CHANGES.
  Update to the database is only performed if UPDATE flag is set to update.
  If default value (i.e., NOUPDATE) of UPDATE then no database action will
  be performed. Also with NOUPDATE the name of the output file will be
  same as the name of the input file except the extension which is set to
  zero. For eg. if the name is "s0********.*"
  the output will be "s0********.0". 
  The raw record of the parent file is updated to filestatus of zero and the
  note field to indicate that it has been changed by gllmvln. Also a new raw
  record for the child file (the outputfile) is created with all the data
  being same as parent except the filename, the gaps data, and the note. The
  note section indicates that the image has been created my gllmvln by moving
  line to movetoline. The gaps calculation is performed before the image is
  written to the disk since we are suppose to write the record before the
  image is written to disk. Valid gaps are only gaps that are within the
  CUT_OUT_WINDOW. The calculation results for different conditions
  is given in the following table :
  B,A    : BEFORE AND AFTER.
  L      : BEGINNING LINE NUMBER INDICATING THE BLOCK TO BE MOVED.
  ML     : THE LINE NUMBER INDICATING WHERE THE BLOCK SHOULD BE MOVED.
  S1,ST1 : STARTING AND STOPINE LINE NUMBER OF THE BIGGEST GAP IN THE PARENT 
           IMAGE.
  S1,ST1 : STARTING AND STOPINE LINE NUMBER OF THE SECOND BIGGEST GAP IN THE 
           PARENT IMAGE.
  S1,ST1 : STARTING AND STOPINE LINE NUMBER OF THE THIRD BIGGEST GAP IN THE
           PARENT IMAGE.
  #G     : TOTAL NUMBER OF GAPS IN THE PARENT IMAGE.

  S1,ST1,S2,ST2,S3,ST3,#G CAN BE FOUND IN THE SSIRAW UNDER CATALOG.
  NOTE : ONLY GAPS THAT OCCURS WITHIN CUT_OUT_WINDOW ARE VALID GAPS. ALSO
         GLLMVLN DOES NOT DEPEND ON THIS INFORMATION FOR CALCULATIONS OF GAPS.

  ----------------------------------------------------------------------------
  |   L   |   ML   |   S1   |   S2   |   S3   |  ST1  |  ST2  |  ST3  |  #G  |
  ----------------------------------------------------------------------------
B |       |        |   305  |   396  |   81   |  144  |   0   |   0   |  2   |
  ----------------------------------------------------------------------------
A |   73  |   75   |   307  |   398  |   83   |  146  |   73  |  74   |  3   |
  ----------------------------------------------------------------------------
B |       |        |   305  |   396  |   81   |  144  |   0   |   0   |  2   |
  ----------------------------------------------------------------------------
A |   77  |   83   |   311  |   402  |   87   |  150  |   77  |  82   |  3   |
  ----------------------------------------------------------------------------
B |       |        |   393  |   400  |   0    |   0   |   0   |   0   |  1   |
  ----------------------------------------------------------------------------
A |  106  |  110   |   397  |   404  |  106   |  109  |   0   |   0   |  2   |
  ----------------------------------------------------------------------------
B |       |        |    10  |    20  |   0    |   0   |   0   |   0   |  1   |
  ----------------------------------------------------------------------------
A |    1  |  705   |     0  |     0  |   0    |   0   |   0   |   0   |  0   |
  ----------------------------------------------------------------------------

  CALCULATING GAPS :
    As mentioned before, gaps are only calculated with in CUT_OUT_WINDOW.
    Gaps are calculated based on the logical sequence number (log_seq) of a
    line in its prefix. If log_seq is zero then it is consider a gap.
    Gaps related information that is stored in database are the start and
    stop gap line numbers of three biggest gaps and number of gaps in the
    image.
    Input images may or may not have data on every line. The line left
    between each input line is calculated depending on the READOUTMODE and
    TEMFMT of the input file. If READOUTMODE is SAMPLE and TLMFMT is HMA
    then the gap is 1 and if TLMFMT is HCA then it is 3, i.e., data every
    other line or every other fourth line.
    Calculating gaps from old image is little complicated since we may or
    may not be creating a new gap and also the CUT_OUT_WINDOW has changed. 
    To do this calculation a logical array of integers of length 800 is
    created and assigned all zeros to begin with. The post condition for
    this array is as follows :

                        
                          -
                          |0, if img[line].prefix.log_seq = 0,
          logical[line] = |   where  SL<= line < SL+NL.
                          |1, otherwise.
                          -
          logical[line] = 0, for SL > line  or line >= SL+NL.

  Once this array is obtained it is sorted to obtained that first three
  biggest gaps, if there are three or more, and their start and stop
  lines. After this the log_seq number of the old image that is in the
  memory are calculated as follow :
    
                             -
                             |0, if logical[iline] = 0,
  img[line].prefix.log_seq = |   where  MOVETOLINE<= iline < SL+NL
                             |   and LINE <= line < MOVETOLINE
                             |iline, otherwise.
                             -
  img[line].prefix.log_seq = 0, for SL > line  or line >= SL+NL.


  CUT_OUT_WINDOW is calculated as follow :
  (SL=STARTING LINE, NL=NUMBER OF LINES, NP=NUMBER OF GAPS)
  There are two cases :
  1) LINE = SL
     In this case SL is set to MOVETOLINE for the new image.
     NP not incremented.**
  2) LINE is in the CUT_OUT_WINDOW of the old image.
     In this case NL is incremented by MOVETOLINE-LINE.
     NP is incremented.**
  The next check is to assure that the new SL+NL-1 does not exceed 800.
  If it does then NL is set to 800-SL-1.
  ** NP may be decremented if we loose a gap that was at the bottom of
  the image.
 

Written By: Rajesh R. Patel.
Current Cognizant Programmer: Helen B. Mortensen

History: 

02.21.97 RRP Initial Release.
03.18.97 RRP Added update flag for database update. Also if noupdate then
             to generate a .0 ext output file. Added checks for line
             and movetoline for sample mode.
06.17.97 RRP In noupdate mode append the outpath name to the file. And in the
             update mode appended correct version number to filename. (FR90055)
02.09.98 GMY Changed from C to ANSI C compiler.  Moved test images to WMS.
04.22.98 RRP AR-9152. 
             1) Modified to update LSCLK and FSCLK.
             2) Corrected spelling mistake from stopgapline1 to startgapline1.
             3) Modified tstgllmvln.pdf to use updated user information.
             4) Line 1 being not in the new calculated gaps is an error.
                When the beginning of a cut out window moved downwards it
                creates a new cut out window and the gap it creates is outside
                of the new cut out window. 
06.01.98 RRP Updated not to exceed beyound line 400 in a summation mode image.
07.17.98 RRP Updated to correctly modify LSCLK and FSCLK (AR-100469). Also
             updated to zero out rim in the line prefix when line contains
             invalid data. Updated to check for line and movetoline having
             valid values. Rewrote tstgllmvln.pdf to for more vigorous
             testing.
05.04.99 RRP Updated to extract raw num and file extension correctly from
             filename (AR-102978).
03.10.00 HBM Updated to move lines backward.
09.29.00 AXC Corrected and updated subroutine GET_READOUT_SCLK for HIM & AI8
             telemetry formats.


PARAMETERS:


CATUSR

STRING-USER NAME

CATSRV

STRING-SERVER

CATDB

STRING-DATABASE

INP

INPUT FILE NAME UDR FILES ONLY.

OUTPATH

STRING OUTPUT PATH

LINE

INTEGER-VALUE TO INDICATE THE LINE TO BE MOVED.

MOVETOLINE

INTEGER-VALUE TO INDICATE THE LOCATION TO MOVE LINE TO.

UPDATE

STRING-OPTIONAL FLAG TO INDICATE IF THE USER WANTS DATABASE UPDATES.

CATPW

STRING-OPTIONAL REQUIRED ONLY IF USER DON'T HAVE A VALID KERBEROS TICKET. .END

See Examples:


Cognizant Programmer: