diff --git a/examples/notebook_population.ipynb b/examples/notebook_population.ipynb index b6a37baa8d90a2f36c0fd19311548ed49e77f173..f00022b0cefa30d956207c7f77be45d5c924749c 100644 --- a/examples/notebook_population.ipynb +++ b/examples/notebook_population.ipynb @@ -23,9 +23,11 @@ "outputs": [], "source": [ "import os\n", + "\n", "from binarycpython.utils.custom_logging_functions import temp_dir\n", "from binarycpython.utils.grid import Population\n", "\n", + "TMP_DIR = temp_dir(\"notebooks\", \"notebook_population\")\n", "# help(Population) # Uncomment to see the public functions of this object" ] }, @@ -60,7 +62,8 @@ "adding: max_evolution_time=15000 to BSE_options\n", "adding: eccentricity=0.02 to BSE_options\n", "adding: amt_cores=2 to grid_options\n", - "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python/example_python_population_result to custom_options >>>>\n", + "adding: tmp_dir=/tmp/binary_c_python/notebooks/notebook_population to grid_options\n", + "<<<< Warning: Key does not match previously known parameter: adding: data_dir=/tmp/binary_c_python/notebooks/notebook_population/example_python_population_result to custom_options >>>>\n", "<<<< Warning: Key does not match previously known parameter: adding: base_filename=example_pop.dat to custom_options >>>>\n", "1\n", "example_pop.dat\n", @@ -88,11 +91,12 @@ "\n", "\n", " # grid_options\n", - " amt_cores=2, # grid_options\n", + " amt_cores=2,\n", + " tmp_dir=TMP_DIR,\n", " \n", " # Custom options # TODO: need to be set in grid_options probably\n", " data_dir=os.path.join(\n", - " temp_dir(), \"example_python_population_result\"\n", + " TMP_DIR, \"example_python_population_result\"\n", " ), # custom_options\n", " base_filename=\"example_pop.dat\", # custom_options\n", ")\n", @@ -133,13 +137,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Writing settings to /tmp/binary_c_python/example_python_population_result/example_pop_settings.json\n" + "Writing settings to /tmp/binary_c_python/notebooks/notebook_population/example_python_population_result/example_pop_settings.json\n" ] }, { "data": { "text/plain": [ - "'/tmp/binary_c_python/example_python_population_result/example_pop_settings.json'" + "'/tmp/binary_c_python/notebooks/notebook_population/example_python_population_result/example_pop_settings.json'" ] }, "execution_count": 3, @@ -181,7 +185,7 @@ "text": [ "Help on method add_grid_variable in module binarycpython.utils.grid:\n", "\n", - "add_grid_variable(name:str, longname:str, valuerange:Union[list, str], resolution:str, spacingfunc:str, probdist:str, dphasevol:Union[str, int], parameter_name:str, gridtype:str='edge', branchpoint:int=0, precode:Union[str, NoneType]=None, condition:Union[str, NoneType]=None) -> None method of binarycpython.utils.grid.Population instance\n", + "add_grid_variable(name:str, longname:str, valuerange:Union[list, str], resolution:str, spacingfunc:str, probdist:str, dphasevol:Union[str, int], parameter_name:str, gridtype:str='centred', branchpoint:int=0, precode:Union[str, NoneType]=None, condition:Union[str, NoneType]=None) -> None method of binarycpython.utils.grid.Population instance\n", " Function to add grid variables to the grid_options.\n", " \n", " The execution of the grid generation will be through a nested for loop.\n", @@ -199,25 +203,25 @@ " name:\n", " name of parameter. This is evaluated as a parameter and you can use it throughout\n", " the rest of the function\n", - " \n", + " \n", " Examples:\n", " name = 'lnm1'\n", " longname:\n", " Long name of parameter\n", - " \n", + " \n", " Examples:\n", " longname = 'Primary mass'\n", " range:\n", " Range of values to take. Does not get used really, the spacingfunction is used to\n", " get the values from\n", - " \n", + " \n", " Examples:\n", " range = [math.log(m_min), math.log(m_max)]\n", " resolution:\n", " Resolution of the sampled range (amount of samples).\n", " TODO: check if this is used anywhere\n", " \n", - " Examples: \n", + " Examples:\n", " resolution = resolution[\"M_1\"]\n", " spacingfunction:\n", " Function determining how the range is sampled. You can either use a real function,\n", @@ -230,12 +234,12 @@ " precode:\n", " Extra room for some code. This code will be evaluated within the loop of the\n", " sampling function (i.e. a value for lnm1 is chosen already)\n", - " \n", + " \n", " Examples:\n", " precode = 'M_1=math.exp(lnm1);'\n", " probdist:\n", " Function determining the probability that gets assigned to the sampled parameter\n", - " \n", + " \n", " Examples:\n", " probdist = 'Kroupa2001(M_1)*M_1'\n", " dphasevol:\n", @@ -249,7 +253,7 @@ " condition = 'self.grid_options['binary']==1'\n", " gridtype:\n", " Method on how the value range is sampled. Can be either 'edge' (steps starting at\n", - " the lower edge of the value range) or 'center'\n", + " the lower edge of the value range) or 'centred'\n", " (steps starting at lower edge + 0.5 * stepsize).\n", "\n" ] @@ -313,7 +317,7 @@ " \"dphasevol\": \"dlnm1\",\n", " \"parameter_name\": \"M_1\",\n", " \"condition\": \"\",\n", - " \"gridtype\": \"edge\",\n", + " \"gridtype\": \"centred\",\n", " \"branchpoint\": 0,\n", " \"grid_variable_number\": 0\n", "}\n" @@ -457,7 +461,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "adding: parse_function=<function parse_function at 0x7ff3bdf79620> to grid_options\n" + "adding: parse_function=<function parse_function at 0x7f531bc3b6a8> to grid_options\n" ] } ], @@ -536,25 +540,25 @@ "Generating grid code\n", "Constructing/adding: lnm1\n", "Grid has handled 20 stars\n", - "with a total probability of 0.05150046619238192\n", + "with a total probability of 0.044402888438054094\n", "Total starcount for this run will be: 20\n", - "EXAMPLE_COMPACT_OBJECT 2.867655467480e+01 1.33079 9.81391 0.00167028 13\n", "Generating grid code\n", "Constructing/adding: lnm1\n", - "EXAMPLE_COMPACT_OBJECT 1.931266944719e+01 1.3933 12.3177 0.00124307 13\n", - "EXAMPLE_COMPACT_OBJECT 4.439623364590e+01 1.38004 7.81906 0.00224431 13\n", - "EXAMPLE_COMPACT_OBJECT 1.364277535630e+01 1.47961 15.4603 0.000925128 13\n", - "EXAMPLE_COMPACT_OBJECT 1.017435498578e+01 1.59052 19.4046 0.000688507 13\n", - "EXAMPLE_COMPACT_OBJECT 8.294870923827e+00 1.7197 24.3552 0.000512406 13\n", - "EXAMPLE_COMPACT_OBJECT 6.802132608769e+00 1.84162 30.5689 0.000381347 13\n", - "EXAMPLE_COMPACT_OBJECT 5.723570798020e+00 1.99471 38.3678 0.00028381 13\n", - "EXAMPLE_COMPACT_OBJECT 4.933751523833e+00 2.15875 48.1564 0.000211219 13\n", - "EXAMPLE_COMPACT_OBJECT 4.337250536639e+00 2.35209 60.4424 0.000157195 14\n", - "EXAMPLE_COMPACT_OBJECT 3.862081089332e+00 2.56776 75.8628 0.000116989 14\n", - "EXAMPLE_COMPACT_OBJECT 3.449960890183e+00 2.80457 95.2174 8.70668e-05 14\n", - "EXAMPLE_COMPACT_OBJECT 3.172196856333e+00 3.05193 119.51 6.47976e-05 14\n", - "EXAMPLE_COMPACT_OBJECT 3.069627290216e+00 3.27563 150 4.82242e-05 14\n", - "Population-2a7732d03e594ef4b5dfe9051b41d9c0 finished! The total probability was: 0.05150046619238191. It took a total of 0.7797017097473145s to run 20 systems on 2 cores\n", + "EXAMPLE_COMPACT_OBJECT 4.139293101586e+01 1.29427 8.13626 0.00202467 13\n", + "EXAMPLE_COMPACT_OBJECT 2.802986496151e+01 1.33699 10.0967 0.00152924 13\n", + "EXAMPLE_COMPACT_OBJECT 1.963621764679e+01 1.39754 12.5294 0.00115504 13\n", + "EXAMPLE_COMPACT_OBJECT 1.427601421985e+01 1.47745 15.5483 0.000872405 13\n", + "EXAMPLE_COMPACT_OBJECT 1.094409257247e+01 1.57571 19.2947 0.00065893 13\n", + "EXAMPLE_COMPACT_OBJECT 9.181971798545e+00 1.68748 23.9436 0.000497691 13\n", + "EXAMPLE_COMPACT_OBJECT 7.905335716621e+00 1.77287 29.7128 0.000375908 13\n", + "EXAMPLE_COMPACT_OBJECT 7.451192744924e+00 1.81495 36.872 0.000283924 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396133472739e+00 1.82088 45.7561 0.000214449 13\n", + "EXAMPLE_COMPACT_OBJECT 7.396675941641e+00 1.82123 56.7809 0.000161974 13\n", + "EXAMPLE_COMPACT_OBJECT 7.404641347602e+00 1.82074 70.4621 0.000122339 13\n", + "EXAMPLE_COMPACT_OBJECT 7.444217227690e+00 1.81636 87.4397 9.2403e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.453317880232e+00 1.81536 108.508 6.97923e-05 13\n", + "EXAMPLE_COMPACT_OBJECT 7.450828476484e+00 1.81563 134.653 5.27143e-05 13\n", + "Population-f28b5f98d7ef40dcb17fc2481a6d3ced finished! The total probability was: 0.04440288843805411. It took a total of 2.785212755203247s to run 20 systems on 2 cores\n", "There were no errors found in this run.\n" ] } @@ -586,7 +590,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'population_name': '2a7732d03e594ef4b5dfe9051b41d9c0', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.05150046619238191, 'total_count': 20, 'start_timestamp': 1628444120.234709, 'end_timestamp': 1628444121.0144107, 'total_mass_run': 730.1048014407228, 'total_probability_weighted_mass_run': 0.2983275843337705, 'zero_prob_stars_skipped': 0}\n" + "{'population_name': 'f28b5f98d7ef40dcb17fc2481a6d3ced', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.04440288843805411, 'total_count': 20, 'start_timestamp': 1629459533.935186, 'end_timestamp': 1629459536.7203987, 'total_mass_run': 684.2544031669779, 'total_probability_weighted_mass_run': 0.28134439269236855, 'zero_prob_stars_skipped': 0}\n" ] } ], @@ -660,42 +664,22 @@ "Generating grid code\n", "Constructing/adding: lnm1\n", "Saving grid code to grid_options\n", - "Writing grid code to /tmp/binary_c_python/binary_c_grid_2a7732d03e594ef4b5dfe9051b41d9c0.py\n", - "Loading grid code function from /tmp/binary_c_python/binary_c_grid_2a7732d03e594ef4b5dfe9051b41d9c0.py\n", + "Writing grid code to /tmp/binary_c_python/notebooks/notebook_population/binary_c_grid_f28b5f98d7ef40dcb17fc2481a6d3ced.py\n", + "Loading grid code function from /tmp/binary_c_python/notebooks/notebook_population/binary_c_grid_f28b5f98d7ef40dcb17fc2481a6d3ced.py\n", "Grid code loaded\n", - "Writing binary_c calls to /tmp/binary_c_python/example_python_population_result/binary_c_calls.txt\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", - "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n", + "Writing binary_c calls to /tmp/binary_c_python/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", "Grid has handled 20 stars\n", - "with a total probability of 0.05150046619238192\n", - "/tmp/binary_c_python/example_python_population_result/binary_c_calls.txt\n", - "binary_c M_1 2.0 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.013208238029791246\n", - "binary_c M_1 2.5102526289471614 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.009829948023831718\n", - "binary_c M_1 3.1506841305680684 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.0073157281034221516\n", - "binary_c M_1 3.9545065608702976 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.005444573822104362\n" + "with a total probability of 0.044402888438054094\n", + "/tmp/binary_c_python/notebooks/notebook_population/example_python_population_result/binary_c_calls.txt\n", + "binary_c M_1 2.227955577093495 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681548 probability 0.010905083645619543\n", + "binary_c M_1 2.7647737053496777 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681548 probability 0.008236638755149857\n", + "binary_c M_1 3.4309362899259503 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681548 probability 0.006221155214163634\n", + "binary_c M_1 4.257608426597089 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.21587440567681548 probability 0.004698855121516278\n" ] } ], "source": [ - "example_pop.set(verbosity=10)\n", + "example_pop.set(verbosity=1)\n", "calls_filename = example_pop.write_binary_c_calls_to_file()\n", "print(calls_filename)\n", "\n", @@ -725,39 +709,34 @@ "Generating grid code\n", "Constructing/adding: lnm1\n", "Grid has handled 20 stars\n", - "with a total probability of 0.05150046619238192\n", + "with a total probability of 0.044402888438054094\n", "Total starcount for this run will be: 20\n", "Generating grid code\n", "Constructing/adding: lnm1\n", - "Population-3680f3882c0a449c944462abffea2447 finished! The total probability was: 0.05150046619238191. It took a total of 0.6246354579925537s to run 20 systems on 2 cores\n", + "Population-e45c25448b32440cb7e220f4a3562907 finished! The total probability was: 0.04440288843805411. It took a total of 1.9539172649383545s to run 20 systems on 2 cores\n", "There were no errors found in this run.\n", "\n", "\n", "time mass zams_mass probability radius stellar_type\n", - "2.867655467480e+01 1.33079 9.81391 0.00167028 1.72498e-05 13\n", - "1.931266944719e+01 1.3933 12.3177 0.00124307 1.72498e-05 13\n", - "4.439623364590e+01 1.38004 7.81906 0.00224431 1.72498e-05 13\n", - "1.364277535630e+01 1.47961 15.4603 0.000925128 1.72498e-05 13\n", - "1.017435498578e+01 1.59052 19.4046 0.000688507 1.72498e-05 13\n", - "8.294870923827e+00 1.7197 24.3552 0.000512406 1.72498e-05 13\n", - "6.802132608769e+00 1.84162 30.5689 0.000381347 1.72498e-05 13\n", - "5.723570798020e+00 1.99471 38.3678 0.00028381 1.72498e-05 13\n", - "4.933751523833e+00 2.15875 48.1564 0.000211219 1.72498e-05 13\n", - "4.337250536639e+00 2.35209 60.4424 0.000157195 9.97286e-06 14\n", - "3.862081089332e+00 2.56776 75.8628 0.000116989 1.08873e-05 14\n", - "3.449960890183e+00 2.80457 95.2174 8.70668e-05 1.18914e-05 14\n", - "3.172196856333e+00 3.05193 119.51 6.47976e-05 1.29402e-05 14\n", - "3.069627290216e+00 3.27563 150 4.82242e-05 1.38887e-05 14\n", + "4.139293101586e+01 1.29427 8.13626 0.00202467 1.72498e-05 13\n", + "2.802986496151e+01 1.33699 10.0967 0.00152924 1.72498e-05 13\n", + "1.963621764679e+01 1.39754 12.5294 0.00115504 1.72498e-05 13\n", + "1.427601421985e+01 1.47745 15.5483 0.000872405 1.72498e-05 13\n", + "1.094409257247e+01 1.57571 19.2947 0.00065893 1.72498e-05 13\n", + "9.181971798545e+00 1.68748 23.9436 0.000497691 1.72498e-05 13\n", + "7.905335716621e+00 1.77287 29.7128 0.000375908 1.72498e-05 13\n", + "7.451192744924e+00 1.81495 36.872 0.000283924 1.72498e-05 13\n", + "7.396133472739e+00 1.82088 45.7561 0.000214449 1.72498e-05 13\n", + "7.396675941641e+00 1.82123 56.7809 0.000161974 1.72498e-05 13\n", + "7.404641347602e+00 1.82074 70.4621 0.000122339 1.72498e-05 13\n", + "7.444217227690e+00 1.81636 87.4397 9.2403e-05 1.72498e-05 13\n", + "7.453317880232e+00 1.81536 108.508 6.97923e-05 1.72498e-05 13\n", + "7.450828476484e+00 1.81563 134.653 5.27143e-05 1.72498e-05 13\n", "\n" ] } ], "source": [ - "import os\n", - "\n", - "from binarycpython.utils.grid import Population\n", - "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "\n", "def parse_function(self, output):\n", " \"\"\"\n", " Example parsing function\n", @@ -817,11 +796,12 @@ " eccentricity=0.02, # bse_options\n", " \n", " # grid_options\n", - " amt_cores=2, # grid_options\n", + " amt_cores=2,\n", + " tmp_dir=TMP_DIR,\n", "\n", " # Custom options: the data directory and the output filename\n", " data_dir=os.path.join(\n", - " temp_dir(), \"example_python_population_result\"\n", + " TMP_DIR, \"example_python_population_result\"\n", " ), # custom_options\n", " base_filename=\"example_pop.dat\", # custom_options\n", ")\n", @@ -876,15 +856,15 @@ "example_pop.export_all_info()\n", "\n", "# remove the result file if it exists\n", - "if os.path.isfile(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\")):\n", - " os.remove(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\"))\n", + "if os.path.isfile(os.path.join(TMP_DIR, \"example_python_population_result\", \"example_pop.dat\")):\n", + " os.remove(os.path.join(TMP_DIR, \"example_python_population_result\", \"example_pop.dat\"))\n", "\n", "\n", "# Evolve the population\n", "example_pop.evolve()\n", "\n", "# \n", - "with open(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\"), 'r') as f:\n", + "with open(os.path.join(TMP_DIR, \"example_python_population_result\", \"example_pop.dat\"), 'r') as f:\n", " output = f.read()\n", "print(\"\\n\")\n", "print(output)" @@ -912,96 +892,39 @@ "Constructing/adding: lnm1\n", "Constructing/adding: q\n", "Constructing/adding: log10per\n", - "Grid has handled 125 stars\n", - "with a total probability of 0.0862478164626921\n", - "Total starcount for this run will be: 125\n", + "Grid has handled 27 stars\n", + "with a total probability of 0.024868380796643753\n", + "Total starcount for this run will be: 27\n", "Generating grid code\n", "Constructing/adding: lnm1\n", "Constructing/adding: q\n", "Constructing/adding: log10per\n", - "Population-d20a4c74d20a43b881c0c9e5def5f76c finished! The total probability was: 0.08624781646269201. It took a total of 8.561265707015991s to run 125 systems on 2 cores\n", + "Population-05128ef4c5fe4274a0356c3e99e2f2d2 finished! The total probability was: 0.024868380796643757. It took a total of 9.792905807495117s to run 27 systems on 2 cores\n", "There were no errors found in this run.\n", "\n", "\n", "time mass_1 zams_mass_1 mass_2 zams_mass_2 stellar_type_1 prev_stellar_type_1 stellar_type_2 prev_stellar_type_2 metallicity probability\n", - "8.863377990313e+01 1.29444 5.88566 0 2.99283 13 5 15 15 0.02 0.000627913\n", - "1.146421815741e+02 0 5.88566 1.33062 4.43925 15 15 13 5 0.02 0.000627913\n", - "7.222715508467e+01 1.34922 5.88566 0 5.88566 13 5 15 15 0.02 0.000627913\n", - "1.350021848285e+01 1.48488 17.3205 0 0.1 13 5 15 15 0.02 0.000154349\n", - "1.171108213270e+01 1.53113 17.3205 0 0.1 13 5 15 15 0.02 0.000154349\n", - "1.171086983243e+01 1.53177 17.3205 0 0.1 13 9 15 15 0.02 0.000154349\n", - "1.170770599495e+01 1.53176 17.3205 0 4.40513 13 5 15 15 0.02 0.000172877\n", - "1.230407246199e+01 1.59499 17.3205 0 4.40513 13 5 15 15 0.02 0.000610573\n", - "1.108751340926e+01 1.70319 17.3205 0 8.71025 13 4 15 15 0.02 0.000610573\n", - "1.941017702765e+01 1.34903 17.3205 1.65097 8.71025 13 13 13 5 0.02 0.000172877\n", - "1.980988739731e+01 1.36979 17.3205 1.60808 8.71025 13 13 13 5 0.02 0.000121486\n", - "3.571858031651e+01 1.53174 17.3205 1.30504 8.71025 13 13 13 5 0.02 8.42148e-05\n", - "3.459153942631e+01 1.53176 17.3205 1.31004 8.71025 13 13 13 5 0.02 9.8162e-05\n", - "1.687368550125e+01 1.34937 17.3205 1.73856 13.0154 13 13 13 8 0.02 0.000172877\n", - "1.194842917007e+01 1.78096 17.3205 0 13.0154 13 8 15 15 0.02 0.000610573\n", - "1.733614170983e+01 1.53184 17.3205 1.42375 13.0154 13 13 13 5 0.02 9.8162e-05\n", - "1.723547465714e+01 1.38403 17.3205 1.71288 13.0154 13 13 13 8 0.02 0.000121486\n", - "1.764340254985e+01 1.53174 17.3205 1.41264 13.0154 13 13 13 5 0.02 8.42148e-05\n", - "1.170425790780e+01 1.52963 17.3205 0 17.3205 13 5 15 15 0.02 0.000172877\n", - "8.922967341481e+00 1.85486 17.3205 0 17.3205 13 8 15 15 0.02 0.000610573\n", - "1.232906623449e+01 1.41074 17.3205 1.34281 17.3205 13 13 13 8 0.02 0.000121486\n", - "1.170775828562e+01 1.53183 17.3205 1.53183 17.3205 13 5 13 5 0.02 9.8162e-05\n", - "1.170770422321e+01 1.53175 17.3205 1.53175 17.3205 13 5 13 5 0.02 8.42148e-05\n", - "5.075844624794e+00 2.12303 50.9713 0 0.1 13 8 15 15 0.02 3.79411e-05\n", - "4.766606588165e+00 2.20484 50.9713 0 0.1 14 8 15 15 0.02 3.79411e-05\n", - "4.768305081494e+00 2.18838 50.9713 0 0.1 13 8 15 15 0.02 3.79411e-05\n", - "4.458869865939e+00 2.29864 50.9713 0 12.8178 14 8 15 15 0.02 0.000150087\n", - "1.806014211040e+01 2.10446 50.9713 1.40749 12.8178 13 13 13 5 0.02 2.9863e-05\n", - "4.797342083485e+00 2.10328 50.9713 0 12.8178 13 13 15 1 0.02 4.24954e-05\n", - "1.721374713429e+01 2.21673 50.9713 1.42212 12.8178 14 14 13 5 0.02 2.41295e-05\n", - "4.055645404546e+00 2.47276 50.9713 0 25.5357 14 7 15 15 0.02 0.000150087\n", - "1.806123543037e+01 2.21893 50.9713 1.40745 12.8178 14 14 13 5 0.02 2.07011e-05\n", - "8.117519147635e+00 2.10433 50.9713 2.21473 25.5357 13 13 14 8 0.02 4.24954e-05\n", - "8.315554923168e+00 2.15343 50.9713 2.08519 25.5357 13 13 13 8 0.02 2.9863e-05\n", - "7.917420996633e+00 2.21892 50.9713 1.7431 25.5357 14 14 13 8 0.02 2.07011e-05\n", - "7.693213405973e+00 2.21805 50.9713 1.78384 25.5357 14 14 13 8 0.02 2.41295e-05\n", - "3.753837732894e+00 2.62517 50.9713 0 38.2535 14 7 15 15 0.02 0.000150087\n", - "7.087296558990e+00 2.10417 50.9713 2.40935 38.2535 13 13 14 8 0.02 4.24954e-05\n", - "7.007109286263e+00 2.15854 50.9713 2.28672 38.2535 13 13 14 8 0.02 2.9863e-05\n", - "5.653200958306e+00 2.21878 50.9713 2.0587 38.2535 14 14 13 8 0.02 2.41295e-05\n", - "5.733794947644e+00 2.21892 50.9713 1.99255 38.2535 14 14 13 8 0.02 2.07011e-05\n", - "3.513216011269e+00 2.76647 50.9713 0 50.9713 14 7 15 15 0.02 0.000150087\n", - "4.750574783854e+00 2.27442 50.9713 0 50.9713 14 8 15 15 0.02 4.24954e-05\n", - "7.278384712062e+00 1.29678 50.9713 2.09216 50.9713 13 8 13 13 0.02 2.9863e-05\n", - "4.765996194699e+00 2.20787 50.9713 2.20787 50.9713 14 8 14 8 0.02 2.07011e-05\n", - "4.765535914728e+00 2.21331 50.9713 2.21331 50.9713 14 8 14 8 0.02 2.41295e-05\n", - "3.104706358826e+00 3.17639 150 0 0.1 14 7 15 15 0.02 9.32641e-06\n", - "3.069363482023e+00 3.27572 150 0 0.1 14 7 15 15 0.02 9.32641e-06\n", - "3.047074050271e+00 3.3836 150 0 37.575 14 7 15 15 0.02 3.68933e-05\n", - "5.974759306305e+00 3.23604 150 2.53922 37.575 14 14 14 7 0.02 1.04459e-05\n", - "6.074084349384e+00 3.30145 150 2.13876 37.575 14 14 13 8 0.02 7.34071e-06\n", - "5.733865371895e+00 3.29994 150 2.00498 37.575 14 14 13 8 0.02 5.93135e-06\n", - "3.027099358410e+00 3.53631 150 0 75.05 14 7 15 15 0.02 3.68933e-05\n", - "5.807147339697e+00 3.30197 150 1.9791 37.575 14 14 13 8 0.02 5.08861e-06\n", - "4.862942347290e+00 3.25294 150 2.97823 75.05 14 14 14 7 0.02 1.04459e-05\n", - "4.556479830908e+00 3.29942 150 2.73221 75.05 14 14 14 7 0.02 7.34071e-06\n", - "3.853070305680e+00 3.29977 150 2.62486 75.05 14 14 14 7 0.02 5.93135e-06\n", - "3.881529045940e+00 3.30149 150 2.55924 75.05 14 14 14 7 0.02 5.08861e-06\n", - "3.015033359333e+00 3.64419 150 0 112.525 14 7 15 15 0.02 3.68933e-05\n", - "4.126828648362e+00 3.32047 150 0 112.525 14 14 15 3 0.02 1.04459e-05\n", - "3.990017992944e+00 3.3032 150 2.94027 112.525 14 14 14 7 0.02 7.34071e-06\n", - "3.206771867883e+00 3.07671 150 3.11282 112.525 14 14 14 7 0.02 5.93135e-06\n", - "3.006827156705e+00 3.72638 150 0 150 14 7 15 15 0.02 3.68933e-05\n", - "3.218786094847e+00 3.30337 150 3.01344 112.525 14 14 14 7 0.02 5.08861e-06\n", - "4.527722847382e+00 1.42238 150 0 150 13 5 15 15 0.02 1.04459e-05\n", - "3.069567332611e+00 3.27804 150 3.27804 150 14 7 14 7 0.02 5.93135e-06\n", - "5.726405299909e+00 1.29746 150 3.22759 150 13 8 14 14 0.02 7.34071e-06\n", - "3.069626478211e+00 3.27565 150 3.27565 150 14 7 14 7 0.02 5.08861e-06\n", + "1.219029061236e+01 1.60007 17.3205 0 2.97008 13 5 15 15 0.02 0.000498487\n", + "1.935920346899e+01 1.29448 17.3205 0 8.71025 13 13 15 2 0.02 0.000498487\n", + "2.123795595728e+01 1.30902 17.3205 1.58519 8.71025 13 13 13 5 0.02 0.000287968\n", + "3.579099761269e+01 1.52414 17.3205 1.30642 8.71025 13 13 13 5 0.02 0.000220016\n", + "1.674063083432e+01 1.29457 17.3205 0 14.4504 13 13 15 2 0.02 0.000498487\n", + "1.779197348711e+01 1.3228 17.3205 1.71196 14.4504 13 13 13 8 0.02 0.000287968\n", + "1.548740826516e+01 1.52415 17.3205 1.45407 14.4504 13 13 13 5 0.02 0.000220016\n", + "1.772169325356e+01 1.81957 73.0434 1.46573 12.2572 13 13 13 5 0.02 4.43422e-05\n", + "1.367065500196e+01 1.66003 73.0434 1.79487 12.2572 13 13 13 8 0.02 7.67586e-05\n", + "2.021960493499e+01 1.82061 73.0434 1.39205 12.2572 13 13 13 5 0.02 3.38788e-05\n", + "9.012246630357e+00 1.81529 73.0434 0 36.5717 13 8 15 15 0.02 7.67586e-05\n", + "7.462779538274e+00 1.82255 73.0434 1.81499 36.5717 13 13 13 8 0.02 3.38788e-05\n", + "1.030499912298e+01 1.80592 73.0434 1.81066 36.5717 13 13 13 8 0.02 4.43422e-05\n", + "4.227002356107e+00 2.43719 73.0434 0 60.8862 14 14 15 1 0.02 7.67586e-05\n", + "7.396288708628e+00 1.8216 73.0434 1.8216 60.8862 13 8 13 8 0.02 3.38788e-05\n", + "7.394728392218e+00 1.80919 73.0434 1.79091 60.8862 13 13 13 8 0.02 4.43422e-05\n", "\n" ] } ], "source": [ - "import os\n", - "\n", - "from binarycpython.utils.grid import Population\n", - "from binarycpython.utils.custom_logging_functions import temp_dir\n", - "\n", "def parse_function(self, output):\n", " \"\"\"\n", " Example parsing function\n", @@ -1067,10 +990,11 @@ " \n", " # grid_options\n", " amt_cores=2, # grid_options\n", + " tmp_dir=TMP_DIR,\n", "\n", " # Custom options: the data directory and the output filename\n", " data_dir=os.path.join(\n", - " temp_dir(), \"example_python_population_result\"\n", + " TMP_DIR, \"example_python_population_result\"\n", " ), # custom_options\n", " base_filename=\"example_pop.dat\", # custom_options\n", ")\n", @@ -1168,14 +1092,14 @@ "example_pop.export_all_info()\n", "\n", "# remove the result file if it exists\n", - "if os.path.isfile(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\")):\n", - " os.remove(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\"))\n", + "if os.path.isfile(os.path.join(TMP_DIR, \"example_python_population_result\", \"example_pop.dat\")):\n", + " os.remove(os.path.join(TMP_DIR, \"example_python_population_result\", \"example_pop.dat\"))\n", "\n", "# Evolve the population\n", "example_pop.evolve()\n", "\n", "# \n", - "with open(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\"), 'r') as f:\n", + "with open(os.path.join(TMP_DIR, \"example_python_population_result\", \"example_pop.dat\"), 'r') as f:\n", " output = f.read()\n", "print(\"\\n\")\n", "print(output)"