diff --git a/binarycpython/utils/distribution_functions.py b/binarycpython/utils/distribution_functions.py index 07ddd447de6868239badd50da8a3202fc408244d..807f938bfc1d1073147a6b69cd70276fd4929d37 100644 --- a/binarycpython/utils/distribution_functions.py +++ b/binarycpython/utils/distribution_functions.py @@ -31,8 +31,8 @@ import numpy as np from binarycpython.utils.useful_funcs import calc_period_from_sep, calc_sep_from_period from binarycpython.utils.functions import verbose_print from binarycpython.utils.grid_options_defaults import ( - _MS_VERBOSITY_LEVEL, - _MS_VERBOSITY_INTERPOLATOR_LEVEL, + _MOE2017_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_INTERPOLATOR_LEVEL, ) ### @@ -971,11 +971,11 @@ def poisson(lambda_val, n, nmax=None, verbosity=0): p_val = distribution_constants["poisson_cache"][cachekey] verbose_print( - "\tM&S: found cached value for poisson({}, {}, {}): {}".format( + "\tMoe and di Stefano 2017: found cached value for poisson({}, {}, {}): {}".format( lambda_val, n, nmax, p_val ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) return p_val @@ -998,9 +998,9 @@ def poisson(lambda_val, n, nmax=None, verbosity=0): distribution_constants["poisson_cache"][cachekey] = p_val verbose_print( - "\tM&S: Poisson({}, {}, {}): {}".format(lambda_val, n, nmax, p_val), + "\tMoe and di Stefano 2017: Poisson({}, {}, {}): {}".format(lambda_val, n, nmax, p_val), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) return p_val @@ -1038,7 +1038,7 @@ def merge_multiplicities(result_array, max_multiplicity, verbosity=0): """ if not max_multiplicity in range(1, 5): - msg = "\tM&S: merge_multiplicities: max_multiplicity has to be between 1 and 4. It is {} now".format( + msg = "\tMoe and di Stefano 2017: merge_multiplicities: max_multiplicity has to be between 1 and 4. It is {} now".format( max_multiplicity ) verbose_print( @@ -1050,21 +1050,21 @@ def merge_multiplicities(result_array, max_multiplicity, verbosity=0): # Fold multiplicities: verbose_print( - "\tM&S: merge_multiplicities: Merging multiplicities with initial array {} and max multiplicity {}".format( + "\tMoe and di Stefano 2017: merge_multiplicities: Merging multiplicities with initial array {} and max multiplicity {}".format( result_array, max_multiplicity ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) for i in range(max_multiplicity, len(result_array))[::-1]: result_array[i - 1] += result_array[i] result_array[i] = 0 verbose_print( - "\tM&S: merge_multiplicities: Merging multiplicities to new array {}".format( + "\tMoe and di Stefano 2017: merge_multiplicities: Merging multiplicities to new array {}".format( result_array ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) return result_array @@ -1133,7 +1133,7 @@ def Moe_di_Stefano_2017_multiplicity_fractions(options, verbosity=0): table=Moecache["multiplicity_table"], # Contains the table of data nparams=1, # logM1 ndata=4, # The number of datapoints (the parameters that we want to interpolate) - verbosity=verbosity - (_MS_VERBOSITY_INTERPOLATOR_LEVEL - 1), + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), ) if options["multiplicity_model"] == "Poisson": @@ -1149,11 +1149,11 @@ def Moe_di_Stefano_2017_multiplicity_fractions(options, verbosity=0): full_fractions_array = full_fractions_array / np.sum(full_fractions_array) verbose_print( - "\tM&S: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( "Poisson", full_fractions_array ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif options["multiplicity_model"] == "data": @@ -1171,22 +1171,22 @@ def Moe_di_Stefano_2017_multiplicity_fractions(options, verbosity=0): # Set last value full_fractions_array[3] = 0.0 # no quadruples verbose_print( - "\tM&S: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: using model {}: full_fractions_array: {}".format( "data", full_fractions_array ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Normalisation: if options["normalize_multiplicities"] == "raw": # Don't multiply by the multiplicity_array, but do give a fractions array verbose_print( - "\tM&S: Moe_di_Stefano_2017_multiplicity_fractions: Not normalising (using raw results): results: {}".format( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Not normalising (using raw results): results: {}".format( full_fractions_array ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) result = full_fractions_array @@ -1198,11 +1198,11 @@ def Moe_di_Stefano_2017_multiplicity_fractions(options, verbosity=0): result = weighted_fractions_array / np.sum(weighted_fractions_array) verbose_print( - "\tM&S: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}. result: {}".format( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}. result: {}".format( "norm", result ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif options["normalize_multiplicities"] == "merge": @@ -1216,17 +1216,17 @@ def Moe_di_Stefano_2017_multiplicity_fractions(options, verbosity=0): result = result / np.sum(result) verbose_print( - "\tM&S: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}, max_multiplicity={} result={}".format( + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: Normalising with {}, max_multiplicity={} result={}".format( "merge", max_multiplicity, result ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) verbose_print( - "\tM&S: Moe_di_Stefano_2017_multiplicity_fractions: {}".format(str(result)), + "\tMoe and di Stefano 2017: Moe_di_Stefano_2017_multiplicity_fractions: {}".format(str(result)), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # return array reference @@ -1250,7 +1250,7 @@ def build_q_table(options, m, p, verbosity=0): # mass is in $opts->{$m} # period is $opts->{$p} # - # Since the information from the table for M&S is independent of any choice we make, + # Since the information from the table for Moe and di Stefano 2017 is independent of any choice we make, # we need to take into account that for example our choice of minimum mass leads to # a minimum q_min that is not the same as in the table # We should ignore those parts of the table and renormalise. @@ -1272,19 +1272,19 @@ def build_q_table(options, m, p, verbosity=0): incache = True verbose_print( - "\tM&S: build_q_table: Found cached values for m={} p={}".format( + "\tMoe and di Stefano 2017: build_q_table: Found cached values for m={} p={}".format( options[m], options[p] ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) else: verbose_print( - "\tM&S: build_q_table: Cached values for different m={} p={}. Freeing current table and making new table".format( + "\tMoe and di Stefano 2017: build_q_table: Cached values for different m={} p={}. Freeing current table and making new table".format( options[m], options[p] ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # @@ -1299,11 +1299,11 @@ def build_q_table(options, m, p, verbosity=0): qmin = options["Mmin"] / options["M_1"] verbose_print( - "\tM&S: build_q_table qmin: {}".format( + "\tMoe and di Stefano 2017: build_q_table qmin: {}".format( qmin, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # qmax = maximum_mass_ratio_for_RLOF(options[m], options[p]) @@ -1318,11 +1318,11 @@ def build_q_table(options, m, p, verbosity=0): qeps = 1e-8 # small number but such that qeps+1 != 1 if qeps + 1 == 1.0: verbose_print( - "\tM&S: build_q_table: qeps (= {}) +1 == 1. Make qeps larger".format( + "\tMoe and di Stefano 2017: build_q_table: qeps (= {}) +1 == 1. Make qeps larger".format( qeps, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) if qmin >= qmax: @@ -1431,11 +1431,11 @@ def build_q_table(options, m, p, verbosity=0): qlimit = qmin if pre == "low" else qmax verbose_print( - "\tM&S: build_q_table: Extrapolating: Q: {} method: {}, indices: {} End index: {}".format( + "\tMoe and di Stefano 2017: build_q_table: Extrapolating: Q: {} method: {}, indices: {} End index: {}".format( pre, method, indices, end_index ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # truncate the distribution @@ -1444,9 +1444,9 @@ def build_q_table(options, m, p, verbosity=0): if method == None: # no extrapolation : just interpolate between 0.10 and 0.95 verbose_print( - "\tM&S: build_q_table: using no extrapolations".format(), + "\tMoe and di Stefano 2017: build_q_table: using no extrapolations".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) continue elif method == "flat": @@ -1454,9 +1454,9 @@ def build_q_table(options, m, p, verbosity=0): # with zero slope qdata[qlimit] = qdata[qs[end_index]] verbose_print( - "\tM&S: build_q_table: using constant extrapolation".format(), + "\tMoe and di Stefano 2017: build_q_table: using constant extrapolation".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif method == "linear": qdata[qlimit] = linear_extrapolation_q( @@ -1469,9 +1469,9 @@ def build_q_table(options, m, p, verbosity=0): ) verbose_print( - "\tM&S: build_q_table: using linear extrapolation".format(), + "\tMoe and di Stefano 2017: build_q_table: using linear extrapolation".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) if pre == "low": below_qlimit = qlimit - qeps @@ -1479,11 +1479,11 @@ def build_q_table(options, m, p, verbosity=0): qdata[below_qlimit] = 0 qdata[0] = 0 verbose_print( - "\tM&S: build_q_table: using linear extrapolation and setting the points below the lower q bound ({}) to 0 ".format( + "\tMoe and di Stefano 2017: build_q_table: using linear extrapolation and setting the points below the lower q bound ({}) to 0 ".format( qlimit ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif method == "plaw2": @@ -1492,32 +1492,32 @@ def build_q_table(options, m, p, verbosity=0): ) verbose_print( - "\tM&S: build_q_table: using powerlaw extrapolation".format(), + "\tMoe and di Stefano 2017: build_q_table: using powerlaw extrapolation".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif method == "nolowq": newq = 0.05 qdata[newq] = 0 verbose_print( - "\tM&S: build_q_table: setting lowq to 0".format(), + "\tMoe and di Stefano 2017: build_q_table: setting lowq to 0".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif method == "poly": # TODO: consider implementing the poly method (see Perl version) raise ValueError( - "M&S: build_q_table: Method 'poly' not implemented" + "Moe and di Stefano 2017: build_q_table: Method 'poly' not implemented" ) else: - msg = "\tM&S: build_q_table: Error no other methods available. The chosen method ({}) does not exist!".format( + msg = "\tMoe and di Stefano 2017: build_q_table: Error no other methods available. The chosen method ({}) does not exist!".format( method ) verbose_print( msg, verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) raise ValueError(msg) @@ -1531,19 +1531,19 @@ def build_q_table(options, m, p, verbosity=0): table=tmp_table, nparams=1, ndata=1, # Contains the table of data # q # - verbosity=verbosity - (_MS_VERBOSITY_INTERPOLATOR_LEVEL - 1), + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), ) verbose_print( - "\tM&S: build_q_table: Created a new Q table", + "\tMoe and di Stefano 2017: build_q_table: Created a new Q table", verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) if can_renormalize: verbose_print( - "\tM&S: build_q_table: Renormalising table", + "\tMoe and di Stefano 2017: build_q_table: Renormalising table", verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # now we integrate and renormalise (if the table is not all zero) @@ -1563,20 +1563,20 @@ def build_q_table(options, m, p, verbosity=0): # fail if error in integral > 1e-6 (should be ~ machine precision) if abs(1.0 - new_I) > 1e-6: verbose_print( - "\tM&S: build_q_table: Error: > 1e-6 in q probability integral: {}".format( + "\tMoe and di Stefano 2017: build_q_table: Error: > 1e-6 in q probability integral: {}".format( I ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # set this new table in the cache Moecache["rinterpolator_q_given_{}_log10{}".format(m, p)] = q_interpolator verbose_print( - "\tM&S: build_q_table: stored q_interpolater as {}".format( + "\tMoe and di Stefano 2017: build_q_table: stored q_interpolater as {}".format( "rinterpolator_q_given_{}_log10{}".format(m, p) ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Store the values for which this table was set up in the dict @@ -1616,9 +1616,9 @@ def linear_extrapolation_q(qs, indices, qlimit, qdata, end_index, verbosity=0): if dq == 0: verbose_print( - "\tM&S: build_q_table: linear dq=0".format(), + "\tMoe and di Stefano 2017: build_q_table: linear dq=0".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # No change return qs[end_index] @@ -1628,11 +1628,11 @@ def linear_extrapolation_q(qs, indices, qlimit, qdata, end_index, verbosity=0): intercept = qdata[qs[indices[0]]] - slope * qs[indices[0]] qdata[qlimit] = max(0.0, slope * qlimit + intercept) verbose_print( - "\tM&S: build_q_table: linear Slope: {} intercept: {} dn/dq({}) = {}".format( + "\tMoe and di Stefano 2017: build_q_table: linear Slope: {} intercept: {} dn/dq({}) = {}".format( slope, intercept, qlimit, qdata[qlimit] ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) return max(0.0, slope * qlimit + intercept) @@ -1650,21 +1650,21 @@ def get_integration_constant_q(q_interpolator, tmp_table, qdata, verbosity=0): for q in np.arange(0, 1 + 2e-6, dq): x = q_interpolator.interpolate([q]) if len(x) == 0: - msg = "\tM&S: build_q_table: Q interpolator table interpolation failed.\n\t\ttmp_table = {}\n\t\tq_data = {}".format( + msg = "\tMoe and di Stefano 2017: build_q_table: Q interpolator table interpolation failed.\n\t\ttmp_table = {}\n\t\tq_data = {}".format( str(tmp_table), str(qdata) ) verbose_print( msg, verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) raise ValueError(msg) else: I += x[0] * dq # verbose_print( - # "\tM&S: build_q_table: dn/dq ({}) = {} I -> = {}".format(q, x[0], I), + # "\tMoe and di Stefano 2017: build_q_table: dn/dq ({}) = {} I -> = {}".format(q, x[0], I), # verbosity, - # _MS_VERBOSITY_LEVEL, + # _MOE2017_VERBOSITY_LEVEL, # ) return I @@ -1735,7 +1735,7 @@ def calc_e_integral( # Set the integral value in the dict Moecache[integrals_string][mass_period_string] = I verbose_print( - "\tM&S: calc_ecc_integral: min_ecc: {} max ecc: {} integrals_string: {} interpolator_name: {} mass_string: {} period_string: {} mass: {} period: {} I: {}".format( + "\tMoe and di Stefano 2017: calc_ecc_integral: min_ecc: {} max ecc: {} integrals_string: {} interpolator_name: {} mass_string: {} period_string: {} mass: {} period: {} I: {}".format( min_ecc, max_ecc, integrals_string, @@ -1747,11 +1747,11 @@ def calc_e_integral( I, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) else: verbose_print( - "\tM&S: calc_ecc_integral: Found cached value for min_ecc: {} max ecc: {} integrals_string: {} interpolator_name: {} mass_string: {} period_string: {} mass: {} period: {} I: {}".format( + "\tMoe and di Stefano 2017: calc_ecc_integral: Found cached value for min_ecc: {} max ecc: {} integrals_string: {} interpolator_name: {} mass_string: {} period_string: {} mass: {} period: {} I: {}".format( min_ecc, max_ecc, integrals_string, @@ -1763,7 +1763,7 @@ def calc_e_integral( Moecache[integrals_string][mass_period_string], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) @@ -1798,7 +1798,7 @@ def calc_P_integral( # Set the integral value in the dict Moecache[integrals_string][options[mass_string]] = I verbose_print( - "\tM&S: calc_P_integral: min_logP: {} integrals_string: {} interpolator_name: {} mass_string: {} mass: {} I: {}".format( + "\tMoe and di Stefano 2017: calc_P_integral: min_logP: {} integrals_string: {} interpolator_name: {} mass_string: {} mass: {} I: {}".format( min_logP, integrals_string, interpolator_name, @@ -1807,11 +1807,11 @@ def calc_P_integral( I, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) else: verbose_print( - "\tM&S: calc_P_integral: Found cached value for min_logP: {} integrals_string: {} interpolator_name: {} mass_string: {} mass: {} I: {}".format( + "\tMoe and di Stefano 2017: calc_P_integral: Found cached value for min_logP: {} integrals_string: {} interpolator_name: {} mass_string: {} mass: {} I: {}".format( min_logP, integrals_string, interpolator_name, @@ -1820,7 +1820,7 @@ def calc_P_integral( Moecache[integrals_string][options[mass_string]], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) @@ -1852,11 +1852,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): """ verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf with options:\n\t\t{}".format( + "\tMoe_di_Stefano_2017_pdf with options:\n\t\t{}".format( json.dumps(options) ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) prob_dict = ( @@ -1866,11 +1866,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # Get the multiplicity from the options, and if its not there, calculate it based on the # TODO: the function below makes no sense. We NEED to pass the multiplicity in the if not options.get("multiplicity", None): - msg = "\tM&S: Moe_di_Stefano_2017_pdf: Did not find a multiplicity value in the options dictionary" + msg = "\tMoe_di_Stefano_2017_pdf: Did not find a multiplicity value in the options dictionary" verbose_print( msg, verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) raise ValueError(msg) # multiplicity = 1 @@ -1882,9 +1882,9 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # Immediately return 0 if the multiplicity modulator is 0 if options["multiplicity_modulator"][multiplicity - 1] == 0: verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: returning 0 because of the multiplicity modulator being 0", + "\tMoe_di_Stefano_2017_pdf: returning 0 because of the multiplicity modulator being 0", verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) return 0 @@ -1897,11 +1897,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): )[multiplicity - 1] prob_dict["multiplicity"] = multiplicity_probability verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Appended multiplicity (mass1 = {}) probability ({}) to the prob dict ({})".format( + "\tMoe_di_Stefano_2017_pdf: Appended multiplicity (mass1 = {}) probability ({}) to the prob dict ({})".format( options["M_1"], prob_dict["multiplicity"], prob_dict ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) ############################################################ @@ -1915,11 +1915,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): M1_probability = Kroupa2001(options["M_1"]) * options["M_1"] prob_dict["M_1"] = M1_probability verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Appended Mass (m={}) probability ({}) to the prob dict ({})".format( + "\tMoe_di_Stefano_2017_pdf: Appended Mass (m={}) probability ({}) to the prob dict ({})".format( options["M_1"], prob_dict["M_1"], prob_dict ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if M1_probability == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -1940,14 +1940,14 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): table=Moecache["period_distributions"], # Contains the table of data nparams=2, # log10M, log10P ndata=2, # binary, triple - verbosity=verbosity - (_MS_VERBOSITY_INTERPOLATOR_LEVEL - 1), + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), ) verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Created new period interpolator: {}".format( + "\tMoe_di_Stefano_2017_pdf: Created new period interpolator: {}".format( Moecache["rinterpolator_log10P"] ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Make a table storing Moe's data for q distributions @@ -1961,14 +1961,14 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): table=Moecache["q_distributions"], # Contains the table of data nparams=3, # log10M, log10P, q ndata=1, # - verbosity=verbosity - (_MS_VERBOSITY_INTERPOLATOR_LEVEL - 1), + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), ) verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Created new q interpolator: {}".format( + "\tMoe_di_Stefano_2017_pdf: Created new q interpolator: {}".format( Moecache["rinterpolator_q"] ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Make a table storing Moe's data for q distributions, but only if the ecc is actually sampled @@ -1981,14 +1981,14 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): ], # Contains the table of data nparams=3, # log10M, log10P, e ndata=1, # - verbosity=verbosity - (_MS_VERBOSITY_INTERPOLATOR_LEVEL - 1), + verbosity=verbosity - (_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL - 1), ) verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Created new e interpolator: {}".format( + "\tMoe_di_Stefano_2017_pdf: Created new e interpolator: {}".format( Moecache["rinterpolator_e"] ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) ############### @@ -2021,11 +2021,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): p_val = p_val / Moecache["P_integrals"][options["M_1"]] prob_dict["P"] = p_val verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Appended period (m={}, P={}) probability ({}) to the prob list ({})".format( + "\tMoe_di_Stefano_2017_pdf: Appended period (m={}, P={}) probability ({}) to the prob list ({})".format( options["M_1"], options["P"], prob_dict["P"], prob_dict ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['P'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2047,7 +2047,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # Construct the q table build_q_table(options, m_label, p_label, verbosity=verbosity) verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Created q_table ({}) for m={} p={}".format( + "\tMoe_di_Stefano_2017_pdf: Created q_table ({}) for m={} p={}".format( Moecache[ "rinterpolator_q_given_{}_log10{}".format(m_label, p_label) ], @@ -2055,7 +2055,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): options[p_label], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Add probability for the mass ratio @@ -2064,7 +2064,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): ].interpolate([secondary_mass / primary_mass])[0] prob_dict["q"] = q_prob verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: appended mass ratio (M={} P={} q={}) probability ({}) to the prob list ({}) ".format( + "\tMoe_di_Stefano_2017_pdf: appended mass ratio (M={} P={} q={}) probability ({}) to the prob list ({}) ".format( options["M_1"], options["P"], options["M_2"] / options["M_1"], @@ -2072,7 +2072,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['q'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2098,7 +2098,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): ecc_val = ecc_val / Moecache["ecc_integrals"][mass_period_string] prob_dict["ecc"] = ecc_val verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Appended eccentricity (m={}, P={}, ecc={}) probability ({}) to the prob list ({})".format( + "\tMoe_di_Stefano_2017_pdf: Appended eccentricity (m={}, P={}, ecc={}) probability ({}) to the prob list ({})".format( options["M_1"], options["P"], options["ecc"], @@ -2106,7 +2106,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['ecc'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2141,11 +2141,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # period is too short : system is not hierarchical prob_dict["P2"] = 0 verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: period2 is too short: {} < {}, system is not hierarchical. Added 0 to probability list".format( + "\tMoe_di_Stefano_2017_pdf: period2 is too short: {} < {}, system is not hierarchical. Added 0 to probability list".format( options["P1"], min_P2 ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['P2'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2177,7 +2177,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): p_val = p_val / Moecache["P2_integrals"][options["M_1+M_2"]] prob_dict["P2"] = p_val verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Appended period2 (m1={} m2={}, P2={}) probability ({}) to the prob list ({})".format( + "\tMoe_di_Stefano_2017_pdf: Appended period2 (m1={} m2={}, P2={}) probability ({}) to the prob list ({})".format( options["M_1"], options["M_2"], options["P2"], @@ -2185,7 +2185,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['P2'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2206,9 +2206,9 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # Build q table build_q_table(options, m_label, p_label, verbosity=verbosity) verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Called build_q_table", + "\tMoe_di_Stefano_2017_pdf: Called build_q_table", verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Add the probability @@ -2217,7 +2217,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): ].interpolate([secondary_mass / primary_mass])[0] prob_dict["q2"] = q2_val verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2={} M_3={} P={} q={}) probability ({}) to the prob list ({}) ".format( + "\tMoe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2={} M_3={} P={} q={}) probability ({}) to the prob list ({}) ".format( options["M_1+M_2"], options["M_3"], options["P"], @@ -2226,7 +2226,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['q2'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2269,7 +2269,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): p_val = p_val / Moecache["P2_integrals"][options["M_1+M_2"]] prob_dict["P3"] = p_val verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Appended period2 (M=4) (M_1={} M_2={}, P2={}) probability ({}) to the prob list ({})".format( + "\tMoe_di_Stefano_2017_pdf: Appended period2 (M=4) (M_1={} M_2={}, P2={}) probability ({}) to the prob list ({})".format( options["M_1"], options["M_2"], options["P2"], @@ -2277,7 +2277,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['P3'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2299,9 +2299,9 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # Calculate new q table build_q_table(options, m_label, p_label, verbosity=verbosity) verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: Created q_table ".format(), + "\tMoe_di_Stefano_2017_pdf: Created q_table ".format(), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Add the probability @@ -2310,7 +2310,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): ].interpolate([secondary_mass / primary_mass])[0] prob_dict["q3"] = q3_prob verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2={} M_3={} P={} q={}) probability ({}) to the prob list ({}) ".format( + "\tMoe_di_Stefano_2017_pdf: appended mass ratio (M_1+M_2={} M_3={} P={} q={}) probability ({}) to the prob list ({}) ".format( options["M_1+M_2"], options["M_3"], options["P"], @@ -2319,7 +2319,7 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict, ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # if prob_dict['q3'] == 0: # If the probability is 0 then we don't have to calculate more # calc_total_probdens(prob_dict) @@ -2329,13 +2329,13 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # check for input of multiplicity elif multiplicity not in range(1, 5): - msg = "\tM&S: Moe_di_Stefano_2017_pdf: Unknown multiplicity {}".format( + msg = "\tMoe_di_Stefano_2017_pdf: Unknown multiplicity {}".format( multiplicity ) verbose_print( msg, verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) raise ValueError(msg) @@ -2345,18 +2345,18 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): # Some info if multiplicity == 1: verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: M_1={} q=N/A log10P=N/A ({}): {} -> {}\n".format( + "\tMoe_di_Stefano_2017_pdf: M_1={} q=N/A log10P=N/A ({}): {} -> {}\n".format( options["M_1"], len(prob_dict), str(prob_dict), prob_dict["total_probdens"], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif multiplicity == 2: verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: M_1={} q={} log10P={} ecc={} ({}): {} -> {}\n".format( + "\tMoe_di_Stefano_2017_pdf: M_1={} q={} log10P={} ecc={} ({}): {} -> {}\n".format( options["M_1"], options["M_2"] / options["M_1"] if options.get("M_2", None) else "N/A", np.log10(options["P"]), @@ -2366,11 +2366,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict["total_probdens"], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif multiplicity == 3: verbose_print( - "\tM&S: Moe_di_Stefano_2017_pdf: M_1={} q={} log10P={} ecc={} M_3={} log10P2={} ecc2={} ({}): {} -> {}".format( + "\tMoe_di_Stefano_2017_pdf: M_1={} q={} log10P={} ecc={} M_3={} log10P2={} ecc2={} ({}): {} -> {}".format( options["M_1"], options["M_2"] / options["M_1"] if options.get("M_2", None) else "N/A", np.log10(options["P"]), @@ -2383,11 +2383,11 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict["total_probdens"], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) elif multiplicity == 4: verbose_print( - "M&S: Moe_di_Stefano_2017_pdf: M_1={} q={} log10P={} ecc={} M_3={} log10P2={} ecc2={} M_4={} log10P3={} ecc3={} ({}) : {} -> {}".format( + "Moe_di_Stefano_2017_pdf: M_1={} q={} log10P={} ecc={} M_3={} log10P2={} ecc2={} M_4={} log10P3={} ecc3={} ({}) : {} -> {}".format( options["M_1"], options["M_2"] / options["M_1"] if options.get("M_2", None) else "N/A", np.log10(options["P"]), @@ -2403,6 +2403,6 @@ def Moe_di_Stefano_2017_pdf(options, verbosity=0): prob_dict["total_probdens"], ), verbosity, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) return prob_dict diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index d0edf56b43f0f0df5a87f5c3997c36a895711ae6..a28022334ea6a865638324f97635694ed83fe12e 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -52,7 +52,7 @@ colorama_init() from binarycpython.utils.grid_options_defaults import ( grid_options_defaults_dict, moe_di_stefano_default_options, - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, _CUSTOM_LOGGING_VERBOSITY_LEVEL, _LOGGER_VERBOSITY_LEVEL, ) @@ -152,10 +152,10 @@ class Population: self.set(**kwargs) # Load Moe and di Stefano options - self.grid_options["m&s_options"] = copy.deepcopy(moe_di_stefano_default_options) - self.custom_options["m&s_JSON_data"] = None + self.grid_options["Moe2017_options"] = copy.deepcopy(moe_di_stefano_default_options) + self.custom_options["Moe2017_JSON_data"] = None - # Write M&S options to a file. NOTE: not sure why i put this here anymore + # Write MOE2017 options to a file. NOTE: not sure why i put this here anymore os.makedirs( os.path.join(self.grid_options["tmp_dir"], "moe_distefano"), exist_ok=True ) @@ -166,7 +166,7 @@ class Population: ), "w", ) as f: - f.write(json.dumps(self.grid_options["m&s_options"], indent=4)) + f.write(json.dumps(self.grid_options["Moe2017_options"], indent=4)) f.close() # Argline dict @@ -3756,8 +3756,8 @@ class Population: # Take the option dictionary that was given and override. - options = update_dicts(self.grid_options["m&s_options"], options) - self.grid_options["m&s_options"] = copy.deepcopy(options) + options = update_dicts(self.grid_options["Moe2017_options"], options) + self.grid_options["Moe2017_options"] = copy.deepcopy(options) # Write options to a file os.makedirs( @@ -3771,7 +3771,7 @@ class Population: ), "w", ) as f: - f.write(json.dumps(self.grid_options["m&s_options"], indent=4)) + f.write(json.dumps(self.grid_options["Moe2017_options"], indent=4)) f.close() def _load_moe_di_stefano_data(self): @@ -3780,16 +3780,16 @@ class Population: """ # Only if the grid is loaded and Moecache contains information - if (not self.grid_options["_loaded_ms_data"]): # and not Moecache: + if (not self.grid_options["_loaded_Moe2017_data"]): # and not Moecache: - if self.custom_options["m&s_JSON_data"]: + if self.custom_options["Moe2017_JSON_data"]: # Use the existing (perhaps modified) JSON data - json_data = self.custom_options["m&s_JSON_data"] + json_data = self.custom_options["Moe2017_JSON_data"] else: # Load the JSON data from a file json_data = get_moe_di_stefano_dataset( - self.grid_options["m&s_options"], + self.grid_options["Moe2017_options"], verbosity=self.grid_options["verbosity"], ) @@ -3799,7 +3799,7 @@ class Population: json_data["log10M1"] = json_data["log10M1"][0] # save this data in case we want to modify it later - self.custom_options["m&s_JSON_data"] = json_data + self.custom_options["Moe2017_JSON_data"] = json_data # Get all the masses logmasses = sorted(json_data["log10M1"].keys()) @@ -4029,28 +4029,28 @@ class Population: len(Moecache["period_distributions"]) ), self.grid_options["verbosity"], - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) verbose_print( "\tMoe_di_Stefano_2017: Length multiplicity table: {}".format( len(Moecache["multiplicity_table"]) ), self.grid_options["verbosity"], - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) verbose_print( "\tMoe_di_Stefano_2017: Length q table: {}".format( len(Moecache["q_distributions"]) ), self.grid_options["verbosity"], - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) verbose_print( "\tMoe_di_Stefano_2017: Length ecc table: {}".format( len(Moecache["ecc_distributions"]) ), self.grid_options["verbosity"], - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) # Write to log file @@ -4068,7 +4068,7 @@ class Population: cache_filehandle.write(json.dumps(Moecache, indent=4)) # Signal that the data has been loaded - self.grid_options["_loaded_ms_data"] = True + self.grid_options["_loaded_Moe2017_data"] = True def _set_moe_di_stefano_distributions(self): """ @@ -4080,12 +4080,12 @@ class Population: # for singles, binaries, triples, quadruples, ... max_multiplicity = get_max_multiplicity( - self.grid_options["m&s_options"]["multiplicity_modulator"] + self.grid_options["Moe2017_options"]["multiplicity_modulator"] ) verbose_print( "\tMoe_di_Stefano_2017: Max multiplicity = {}".format(max_multiplicity), self.grid_options["verbosity"], - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) ###### # Setting up the grid variables @@ -4099,10 +4099,10 @@ class Population: resolution=4, spacingfunc="range(1, 5)", precode='self.grid_options["multiplicity"] = multiplicity; self.bse_options["multiplicity"] = multiplicity; options={}'.format( - self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"] ), condition="({}[multiplicity-1] > 0)".format( - str(self.grid_options["m&s_options"]["multiplicity_modulator"]) + str(self.grid_options["Moe2017_options"]["multiplicity_modulator"]) ), gridtype="edge", dphasevol=-1, @@ -4119,19 +4119,19 @@ class Population: longname="Primary mass", resolution="options['resolutions']['M'][0]", spacingfunc="const(np.log({}), np.log({}), {})".format( - self.grid_options["m&s_options"]["ranges"]["M"][0], - self.grid_options["m&s_options"]["ranges"]["M"][1], - self.grid_options["m&s_options"]["resolutions"]["M"][0], + self.grid_options["Moe2017_options"]["ranges"]["M"][0], + self.grid_options["Moe2017_options"]["ranges"]["M"][1], + self.grid_options["Moe2017_options"]["resolutions"]["M"][0], ), valuerange=[ - "np.log({})".format(self.grid_options["m&s_options"]["ranges"]["M"][0]), - "np.log({})".format(self.grid_options["m&s_options"]["ranges"]["M"][1]), + "np.log({})".format(self.grid_options["Moe2017_options"]["ranges"]["M"][0]), + "np.log({})".format(self.grid_options["Moe2017_options"]["ranges"]["M"][1]), ], gridtype="centred", dphasevol="dlnm1", precode='M_1 = np.exp(lnm1); options["M_1"]=M_1', probdist="Moe_di_Stefano_2017_pdf({{{}, {}, {}}}, verbosity=self.grid_options['verbosity'])['total_probdens'] if multiplicity == 1 else 1".format( - str(dict(self.grid_options["m&s_options"]))[1:-1], + str(dict(self.grid_options["Moe2017_options"]))[1:-1], "'multiplicity': multiplicity", "'M_1': M_1", ), @@ -4144,7 +4144,7 @@ class Population: name="log10per", parameter_name="orbital_period", longname="log10(Orbital_Period)", - resolution=self.grid_options["m&s_options"]["resolutions"]["logP"][0], + resolution=self.grid_options["Moe2017_options"]["resolutions"]["logP"][0], probdist=1.0, condition='(self.grid_options["multiplicity"] >= 2)', branchpoint=1 @@ -4153,19 +4153,19 @@ class Population: gridtype="centred", dphasevol="({} * dlog10per)".format(LOG_LN_CONVERTER), valuerange=[ - self.grid_options["m&s_options"]["ranges"]["logP"][0], - self.grid_options["m&s_options"]["ranges"]["logP"][1], + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], ], spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["logP"][0], - self.grid_options["m&s_options"]["ranges"]["logP"][1], - self.grid_options["m&s_options"]["resolutions"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], + self.grid_options["Moe2017_options"]["resolutions"]["logP"][0], ), precode="""orbital_period = 10.0**log10per qmin={}/M_1 qmax=maximum_mass_ratio_for_RLOF(M_1, orbital_period) """.format( - self.grid_options["m&s_options"]["Mmin"] + self.grid_options["Moe2017_options"]["Mmin"] ), ) # TODO: change the maximum_mass_ratio_for_RLOF @@ -4175,14 +4175,14 @@ qmax=maximum_mass_ratio_for_RLOF(M_1, orbital_period) parameter_name="M_2", longname="Mass ratio", valuerange=[ - self.grid_options["m&s_options"]["ranges"]["q"][0] - if self.grid_options["m&s_options"].get("ranges", {}).get("q", None) + self.grid_options["Moe2017_options"]["ranges"]["q"][0] + if self.grid_options["Moe2017_options"].get("ranges", {}).get("q", None) else "options['Mmin']/M_1", - self.grid_options["m&s_options"]["ranges"]["q"][1] - if self.grid_options["m&s_options"].get("ranges", {}).get("q", None) + self.grid_options["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"].get("ranges", {}).get("q", None) else "qmax", ], - resolution=self.grid_options["m&s_options"]["resolutions"]["M"][1], + resolution=self.grid_options["Moe2017_options"]["resolutions"]["M"][1], probdist=1, gridtype="centred", dphasevol="dq", @@ -4191,27 +4191,27 @@ M_2 = q * M_1 sep = calc_sep_from_period(M_1, M_2, orbital_period) """, spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["q"][0] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][0] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", [None, None])[0] - else "{}/M_1".format(self.grid_options["m&s_options"]["Mmin"]), - self.grid_options["m&s_options"]["ranges"]["q"][1] - if self.grid_options["m&s_options"] + else "{}/M_1".format(self.grid_options["Moe2017_options"]["Mmin"]), + self.grid_options["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", [None, None])[1] else "qmax", - self.grid_options["m&s_options"]["resolutions"]["M"][1], + self.grid_options["Moe2017_options"]["resolutions"]["M"][1], ), ) # (optional) binaries: eccentricity - if self.grid_options["m&s_options"]["resolutions"]["ecc"][0] > 0: + if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][0] > 0: self.add_grid_variable( name="ecc", parameter_name="eccentricity", longname="Eccentricity", - resolution=self.grid_options["m&s_options"]["resolutions"]["ecc"][ + resolution=self.grid_options["Moe2017_options"]["resolutions"]["ecc"][ 0 ], probdist=1, @@ -4219,17 +4219,17 @@ sep = calc_sep_from_period(M_1, M_2, orbital_period) dphasevol="decc", precode="eccentricity=ecc", valuerange=[ - self.grid_options["m&s_options"]["ranges"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ 0 ], # Just fail if not defined. - self.grid_options["m&s_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], ], spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ 0 ], # Just fail if not defined. - self.grid_options["m&s_options"]["ranges"]["ecc"][1], - self.grid_options["m&s_options"]["resolutions"]["ecc"][0], + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["resolutions"]["ecc"][0], ), ) @@ -4240,7 +4240,7 @@ sep = calc_sep_from_period(M_1, M_2, orbital_period) name="log10per2", parameter_name="orbital_period_triple", longname="log10(Orbital_Period2)", - resolution=self.grid_options["m&s_options"]["resolutions"]["logP"][ + resolution=self.grid_options["Moe2017_options"]["resolutions"]["logP"][ 1 ], probdist=1.0, @@ -4251,19 +4251,19 @@ sep = calc_sep_from_period(M_1, M_2, orbital_period) gridtype="centred", dphasevol="({} * dlog10per2)".format(LOG_LN_CONVERTER), valuerange=[ - self.grid_options["m&s_options"]["ranges"]["logP"][0], - self.grid_options["m&s_options"]["ranges"]["logP"][1], + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], ], spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["logP"][0], - self.grid_options["m&s_options"]["ranges"]["logP"][1], - self.grid_options["m&s_options"]["resolutions"]["logP"][1], + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], + self.grid_options["Moe2017_options"]["resolutions"]["logP"][1], ), precode="""orbital_period_triple = 10.0**log10per2 q2min={}/(M_1+M_2) q2max=maximum_mass_ratio_for_RLOF(M_1+M_2, orbital_period_triple) """.format( - self.grid_options["m&s_options"]["Mmin"] + self.grid_options["Moe2017_options"]["Mmin"] ), ) @@ -4274,18 +4274,18 @@ q2max=maximum_mass_ratio_for_RLOF(M_1+M_2, orbital_period_triple) parameter_name="M_3", longname="Mass ratio outer/inner", valuerange=[ - self.grid_options["m&s_options"]["ranges"]["q"][0] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][0] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "options['Mmin']/(M_1+M_2)", - self.grid_options["m&s_options"]["ranges"]["q"][1] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "q2max", ], - resolution=self.grid_options["m&s_options"]["resolutions"]["M"][2], + resolution=self.grid_options["Moe2017_options"]["resolutions"]["M"][2], probdist=1, gridtype="centred", dphasevol="dq2", @@ -4295,27 +4295,27 @@ sep2 = calc_sep_from_period((M_1+M_2), M_3, orbital_period_triple) eccentricity2=0 """, spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["q"][0] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][0] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "options['Mmin']/(M_1+M_2)", - self.grid_options["m&s_options"]["ranges"]["q"][1] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "q2max", - self.grid_options["m&s_options"]["resolutions"]["M"][2], + self.grid_options["Moe2017_options"]["resolutions"]["M"][2], ), ) # (optional) triples: eccentricity - if self.grid_options["m&s_options"]["resolutions"]["ecc"][1] > 0: + if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][1] > 0: self.add_grid_variable( name="ecc2", parameter_name="eccentricity2", longname="Eccentricity of the triple", - resolution=self.grid_options["m&s_options"]["resolutions"][ + resolution=self.grid_options["Moe2017_options"]["resolutions"][ "ecc" ][1], probdist=1, @@ -4323,17 +4323,17 @@ eccentricity2=0 dphasevol="decc2", precode="eccentricity2=ecc2", valuerange=[ - self.grid_options["m&s_options"]["ranges"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ 0 ], # Just fail if not defined. - self.grid_options["m&s_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], ], spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ 0 ], # Just fail if not defined. - self.grid_options["m&s_options"]["ranges"]["ecc"][1], - self.grid_options["m&s_options"]["resolutions"]["ecc"][1], + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["resolutions"]["ecc"][1], ), ) @@ -4343,7 +4343,7 @@ eccentricity2=0 name="log10per3", parameter_name="orbital_period_quadruple", longname="log10(Orbital_Period3)", - resolution=self.grid_options["m&s_options"]["resolutions"][ + resolution=self.grid_options["Moe2017_options"]["resolutions"][ "logP" ][2], probdist=1.0, @@ -4354,19 +4354,19 @@ eccentricity2=0 gridtype="centred", dphasevol="({} * dlog10per3)".format(LOG_LN_CONVERTER), valuerange=[ - self.grid_options["m&s_options"]["ranges"]["logP"][0], - self.grid_options["m&s_options"]["ranges"]["logP"][1], + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], ], spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["logP"][0], - self.grid_options["m&s_options"]["ranges"]["logP"][1], - self.grid_options["m&s_options"]["resolutions"]["logP"][2], + self.grid_options["Moe2017_options"]["ranges"]["logP"][0], + self.grid_options["Moe2017_options"]["ranges"]["logP"][1], + self.grid_options["Moe2017_options"]["resolutions"]["logP"][2], ), precode="""orbital_period_quadruple = 10.0**log10per3 q3min={}/(M_3) q3max=maximum_mass_ratio_for_RLOF(M_3, orbital_period_quadruple) """.format( - self.grid_options["m&s_options"]["Mmin"] + self.grid_options["Moe2017_options"]["Mmin"] ), ) @@ -4376,18 +4376,18 @@ q3max=maximum_mass_ratio_for_RLOF(M_3, orbital_period_quadruple) parameter_name="M_4", longname="Mass ratio outer low/outer high", valuerange=[ - self.grid_options["m&s_options"]["ranges"]["q"][0] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][0] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "options['Mmin']/(M_3)", - self.grid_options["m&s_options"]["ranges"]["q"][1] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "q3max", ], - resolution=self.grid_options["m&s_options"]["resolutions"]["M"][ + resolution=self.grid_options["Moe2017_options"]["resolutions"]["M"][ 3 ], probdist=1, @@ -4399,27 +4399,27 @@ sep3 = calc_sep_from_period((M_3), M_4, orbital_period_quadruple) eccentricity3=0 """, spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["q"][0] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][0] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "options['Mmin']/(M_3)", - self.grid_options["m&s_options"]["ranges"]["q"][1] - if self.grid_options["m&s_options"] + self.grid_options["Moe2017_options"]["ranges"]["q"][1] + if self.grid_options["Moe2017_options"] .get("ranges", {}) .get("q", None) else "q3max", - self.grid_options["m&s_options"]["resolutions"]["M"][2], + self.grid_options["Moe2017_options"]["resolutions"]["M"][2], ), ) # (optional) triples: eccentricity - if self.grid_options["m&s_options"]["resolutions"]["ecc"][2] > 0: + if self.grid_options["Moe2017_options"]["resolutions"]["ecc"][2] > 0: self.add_grid_variable( name="ecc3", parameter_name="eccentricity3", longname="Eccentricity of the triple+quadruple/outer binary", - resolution=self.grid_options["m&s_options"]["resolutions"][ + resolution=self.grid_options["Moe2017_options"]["resolutions"][ "ecc" ][2], probdist=1, @@ -4427,17 +4427,17 @@ eccentricity3=0 dphasevol="decc3", precode="eccentricity3=ecc3", valuerange=[ - self.grid_options["m&s_options"]["ranges"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ 0 ], # Just fail if not defined. - self.grid_options["m&s_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], ], spacingfunc="const({}, {}, {})".format( - self.grid_options["m&s_options"]["ranges"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][ 0 ], # Just fail if not defined. - self.grid_options["m&s_options"]["ranges"]["ecc"][1], - self.grid_options["m&s_options"]["resolutions"]["ecc"][ + self.grid_options["Moe2017_options"]["ranges"]["ecc"][1], + self.grid_options["Moe2017_options"]["resolutions"]["ecc"][ 2 ], ), @@ -4450,7 +4450,7 @@ eccentricity3=0 # and add some keys to it: updated_options = "{{{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}}".format( - str(dict(self.grid_options["m&s_options"]))[1:-1], + str(dict(self.grid_options["Moe2017_options"]))[1:-1], '"multiplicity": multiplicity', '"M_1": M_1', '"M_2": M_2', @@ -4476,11 +4476,11 @@ eccentricity3=0 verbose_print( "\tMoe_di_Stefano_2017: Added final call to the pdf function", self.grid_options["verbosity"], - _MS_VERBOSITY_LEVEL, + _MOE2017_VERBOSITY_LEVEL, ) - # Signal that the M&S grid has been set - self.grid_options["_set_ms_grid"] = True + # Signal that the MOE2017 grid has been set + self.grid_options["_set_Moe2017_grid"] = True ################################################################################################ def Moe_di_Stefano_2017(self, options=None): @@ -4509,7 +4509,7 @@ eccentricity3=0 Moecache.clear() if options['clean all'] or options['clean load flag']: - self.grid_options["_loaded_ms_data"] = False + self.grid_options["_loaded_Moe2017_data"] = False # Set the user input if options['apply settings']: @@ -4602,10 +4602,10 @@ eccentricity3=0 elif self.grid_options["multiplicity_fraction_function"] == 3: # We need to check several things now here: - # First, are the options for the M&S grid set? On start it is filled with the default settings - if not self.grid_options["m&s_options"]: - msg = "The M&S options do not seem to be set properly. The value is {}".format( - self.grid_options["m&s_options"] + # First, are the options for the MOE2017 grid set? On start it is filled with the default settings + if not self.grid_options["Moe2017_options"]: + msg = "The MOE2017 options do not seem to be set properly. The value is {}".format( + self.grid_options["Moe2017_options"] ) raise ValueError(msg) @@ -4621,14 +4621,14 @@ eccentricity3=0 self._load_moe_di_stefano_data() # record the prev value - prev_M1_value_ms = self.grid_options["m&s_options"].get("M_1", None) + prev_M1_value_ms = self.grid_options["Moe2017_options"].get("M_1", None) # Set value of M1 of the current system - self.grid_options["m&s_options"]["M_1"] = system_dict["M_1"] + self.grid_options["Moe2017_options"]["M_1"] = system_dict["M_1"] # Calculate the multiplicity fraction multiplicity_fraction_list = Moe_di_Stefano_2017_multiplicity_fractions( - self.grid_options["m&s_options"], self.grid_options["verbosity"] + self.grid_options["Moe2017_options"], self.grid_options["verbosity"] ) # Turn into dict @@ -4638,7 +4638,7 @@ eccentricity3=0 } # Set the prev value back - self.grid_options["m&s_options"]["M_1"] = prev_M1_value_ms + self.grid_options["Moe2017_options"]["M_1"] = prev_M1_value_ms # we don't know what to do next else: diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py index 5467f69abc61128b187f4dc3cccbb750eff78d5c..44bb9ade4a6c9050b11177cd2c5fd71c39203030 100644 --- a/binarycpython/utils/grid_options_defaults.py +++ b/binarycpython/utils/grid_options_defaults.py @@ -20,9 +20,9 @@ from binarycpython.utils.functions import return_binary_c_version_info _LOGGER_VERBOSITY_LEVEL = 1 _CUSTOM_LOGGING_VERBOSITY_LEVEL = 2 -_MS_VERBOSITY_LEVEL = 5 -_MS_VERBOSITY_INTERPOLATOR_LEVEL = 6 -_MS_VERBOSITY_INTERPOLATOR_EXTRA_LEVEL = 7 +_MOE2017_VERBOSITY_LEVEL = 5 +_MOE2017_VERBOSITY_INTERPOLATOR_LEVEL = 6 +_MOE2017_VERBOSITY_INTERPOLATOR_EXTRA_LEVEL = 7 # Options dict grid_options_defaults_dict = { @@ -31,7 +31,7 @@ grid_options_defaults_dict = { ########################## "num_cores": 1, # total number of cores used to evolve the population "parse_function": None, # Function to parse the output with. - "multiplicity_fraction_function": 0, # Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: M&S 2017 + "multiplicity_fraction_function": 0, # Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano 2017 "tmp_dir": temp_dir(), # Setting the temp dir of the program "_main_pid": -1, # Placeholder for the main process id of the run. "combine_ensemble_with_thread_joining": True, # Flag on whether to combine everything and return it to the user or if false: write it to data_dir/ensemble_output_{population_id}_{thread_id}.json @@ -68,11 +68,11 @@ grid_options_defaults_dict = { ), # TODO: make this more robust "_binary_c_dir": os.environ["BINARY_C"], ########################## - # M&S internal settings + # Moe and di Stefano (2017) internal settings ########################## - "_loaded_ms_data": False, # Holds flag whether the M&S data is loaded into memory - "_set_ms_grid": False, # Whether the M&S grid has been loaded - "m&s_options": None, # Holds the M&S options. + "_loaded_Moe2017_data": False, # Holds flag whether the Moe and di Stefano (2017) data is loaded into memory + "_set_Moe2017_grid": False, # Whether the Moe and di Stefano (2017) grid has been loaded + "Moe2017_options": None, # Holds the Moe and di Stefano (2017) options. ########################## # Custom logging ########################## @@ -491,13 +491,13 @@ grid_options_descriptions = { "_total_probability_weighted_mass_run": "To count the total mass * probability for each system that thread/process has ran", "_actually_evolve_system": "Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid", "max_queue_size": "Maximum size of the queue that is used to feed the processes. Don't make this too big! Default: 1000. Input: int", - "_set_ms_grid": "Internal flag whether the M&S grid has been loaded", + "_set_Moe2017_grid": "Internal flag whether the Moe and di Stefano (2017) grid has been loaded", "run_zero_probability_system": "Whether to run the zero probability systems. Default: True. Input: Boolean", "_zero_prob_stars_skipped": "Internal counter to track how many systems are skipped because they have 0 probability", "ensemble_factor_in_probability_weighted_mass": "Flag to multiply all the ensemble results with 1/probability_weighted_mass", - "multiplicity_fraction_function": "Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: M&S 2017", - "m&s_options": "Internal variable that holds the M&S options. Don't write to this your self", - "_loaded_ms_data": "Internal variable storing whether the M&S data has been loaded into memory", + "multiplicity_fraction_function": "Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: Moe and di Stefano (2017) 2017", + "m&s_options": "Internal variable that holds the Moe and di Stefano (2017) options. Don't write to this your self", + "_loaded_Moe2017_data": "Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory", "do_dry_run": "Whether to do a dry run to calculate the total probability for this run", }