### Numbering

When MRTCAL opens an index file (usually index.mrt), it builds what is called the input index in memory. However, for many reasons the contents of the index file may be disordered. In order to give friendly lists to the user, the input index is implicitly sorted by observing date, then scan number, then backend identifier1. For example, the following files are ordered like this:

    MRTCAL> $ls *.fits
    iram30m-4mhz-20100930s200-imb.fits  iram30m-fts-20100930s201-imb.fits
    iram30m-4mhz-20100930s201-imb.fits  iram30m-wilma-20100930s200-imb.fits
    iram30m-fts-20100930s200-imb.fits   iram30m-wilma-20100930s201-imb.fits
    MRTCAL> mlist in  ! "in" lists the input index
      N.V ProjId    Source         Date          UT     Scn Backe  ObsType    Swi Calibr
      1.1 054-09   CONTROLD     30-SEP-2010  20:52:47.0 200 4MHZ  CALIBRATE   PSW NONE
      2.1 054-09   CONTROLD     30-SEP-2010  20:52:47.0 200 WILMA CALIBRATE   PSW NONE
      3.1 054-09   CONTROLD     30-SEP-2010  20:52:47.0 200 FTS   CALIBRATE   PSW NONE
      4.1 054-09   CONTROLD     30-SEP-2010  20:53:37.0 201 4MHZ  TRACKED     PSW NONE
      5.1 054-09   CONTROLD     30-SEP-2010  20:53:37.0 201 WILMA TRACKED     PSW NONE
      6.1 054-09   CONTROLD     30-SEP-2010  20:53:37.0 201 FTS   TRACKED     PSW NONE

From the input index, the user has to build the current index2 with MFIND. They can be identical (MFIND called without argument), or the current index can be a subset of the input index. For example:

    MRTCAL> mfind /backend 4mhz
    I-FIND,  2 entries in Current indeX
    MRTCAL> mlist  ! No argument: list the current index
      N.V ProjId    Source         Date          UT     Scn Backe  ObsType    Swi Calibr
      1.1 054-09   CONTROLD     30-SEP-2010  20:52:47.0 200 4MHZ  CALIBRATE   PSW NONE
      4.1 054-09   CONTROLD     30-SEP-2010  20:53:37.0 201 4MHZ  TRACKED     PSW NONE

The number which can be seen in the first column is used by several commands to identify the file to be processed (for example, CALIBRATE 1). In most of the cases, especially when dealing with a data set which does not evolve, using this number in procedures is acceptable. However, there are some use cases where one needs to pay attention:

- INDEX UPDATE: if new files are to be added to an old index file, they will be inserted according to the sorting rule described earlier. If those files were observed after the old ones (e.g. if adding a new observation session), they will be appended to the end of the index, so this makes no problem. But if a file has to be inserted before, this will modify the entry numbers.
- INDEX OPEN /RECURSIVE: when opening several directories (one index file each), one has to be careful that, again, all the files will be sorted with the same rule. This basically means that the entry numbers which are seen when opening a single directory are not the same when this directory is opened together with other directories.