1 Language
                        MRTCAL\ Command Language Summary

    CALIBRATE: Calibrate a single file
    MCOPY    : copy the current index to a file
    MDUMP    : DUMP the content of the Mrtcal buffers
    MFIND    : Select entries from index file
    INDEX    : Build/read the index of the IMB-FITS files
    MLIST    : List the files selected by the FIND command.
    PIPELINE : Calibrate the Current indeX
    READ     : READ IMBFITS file
    MSETUP   : Tune some program behaviours
    VARIABLE : Add Sic variables mapping internal buffers
    MWRITE   : WRITE the class data format
1 CALIBRATE
        [MRTCAL\]CALIBRATE Num[.Ver] [/WITH Num[.Ver]]

    Calibrate  the  file  indentified by its Number. The calibration scan is
    chosen implicitly by the command, except if explicitly specified through
    the option /WITH.

    Boths file numbers can be added a Version number. If not given, the lat-
    est version is selected.
1 MCOPY
        [MRTCAL\]MCOPY IndexFile

    Copy the current index (from memory) to the given file  (to  disk).  Any
    pre-existing  file  is  overwritten. This command is useful for two main
    purposes:
      - extract a subset from an index file, by combining the commands INDEX
        OPEN, MFIND (with criteria), and MCOPY, or
      - merge  several  index  files,  by combining INDEX OPEN, INDEX APPEND
        (repeated), MFIND, MCOPY.
1 MDUMP
        [MRTCAL\]MDUMP [ALL|SUMMARY|FILE|PRIMARY|SCAN|FRONTEND|BACKEND|BACK-
    DATA|ANTSLOW|ANTFAST|DATA|SUBSCANS] [/OUTPUT LogFile]

    Display  the  content  of  all  or  one section from the internal memory
    buffers. Default section is ALL sections.

    SUMMARY displays a summary of the main HDUs and the subscans (as equiva-
    lence classes). SUBSCANS displays the full list of subscans and re-reads
    the whole file to do so.

    The option /OUTPUT will redirect the display to the given file.  Default
    is on screen (STDOUT).
1 MFIND
        [MRTCAL\]MFIND  [/DATE Date] [/SCAN List] [/BACKEND Name] [/FRONTEND
    Name] [/OBSTYPE List] [/SWITCHMODE List]  [/SOURCE  Name]  [/PROJID  Id]
    [/COMPLETENESS Key] [/CALIBRATED List]

    Select IMB-FITS files from the index file and build the Current Index in
    memory. With no options, all files are selected. The  options  allow  to
    add  one  or more selection criteria. Using a wildcard ’*’ as the option
    value makes it uneffective. The number of selected entries is stored  in
    the variable MFOUND, and the index arrays are available in the structure
    MDX%.

      - /DATE: the date list, various formats are supported (see subtopic
          for details),
      - /SCAN: the scan list. See subtopic for details
      - /BACKEND: the backend name as known in the IMB-FITS file.
      - /FRONTEND: the receiver name as known in the IMB-FITS file. Note
          that there can be several receivers per file, at least one should
          match.
      - /OBSTYPE: the observation type(s) as known in the IMB-FITS file.
      - /SWITCHMODE: the switching mode(s) in the list PSW, WSW, FSW, BSW,
          and UNK(nown).
      - /SOURCE: the source name. Wildcards are allowed in the name.
      - /PROJID: the project identifier (character string).  Wildcards are
          allowed in the string.
      - /COMPLETENESS: one of the following:
            . YES: select only complete files,
            . NO: select unreadable, empty (0 subscan) or partial (missing
                  subscans) files,
            . READABLE: select partial or complete files,
            . UNREADABLE: select only unreadable or empty files
      - /CALIBRATED: select by one or several calibration statuses, in NONE,
          DONE, or FAILED.
2 /SCAN
        [MRTCAL\]MFIND /SCAN [List1] [List 2] ... [ListN]

    Scan is selected if its number is found in one of the given lists, where
    one list has the form "Val1 [TO Val2]". Typical uses are:
      /SCAN Val: select this unique value,
      /SCAN Val1 Val2 Val3: select those 3 scalar values,
      /SCAN Val1 TO Val2: select this range of values,
      /SCAN Val1 Val2 Val3 TO Val4: select these values (Val1, Val2) or
        range of values (Val3 to Val4).
2 /DATE
        [MRTCAL\]MFIND /DATE [List1] [List 2] ... [ListN]

    The file is selected if its scan date, as found in the file name, match-
    es  one of the the given lists. The dates in the lists should be strings
    in one of the following formats:
        - DD-MMM-YYYY (MMM as letters),
        - YYYYMMDD (all numbers),
        - Keyword "TODAY" or "YESTERDAY".

    A list has the form "Date1 [TO Date2]". Typical uses are:
      /DATE Date: select this unique date,
      /DATE Date1 Date2 Date3: select those 3 scalar dates,
      /DATE Date1 TO Date2: select this range of dates,
      /DATE Date1 Date2 Date3 TO Date4: select these dates (Date1,
        Date2) or range of dates (Date3 to Date4).

    Note that if the scan was started just before  midnight,  there  can  be
    subscans  on  the  next  day,  i.e. calibrated data may have a different
    date.
1 INDEX
        [MRTCAL\]INDEX [BUILD|UPDATE|OPEN|APPEND|WATCH [DirName]] [/FILE In-
    dexFile] [/RECURSIVE] [/PATTERN String] [/DATE DateString]

    This commands creates, updates, or opens a file index (database) of IMB-
    FITS files, for later use by the commands MFIND and/or CALIBRATE.
      - BUILD creates or rebuilds the index file from scratch, overwriting
          the previous one if any,
      - UPDATE creates or updates the index file if it already exists,
      - OPEN opens the index file.
      - APPEND appends in memory another index file.
      - WATCH waits for new files to appear in the IMB-FITS directory,
          and index them (INDEX UDPATE) as soon as one new is found.
    BUILD and UPDATE will implicitly OPEN the index file after creating  it.
    The default is to open the index of the current working directory.

    By default, the index file created/searched as ’index.mrt’ in the direc-
    tory where the IMB-FITS files are (DirName). However,  if  user  has  no
    right  (e.g.  write  access) to put the index file in this directory, he
    can override this default and give any IndexFile name (with  its  path).
    In  this  case, it is his responsibility to ensure a correct DirName/In-
    dexFile match. For clarity reasons, the default should be prefered  when
    possible.
2 UPDATE
        [MRTCAL\]INDEX UPDATE [DirName] [/PATTERN String] [DATE DateString]

    Build  or update the index of the IMB-FITS files. The index is stored in
    a binary file named ’index.mrt’. The command implicitly performs an  IN-
    DEX OPEN right after the UPDATE to allow direct use of the index.

    The  index lists all the files named ’iram30m-*-*s*-imb.fits’ in the di-
    rectory, including unreadable and incomplete (in terms of number of sub-
    scans)  ones.  Selection is made from this list with the various options
    and features of the commands using this list.

    The command can be called several times. The index file  is  updated  if
    needed,  in  particular  if the file readability has improved (e.g. scan
    has been completed).

    By default, the command searches for the IMB-FITS files in  the  current
    working  directory. This can be overriden thanks to the option /DIRECTO-
    RY. Note that the index file is always created in the same directory  of
    the  files  it  lists (write access is thus needed). Directory search is
    not recursive.
2 OPEN
        [MRTCAL\]INDEX OPEN [DirName]

    Load the index in memory, for subsequent use by the commands FIND and/or
    CALIBRATE.  Default is to open the index of the current working directo-
    ry.
2 /PATTERN
        [MRTCAL\]INDEX  [BUILD|UPDATE|WATCH  [DirName]]  [/FILE   IndexFile]
    [/RECURSIVE] /PATTERN String

    The  option  /PATTERN  allows to indicate which files should be indexed.
    Default is ’iram30m-*-*s*-imb.fits’, i.e. all the IMB-FITS files in  the
    directory,  but  this  can  be restricted with other patterns. Note that
    file names matter in Mrtcal: basically you can not index a file which do
    not match the default pattern above.

    For best portability, you should use a sh-compatible syntax.
2 /DATE
        [MRTCAL\]INDEX   [BUILD|UPDATE|WATCH  [DirName]]  [/FILE  IndexFile]
    [/RECURSIVE] /DATE DateString

    The option /DATE allows to restrict the files to be indexed for a  given
    date only. Accepted formats are:
        - DD-MMM-YYYY (MMM as letters),
        - YYYYMMDD (all numbers),
        - Keyword "TODAY" or "YESTERDAY".
1 MLIST

        [MRTCAL\]MLIST  [IN|CURRENT] [/TOC List] [/COLUMNS List] [/FILE Out-
    putFile] [/VARIABLE VarName]

    MLIST the content of the given index. MLIST CURRENT refers to the selec-
    tion  made with the command MFIND. MLIST IN lists all the files known in
    the memory index. Default is MLIST CURRENT.

    The output can be redirected to an  ASCII  file  thanks  to  the  option
    /FILE. Default is print to STDOUT.
2 /TOC
        MRTCAL\MLIST  [IN|CURRENT]  /TOC  [Attr1 Attr2 ... AttrN] [/VARIABLE
    VarName]

    MLIST /TOC displays the Table Of Contents of the current  index,  or  of
    the  input  (MLIST  IN) index file. A summary of the different values of
    each attribute is made, plus a final summary  of  all  the  combinations
    (setups).  The  results are accessible in the structure MTOC%. This name
    can be customized thanks to the option /VARIABLE. The attributes can be:
        - NUMBER: observation number
        - VERSION: observation version
        - TELESCOPE
        - ID
        - SOURCE
        - OBSERVED
        - SCAN
        - FRONTEND
        - BACKEND
        - OBSTYPE
        - SWITCHMODE
        - CALIBRATED: calibration status
        - DIRECTORY
    By default, OBSERVED and SCAN are used.
2 /COLUMNS
        MRTCAL\MLIST [IN|OUT] /COLUMNS [Attr1 Attr2 ... AttrN]

    MLIST  /COLUMNS  allows  to customize the columns displayed. They can be
    repeated as many time as desire. Valid values are:
        - NUMBER
        - VERSION
        - DIRECTORY
        - FITSFILE
        - MRTFILE  (the index file)
        - RECORD  (position in MRT index file)
        - WORD  (position in MRT in record)
        - TELESCOPE
        - PROJID
        - SOURCE
        - OBSERVED
        - UT
        - LST
        - AZIMUTH
        - ELEVATION
        - FRONTEND
        - SCAN
        - BACKEND
        - OBSTYPE
        - SWITCHMODE
        - COMPLETE
        - CALIBRATED
        - ITIME (last indexation time)
1 PIPELINE
        [MRTCAL\]PIPELINE [/SHOW [NONE|DONE|FAILED]]

    Calibrate iteratively all the elements in the Current  indeX.  Selection
    of the calibration scans is automatic.

    The  option  /SHOW  will update the Current indeX at the end of the pro-
    cess, and MLIST it. The optional argument indicates to populate CX  only
    with the elements with the corresponding calibration status.
1 READ
        [MRTCAL\]READ   [FileName|FileNum|FIRST|LAST|NEXT|PREV]  [/FILENAME]
    [/SUBSCAN Isub]
        [MRTCAL\]READ ZERO

    Load a file in the Mrtcal buffers:
      - the 4 first HDU in the  IMBFITS  file  (namely  Primary,  IMBF-scan,
        IMBF-frontend and IMBF-backend), and then read
      - the 3 HDU IMBFITS-backendXXX, IMBFITS-antenna and IMBFITS-subreflec-
        tor (this latter not implemented) for the subscan number  Isub  (de-
        fault 1)
      - the on-track part of the DATA column of the HDU IMBFITS-backendXXX
          is read (take care that it may be large).

    Without  argument,  the command will try to read again the current file-
    name.  Else the command argument can be either
      - the file name when the /FILENAME option is present,
      - the file number (and optionally its version) in the Input index, of
          the form Num (or Num.Ver),
      - the FIRST|LAST file in Current indeX,
      - the NEXT|PREVIOUS file in Current indeX, considered from previous
          call to the command.

    The reference file (for NEXT or PREVIOUS) in Current indeX is  reset  by
    the  command MFIND. READ ZERO also reset the reference file and does not
    read any file.
1 MSETUP
        [MRTCAL\]MSETUP [BOOKKEEPING|CALIBRATION|OUTPUT|PIPELINE|DEBUG]

    Tune global 5  different  kinds  of  behaviour  for  the  CALIBRATE  and
    PIPELINE commands:
        BOOKKEEPING: how the input data is handled
        CALIBRATION: how the calibration is performed
        OUTPUT: how the spectra are output in CLASS format
        PIPELINE: how the pipeline works.
        DEBUG: which debugging messages are displayed.

    The  MSETUP command without arguments will display the current status of
    all these categories. MSETUP CATEGORY without further argument will dis-
    play the current status of the named category.
2 BOOKKEEPING
        [MRTCAL\]MSETUP BOOKKEPPING SPACE value

    Set  the  amount  (in MB) of RAM memory used to buffer the input backend
    data. This allows the user to handle huge data amount on a small comput-
    er, even though it will be slower.
2 CALIBRATION
        [MRTCAL\]MSETUP CALIBRATION Keyword Switch

    [MRTCAL\]MSETUP CALIBRATION SCAN NEAREST|LINEAR

    Define  how  to select the calibration scan used calibrate science data.
    In NEAREST mode, the scan nearest in time will be used. In LINEAR  mode,
    the  algorithm  will linearly interpolate calibration parameters between
    the two nearest calibration scans. Default is NEAREST.

    [MRTCAL\]MSETUP CALIBRATION OFF NEAREST|LINEAR

    Define how to select the OFF data matching the current ON data. In NEAR-
    EST mode, the OFF data nearest in time will be used. In LINEAR mode, the
    algorithm will linearly interpolate between the two nearest OFF spectra.
    This tuning is only meaningfull for On-The-Fly data. Default is NEAREST.

    [MRTCAL\]MSETUP CALIBRATION TSYS LINEAR|NEAREST

    Define how the applied system temperature  will  be  interpolated  as  a
    function  of frequency. In NEAREST mode, the algorithm will use the sys-
    tem temperature computed at the nearest RF frequency. In LINEAR mode, it
    will  linearly  interpolate the system temperatures surrounding the cur-
    rent frequency. Default is LINEAR.

    [MRTCAL\]MSETUP CALIBRATION BANDWIDTH value

    Setup the desired calibration bandwidth in MHz. The nearest  value  that
    allows  the  division  of  the good spectra channels of each chunkset in
    equal virtual chunk sizes, will be used. A value of implies the  use  of
    the  native hardware chunk size. The native hardware chunk size will au-
    tomatically be used every time the user will require a larger bandwidth.
    Default is 20 MHz.

    [MRTCAL\]MSETUP CALIBRATION FEEDBACK PIXEL|SET|ELEMENT

    Tune the granurality of the calibration results (Tsys, Tcal, Trec, ...).
    The median value per pixel, per chunkset, or per chunk element  will  be
    printed  in the PIXEL, SET, or ELEMENT mode, respectively. One value per
    chunk element may result in very long lists  when  using  virtual  chunk
    sizes (see MSETUP CALIBRATION BANDWIDTH). Default is SET.
2 OUTPUT
        [MRTCAL\]MSETUP OUTPUT Keyword Switch

    [MRTCAL\]MSETUP OUTPUT SPECTRA YES|NO

    Indicate whether the calibration spectra should be written in the output
    CLASS file. Default is YES, i.e., write the results.

    [MRTCAL\]MSETUP OUTPUT USERSECTION YES|NO

    Indicate whether the MRTCAL user section  should  be  written  for  each
    CLASS  observation.  Default is NO, as this is very experimental to test
    future use CLASS, i.e., we do not warrants its stability.

    [MRTCAL\]MSETUP OUTPUT CHUNK ELEMENT|SET

    Write one CLASS spectra per CHUNK ELEMENT or per  CHUNKSET.  Default  is
    CHUNKSET.

    [MRTCAL\]MSETUP OUTPUT INTEGRATION CYCLE|SUBSCAN|SCAN

    Write  one  CLASS  spectra per phase cycle, or per subscan, or per scan.
    Only tracked observations are affected. On-The-Fly observations are  al-
    ways written per phase cycle. The default is SCAN.
2 PIPELINE
        [MRTCAL\]MSETUP PIPELINE ONERROR CONTINUE|STOP

    Set  the  error recovery mode of the PIPELINE command. In STOP mode, any
    raised error will immediately stop the pipeline. In CONTINUE  mode,  the
    pipeline  will ontinue to iterate with the next index item when an error
    is raised on the current item. Default is CONTINUE.
2 DEBUG
        [MRTCAL\]MSETUP DEBUG [Topic [Subtopic]] ON|OFF

    Turn ON or OFF debugging messages for the given topics:
        - IMBFITS [ALLOCATION|OTHERS]: for the IMB-FITS reader,
        - INDEX [ALLOCATION|OTHERS]: for the index.mrt reading/writing,
        - SYNCHRONIZATION: time synchronization of the tables,
        - CALIBRATION [ALLOCATION|BOOKKEEPING|OTHERS]: for the calibration
      process.

    Use MSET DEBUG ON|OFF to turn ON or OFF all the debug messages.
1 VARIABLE
        [MRTCAL\]VARIABLE

    Create the Sic structures mapping the Mrtcal internal buffers, namely:
      - IMBF%PRIM, IMBF%SCAN, IMBF%FRONT, IMBF%BACK map the  FITS  HDUs  for
        the scan,
      - SUBS%BACKDATA,  SUBS%ANTSLOW, SUBS%ANTFAST map the FITS HDUs for one
        subscan,
      - IMBDATA%TIME and IMBDATA%IMBF% describe a portion of data of the DA-
        TA table,
      - MHEAD%KEY,  MHEAD%PRI, MHEAD%CAL map the sections of the index entry
        which was read.

    Note that these variables are not updated when the buffers are  changed.
    For safety they should be updated by recalling the command.
1 MWRITE
        [MRTCAL\]MWRITE

    Convert  the  chunks as Class observations and WRITE them in the current
    Class output file. The chunks are written one by one or are stitched  by
    chunk set before writing according to the MRTCAL\SET BYCHUNK rule.
1 ENDOFHELP





























































