<commit_before>from __future__ import print_function, division, absolute_import, unicode_literals
from builtins import bytes, dict, object, range, map, input, str
from future.utils import itervalues, viewitems, iteritems, listvalues, listitems
from io import open

import numpy as np
import os.path
from numba import jit

import logging
logger = logging.getLogger(__name__)


### Functional form

def apply_telcal(st, data, threshold=1/50., onlycomplete=True, sign=+1):
    """ Wrap all telcal functions to parse telcal file and apply it to data
    sign defines if calibration is applied (+1) or backed out (-1).
    assumes dual pol and that each spw has same nch and chansize.
    Threshold is minimum ratio of gain amp to median gain amp.
    If no solution found, it will blank the data to zeros.
    """

    assert sign in [-1, +1], 'sign must be +1 or -1'

    if st.gainfile is None:
        return data
    else:
        if (not os.path.exists(st.gainfile)) or (not os.path.isfile(st.gainfile)):
            logger.warn('{0} is not a valid gain file. No calibration applied.'
                        .format(st.gainfile))
            return data
        else:
            pols = [0, 1]
            reffreq = np.array(st.metadata.spw_reffreq)[st.spw]
            chansize = np.array(st.metadata.spw_chansize)[st.spw]
            nchan = np.array(st.metadata.spw_nchan)[st.spw]
            skyfreqs = np.around(reffreq + (chansize*nchan/2), -6)/1e6  # GN skyfreq is band center

            sols = parseGN(st.gainfile)
            solskyfreqs = np.unique(sols['skyfreq'])
            if not all([skyfreq in np.unique(solskyfreqs)
                        for skyfreq in skyfreqs]):
                logger.warn("Not all data frequencies ({0}) in solution set ({1})"
                            .format(np.unique(skyfreqs), solskyfreqs))
            # must run time select before flagants for complete solutions
            sols = select(sols, time=st.segmenttimes.mean())<commit_msg>tuning low gain amp flagging down<commit_after>from __future__ import print_function, division, absolute_import, unicode_literals
from builtins import bytes, dict, object, range, map, input, str
from future.utils import itervalues, viewitems, iteritems, listvalues, listitems
from io import open

import numpy as np
import os.path
from numba import jit

import logging
logger = logging.getLogger(__name__)


### Functional form

def apply_telcal(st, data, threshold=1/10., onlycomplete=True, sign=+1):
    """ Wrap all telcal functions to parse telcal file and apply it to data
    sign defines if calibration is applied (+1) or backed out (-1).
    assumes dual pol and that each spw has same nch and chansize.
    Threshold is minimum ratio of gain amp to median gain amp.
    If no solution found, it will blank the data to zeros.
    """

    assert sign in [-1, +1], 'sign must be +1 or -1'

    if st.gainfile is None:
        return data
    else:
        if (not os.path.exists(st.gainfile)) or (not os.path.isfile(st.gainfile)):
            logger.warn('{0} is not a valid gain file. No calibration applied.'
                        .format(st.gainfile))
            return data
        else:
            pols = [0, 1]
            reffreq = np.array(st.metadata.spw_reffreq)[st.spw]
            chansize = np.array(st.metadata.spw_chansize)[st.spw]
            nchan = np.array(st.metadata.spw_nchan)[st.spw]
            skyfreqs = np.around(reffreq + (chansize*nchan/2), -6)/1e6  # GN skyfreq is band center

            sols = parseGN(st.gainfile)
            solskyfreqs = np.unique(sols['skyfreq'])
            if not all([skyfreq in np.unique(solskyfreqs)
                        for skyfreq in skyfreqs]):
                logger.warn("Not all data frequencies ({0}) in solution set ({1})"
                            .format(np.unique(skyfreqs), solskyfreqs))
            # must run time select before flagants for complete solutions
            sols = select(sols, time=st.segmenttimes.mean())
{'fraction_non_alphanumeric': 0.09554777388694347, 'fraction_numerical': 0.009504752376188095, 'mean_word_length': 2.501751313485114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1165037', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1183, 'n_words': 406}