Munipack ‒ Common Options

# Common Options

Commonly used options and switches.

## Verbose Output

`$ munipack --verbose ... action and so on ...`

This switch enables detailed reports. The additional information can be useful for exploring of processing or in doubts.

Without this switch, Munipack respects standard UNIX philosophy: Only errors are reported. A silent run means no errors. It is very usefully for processing of large datasets because only important errors should be delivered to users.

## Numerical Data Types

    -B [8|16|32|-32]
    --bitpix[=8|16|32|-32]

Select bits per pixel of output images. Possible values are: 8 (0-255), 16 (0-65535), 32 (0-4294967296) for integer non-negative numbers of ℕ set and -32 (-10-38 .. 1038, 6 decimal digits) for real numbers of ℝ set, (values in braces indicates numerical ranges).

The parameter is set according to BITPIX in original frames for photometric pre-corrections or set to -32 for derived images. Defaults are usually satisfactory.

General guidelines: An optimal bitpix for raw (instrumental) data is 16 (default) which covers a full range of digital cameras. The representation occupies 2 × width × height bytes. Some out of range (rare) values will be cut-off.

The representing by real numbers (eg. -32) is recommended value for images intended for further processing because saves numerical precision and their numerical range (but occupies of twice more space with respect to 16).

8-bits reduces range (eg. suppress dynamical range) and 32 wastes a lot of storage place only.

## Input Filenames For A Single Output

    file(s).fits
    @[file.lst]
    -

The list of files to process. Usually as a names with wildcards (* or ?). Use @ (at) or - (dash) to read from a standard input. (@ character is used in the same meaning in classical softwares Iraf and Midas.)

For single output file (actions with `-o|--output` like bias, dark, flat and timeseries), the input files can be passed as command line arguments or in a file. Arguments can be used by many ways:

- Filenames: `munipack ... one.fits more.fits red.fits nightmare.fits`
- Wildcards: `munipack ... *.fits`
- Generated: `munipack ... `find dir/ -name '*.fits'``

The input from file is initiated with @ character followed a file-name (file.lst). The file is a plain text file with single file per line. As example, the content of the file.lst equivalent to the previous example:

    one.fits
    more.fits
    red.fits
    nightmare.fits

The file can be prepared by hand or prepared by the command with using of shell redirection and find utility:

    $ ls *.fits > file.lst                  # files in current directory
    $ find dir/ -name '*.fits' > file.lst   # all files in dir/, recursive
    $ ls *.fits | munipack dark -           # filenames are piped from ls

## Input Filenames For Multiple Outputs

`file(s)[,result(s)] @[file.lst] -`

The list of files to process. Usually as a names with wildcards (* or ?). The optional parameter `result(s)` can be used for a direct setting of a new filename. Use @ (at) or - (dash) to read from a standard input.

For multiple output (actions without `-o|--output` like find, aphot, astrometry and phcal), the input files are manipulated the same way as in previous example. Moreover, the twines of files separated by a comma are recognized and result files can be named differently.

Examples similar to previous ones:

- Filenames: `munipack ... one.fits,two.fits red.fits,green.fits`
- Wildcards: `munipack ... *.fits`
- Generated: `munipack ... `find /dir -name '*.fits'``

(No change for both wildcard and generated ones.)

    one.fits,two.fits
    red.fits,green.fits

    $ for F in *.fits; do echo ${F},${F%.fits}_result.fits; done > file.lst

Last example illustrates, how a lot of files can be easy renamed and used

Note, that renaming can be modified by a powerful way as describes Advanced Output Filenames section.

## Simple Output Filenames

    -o name
    --output name

Specify an output file name for a single file. If the option is not presented, the output name is derived from the particular action name.

## Target Directory

    -t directory
    --target-directory=directory

It would be useful to store output files in a specified directory. The most typical use is storing modified files in a working directory when original files are untouched.

## Backup Strategy

Backup strategy for Munipack modifies traditional conventions. Backups are switched-on by default (equivalent to use of -b option in every command). This is the important difference to other FITS relates utilities. The observed data are too unique, valuable and once-in-a-lifetime for ignoring backups. The default behavior can be switched-off by using option `--backup off`.

For a comfortable use of routines, the backup method with just only once-time copy is chooses. This may by potentially dangerous to data because older (original) files are replaced.

The recommended way for processing is to use a working directory, different to a directory with original data. Moreover, it is highly recommended to store original data with permission flag set to read-only.

The parameter `-t` (`--target-directory`) can be used for this:

    $ munipack -t ~/work dark flat.fits *.fits

Ones simply reads original data as `sources.fits` and store results in `~/work/sources.fits`.

## Backup Options

    -b
    --backup[=method]

Backup options (default: on). Their syntax, environment variables and behavior exactly corresponds to GNU core util's Backup options.

    -S suffix
    --suffix=suffix

Specify a suffix for backup files. Defaults set to tilde (~).

Certain characters (%,#,..) may interfere with bash and general regular expression syntax which is used to recognize text patterns and ones are not recommended as suffixes.

Sometimes, perhaps to save a some disk space, backups can be just switch-off with setting of the environment variable:

    $ export VERSION_CONTROL=off

## Advanced Output Filenames

    -O
    --pattern pattern (default: (.+)\.(.+))
    --mask mask (default: empty)
    --format format (default: empty)

Specify a regular expression or a format to describe of an output file name(s). The `-O` switch-on the advanced functionality (else the simple backup with suffix is used). The pattern is a regular expression used to matching and on will usually include bracket expression for back-references. The back-references can be used in mask with \number. To test a regular expression, use sed: `sed s/pattern/mask/`. `--mask` is used for newly created files whilst `--backup` for specify of backup files.

The default pattern splits filenames onto two parts name and extension separated by a dot (\.). The pattern recognizing algorithm uses Regular Expression rules syntax. The parts are accessible via \number operator. The \0 means original filename, \1 name and \2 extension.

The format is a standard format for output of sequence images. To test a format, use `printf "out%d.fits",666`.

When just only `-O` is specified, backups are disabled.

When the advanced filename processing is set, the options `-t,-S,-b` are ignored, because their functionality can be simply simulated.

Examples:

    # store outputs in /tmp directory : -O --mask '/tmp/\0'
     barnard_0011R.fits -> /tmp/barnard_0011R.fits

    # modify suffix: -O --pattern '(.+)\.fits' --mask '\1.fit'
     barnard_0011R.fits -> barnard_0011R.fit

    # modify filename: -O --pattern '(.+)\.(.+)' --mask '\1_D.\2'
     barnard_0011R.fits -> barnard_0011R_D.fits

    # alternate backups: -O --mask '\0.bak'
     barnard_0011R.fits -> barnard_0011R.fits.bak

    # overwrite output: -O --mask '!\0'
     barnard_0011R.fits -> !barnard_0011R.fits

    # list of numbered files: -O --format 'out_%02d.fits'
     barnard_0001R.fits -> out_01.fits

    # disable backups: -O
     barnard_0001R.fits -> barnard_0001R.fits

See also: wxRegEx, wxString