<commit_before>from __future__ import division, absolute_import, print_function
from past.builtins import xrange

import fitsio
import esutil
import numpy as np
from scipy import interpolate

from .chisq_dist import ChisqDist
from .chisq_dist import compute_chisq
from .catalog import Catalog
from .utilities import CubicSpline
from .utilities import MStar

class RedSequenceColorPar(object):
    """
    Class which contains a red-sequence parametrization

    parameters
    ----------
    filename: string
        red sequence parameter file
    zbinsize: float, optional
        interpolation bin size in redshift
    minsig: float, optional
        minimum intrinsic scatter.  Default 0.01
    fine: bool, optional
        finest binning, set in filename header.  Default False
    zrange: float*2, optional
        redshift range [zlo,zhi].  Default from filename header
        (maximum range)

    """
    def __init__(self, filename, zbinsize=None, minsig=0.01, fine=False, zrange=None, config=None):

        if filename is None:
            if config is None:
                raise ValueError("Must have either filename or config")
            limmag = config.limmag_catalog
            if zrange is None:
                zrange = config.zrange
            alpha = config.calib_lumfunc_alpha
            mstar_survey = config.mstar_survey
            mstar_band = config.mstar_band
            ncol = config.nmag - 1

            # A compromize zbinsize
            zbinsize = 0.001

            has_file = False
        else:
            pars,hdr=fitsio.read(filename, ext=1, header=True, upper=True)
            try:
                limmag = hdr['LIMMAG']
                if (zrange is None):
                    zrange = np.array([hdr['ZRANGE0'],hdr['ZRANGE1']])
                alpha = hdr['ALPHA']
                mstar_survey = hdr['MSTARSUR']
                mstar_band = hdr['MSTARBAN']
                ncol = hdr['NCOL']<commit_msg>Allow to specify limmag if desired<commit_after>from __future__ import division, absolute_import, print_function
from past.builtins import xrange

import fitsio
import esutil
import numpy as np
from scipy import interpolate

from .chisq_dist import ChisqDist
from .chisq_dist import compute_chisq
from .catalog import Catalog
from .utilities import CubicSpline
from .utilities import MStar

class RedSequenceColorPar(object):
    """
    Class which contains a red-sequence parametrization

    parameters
    ----------
    filename: string
        red sequence parameter file
    zbinsize: float, optional
        interpolation bin size in redshift
    minsig: float, optional
        minimum intrinsic scatter.  Default 0.01
    fine: bool, optional
        finest binning, set in filename header.  Default False
    zrange: float*2, optional
        redshift range [zlo,zhi].  Default from filename header
        (maximum range)

    """
    def __init__(self, filename, zbinsize=None, minsig=0.01, fine=False, zrange=None, config=None, limmag=None):

        if filename is None:
            if config is None:
                raise ValueError("Must have either filename or config")
            if limmag is None:
                limmag = config.limmag_catalog
            else:
                limmag = limmag
            if zrange is None:
                zrange = config.zrange
            alpha = config.calib_lumfunc_alpha
            mstar_survey = config.mstar_survey
            mstar_band = config.mstar_band
            ncol = config.nmag - 1

            # A compromize zbinsize
            zbinsize = 0.001

            has_file = False
        else:
            pars,hdr=fitsio.read(filename, ext=1, header=True, upper=True)
            try:
                if limmag is None:
                    limmag = hdr['LIMMAG']
                else:
                    limmag = limmag
                if (zrange is None):
                    zrange = np.array([hdr['ZRANGE0'],hdr['ZRANGE1']])
                alpha = hdr['ALPHA']
                mstar_survey = hdr['MSTARSUR']
                mstar_band = hdr['MSTARBAN']
                ncol = hdr['NCOL']
{'fraction_non_alphanumeric': 0.07281553398058252, 'fraction_numerical': 0.007281553398058253, 'mean_word_length': 1.997090909090909, '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': '3709719', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1129, 'n_words': 349}