multicolorfits.draw_progress_bar#

multicolorfits.draw_progress_bar(percent, barlength=20, prefix='', suffix='')[source]#

Dependency-free ANSI progress bar written to stdout.

This is the built-in helper used by reproject_cube() when print_progress=True. It needs no third-party packages and stays in the public API (including the legacy alias drawProgressBar) for scripts and back-compat. For richer bars in your own loops, use tqdm directly — multicolorfits does not wrap or depend on it.

Parameters:
  • percent (float) – Completion fraction in [0, 1] (values outside that range are still rendered; callers usually clamp).

  • barlength (int, optional) – Number of character cells in the bar body (default 20).

  • prefix (str, optional) – Text printed immediately before / after the [====--] xx.xx% segment (e.g. a label and a "i of n" counter).

  • suffix (str, optional) – Text printed immediately before / after the [====--] xx.xx% segment (e.g. a label and a "i of n" counter).

Notes

Each call overwrites the current line with \r. Pass a trailing newline in suffix (as reproject_cube does on the final update) to leave the finished bar on screen.

Examples

Built-in style (percent updates):

import multicolorfits as mcf
n = 10
for i in range(n):
    # ... do work ...
    mcf.draw_progress_bar((i + 1) / n, prefix='Working ',
                          suffix='  %d of %d' % (i + 1, n))
mcf.draw_progress_bar(1.0, prefix='Working ',
                      suffix='  %d of %d\n' % (n, n))

Spectral cube reprojection (uses this helper internally):

cube_out = mcf.reproject_cube(
    cube, hdr_from, hdr_to, print_progress=True)

Same cube loop with tqdm instead (optional third-party):

from tqdm import tqdm
planes = []
for z in tqdm(range(cube.shape[-3]), desc='Reprojecting'):
    planes.append(
        mcf.reproject_image(cube[z], hdr_from, hdr_to))
cube_out = np.array(planes)

See also

reproject_cube

set print_progress=True to drive this bar per spectral plane.