<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
"""
==================
desitarget.mock.io
==================

Handles mock data to build target catalogs.
"""
from __future__ import (absolute_import, division, print_function)
#
import numpy as np
import fitsio
import os, re
import desitarget.io
import h5py
import desitarget.targets


"""
How to distribute 52 user bits of targetid.

Used to generate target IDs as combination of input file and row in input file.
Sets the maximum number of rows per input file for mocks using this scheme to
generate target IDs
"""
# First 32 bits are row
ENCODE_ROW_END     = 32
ENCODE_ROW_MASK    = 2**ENCODE_ROW_END - 2**0
ENCODE_ROW_MAX     = ENCODE_ROW_MASK
# Next 20 bits are file
ENCODE_FILE_END    = 52
ENCODE_FILE_MASK   = 2**ENCODE_FILE_END - 2**ENCODE_ROW_END
ENCODE_FILE_MAX    = ENCODE_FILE_MASK >> ENCODE_ROW_END

def print_all_mocks_info(params):
    """
    Prints parameters to read mock files.
    Parameters
    ----------
        params (dictionary) The different kind of sources are stored under the 'sources' key.
    """
    print('The following populations and paths are specified:')
    for source_name in sorted(params['sources'].keys()):
        source_format = params['sources'][source_name]['format']
        source_path = params['sources'][source_name]['root_mock_dir']
        target_name = params['sources'][source_name]['target_name']
        print('source_name: {}\n format: {} \n target_name {} \n path: {}'.format(source_name, source_format, target_name, source_path))

def load_all_mocks(params):
        """
    Prints parameters to read mock files.
    Parameters
    ----------
        params (dictionary) The different kind of sources are stored under the 'sources' key.

    Returns
    -------
        source_data_all (dictionary). The keys correspond to the different input 'sources'
        stored under params['sources'].keys()<commit_msg>fixed indentation problem<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
"""
==================
desitarget.mock.io
==================

Handles mock data to build target catalogs.
"""
from __future__ import (absolute_import, division, print_function)
#
import numpy as np
import fitsio
import os, re
import desitarget.io
import h5py
import desitarget.targets


"""
How to distribute 52 user bits of targetid.

Used to generate target IDs as combination of input file and row in input file.
Sets the maximum number of rows per input file for mocks using this scheme to
generate target IDs
"""
# First 32 bits are row
ENCODE_ROW_END     = 32
ENCODE_ROW_MASK    = 2**ENCODE_ROW_END - 2**0
ENCODE_ROW_MAX     = ENCODE_ROW_MASK
# Next 20 bits are file
ENCODE_FILE_END    = 52
ENCODE_FILE_MASK   = 2**ENCODE_FILE_END - 2**ENCODE_ROW_END
ENCODE_FILE_MAX    = ENCODE_FILE_MASK >> ENCODE_ROW_END

def print_all_mocks_info(params):
    """
    Prints parameters to read mock files.
    Parameters
    ----------
        params (dictionary) The different kind of sources are stored under the 'sources' key.
    """
    print('The following populations and paths are specified:')
    for source_name in sorted(params['sources'].keys()):
        source_format = params['sources'][source_name]['format']
        source_path = params['sources'][source_name]['root_mock_dir']
        target_name = params['sources'][source_name]['target_name']
        print('source_name: {}\n format: {} \n target_name {} \n path: {}'.format(source_name, source_format, target_name, source_path))

def load_all_mocks(params):
    """
    Prints parameters to read mock files.
    Parameters
    ----------
    params (dictionary) The different kind of sources are stored under the 'sources' key.
    
    Returns
    -------
        source_data_all (dictionary). The keys correspond to the different input 'sources'
        stored under params['sources'].keys()
{'fraction_non_alphanumeric': 0.11880687563195147, 'fraction_numerical': 0.00910010111223458, 'mean_word_length': 3.6498237367802586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '779744', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1125, 'n_words': 387}