<commit_before>import os
import time
import traceback
from collections import defaultdict

import numpy as np
from astropy.table import Table, join, vstack
from astropy.time import Time
from easyquery import Query

from .. import utils
from ..database import CsvTable, Database, DataObject, FileObject, FitsTable
from ..hosts import HostCatalog
from ..utils import fill_values_by_query, get_all_colors, get_sdss_bands
from . import build, build2
from . import cuts as C
from .manual_fixes import fixes_to_nsa_v012, fixes_to_nsa_v101

__all__ = ["ObjectCatalog", "get_unique_objids"]


def get_unique_objids(objid_col):
    try:
        objid_col = objid_col.compressed()
    except AttributeError:
        pass
    return np.unique(np.asarray(objid_col, dtype=np.int64))


def calc_fiducial_p_sat(base, params=(-1.4, 1, -4, 1.9, 0.5)):
    gr = np.where(
        C.valid_g_mag.mask(base),
        base["gr"],
        np.where(
            C.valid_i_mag.mask(base),
            base["ri"] + 0.1,
            np.where(C.valid_z_mag.mask(base), base["rz"] + 0.2, 0.92 - 0.03 * base["r_mag"]),
        ),
    )

    sb = np.where(
        C.valid_sb.mask(base),
        base["sb_r"],
        20 + 0.6 * (base["r_mag"] - 14),
    )

    r = base["r_mag"]

    mu = params[0] * r + params[1] * sb + params[2] * gr + params[3]
    mu = np.where(np.isnan(mu), np.inf, mu)
    p = params[4] / (1 + np.exp(-mu))

    return p


class ObjectCatalog(object):
    """
    This class provides a high-level interface to access object catalogs
    (also known as "base catalogs")

    Parameters<commit_msg>update prob model params<commit_after>import os
import time
import traceback
from collections import defaultdict

import numpy as np
from astropy.table import Table, join, vstack
from astropy.time import Time
from easyquery import Query

from .. import utils
from ..database import CsvTable, Database, DataObject, FileObject, FitsTable
from ..hosts import HostCatalog
from ..utils import fill_values_by_query, get_all_colors, get_sdss_bands
from . import build, build2
from . import cuts as C
from .manual_fixes import fixes_to_nsa_v012, fixes_to_nsa_v101

__all__ = ["ObjectCatalog", "get_unique_objids"]


def get_unique_objids(objid_col):
    try:
        objid_col = objid_col.compressed()
    except AttributeError:
        pass
    return np.unique(np.asarray(objid_col, dtype=np.int64))


def calc_fiducial_p_sat(base, params=(-1.68, 1.25, -5.5, 2, 0.5)):
    gr = np.where(
        C.valid_g_mag.mask(base),
        base["gr"],
        np.where(
            C.valid_i_mag.mask(base),
            base["ri"] + 0.1,
            np.where(C.valid_z_mag.mask(base), base["rz"] + 0.2, 0.92 - 0.03 * base["r_mag"]),
        ),
    )

    sb = np.where(
        C.valid_sb.mask(base),
        base["sb_r"],
        20 + 0.6 * (base["r_mag"] - 14),
    )

    r = base["r_mag"]

    mu = params[0] * r + params[1] * sb + params[2] * gr + params[3]
    mu = np.where(np.isnan(mu), np.inf, mu)
    p = params[4] / (1 + np.exp(-mu))

    return p


class ObjectCatalog(object):
    """
    This class provides a high-level interface to access object catalogs
    (also known as "base catalogs")

    Parameters
{'fraction_non_alphanumeric': 0.12480450422270879, 'fraction_numerical': 0.025336252736940883, 'mean_word_length': 2.9047619047619047, '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': '1758211', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1121, 'n_words': 290}