# Path: cubical/tools/logger.py
# def logToFile(filename, append=False):
# def getLogFilename():
#     def __init__(self, logger, level, color=None, bold=None):
#     def write(self, message, level_override=None, print_once=None):
#     def print(self, *args):
#     def __init__(self, logger, verbose=None, log_verbose=None):
#     def verbosity(self, set_verb=None):
#     def log_verbosity(self, set_verb=None):
#     def __call__(self, level, color=None):
#     def warn(self, msg, color=None, print_once=None):
#     def error(self, msg, color="red", print_once=None):
#     def info(self, msg, color=None, print_once=None):
#     def critical(self, msg, color=None, print_once=None):
#     def debug(self, msg, color=None, print_once=None):
#     def exception(self, msg, color=None, print_once=None):
#     def print(self, *args):
#     def write(self, message, level=logging.INFO, verbosity=0, print_once=None, color=None):
# def enableMemoryLogging(level=1):
# def set_subprocess_label(label):
# def get_subprocess_label():
# def _sigusr1_handler(signum, frame):
# def _sigusr2_handler(signum, frame):
#     def setMemoryLogging(level):
#     def filter(self, event):
#     def __init__(self, fmt, datefmt, strip=True):
#     def label(self, record):
#     def format(self, record):
# def init(app_name):
# def getLogger(name, verbose=None, log_verbose=None):
# def setBoring(boring=True):
# def setGlobalVerbosity(verbosity):
# def setGlobalLogVerbosity(verbosity):
# def setSilent(Lname):
# def setLoud(Lname):
# class _DefaultWriter(object):
# class LoggerWrapper(object):
# class LogFilter(logging.Filter):
# class ColorStrippingFormatter(logging.Formatter):
# GB = float(1024 ** 3)
#                 KEYS = _log_memory_types[memlevel]
# 
# Path: cubical/tools/ModColor.py
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
#     HEADER = ''
#     OKBLUE = ''
#     OKGREEN = ''
#     WARNING = ''
#     FAIL = ''
#     ENDC = ''
# def disableColors():
# def Str(strin0,col="red",Bold=True):
# def Sep(strin=None,D=1):
# def Title(strin,Big=False):
# def disable():


from builtins import range
from past.builtins import cmp
from functools import cmp_to_key
from cubical.tools import logger, ModColor
from collections import OrderedDict
import numpy as np
import re
import cubical.plots as plots
        import pylab
            del self.order[self.order.index(name)]
            self.ms.removecolkeyword('BITFLAG','FLAGSET_%s'%name)
        # write new list of bitflags
        self.ms._putkeyword('BITFLAG','FLAGSETS',-1,False,','.join(self.order))
        self.ms.flush()

        return mask

def flag_chisq (st, GD, basename, nddid):
    """
    Flags timeslots and channels based on accumulated chi-squared statistics.

    Args:
        st (:obj:`~cubical.statistics.SolverStats`):
            Object containing solver statistics.
        GD (dict):
            Dictionary of global options.
        basename (str):
            Base name for output plots.
        nddid (int):
            Number of data descriptor identifiers.

    Returns:
        np.ndarray:
            Flag cube of shape (n_times, n_ddids, n_chans).
    """

    chi2 = np.ma.masked_array(st.timechan.chi2, st.timechan.chi2==0)
    total = (~chi2.mask).sum()
    if not total:

# Path: cubical/tools/logger.py
# def logToFile(filename, append=False):
# def getLogFilename():
#     def __init__(self, logger, level, color=None, bold=None):
#     def write(self, message, level_override=None, print_once=None):
#     def print(self, *args):
#     def __init__(self, logger, verbose=None, log_verbose=None):
#     def verbosity(self, set_verb=None):
#     def log_verbosity(self, set_verb=None):
#     def __call__(self, level, color=None):
#     def warn(self, msg, color=None, print_once=None):
#     def error(self, msg, color="red", print_once=None):
#     def info(self, msg, color=None, print_once=None):
#     def critical(self, msg, color=None, print_once=None):
#     def debug(self, msg, color=None, print_once=None):
#     def exception(self, msg, color=None, print_once=None):
#     def print(self, *args):
#     def write(self, message, level=logging.INFO, verbosity=0, print_once=None, color=None):
# def enableMemoryLogging(level=1):
# def set_subprocess_label(label):
# def get_subprocess_label():
# def _sigusr1_handler(signum, frame):
# def _sigusr2_handler(signum, frame):
#     def setMemoryLogging(level):
#     def filter(self, event):
#     def __init__(self, fmt, datefmt, strip=True):
#     def label(self, record):
#     def format(self, record):
# def init(app_name):
# def getLogger(name, verbose=None, log_verbose=None):
# def setBoring(boring=True):
# def setGlobalVerbosity(verbosity):
# def setGlobalLogVerbosity(verbosity):
# def setSilent(Lname):
# def setLoud(Lname):
# class _DefaultWriter(object):
# class LoggerWrapper(object):
# class LogFilter(logging.Filter):
# class ColorStrippingFormatter(logging.Formatter):
# GB = float(1024 ** 3)
#                 KEYS = _log_memory_types[memlevel]
# 
# Path: cubical/tools/ModColor.py
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
#     HEADER = ''
#     OKBLUE = ''
#     OKGREEN = ''
#     WARNING = ''
#     FAIL = ''
#     ENDC = ''
# def disableColors():
# def Str(strin0,col="red",Bold=True):
# def Sep(strin=None,D=1):
# def Title(strin,Big=False):
# def disable():


# Path: cubical/flagging.py
from builtins import range
from past.builtins import cmp
from functools import cmp_to_key
from cubical.tools import logger, ModColor
from collections import OrderedDict
import numpy as np
import re
import cubical.plots as plots
        import pylab

            del self.order[self.order.index(name)]
            self.ms.removecolkeyword('BITFLAG','FLAGSET_%s'%name)
        # write new list of bitflags
        self.ms._putkeyword('BITFLAG','FLAGSETS',-1,False,','.join(self.order))
        self.ms.flush()

        return mask

def flag_chisq (st, GD, basename, nddid):
    """
    Flags timeslots and channels based on accumulated chi-squared statistics.

    Args:
        st (:obj:`~cubical.statistics.SolverStats`):
            Object containing solver statistics.
        GD (dict):
            Dictionary of global options.
        basename (str):
            Base name for output plots.
        nddid (int):
            Number of data descriptor identifiers.

    Returns:
        np.ndarray:
            Flag cube of shape (n_times, n_ddids, n_chans).
    """

    chi2 = np.ma.masked_array(st.timechan.chi2, st.timechan.chi2==0)
    total = (~chi2.mask).sum()
    if not total:

        print(ModColor.Str("no valid solutions anywhere: skipping post-solution flagging."), file=log)