<commit_before>
import numpy as np
import constants as c
import asciidata as AD
import dust
import scipy.special as special # Needed for WD01 equations                                                         
MW_caseA_file = 'Table1.WD.dat'
LMC_avg_file  = 'Table3_LMCavg.WD.dat'
LMC_2_file    = 'Table3_LMC2.WD.dat'
SMC_file      = 'Table3_SMC.WD.dat'

def get_dist_params( R_V=3.1, bc=0.0, type='Graphite', gal='MW' ):
    """
    get_dist_params( 
    R_V [float : 3.1, 4.0, or 5.5]
    bc [float : 0,1,2,3...], 
    type [string : 'Graphite' or 'Silicate],
    gal [string : 'MW','LMC' or 'SMC'] )
    ------------------------------------------
    Returns (alpha, beta, a_t, a_c, C) : Parameters used in WD01 fits
    """
    is_MW = False

    if gal == 'MW':
        table_filename = MW_caseA_file
        is_MW = True
    elif gal == 'SMC':
        table_filename = SMC_file
    elif gal == 'LMC':
        table_filename = LMC_avg_file
    else:
        print 'Error: Galaxy type not recognized'
        return

    table_info = AD.open( table_filename )

    RV_col = table_info[0] # either a float or '--' (LMC/SMC case)
    bc_col = table_info[1].tonumpy()

    # Get index of rows associated with the input R_V value
    # R_V values are not unique, which is why I can't use a dictionary

    if is_MW:
        i_RV     = []
        count_RV = 0
        for val in RV_col:
            if val == R_V:
                i_RV.append(count_RV)
            count_RV += 1
                
        if len(i_RV) == 0:<commit_msg>find_wdfile added for flexibility with different systems<commit_after>import numpy as np
import constants as c
import asciidata as AD
import dust
import scipy.special as special # Needed for WD01 equations                                                         
MW_caseA_file = 'Table1.WD.dat'
LMC_avg_file  = 'Table3_LMCavg.WD.dat'
LMC_2_file    = 'Table3_LMC2.WD.dat'
SMC_file      = 'Table3_SMC.WD.dat'

def find_wdfile( name ):
    file_not_found = True

    path_list = os.getenv("PYTHONPATH").split(':')

    for path in path_list:
        print("looking in %s" % (path))
        for root, dirs, files in os.walk(path+"/"):
            if name in files:
                return os.path.join(root, name)

    if file_not_found:
        print("ERROR: Cannot find DM03 file")
        return result


def get_dist_params( R_V=3.1, bc=0.0, type='Graphite', gal='MW' ):
    """
    get_dist_params( 
    R_V [float : 3.1, 4.0, or 5.5]
    bc [float : 0,1,2,3...], 
    type [string : 'Graphite' or 'Silicate],
    gal [string : 'MW','LMC' or 'SMC'] )
    ------------------------------------------
    Returns (alpha, beta, a_t, a_c, C) : Parameters used in WD01 fits
    """
    is_MW = False

    if gal == 'MW':
        table_filename = find_wdfile( MW_caseA_file )
        is_MW = True
    elif gal == 'SMC':
        table_filename = find_wdfile( SMC_file )
    elif gal == 'LMC':
        table_filename = find_wdfile( LMC_avg_file )
    else:
        print 'Error: Galaxy type not recognized'
        return

    table_info = AD.open( table_filename )

    RV_col = table_info[0] # either a float or '--' (LMC/SMC case)
    bc_col = table_info[1].tonumpy()

    # Get index of rows associated with the input R_V value
    # R_V values are not unique, which is why I can't use a dictionary

    if is_MW:
        i_RV     = []
        count_RV = 0
        for val in RV_col:
            if val == R_V:
                i_RV.append(count_RV)
            count_RV += 1
                
        if len(i_RV) == 0:
{'fraction_non_alphanumeric': 0.1283860045146727, 'fraction_numerical': 0.016930022573363433, 'mean_word_length': 1.8821138211382114, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4161122', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1194, 'n_words': 343}